-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
46 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/--- Day 10: Elves Look, Elves Say --- | ||
|
||
res:{raze {count[x],first x}each cut[where differ x;x]}\[50;]10 vs "J"$ first read0 `:input/10.txt; | ||
res:{raze (1_deltas i,1),'x i:where differ x}\[50;]10 vs "J"$ first read0 `:input/10.txt | ||
count res 40 | ||
/252594 | ||
count res 50 | ||
/3579328 | ||
/3579328 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
/--- Day 15: Dueling Generators --- | ||
|
||
f:16807 48271 | ||
m:2147483647 | ||
c:0; | ||
{ | ||
c+:1*(~/) -16#'0b vs'x:(f*x) mod m; | ||
x | ||
}/[40000000;f*i:first (" i";" ") 0: `:input/15.txt]; | ||
c | ||
g:{ (first[x]+(~/)mod[r;65536];r:(16807 48271*last x) mod 2147483647) }/[40000000;] | ||
first g (0;) i:first (" j";" ") 0: `:input/15.txt | ||
/650 | ||
|
||
A:B:() | ||
|
||
{ A,:$[0=mod[x:(first[f]*x) mod m;4];x;()];x }/[{ 5000000>count A };first i]; | ||
{ B,:$[0=mod[x:(last[f]*x) mod m;8];x;()];x }/[{ 5000000>count B };last i]; | ||
{ if[0=mod[x:(x*16807) mod 2147483647;4];A,:x mod 65536];x }/[{ 5000000>count A };first i]; | ||
{ if[0=mod[x:(x*48271) mod 2147483647;8];B,:x mod 65536];x }/[{ 5000000>count B };last i]; | ||
|
||
sum {x~y}'[(-16#'0b vs 'B);(-16#'0b vs'A)] | ||
/336 | ||
sum A~'B | ||
/336 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
/--- Day 24: Electromagnetic Moat --- | ||
|
||
bridge:{ | ||
w:y~\:2#-1#x; | ||
res:.z.s'[x,/:y where w;y _/:where w], | ||
.z.s'[x,/:y where a;y _/:where a:not[w] and (last last x)=y[;0]], | ||
.z.s'[x,/:reverse each y where a;y _/:where a:not[w] and (last last x)=y[;1]]; | ||
$[count res;res;x] | ||
}; | ||
f:{[bridge;options] | ||
w1:where options[;0]=lc:last bridge; / options that match | ||
w2:except[;w1] where options[;1]=lc; / options that match in reverse | ||
if[0=count w1,w2;:enlist bridge]; / return if no further options | ||
|
||
flat:{ (raze .z.s each x where t),x where not t:0h=type each x }; | ||
raze .z.s'[bridge,/:(options w1),reverse each options w2;options _/:w1,w2]; | ||
} | ||
|
||
max sum each res:flat bridge[0;] "J"$"/"vs'read0 `:input/24.txt | ||
max sum each res:f[0;] "J"$"/"vs'read0 `:input/24.txt | ||
/1940 | ||
max sum each res where c=max c:count each res | ||
/1928 | ||
/1928 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters