Skip to content

Instantly share code, notes, and snippets.

@taoliu
Created March 14, 2012 19:01
Show Gist options
  • Save taoliu/2038683 to your computer and use it in GitHub Desktop.
Save taoliu/2038683 to your computer and use it in GitHub Desktop.
Monte Carlo for Pi
python -c 'import math;import random;n=1000000L;print float( n - reduce( lambda x, y: x//1+y//1, map( lambda x: math.hypot( random.random(), random.random() ), range(n) ) ) )/n*4'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment