Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Created February 6, 2016 11:22
Show Gist options
  • Save yasuharu519/57295f7a99032ba5f03f to your computer and use it in GitHub Desktop.
Save yasuharu519/57295f7a99032ba5f03f to your computer and use it in GitHub Desktop.
One liner to calculate PI with Monte Carlo method.
t=1000000;from random import random as r;print len(filter(lambda(x, y):(pow(x,2)+pow(y,2))<1,[(r(),r())for i in xrange(t)]))/float(t)*4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment