fork download
  1. def s(n,p=__import__("itertools").permutations):
  2. l=["_"]*21
  3. for e in[[(a,x+10),(b,y+10),(c,10-z)]for a,b,c in p(n,3)for x,y in p(range(1,11),2)for z in range(1,11)if a*x+b*y==c*z][0]:l[e[1]]=str(e[0])
  4. return`l`[2::5]+"\n"+" "*10+"^"
  5.  
  6. ip = [
  7. (1,1,1),
  8. (1,2,1),
  9. (3,1,5),
  10. (4,7,2)
  11. ]
  12. for e in ip:
  13. print e
  14. print s(e)
  15.  
Success #stdin #stdout 0.02s 9016KB
stdin
Standard input is empty
stdout
(1, 1, 1)
_______1___11________
          ^
(1, 2, 1)
_____1_____12________
          ^
(3, 1, 5)
_________5_31________
          ^
(4, 7, 2)
_2_________47________
          ^