Skip to content

Instantly share code, notes, and snippets.

@CapnKernel
Created September 26, 2013 06:53
Show Gist options
  • Select an option

  • Save CapnKernel/6710682 to your computer and use it in GitHub Desktop.

Select an option

Save CapnKernel/6710682 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
i1 = 1
i2 = 5
r = xrange(i1, i2 + 1)
solutions = ((x, y, z) for x in r for y in r for z in r if x * x + y * y == z * z)
for solution in solutions:
print "%d^2 + %d^2 = %d^2" % solution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment