Here's a solution for most of them. The remaining 21 are impossible.
- Most of them only use simple arithmetic.
- Some of them use exponentiation.
- Some use square roots.
Edit: Using only the binary operators (including digit concatenation), the number of possible combinations is pretty small (arrange three binary operators, then fill in the four numbers in some order) and I double-checked all of them with a computer. Most numbers are solvable with basic arithmetic, some require exponentiation, some require negation or square roots, and the rest are apparently impossible to solve without some extra operation such as rounding.
Accordingly, it is provably impossible to construct the following twenty-one numbers:
41, 44, 46, 47, 56, 68, 69, 74, 77, 79, 83, 85, 86, 89, 90, 91, 92, 95, 97, 98, 100.
The rest can be constructed as follows:
1-25 (complete)
1. (6+1)-(3+3)
2. (3*3)-(6+1)
3. (3*3)-(6*1)
4. 13-(6+3)
5. 36-31
6. 3*(3+1)-6
7. (6+1)+(3-3)
8. (6-3)3-1
9. 6(3-1)-3
10. 3+13-6
11. 6+3+3-1
12. (6+3+3)*1
13. 6+3+3+1
14. (6*3)-(3+1)
15. 13 + (6/3)
16. 13 + (6-3)
17. 33-16
18. (1+3)*3 + 6
19. (6 + 1/3)*3
20. (3*6)+(3-1)
21. (13-6)*3
22. 13+3+6
23. 36-13
24. (6+1)*3 +3
25. 16+(3*3)
26-50 (except 41, 44, 46, 47)
26. 33 - (6+1)
27. 33 - (6*1)
28. 61 - 33
29. 31 - (6/3)
30. (6+3+1)*3
31. 13 + (6*3)
32. 63-31
33. 13*3 - 6
34. 31+(6-3)
35. 6*(3+3) -1
36. (6+3)(3+1)
37. 6(3+3) + 1
38. 33+(6-1)
39. 33+(6*1)
40. 31+3+6
41. round[36 + √(31)]
42. (3+3+1)*6
43. 16 + (3^3)
44. round[(3-√3)^16]
45. (3*13)+6
46. round[3 * (13 + √6)]
47. round[31√3] - 6
48. (3*3 - 1) *6
49. 36+13
50. 63-13
51-75 (except 56, 68, 69, 74)
51. 16*3 + 3
52. 61 - (3*3)
53. (3*3*6)-1
54. 1*3*3*6
55. 61-(3+3)
56. √(3136) (!)
57. (13+6)*3
58. (3+1)^3 - 6
59. 63 - (3+1)
60. (63*1) - 3
61. 61 + (3 - 3)
62. 61 + (3/3)
63. (6+1)*(3*3)
64. 63 + (1^3)
65. 63 + (3-1)
66. 63 + (3*1)
67. 36 + 31
68. round[63 + √31]
69. round[6 √133]
70. 61+(3*3)
71. (6^3)/3 - 1
72. 36 * (3-1)
73. (6^3)/3 + 1
74. round[3 √613]
75. 13*6 - 3
76-100 (except: 77, 79, 83, 85*, 86, 89,90,91,92, 95, 97, 98, 100.)
76. 63+13
77. round[61 * (3-√3)]
78. 13 * √(36)
79. round[6*13 + √3]
80. √(3^6) * 3 - 1
81. 13*6 + 3
82. √(3^6) * 3 + 1
83. round[(3+31)*√6]
84. 3^√(16) + 3
85. -----
86. round[√(6+√3) * 31]
87. (31*3) - 6
88. 61 + (3^3)
89. round[63 * √(3-1)]
90. round[13 * √(6/3)]
91. round[16 * √33]
92. round[3^√(3*6-1)]
93. 31 * (6-3)
94. 63+31
95. round[3*31 + √6]
96. (13+3)*6
97. round[(√3)^6 * √13]
98. round[36 * (1+√3)]
99. (3*31)+6
100. round[3*(31+√6)]
If you're allowed to concatenate the results of operations (e.g. (3+1)|5 = 45 ) then a solution for 85 is :
85. (3*3)|1 - 6
Python:
from itertools import permutations
from math import sqrt, floor, ceil
concat_literal_numbers_only = True
ops = { "+" : lambda a,b: a+b,
"-" : lambda a,b: a - b,
"/" : lambda a,b : a/float(b),
"*" : lambda a,b : a*b,
"^" : lambda a,b : a**b,
"C" : lambda a,b : float(str(a) + str(b)),
"n" : lambda a : -a,
"s" : lambda a : sqrt(a),
#"f" : lambda a : floor(a)
}
arity = {"+" : 2,
"-" : 2,
"/" : 2,
"*" : 2,
"^" : 2,
"C" : 2,
"n" : 1,
"s" : 1,
"f" : 1,
}
# print ops["/"](1,3)
# args: number of open args available
# nums: available digits to be used
# ops : tuple indicating commands used so far
def evaluate(cmds) :
"""Consume the list of commands in prefix notation, producing a pair (ans, unconsumed_symbols)"""
x = cmds.pop(0)
if not ops.get(x) :
return (x, cmds)
else :
args = []
for y in range(arity[x]) :
try :
(a, cmds) = evaluate(cmds)
args += [a]
except OverflowError :
return (None, None)
return (ops.get(x)(*args), cmds)
def score(ops):
ret = 0
ret += ops.count("+")
ret += 1.1*ops.count("-")
ret += 2 * ops.count("*")
ret += 3 * ops.count("/")
ret += 3 * ops.count("n")
ret += 4 * ops.count("^")
ret += 4 * ops.count("s")
ret += 4 * ops.count("f")
ret += 4 * ops.count("w")
# ret += 4 * ops.count("fs")
# ret += 4 * ops.count("cs")
return ret
agenda = [{"args" : 1, "nums" : [1,3,3,6], "ops" : []}]
seen = {}
only_search_for = None
ret = []
def finish(ops) :
global ret
global seen
ops_tmp = ops[:]
try :
n,_ = evaluate(ops_tmp)
except :
n = None
if n is None or not (0 score(ops) :
seen[n] = ops
print ops,"\t",n
while agenda :
x = agenda.pop(0)
if not x["nums"] and not x["args"] : # finished: used up all numbers; no open spaces.
finish(x["ops"])
if len(x["nums"]) == x["args"] : # fill in numbers only
for nums in set(permutations(x["nums"])) :
finish(x["ops"] + list(nums))
# print {"args" : 0,
# "nums" : [],
# "ops" : x["ops"] + list(nums)}
elif len(x["nums"]) > x["args"] :
# add new operators
for op in ops.keys() :
if arity[op] == 1 and x["ops"] and x["ops"][-1] == op :
continue # limit repeated unary operations
if arity[op] == 1 and x["ops"] and arity.get(x["ops"][-1]) == 1 :
continue # limit repeated unary operations
if (concat_literal_numbers_only and x["ops"] and (x["ops"][-1] == "C" or (len(x["ops"])>1 and x["ops"][-2] == "C")) and op != "C") :
continue
new_x = {"args" : x["args"] + arity[op] - 1,
"nums" : x["nums"],
"ops" : x["ops"] + [op]}
agenda = [new_x] + agenda
if x["args"] == 1 :
continue
for n in set(x["nums"]) :
new_nums = x["nums"][:]
new_nums.remove(n)
new_x = {"args" : x["args"] - 1,
"nums" : new_nums,
"ops" : x["ops"] + [n]}
agenda = [new_x] + agenda
# SHOW HOW TO MAKE ALL OF THE NUMBERS
miss = []
for i in range(0+1,100+1) :
if not seen.get(i) :
miss += [i]
print i, "\t", seen.get(i, "---")
# SHOW WHICH NUMBERS WERE MISSED
print "missed: ", miss
# IF YOU'RE LOOKING FOR ALL POSSIBLE WAYS TO MAKE SOMETHING, SHOW THEM HERE.
if only_search_for is not None :
ret = sorted(ret, key=score)
for x in ret:
print x