-
-
Save nielsmh/7407b1532da3bedd5d0782dc941a0d59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def dist_maxplusman(x,y): return max(x,y)+x+y | |
def dist_square(x,y): return x*x+y*y | |
def randtile(): return (random.randrange(1,255), random.randrange(1,255)) | |
def randtilepair(): return randtile(), randtile() | |
def onetest(): | |
t1, t2 = randtilepair() | |
r1 = dist_maxplusman(*t1) < dist_maxplusman(*t2) | |
r2 = dist_square(*t1) < dist_square(*t2) | |
return r1 == r2 | |
sum(onetest() for x in range(10000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment