Skip to content

Commit 6f08af7

Browse files
committed
day 25: #1480, #1260. I solved this one on wolfram alpha after checking that mod could work next to powers… and I typed one number wrong. I wrote 11570337 instad of 11570336 and submitted and it was wrong and then checked the other one and the two were different and spent like 10 decades and anyway finally got it wow terrible
1 parent bc944db commit 6f08af7

File tree

6 files changed

+151
-0
lines changed

6 files changed

+151
-0
lines changed

2020/solutions/day25/day25.1.ts

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
input: string, lines: string[], dblines: string[][]
3+
copy(text: string) → clipboard
4+
error(message: string) → thrown error
5+
-5..mod(3) → @mod(-5, 3)
6+
*/
7+
8+
// Cardinals:
9+
// [[1,0],[-1,0],[0,1],[0,-1]]
10+
// +Diagonals:
11+
// [[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[-1,1],[1,-1],[1,1]]
12+
13+
export {};
14+
15+
const [card_pkey, door_pkey] = input.split("\n").map(v => +v);
16+
17+
function check(loop_size, subject) {
18+
let value = 1;
19+
20+
for(let i = 0; i < loop_size; i++) {
21+
value *= subject;
22+
value %= 20201227;
23+
}
24+
// let value = (BigInt(subject) ** BigInt(loop_size)) % BigInt(20201227);
25+
26+
return value;
27+
}
28+
29+
// let lp_sz = 0;
30+
// let lp_sz2 = 0;
31+
// for(let i = 0; i < 200000; i++) {
32+
// for(let j = 7; j < 8; j++) {
33+
// const v = check(i, j);
34+
// if(v == card_pkey) {
35+
// lp_sz = i;
36+
// }else if(v == door_pkey){
37+
// lp_sz2 = i;
38+
// }
39+
// }
40+
// }
41+
42+
// print("lp sz:",lp_sz, lp_sz2);
43+
44+
print(check(11570336, 19241437)); // 15767163
45+
print(check(8808305, 17346587)); // 12181021
46+
47+
print(check(8808305, 7) == 19241437); // 19241437 right
48+
print(check(11570336, 7) == 17346587); // 19241437 right
49+
50+
// ???
51+
52+
// 11570337

2020/solutions/day25/day25.2.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
input: string, lines: string[], dblines: string[][]
3+
copy(text: string) → clipboard
4+
error(message: string) → thrown error
5+
-5..mod(3) → @mod(-5, 3)
6+
*/
7+
8+
// Cardinals:
9+
// [[1,0],[-1,0],[0,1],[0,-1]]
10+
// +Diagonals:
11+
// [[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[-1,1],[1,-1],[1,1]]
12+
13+
export {};
14+
15+
const [card_pkey, door_pkey] = input.split("\n").map(v => +v);
16+
17+
function check(loop_size, subject) {
18+
let value = 1;
19+
20+
for(let i = 0; i < loop_size; i++) {
21+
value *= subject;
22+
value %= 20201227;
23+
}
24+
// let value = (BigInt(subject) ** BigInt(loop_size)) % BigInt(20201227);
25+
26+
return value;
27+
}
28+
29+
// let lp_sz = 0;
30+
// let lp_sz2 = 0;
31+
// for(let i = 0; i < 200000; i++) {
32+
// for(let j = 7; j < 8; j++) {
33+
// const v = check(i, j);
34+
// if(v == card_pkey) {
35+
// lp_sz = i;
36+
// }else if(v == door_pkey){
37+
// lp_sz2 = i;
38+
// }
39+
// }
40+
// }
41+
42+
// print("lp sz:",lp_sz, lp_sz2);
43+
44+
print(check(11570336, 19241437)); // 15767163
45+
print(check(8808305, 17346587)); // 12181021
46+
47+
print(check(8808305, 7) == 19241437); // 19241437 right
48+
print(check(11570336, 7) == 17346587); // 19241437 right
49+
50+
// solve mod(7^l,20201227)=19241437
51+
// solve mod(7^l,20201227)=17346587
52+
53+
// ???
54+
55+
// 11570337

2020/solutions/day25/day25.3.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
input: string, lines: string[], dblines: string[][]
3+
copy(text: string) → clipboard
4+
error(message: string) → thrown error
5+
-5..mod(3) → @mod(-5, 3)
6+
*/
7+
8+
// Cardinals:
9+
// [[1,0],[-1,0],[0,1],[0,-1]]
10+
// +Diagonals:
11+
// [[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[-1,1],[1,-1],[1,1]]
12+
13+
export {};
14+

2020/solutions/day25/day25.4.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
input: string, lines: string[], dblines: string[][]
3+
copy(text: string) → clipboard
4+
error(message: string) → thrown error
5+
-5..mod(3) → @mod(-5, 3)
6+
*/
7+
8+
// Cardinals:
9+
// [[1,0],[-1,0],[0,1],[0,-1]]
10+
// +Diagonals:
11+
// [[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[-1,1],[1,-1],[1,1]]
12+
13+
export {};
14+

2020/solutions/day25/day25.5.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
input: string, lines: string[], dblines: string[][]
3+
copy(text: string) → clipboard
4+
error(message: string) → thrown error
5+
-5..mod(3) → @mod(-5, 3)
6+
*/
7+
8+
// Cardinals:
9+
// [[1,0],[-1,0],[0,1],[0,-1]]
10+
// +Diagonals:
11+
// [[1,0],[-1,0],[0,1],[0,-1],[-1,-1],[-1,1],[1,-1],[1,1]]
12+
13+
export {};
14+

2020/solutions/day25/day25.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
19241437
2+
17346587

0 commit comments

Comments
 (0)