Extended list comprehension options - Python -
i use example of code project euler exercise.
[(a, b, c) in range(1, 334) b in range(1, 334) c in range(1,334) if c == 1000 - - b , < b , b < c , a**2 + b**2 == c**2]
i know little list comprehensions wondering if there way imply a, b, c ints > 0 , want increment them
two pseudo code examples might like:
[(a, b, c) > 0 b > c > b if c == 1000 - - b] [(a, b, c) int(a) int(b) int(c) if c == 1000 - - b]
is possible this?
here simplification approach:
[(a, b, 1000 - - b) in range(1, 332) b in range(a+1, 333) if a**2 + b**2 == (1000 - - b)**2]
c
fix,1000 - - b
no need make loop of values it.you can start range of
b
range(a+1,333)
dont have test ifb>a
though wrong solution problem think
Comments
Post a Comment