You are invited to Log in or Register a free Frihost Account!

# Programming Challenge

restonpiston
Hi, I was looking at youtube videos haphazardly and stumble upon this one:

Here they explain a cool way to decompose numbers but they don't know the method to do that.
The decomposition rules are as follows:

You can only use one type of number from 1 to 9

You can only use operations of sum, subtraction, multiplication, division, exponentiation and concatenation

You must look for the shortest expression

Using this rules you can decompose 814 in:
22*(2+2+2)^2+22

I thought about it for a bit and realize that it would be an interesting challenge for many people.

So here is my idea, post your solution of the problem if you have one and we will discuss it against the others.
I dont have the solution myself, so it would be challenge for me. Also, use your favourite language,
but if you don't mind, make it in python so we all have a common syntaxis.

Have fun!
jestoy0514
Hi restonpiston, have you solve the problem yourself. If so can you please share it with us. It is quite interesting.
restonpiston
Unfortunately, my junior year of CS is keeping me pretty busy, but I will give it a try whenever I have enough time
restonpiston
I have a proof of concept of it. It doesn't work yet, but you can see the basics behind it.
 Code: import re; import math; import itertools as it def count(operandos):     d=["+","-","*","/","^","."];     solucion=operandos[-1]     operandos=operandos[:-1]#https://stackoverflow.com/questions/509211/explain-slice-notation     for op in it.permutations(operandos):         #print(op)         for o in comb_general(d,len(operandos)-2):             a=""             if op[0]==1 and op[1]==3 and op[2]==5 and op[3]==7:                 pass;             if o[0]=="+" and o[1]=="^" and o[2]=="+" and o[3]==".":                 pass;             if op[0]==1 and op[1]==3 and op[2]==5 and op[3]==7 and op[4]==8 and o[0]=="+" and o[1]=="^" and o[2]=="+" and o[3]==".":                 print("Help") #             for i in range(len(o)): #                 a=a+str(op[i])+str(o[i]) #             a=a+str(op[len(op)-1])             conto=0;             contop=0;             salida=True;             while (conto=len(cadena):             return aux; #         a=cadena[i] #         if a=="(": #             for j in range(i+1,len(cadena)): #                 if cadena[j]==")": #                     aux=recurs(cadena[i+1:j]) #                     s1="" #                     s2="" #                     if i-1>0: #                         s1=cadena[:i-1] #                     if j+10:                         s1=cadena[:i]                     if j+1