Giter Site home page Giter Site logo

clindev-donut's Introduction

Clinical Developers Club – Donut challenge

Task – set by @stuartbman

"It's very simple- draw a donut

What is a donut?

  • At it's very least, it consists of 2 concentric circles
  • At it's very most, it is a delicious iced dessert with sprinkles

You can use any programming language to make this, and I will look out for solutions which do one of a few things:

  • Fewest lines of code (not really fair to non-python developers i know, sorry!)
  • Best Donut
  • Most creative solution

This is a bit of a departure from previous data analytics challenges, partly to welcome anyone who hasn't entered challenges before/ has been put of by them, and partly because graphics aren't always something considered in introductory programming courses, but are important to bear in mind! This challenge is actually not my own, but comes from a GCHQ recruiting event I was at 2 years ago. I won this challenge in the first category, if anyone beats me I will buy them a drink at our future meetup! Same deadline applies- I will look through the solutions on Sunday and feedback and choose the best ones. I'll be about to answer any questions intermittently.

EDIT: Okay honestly, if anyone can make a coding solution that is better than 78 bytes filesize I will send them a box of krispy kreme donuts"

Solutions below, written in Processing, an open source language with minimal IDE and simple syntax available here

Donut (70 bytes)

fill(#FFB6C1);ellipse(50,50,55,55);fill(#CCCCCC);ellipse(50,50,25,25);

And rendered here http://studio.sketchpad.cc/SMo3UzuhEu

Minimal donut (52 bytes)

ellipse(50,50,50,50);fill(200);ellipse(50,50,22,22);

This one is covered in white icing, rendered here http://studio.sketchpad.cc/VHWc7L4Yfx

Super-minimal donut (43 bytes)

fill(200);strokeWeight(3);ellipse(9,9,9,9);

This one is super-miniature, covered in 99% cocoa dark choc… http://studio.sketchpad.cc/BzHjsPgmJx

And here is Python 3 answer (75 bytes) that prints a donut bitmap – depending on your preferred resolution and if non vectors allowed!

d=[99,93,54,42];print('\n'.join(['{:07b}'.format(b) for b in d+d[-2::-1]]))

Editable here

Output:

1100011
1011101
0110110
0101010
0110110
1011101
1100011

This prints a donut in a 7x7 grid by parsing a string of ints into their binary equivalent. For each int '{:07b}'.format(int) returns the 0-padded 7-bit long binary representation of the int. To save space, the string is made of two arrays 'd', concatenated d+d[-2::-1]. The second half the string is formed by is an inverse slice of the first [::-1] and sliced minus the first char [-2::] to avoid repeating the middle '0'.

clindev-donut's People

Contributors

haematologic avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.