JavaScript(ES7),836个字节
除81、88和97(使用new **
运算符)外,其他所有浏览器都可以正常运行。
通常,这里的所有操作都是手工完成的。我一直在研究蛮力,以改进所有可以改进的地方。目前,它已在各种项目上节省了103个字节。
0: 201&6
1: 2-01%6
2: 2%016
3: 201%6
4: 20%16
5: 201%~6
6: 2%01+6
7: 2-01+6
8: 2*01+6
9: 2+01+6
10: 2-~01+6
11: ~2+016
12: 2^016
13: 20-1-6
14: 2|016
15: 20+1-6
16: 2+016
17: 2-~016
18: 2+0+16
19: 20-1%6
20: 20|16
21: 20+1%6
22: 20*1|6
23: 20+1|6
24: 20+~1+6
25: 20-1+6
26: 20*1+6
27: 20+1+6
28: 2*016
29: 20-~1-~6
30: -2*~016
31: 20|~-16
32: 20*1.6
33: 20*~1^~6
34: -20*~1-6
35: 20+~-16
36: 20+16
37: 20-~16
38: 20-~-~16
39: -~2*~-016
40: 20<<1%6
41: -20*~1-~!6
42: ~2*-016
43: ~20^-1<<6
44: ~20*~1^6
45: ~2*~016
46: 20<<1|6
47: -20*~1-~6
48: ~20*~1+6
49: ~20*~1-~6
50: ~2/.01/-6
51: ~2.0*~16
52: 20|1<<~-6
53: -20*~-~1+~6
54: ~2.0*~-~16
55: -20*~-~1-~-6
56: ~-~2*-016
57: ~20*~-~1-6
58: -20*~-~1^6
59: ~(20/~1*6)
60: -20/~1*6
61: ~2^0-1<<6
62: -2^0-1<<6
63: ~20/~1*6
64: 2-01<<6
65: 2+~0|1<<6
66: 2|01<<6
67: 2-~0|1<<6
68: 2*~!0*~16
69: ~20*~-~1+6
70: 20/~1*~6
71: -~(20/~1*~6)
72: 2+~0/.1*~6
73: -20<<-~1^~6
74: -20<<-~1^-6
75: ~-~-~2*~016
76: ~-20*(~1+6)
77: ~-~20/~1*-~6
78: ~-20<<-~1|6
79: -20<<-~1^~!6
80: 20*(~1+6)
81: ~2*~0**(~1+6)
82: ~-~-20|1<<6
83: ~-20|1<<6
84: 20|1<<6
85: -~20|1<<6
86: 20<<-~1|6
87: 20<<-~1|-~6
88: .2**~!0|1<<6
89: ~20*~-~-~1+~-6
90: ~2*~!0*~-16
91: ~20*~-~-~1-~6
92: ~-2/.01+~-~6
93: ~-2/.01+~6
94: ~-2/.01-6
95: ~-20*1*~-6
96: 2+01<<~-6
97: ~2+.01**~.6
98: ~-2/.01^6
99: ~-2/.01+~.6
100: 20*1*~-6
蛮力
它不是最漂亮的代码,但是在这些部分之间似乎并不重要。
警告:除非您准备好让浏览器/引擎冻结几分钟,否则请不要运行。没有人喜欢计算7个嵌套循环。
var a=new Array().fill("000000000000000000000000000"), // An array of non-solutions to start
time=new Date(), // For timing how long this takes
o=["","+","-","*","/","%","&","|","^",".","<<"], // Operators for between numbers
p=["",".","~.","-","~","~-","-~","~-~","~-~-","~!"]; // Prefixes for each number
for(i=0;i<o.length;i++)
for(j=0;j<o.length;j++)
for(k=0;k<o.length;k++)
for(I=0;I<p.length;I++)
for(J=0;J<p.length;J++)
for(K=0;K<p.length;K++)
for(L=0;L<p.length;L++) { // 7 nested loops = O(len(o)^3 * len(p)^4)
z= p[I]+2
+o[i]+p[J]+0
+o[j]+p[K]+1
+o[k]+p[L]+6; // Put all the current chars in one string.
try { v=eval(z) } // Try setting v to the evaluated value of z.
catch(e) { v=-1 } // If an error occurs, set v to -1.
if( (v === (v|0)) && // If v is an integer, and
v>=0 && v<=100 && // v is between 0 and 100, inclusive, and
z.length<a[v].length ) // z is shorter than the current entry,
a[v]=z; // overwrite the current entry.
}
console.log("time: " + ((new Date()-time)/1e3) + "seconds\n"
+ "length: " + (a.join("").length) + "\n"
+ a.map((x,y) => y + ": " + x).join("\n"))