fork download
def s(n,p=__import__("itertools").permutations):
 l=["_"]*21
 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])
 return`l`[2::5]+"\n"+" "*10+"^"
 
ip = [
	(1,1,1),
	(1,2,1),
    (3,1,5),
    (4,7,2)
]
for e in ip:
 print e
 print s(e)
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________
          ^