Skip to main content
added 27 characters in body
Source Link
Ev_genus
  • 351
  • 1
  • 7

Python3 (436) (434) (434443)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product;k=product;m=map
q=lambda n,h=1:["("+i+c+j+")"for(i,j),c in k(chain(*[k(*map*m(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in mapm("".join,permutations(n))),[])]),list("+",""+-","*","*/","^",""^")+[""]*h)]if 1<len(n)else[n]else[n]*h
a,b=m(int,m(input,"nm"))
for i,j in chain(*[k(q(str(n),0),[n])for n in range(*(map(int,map(inputa,"nm")))b+1)]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127

Python3 (436) (434)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")"for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if 1<len(n)else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127

Python3 (436) (434) (443)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product;m=map
q=lambda n,h=1:["("+i+c+j+")"for(i,j),c in k(chain(*[k(*m(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in m("".join,permutations(n))),[])]),list("+-*/^")+[""]*h)]if 1<len(n)else[n]*h
a,b=m(int,m(input,"nm"))
for i,j in chain(*[k(q(str(n),0),[n])for n in range(a,b+1)]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127
added 11 characters in body
Source Link
Ev_genus
  • 351
  • 1
  • 7

Python3 (436) (436434)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")" for"for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if len1<len(n)>1 else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127

Python3 (436)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")" for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if len(n)>1 else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127

Python3 (436) (434)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")"for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if 1<len(n)else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127
added 155 characters in body
Source Link
Ev_genus
  • 351
  • 1
  • 7

Python3 (436)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")" for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if len(n)>1 else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127

Python3 (436)

It was hard. I can spare some characters make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")" for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if len(n)>1 else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Python3 (436)

It was hard. I can spare some characters if I make output more native.

from itertools import*
r={};k=product
q=lambda n:["("+i+c+j+")" for(i,j),c in k(chain(*[k(*map(q,f))for f in sum(([(x[:q],x[q:])for q in range(1,len(x))]for x in map("".join,permutations(n))),[])]),("+","-","*","/","^",""))]if len(n)>1 else[n]
for i,j in chain(*[k(q(str(n)),[n])for n in range(*(map(int,map(input,"nm"))))]):
    try:exec("if eval(%r)==j:r[j]=i"%i.replace("^","**"))
    except:0
print(len(r))
for j,i in r.items():print(i,j)

Output

n100
m200
6
(2^(8-1)) 128
(3*(51)) 153
((11)^2) 121
(5^(1+2)) 125
(6*(21)) 126
((2^7)-1) 127
Source Link
Ev_genus
  • 351
  • 1
  • 7
Loading