Timeline for Pi Calculation Code Golf
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 17, 2020 at 9:04 | history | edited | CommunityBot | Commonmark migration | |
| Apr 13, 2017 at 2:58 | comment | added | user15259 | @MarkC - Conceptually it is throwing darts randomly in a rectangle 0,0 to 1,1. Those less than or equal to distance 1 from 0,0 are considered inside, else outside. The shape of this distance 1 happens to be a quarter circle or π/4. The [number of darts inside the quarter circle] / [total number of darts] will approximate π/4 as the number of samples increases. | |
| Feb 25, 2017 at 21:10 | comment | added | M.C. | What is it doing? | |
| Mar 25, 2014 at 20:58 | history | edited | user15259 | CC BY-SA 3.0 | Using echo instead of print. |
| Mar 25, 2014 at 15:25 | comment | added | user15259 | @zamnuts - it's in floating point, so <=1 is required - will try echo, not sure about direct line feed, might confuse some people | |
| Mar 2, 2014 at 8:48 | comment | added | zamnuts | nothing mind blowing, but: using echo vs print saves you 1 byte, and <2 instead of <=1 in $j+=$x*$x+$y*$y<=1; saves you another byte. lastly, using an actual line feed instead of \n saves you yet another byte (in the src). ... +1 nice work. | |
| Feb 28, 2014 at 15:45 | history | edited | user15259 | CC BY-SA 3.0 | More shortening. |
| Feb 28, 2014 at 15:35 | comment | added | user15259 | @cloudfeet - Changes made, confirmed code still runs the same. Thank you! | |
| Feb 28, 2014 at 15:35 | history | edited | user15259 | CC BY-SA 3.0 | Revisions suggested by cloudfeet. |
| Feb 27, 2014 at 17:50 | comment | added | cloudfeet | Also $k+=1/4; and print $j/$k could be reduced to $k++; and print 4*$j/$k for another byte. | |
| Feb 27, 2014 at 17:45 | comment | added | cloudfeet | Don't know about PHP, but in JS you can do something like: $j+=$x*$x+$y*$y<=1; which would save you four bytes. | |
| Feb 24, 2014 at 23:51 | history | edited | user15259 | CC BY-SA 3.0 | Clarifications. |
| Feb 24, 2014 at 22:21 | comment | added | blabla999 | Up for an answer which really computes! | |
| Feb 24, 2014 at 22:19 | history | answered | user15259 | CC BY-SA 3.0 |