-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEuler_Problem-059.b93
145 lines (139 loc) · 30.9 KB
/
Euler_Problem-059.b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
v### 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
### ## 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
### 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
## ### 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
### 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
## 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ################################################################################################################################
################################################################################################################################
################################################################################################################################
> 89+10p 020p 030p 023p >20g3*10gg"0"-55+*20 v ################################################################################################################################
v"d"\+8%"d":g03+-"0"gg01+1*3g< ################################################################################################################################
79 59 12 02 79 35 08 28 20 02 03 68 >/p30g1+30p20g1+:93+-#v_$10g1v ################################################################################################################################
08 09 68 45 00 12 09 67 68 04 07 05 |-2+!-1g02!-"u" g01p02<0p01+ < ################################################################################################################################
23 27 01 21 79 85 78 79 85 71 38 10 ################################################################################################################################
71 27 12 02 79 06 02 08 13 09 01 13 v1p12<vp12/2g12p11/2g11+*p13*2:g < ################################################################################################################################
09 08 68 19 07 01 71 56 11 21 11 68 >051p > 061p > 51g61g 11p^>11g21g+!#v_11g2%21g2%+2%31^ ################################################################################################################################
06 03 22 02 14 00 30 79 01 31 06 23 |- **88 2p15:< > 31p0^ >51g"m"+61gp v ################################################################################################################################
19 10 00 73 79 44 02 79 19 06 28 68 v"+~h"< | -**882 p16:+1g16< ################################################################################################################################
16 06 16 15 79 35 08 11 72 71 14 10 + >51g1+^ ################################################################################################################################
03 79 12 02 79 19 06 28 68 32 00 00 * v < ################################################################################################################################
73 79 86 71 39 01 71 24 05 20 79 13 >13p>13g:1-13p#v_ v ################################################################################################################################
09 79 16 15 10 68 05 10 03 14 01 10 v+"a"%+*298:g31< > >^ 5 ################################################################################################################################
14 01 03 71 24 13 19 07 68 32 00 00 >12p892*+/:892*+%"a"+22p892*+/"a"+32pv $ $ 5 ################################################################################################################################
73 79 87 71 39 01 71 12 22 02 14 16 v p430 < $ $ 6 ################################################################################################################################
02 11 68 02 25 01 21 22 16 15 06 10 >014p 55*6*8* >:3%1+24p::"d"%8+\"d"/g"m"+24g2gg :" "\`#^_:"~"`| 8 ################################################################################################################################
00 79 16 15 10 22 02 79 13 20 65 68 ^-1 _v#-" "_v#-9p41+1:g41< * ################################################################################################################################
41 00 16 15 06 10 00 79 01 31 06 23 >$$ ^ * ################################################################################################################################
19 28 68 19 07 05 19 79 12 02 79 00 v < >$ ^ * ################################################################################################################################
14 11 10 64 27 68 10 14 15 02 65 68 > $ ^ 1 ################################################################################################################################
83 79 40 14 09 01 71 06 16 20 10 08 >:3%1+24p::"d"%8+\"d"/g"m"+24g2gg :" "\`#^_:"~"`| 5 ################################################################################################################################
01 79 19 06 28 68 14 01 68 15 06 09 ^-1_v#: _v#-"e"< p ################################################################################################################################
75 79 05 09 11 68 19 07 13 20 79 08 ^ : p43+1g43< 0 ################################################################################################################################
14 09 01 71 08 13 17 10 23 71 03 13 >$34g23g`#v_ ^ 2 ################################################################################################################################
00 07 16 71 27 11 71 10 18 02 29 29 >34g23p 32g22g12g 43p53p63p ^ 5 ################################################################################################################################
08 01 01 73 79 81 71 59 12 02 79 08 p ################################################################################################################################
14 08 12 19 79 23 15 06 10 02 28 68 v < ################################################################################################################################
19 07 22 08 26 03 15 79 16 15 10 68 v p51-1< ################################################################################################################################
03 14 22 12 01 01 20 28 72 71 14 10 >15g:"d"%8+\"d"/g"m"+15g3%4+3gg:25g+25p15g:"d"%8+\"d"/p15g:| ################################################################################################################################
03 79 16 15 10 68 03 14 22 12 01 01 >$25g.@ ################################################################################################################################
20 28 68 04 14 10 71 01 01 17 10 22 ################################################################################################################################
71 10 28 19 06 10 00 26 13 20 07 68 ################################################################################################################################
14 27 74 71 89 68 32 00 00 71 28 01 ################################################################################################################################
09 27 68 45 00 12 09 79 16 15 10 68 ################################################################################################################################
37 14 20 19 06 23 19 79 83 71 27 11 ################################################################################################################################
71 27 01 11 03 68 02 25 01 21 22 11 ################################################################################################################################
09 10 68 06 13 11 18 27 68 19 07 01 ################################################################################################################################
71 03 13 00 07 16 71 28 11 71 27 12 ################################################################################################################################
06 27 68 02 25 01 21 22 11 09 10 68 // 26^3 = 17576 ==> "h~+"+* ################################################################################################################################
10 06 03 15 27 68 05 10 08 14 10 18 // 1200 ==> 5568*** ################################################################################################################################
02 79 06 02 12 05 18 28 01 71 00 02 // 1201 ==> "p!!"*+ ################################################################################################################################
71 07 13 20 79 16 02 28 16 14 02 11 ################################################################################################################################
09 22 74 71 87 68 45 00 12 09 79 12 ################################################################################################################################
14 02 23 02 03 02 71 24 05 20 79 10 ################################################################################################################################
08 27 68 19 07 01 71 03 13 00 07 16 [1,0] convertInput :: Y ################################################################################################################################
92 79 12 02 79 19 06 28 68 08 01 08 [2,0] convertInput :: X ################################################################################################################################
30 79 05 71 24 13 19 01 01 20 28 68 [3,0] convertInput :: I ################################################################################################################################
19 00 68 19 07 01 71 03 13 00 07 16 ################################################################################################################################
73 79 93 71 59 12 02 79 11 09 10 68 [1,1] xorTable :: A ################################################################################################################################
16 07 11 71 06 23 71 27 12 02 79 16 [2,1] xorTable :: B ################################################################################################################################
21 26 01 71 03 13 00 07 16 75 79 19 [3,1] xorTable :: P ################################################################################################################################
15 00 68 00 06 18 02 28 68 11 06 03 [5,1] xorTable :: X ################################################################################################################################
15 27 68 19 00 68 02 25 01 21 22 11 [6,1] xorTable :: Y ################################################################################################################################
09 10 72 71 24 05 20 79 03 08 06 10 ################################################################################################################################
00 79 16 08 79 07 08 02 01 71 06 10 [1,2] crack :: k[0] ################################################################################################################################
19 00 68 19 07 01 71 24 11 21 03 00 [2,2] crack :: k[1] ################################################################################################################################
73 79 85 87 79 38 18 27 68 06 03 16 [3,2] crack :: k[2] ################################################################################################################################
15 00 17 00 07 68 19 07 01 71 24 11 ################################################################################################################################
21 03 00 71 24 05 20 79 09 06 11 01 [1,3] crack :: key-index ################################################################################################################################
71 27 12 21 00 17 00 07 68 15 06 09 [2,3] crack :: E-Count (-BEST-) ################################################################################################################################
75 79 16 15 10 68 16 00 22 11 11 68 ################################################################################################################################
03 06 00 09 72 16 71 29 01 04 00 03 [4,3] crack :: k[0] (-BEST-) ################################################################################################################################
09 06 30 02 79 12 14 02 68 16 07 01 [5,3] crack :: k[1] (-BEST-) ################################################################################################################################
09 79 12 02 79 07 06 02 01 73 79 85 [6,3] crack :: k[2] (-BEST-) ################################################################################################################################
86 79 33 17 10 10 71 06 10 71 07 13 ################################################################################################################################
20 79 11 16 01 68 11 14 10 03 79 05 [1,4] crack :: space counter ################################################################################################################################
09 11 68 06 02 11 09 08 68 15 06 23 [2,4] crack :: current key-position ################################################################################################################################
71 00 19 09 79 20 02 00 20 11 10 72 [3,4] crack :: E-Count (-CURRENT-) ################################################################################################################################
71 07 01 71 24 05 20 79 10 08 27 68 ################################################################################################################################
06 12 07 02 31 16 02 11 74 71 94 86 [1,5] decrypt :: index ################################################################################################################################
71 45 17 19 79 16 08 79 05 11 03 68 [2,5] decrypt :: ASCII sum ################################################################################################################################
16 07 11 71 13 01 11 06 01 17 10 00 ################################################################################################################################
71 07 13 10 79 05 09 11 68 06 12 07 ################################################################################################################################
02 31 16 02 11 68 15 06 09 75 79 12 ################################################################################################################################
02 79 03 06 25 01 71 27 12 02 79 22 ################################################################################################################################
14 08 12 19 79 16 08 79 06 02 12 11 ################################################################################################################################
10 10 68 04 07 13 11 11 22 02 01 68 ################################################################################################################################
08 09 68 32 00 00 73 79 85 84 79 48 ################################################################################################################################
15 10 29 71 14 22 02 79 22 02 13 11 ################################################################################################################################
21 01 69 71 59 12 14 28 68 14 28 68 ################################################################################################################################
09 00 16 71 14 68 23 07 29 20 06 07 ################################################################################################################################
06 03 68 05 06 22 19 07 68 21 10 23 ################################################################################################################################
18 03 16 14 01 03 71 09 22 08 02 68 ################################################################################################################################
15 26 09 06 01 68 23 14 23 20 06 11 ################################################################################################################################
09 79 11 21 79 20 11 14 10 75 79 16 ################################################################################################################################
15 06 23 71 29 01 05 06 22 19 07 68 ################################################################################################################################
04 00 09 02 28 68 01 29 11 10 79 35 ################################################################################################################################
08 11 74 86 91 68 52 00 68 19 07 01 ################################################################################################################################
71 56 11 21 11 68 05 10 07 06 02 01 ################################################################################################################################
71 07 17 10 14 10 71 14 10 03 79 08 ################################################################################################################################
14 25 01 03 79 12 02 29 01 71 00 10 ################################################################################################################################
71 10 05 21 27 12 71 14 09 08 01 03 ################################################################################################################################
71 26 23 73 79 44 02 79 19 06 28 68 ################################################################################################################################
01 26 08 11 79 11 01 79 17 09 09 05 ################################################################################################################################
14 03 13 09 08 68 11 00 18 02 79 05 ################################################################################################################################
09 11 68 01 14 13 19 07 02 18 03 10 ################################################################################################################################
02 28 23 73 79 37 09 11 68 16 10 68 ################################################################################################################################
15 14 18 02 79 23 02 10 10 71 07 13 ################################################################################################################################
20 79 03 11 00 22 30 67 68 19 07 01 ################################################################################################################################
71 08 08 08 29 29 71 00 02 71 27 12 ################################################################################################################################
02 79 11 09 03 29 71 60 11 09 79 11 ################################################################################################################################
01 79 16 15 10 68 33 14 16 15 10 22 ################################################################################################################################
73 ################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
################################################################################################################################
---------------------------------------
This task had a lot of Befunge specific problems, but first let's look at the solving strategy:
- We go through all `26^3` passwords and test look if they generate illegal characters (smaller 32 or bigger 127).
- We also see if one of the first twelve characters is a space, assuming the first word is no longer than twelve characters.
- The leaves us with around one-hundred viable passwords.
- We use the fact that in the English language the letter `e` is pretty common and take the password with the highest count of `e`.
- The rest is just decrypting the text and counting the values.
Now to our Befunge specific problems:
- First we need to input the raw data. Our best call is inserting the data directly into the program and then parsing it in the first step into an array.
- The next problem is the missing xor operator. To perform an xor operation we need to go through all bits and xor them individually (`a xor b == (a+b) % 2`). This is an extremely pricey operation. And to speed this up we generate an complete 128x128 xor look up-table with all possible xor operations.
All in all a not really optimal problem for Befunge but still a fun challenge