fredag 23 september 2016

A slice of pi

I baked a pi with ruby:

()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|

I did a codegolf the other day where the objective was to print out the above ASCII-art in the shortest amount of code possible. The code I came up with looks like this:
It is quite hard to read so here is a "ungolfed" version:
What I did was to create an array with the sub-sections of the pie and then traverse through that array and print out \\::\\n| where n is the current section of pi. For the bottom part I just printed out \\__\\|. I used rjust to get the pie to be right alligned.

Anyway, that's it for today. I've gotta go bake some raspberry pi, thanks for reading my post!

Inga kommentarer:

Skicka en kommentar