algorithm - Smallest positive integer not calculable given digits, possible to due in non exponential time? -


i given challenge: given amount of single digit, 4 8s, find smallest positive integer not calculable standard operations (+,-,*,/) , combination of parenthesis.

i've taken @ these 2 posts: algorithm permutations of operators , operands smallest integer not obtainable {2,3,4,5,6,7,8} (mathematica)

but still don't understand how problem. first link seems algorithm store every every number calculable given digits, , simple lookup. brute force method seems okay albeit slow.

is there pattern can used i'm not seeing? thought dp approach, dp, you'd have trying every single combination digits, operands, , parenthesis seems way slow. solution given in first link, seems you're headed towards exponential solution.

so example if have 4 different digits, have 3 operands need fill out in equation. n o n o n o n. each of operands can take 4 separate values, have 4*4*4 or 4^3 combinations try, exponential.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo