Skip to main content
Removed the 3.x version, fixed the code again
Source Link
beary605
  • 4.4k
  • 2
  • 26
  • 52

Python 2.x (197 212), Python 3.x (182 212 200277)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

fromimport re,itertools importas *I
a=raw_inpute=eval;a=raw_input().split();c=1;b=len(a)
for i in I.product('123456789',repeat=b):
 if eval(''d=''.join(sum(zip([j+'.'for j in i],a),()))[:3*b-1]
 if e(d)==int(a[-1]):print' '.join(i);c=0
print"NO SOLUTION"*c

Python 3.x Version: I don't run Python 3.x, so this may give errors.

from itertools importand *
a=raw_input().splitall();c=1;b=len[e(an)
 %1==0 for in in product('123456789',repeat=b):
 if eval(''re.join(sum(zipfindall(i,a)'\d./\d.',()))[:3*b-1]d)==int(a[-1]]):print('print' '.join(i));c=0
print("NOprint"NO SOLUTION"*c)

Python 2.x (197 212), Python 3.x (182 200)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

from itertools import *
a=raw_input().split();c=1;b=len(a)
for i in product('123456789',repeat=b):
 if eval(''.join(sum(zip([j+'.'for j in i],a),()))[:3*b-1])==int(a[-1]):print' '.join(i);c=0
print"NO SOLUTION"*c

Python 3.x Version: I don't run Python 3.x, so this may give errors.

from itertools import *
a=raw_input().split();c=1;b=len(a)
 for i in product('123456789',repeat=b):
 if eval(''.join(sum(zip(i,a),()))[:3*b-1])==int(a[-1]):print(' '.join(i));c=0
print("NO SOLUTION"*c)

Python (197 212 277)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

import re,itertools as I
e=eval;a=raw_input().split();c=1;b=len(a)
for i in I.product('123456789',repeat=b):
 d=''.join(sum(zip([j+'.'for j in i],a),()))[:3*b-1]
 if e(d)==int(a[-1])and all([e(n)%1==0 for n in re.findall('\d./\d.',d)]):print' '.join(i);c=0
print"NO SOLUTION"*c
fixed the code
Source Link
beary605
  • 4.4k
  • 2
  • 26
  • 52

Python 2.x (199197 212), Python 3.x (182182 200)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

from itertools import *
a=raw_input().split();c=1;b=len(a)
for i in product('123456789',repeat=len(a)repeat=b):
 if eval(''.join(sum(zip([j+'.'for j in i],a),()))[:14]3*b-1])==int(a[-1]):print 'print' '.join(i);b;c=0
print "NOprint"NO SOLUTION"SOLUTION"*c

Python 3.x Version: I don't run Python 3.x, so this may give errors.

from itertools import *
a=raw_input().split();c=1;b=len(a)
for i in product('123456789',repeat=len(a)repeat=b):
 if eval(''.join(sum(zip(i,a),()))[:9]3*b-1])==int(a[-1]):print (' '.join(i);b);c=0
print ("NO SOLUTION"SOLUTION"*c)

Python 2.x (199), Python 3.x (182)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

from itertools import *
a=raw_input().split()
for i in product('123456789',repeat=len(a)):
 if eval(''.join(sum(zip([j+'.'for j in i],a),()))[:14])==int(a[-1]):print ' '.join(i);b
print "NO SOLUTION"

Python 3.x Version:

from itertools import *
a=raw_input().split()
for i in product('123456789',repeat=len(a)):
 if eval(''.join(sum(zip(i,a),()))[:9])==int(a[-1]):print ' '.join(i);b
print "NO SOLUTION"

Python 2.x (197 212), Python 3.x (182 200)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

from itertools import *
a=raw_input().split();c=1;b=len(a)
for i in product('123456789',repeat=b):
 if eval(''.join(sum(zip([j+'.'for j in i],a),()))[:3*b-1])==int(a[-1]):print' '.join(i);c=0
print"NO SOLUTION"*c

Python 3.x Version: I don't run Python 3.x, so this may give errors.

from itertools import *
a=raw_input().split();c=1;b=len(a)
for i in product('123456789',repeat=b):
 if eval(''.join(sum(zip(i,a),()))[:3*b-1])==int(a[-1]):print(' '.join(i));c=0
print("NO SOLUTION"*c)
Source Link
beary605
  • 4.4k
  • 2
  • 26
  • 52

Python 2.x (199), Python 3.x (182)

Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".

Python 2.x Version:

from itertools import *
a=raw_input().split()
for i in product('123456789',repeat=len(a)):
 if eval(''.join(sum(zip([j+'.'for j in i],a),()))[:14])==int(a[-1]):print ' '.join(i);b
print "NO SOLUTION"

Python 3.x Version:

from itertools import *
a=raw_input().split()
for i in product('123456789',repeat=len(a)):
 if eval(''.join(sum(zip(i,a),()))[:9])==int(a[-1]):print ' '.join(i);b
print "NO SOLUTION"