Add solutions from Day 1 to Day 4
This commit is contained in:
parent
ea373e3d52
commit
49547c9170
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"deno.enable": true
|
||||||
|
}
|
1000
day_1/input.txt
Normal file
1000
day_1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
24
day_1/solve_1.ts
Normal file
24
day_1/solve_1.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
let txt = await Deno.readTextFile("input.txt");
|
||||||
|
txt = txt.trim();
|
||||||
|
const lst = txt.split("\r\n").map((x) =>
|
||||||
|
x.split(" ")
|
||||||
|
.filter((x) => x.length > 0))
|
||||||
|
.map(x => {
|
||||||
|
console.log(x);
|
||||||
|
return x;
|
||||||
|
})
|
||||||
|
.map((x) => [parseInt(x[0]), parseInt(x[1])]);
|
||||||
|
|
||||||
|
const left = lst.map((x) => x[0]);
|
||||||
|
const right = lst.map((x) => x[1]);
|
||||||
|
|
||||||
|
// Part 1
|
||||||
|
|
||||||
|
const sl = left.toSorted();
|
||||||
|
const sr = right.toSorted();
|
||||||
|
|
||||||
|
console.log(sr.filter(x => isNaN(x)));
|
||||||
|
|
||||||
|
const sum = sl.map((x, i) => Math.abs(x - sr[i])).reduce((a, b) => a + b, 0);
|
||||||
|
|
||||||
|
console.log(sum);
|
67
day_1/solve_2.ts
Normal file
67
day_1/solve_2.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
let txt = await Deno.readTextFile("input.txt");
|
||||||
|
txt = txt.trim();
|
||||||
|
const lst = txt.split("\r\n").map((x) =>
|
||||||
|
x.split(" ")
|
||||||
|
.filter((x) => x.length > 0))
|
||||||
|
.map(x => {
|
||||||
|
console.log(x);
|
||||||
|
return x;
|
||||||
|
})
|
||||||
|
.map((x) => [parseInt(x[0]), parseInt(x[1])]);
|
||||||
|
|
||||||
|
const left = lst.map((x) => x[0]);
|
||||||
|
const right = lst.map((x) => x[1]);
|
||||||
|
|
||||||
|
// Part 2
|
||||||
|
|
||||||
|
//Counter class
|
||||||
|
class Counter {
|
||||||
|
private _data: Map<number, number> = new Map<number, number>();
|
||||||
|
private _total: number = 0;
|
||||||
|
|
||||||
|
constructor(data: number[]) {
|
||||||
|
data.forEach(x => {
|
||||||
|
this.set(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get total(): number {
|
||||||
|
return this._total;
|
||||||
|
}
|
||||||
|
|
||||||
|
get count(): Map<number, number> {
|
||||||
|
return this._data;
|
||||||
|
}
|
||||||
|
|
||||||
|
get(key: number): number {
|
||||||
|
return this._data.get(key) ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key: number): void {
|
||||||
|
this._total++;
|
||||||
|
const count = this._data.get(key) ?? 0;
|
||||||
|
this._data.set(key, count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the similarity score between two arrays
|
||||||
|
*
|
||||||
|
* @param a
|
||||||
|
* @param b
|
||||||
|
*/
|
||||||
|
function calcSimilarityScore(a: number[], b: number[]): number {
|
||||||
|
const counterA = new Counter(a);
|
||||||
|
const counterB = new Counter(b);
|
||||||
|
|
||||||
|
let score = 0;
|
||||||
|
counterA.count.forEach((v, k) => {
|
||||||
|
const bv = counterB.get(k);
|
||||||
|
score += bv * v * k;
|
||||||
|
});
|
||||||
|
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
const score = calcSimilarityScore(left, right);
|
||||||
|
console.log(score);
|
1000
day_2/input.txt
Normal file
1000
day_2/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
35
day_2/solve_1.ts
Normal file
35
day_2/solve_1.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
const lst = txt.split("\r\n").map((x) => x.split(" ")
|
||||||
|
.filter((x) => x.length > 0))
|
||||||
|
.map(x=> x.map(x => parseInt(x)));
|
||||||
|
|
||||||
|
function isSafeReport(
|
||||||
|
arr: number[]
|
||||||
|
){
|
||||||
|
let isIncreasing = true;
|
||||||
|
let isDecreasing = true;
|
||||||
|
for(let i = 1; i < arr.length; i++){
|
||||||
|
const diff = arr[i] - arr[i - 1];
|
||||||
|
if (Math.abs(diff) > 3){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (diff === 0) {
|
||||||
|
// if the difference is 0, the array is neither increasing nor decreasing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(arr[i] > arr[i - 1]){
|
||||||
|
isDecreasing = false;
|
||||||
|
} else {
|
||||||
|
isIncreasing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isIncreasing || isDecreasing){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// if the array is neither increasing nor decreasing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const safeReports = lst.filter(isSafeReport);
|
||||||
|
console.log(safeReports);
|
||||||
|
console.log(lst.length,safeReports.length);
|
122
day_2/solve_2.ts
Normal file
122
day_2/solve_2.ts
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
const lst = txt.split("\r\n").map((x) => x.split(" ")
|
||||||
|
.filter((x) => x.length > 0))
|
||||||
|
.map(x=> x.map(x => parseInt(x)));
|
||||||
|
|
||||||
|
|
||||||
|
function isSafeReport(
|
||||||
|
arr: number[]
|
||||||
|
){
|
||||||
|
let isIncreasing = true;
|
||||||
|
let isDecreasing = true;
|
||||||
|
for(let i = 1; i < arr.length; i++){
|
||||||
|
const diff = arr[i] - arr[i - 1];
|
||||||
|
if (Math.abs(diff) > 3){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (diff === 0) {
|
||||||
|
// if the difference is 0, the array is neither increasing nor decreasing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(arr[i] > arr[i - 1]){
|
||||||
|
isDecreasing = false;
|
||||||
|
} else {
|
||||||
|
isIncreasing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isIncreasing || isDecreasing){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// if the array is neither increasing nor decreasing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isSafeReportEr(
|
||||||
|
array: number[],
|
||||||
|
options = {
|
||||||
|
errorMargin: 3,
|
||||||
|
errorThreshold: 1
|
||||||
|
}
|
||||||
|
){
|
||||||
|
if (array.length < 2){
|
||||||
|
throw new Error("Array must have at least 2 elements");
|
||||||
|
}
|
||||||
|
const arr = array.slice();
|
||||||
|
const isIncreasingCount = arr.reduce((acc, x, i) => {
|
||||||
|
if (i === 0){
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
if (x > arr[i - 1]){
|
||||||
|
return acc + 1;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, 0);
|
||||||
|
const isDecreasingCount = arr.reduce((acc, x, i) => {
|
||||||
|
if (i === 0){
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
if (x < arr[i - 1]){
|
||||||
|
return acc + 1;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, 0);
|
||||||
|
const isIncreasingMostly = isIncreasingCount > isDecreasingCount;
|
||||||
|
const errorMargin = options.errorMargin;
|
||||||
|
let errorThreshold = options.errorThreshold;
|
||||||
|
|
||||||
|
for (let i = 1; i < arr.length; i++){
|
||||||
|
const diff = arr[i] - arr[i - 1];
|
||||||
|
const overErrorMargin = Math.abs(diff) > errorMargin;
|
||||||
|
const isZero = diff === 0;
|
||||||
|
const orderMismatch = isIncreasingMostly ? diff < 0 : diff > 0;
|
||||||
|
if (overErrorMargin
|
||||||
|
|| isZero
|
||||||
|
|| orderMismatch){
|
||||||
|
// return false;
|
||||||
|
if (errorThreshold === 0){
|
||||||
|
console.log(`Error threshold reached`);
|
||||||
|
console.log(arr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
errorThreshold--;
|
||||||
|
console.log(arr);
|
||||||
|
console.log(`Removing ${arr[i]} at index ${i}`);
|
||||||
|
arr.splice(i, 1);
|
||||||
|
console.log(arr);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// console.log(isSafeReportEr([4,6,7,9,11,12,12]))
|
||||||
|
|
||||||
|
const safeReports = lst.filter(x=> isSafeReportEr(x));
|
||||||
|
// console.log(safeReports.length);
|
||||||
|
// const safeReports2 = lst.filter(x=> isSafeReport(x));
|
||||||
|
// console.log(
|
||||||
|
// new Set(safeReports.map(x => x.join(","))).difference(new Set(safeReports2.map(x => x.join(","))))
|
||||||
|
// );
|
||||||
|
|
||||||
|
const safeReports3 = lst.filter(x=> {
|
||||||
|
const safe = isSafeReport(x);
|
||||||
|
if (!safe){
|
||||||
|
// remove one element at a time
|
||||||
|
for (let i = 0; i < x.length; i++){
|
||||||
|
const copy = x.slice();
|
||||||
|
copy.splice(i, 1);
|
||||||
|
if (isSafeReport(copy)){
|
||||||
|
// console.log(`Removed ${x[i]} at index ${i}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return safe;
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(safeReports3.length);
|
||||||
|
console.log(safeReports.length);
|
||||||
|
console.log(
|
||||||
|
new Set(safeReports3.map(x => x.join(","))).difference(new Set(safeReports.map(x => x.join(","))))
|
||||||
|
);
|
1
day_3/example.txt
Normal file
1
day_3/example.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
|
1
day_3/example2.txt
Normal file
1
day_3/example2.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))
|
6
day_3/input.txt
Normal file
6
day_3/input.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
where())what()@)select()why()?mul(371,776)/%how()'~+:how()mul(977,266)@$@mul(749,170)how()<;$^#what()select()mul(338,975)>from()+,{select()!!mul(626,938)%/>^{((}]mul(733,977)>)() +$)mul(695,376)!%#how()mul(767,788)<(mul(876,501)mul(18,72)[*when(625,65)<mul(515,137)>*('what()mul(491,884)from()?{>how()mul(645,385)/[when(){what()why()mul(802,476)#'select()who(327,719)+-,##mul(103,807)#(mul(192,909):@'^where(247,392)!who()</mul(305,182)[@[;!;mul(553,402)<%mul(247,89)!mul(91,152)$@mul(502,543)+why()what()[when()@>^mul(875,344)why()mul(205,505)?;?when()!],mul(165,670),#$++'>)'mul(503,815):mul(483,302)~+*}!$where()why()&mul(785,794)/,{why();where(218,722)}when()don't();!mul(405,577)where()@mul(521,472){how()what()'what() where(55,484)mul(360,384)%mul(176,384)}%when()-$%what(436,501)mul(652,387)mul(758,52)-~@,*-@mul(343,835)when()select()](;#mul(76,425)from()>})]mul(720,464)#~)why()why()mul(619,682))mul(15,67)mul(569,569)]where()++&@:[#mul(844,620)select()+^*what()why(197,509) mul(280,807)%^mul(233,435)}?*:+^^what()!when()mul(69,464)& )]$mul(393,827)@]^mul(64,552):^)*<&where()?#mul(51,727)mul(159,242),+what())>+mul(140,116)do()~?mul(590,950)};[*;;when()mul(186,556)]&;#&##*!mul(806,651)^select()who()[mul(820,386);?from()mul(771,404)-$+#]&where()}mul(473,823)don't()when(874,250)'}mul(916,835)mul(432,92)how(), :mul(2,546)who(61,440), -mul(486,858)where(869,462)do()'select()&?+&why()where()>>mul(796,512){~(when():^>*&'mul(927,22)%;where()who()^$mul(203,851)%how()mul(820,954)from())~#<don't()select();@??]?mul(693,878)from()when()@/mul(202,438)mul(266,957)from()])[/how()select()don't()+>mul(741,967)select()what()+[[why()&]mul(42,517)>]why()<mul(577,659)&['<where()>,select(297,821):mul(324,191);%{->:!#mul(567,73)don't()?why():^{$*]why()mul(504,229)'mul(40,787)/select()?who();[who()where();$mul(537,42)[#@&*~<@mul(418,58);{}how()*-don't()[<'@from() mul(38,329)-*mul(381,685)what()</:)^(',when()mul(850,565)@,,%select(95,745)#mul(99,343),]^who()[mul(46,377)mul(788,562)?<mul(101,829)]$#-]select()mul(536,292)who(419,754)mul(933:[>?+,,*%)mul(740,7)#)<how()mul(44,988)mul(693,770)why()-;[mul(76,905)where()];mul(457,100)what()mul(63,750)where()!&who()$>#)?^mul(211,355){~#who()<]who()@>~mul(135,667)-^)]'mul(165,161)<;,mul(350,311);%?~}$how(768,325)*mul(773,359)~!(select()?{why()mul(269,149)when()}*who()}mul(536,90)don't()>$ &!where()*who()&mul(405,425)!+mul(304,694)'<#$<<,#select()<mulselect()<?mul(448,840)!]-;mul(79,274)>):%:* -why()#mul[who()when(918,883){ ^''mul(907,968)what()when()[who()>mul(81'how()+what()select()<mul(66,242)mul(32,790)why()why()mul(707,867);{+[@select()@,mul(183,895)~mul(570)],:select(),%{%from()mul(568,881)[{@/}*mul(989,413)^($who()!}<&;mul(380,574)+why()?select()#mul(812,587)why()when()mul(772,647)>;&'']+how()mul(745,379)]^-mul(403,82)mul(840,830)when()+what()how()[!select()mul(827,564)?:]mul(602,333){what()[[mul(606,272)
|
||||||
|
,who()>}who():#from()mul(960,322)where()'<from()why()what()%where()mul(282,700)mul(591,113)<where()%, )mul(17}{')~!-mul(462,619)]mul(422,776)mul(250,987){((mul(880,386)(<>)?,+when() mul(59,855)'mul(308,433)~<how()>[;<why(98,720)@*mul(406,466)-what()when()'do()^mul(293,490)-@;{^why()who()mul(811,340)]^*what()[mul(705,73),:mul(557,31)mul(678,868)how()how()(when()mul:what(),how()where()when(354,851)who(418,214)when()where()mul(500,581)~what()how()mul(109,217)@>$;:mul(486@!>mul(508,605)what()from()mul(597,956)>#' *mul(834,240)}![{who(983,119)]#what()where()mul(533,711))}what()'/-mul(189,207)^*--$?mul(424,618)mul(407,288)why()<[+mul(170,906)&select()[,#who()+,mul(508,516)?who()!}+select()mul(963,397)*/]mul(129,895)$select()'when()^?mul(604,838)>mul(38,524)?why()~)[#*+:mul(793,697))what();}who())]mul(286,779)--where()![@(/}:mul(156-<%mul(862,26)select()mul(679,658);+mul(492,253)/;?$&}#mul(761&'[/*?mul(31,877)^where()mul(366,701)#mul(519,128)what()select():when()* mul](mul(46,247);mul(864,153)*mul(93,786)[$&&+mul(349,493,'~mul(161,724)~+$what():mul(326,607)what()select()mul(108,288)@(where(287,297)~how()<when()how()from()mul!^@->mul(15,832)select()!%( mul(233,322*;%],&@why(660,737)mul(47,778)?mul(68,311)}do()^/>[mul(572,909)^(,$,*~?mul(550,192){select()$${mul(949,906)?[^]@@^what()do()'<what()$mul(318,25)mul(406,742)'mul+['&{[^++@mul(550,647)'@)-mul(339,137),mul(412,523)(select()what()mul(234,64)!$[>mul(581,669)who()how()$~;(where())how()<mulwho()&?]%don't())~@~+mul(879,734)from()))*@#:$?where()mul(954,523)@what()<mul(481,127)]}<'/[who()why()+mul&%mul(244,792){[~mul(706,361)!;mul(658,168)$]mul(386,274)?what()* who()select()where(685,196)$what()mul(929,590)when()who()who()'mul(122,764)^%:@mul(315,523);~+;?/%&mul(97,566)~>what();<>^mul(859,756)mul(323,125%?}%where()mul(694,499),[mul(290,758)how()from()-/*<mul(179,392)how(930,981) ^())*}'$mul(446,657)*why()?]how()how()?from()mul(685,212)%when()' ;;from()?[mulwho(612,115)select()mul(56,213)[]}who()%,mul(241,98)^</%<&~from()mul(786,775) what()mul(748,183)'from()mul(388,111)where(){*}?&select()who()mul(108,115)mul(795,158) (~don't()*select()@:'!^mulselect()mul(838,249)@do() (~%[from()*)mul(327,71)what()%who(142,172)select()[!,what()}]do()>who()&'where()what()where()when()mul(286,592);: how(824,40)^mul(341,311)'&how()};^how()mul(479,155)-&when()%>!from() mul(743,297)/+% mul(785,803)~&/}#($?select()from()mul(378,606)/%when()mul(304,253)who())mul(19 mul(358,187)!/mul(61,423):%: )mul(773,349)select()mul(380,503)where()#%;do()who()$!(:&where()where()mul(25,688who()mul(539,689)?[/(>mul(915,247)how()@ when()why();;from()mul(192,625)?how()who()why()+<~where()!mul(922,457)how()@:+}[&{don't()mul(663,641)& :*]select()from()^>who(646,961)mul(302,499)mul(779,59)#+ /~;}mul(489]mul(883,556)from()#what()#:when():@$^mul(857,680)why(836,2)[mul(815,638)&why()~:why()~mul(960,833)<>from()where()where()$:who()mul(853,356)%;)+ where()from())do()<]mul(139,315){&+why(765,155),what()>@mul(281,247)mul(797,456) <>/:mul(785,173)when()$~-?:select()when()&mul(185,8)mul(510,671)%,when()how()where()from()who()mul(654,885)*who()mul(227,178)} !mul(256,394)
|
||||||
|
mul(888,165);]~mul(93,961)do();where(449,598)*-& #mul(364,267)how()what()where()&@%mul(173,845)+?>({]^-}!mul(500,764)why() , ;where()}mul(509,958)~#when()&'^(#*}mul(567,675)!why()%:(~where(){mul(659,362/<@+mul(442,603)where(232,716)!how()!;)$what()mul(47,742)don't()&{ what()mul(201,59)-how()where()&select()mul(564,724)&when(){><{who(56,63)>#mul(750,782)$,mul(713,443)(^>*who()mul(255,743)+< what()mul(13,455^when()%';how()<<&'%mul(909,623)[?%when()~[$mul(647,666)+why()mul(303,514)mul(866,565)why()*@what()(mul(528,440)mul(580,935)mul(621,192)(from()?who(),!*-mul(834,426),!]/)how()]why()do()how()}!{why()'@~^who()mul(114,512[#^~ select()*who(){^;mul(813,830)+;[#/[do()select()}/^(@!;*mul(667,761;#why()!(+(mul(427,964)why()^where()!;mul(816,813)&select()what()why()$><do()where();)<mul(238~/]^&when()what()what(181,18)mul(755,285) from()how():mul(452,659)#!}]$/what()mul(64,590)%?where()}&}/'}mul(948,939)~what();^+'~mul(688,702)'mul(557,538):'why()(why()from()%mul(731,311)>from()mul(204,891)*#^[-how()how(275,54)mul(862,293)^^/~>,*)mul(858,212)[how()?>where()mul(45,936)select())select() <)where()how()mul(617,746)/ ~%from()~mul(466,629)mul(604,220)why(235,921)^what()^select()who(540,898)what()>mul(893,561),%~(who()how())#+#mul(845};mul(795,975)who(),',mul(988,400)/$+,!$~mul(931,322)( <:%+when()mul+%<&<where():$&where()mul(795,328)'+][{mul(466,329)^mul(190,896){mul(367,236){ --<{~#where()mul(181,169)how(833,790)[/who()mul(876,536)how()(%;/>mul#'mul(892,416)what()why()mul(369,579)''mul(384,303)when()where()[what()-?$[when()mul(179,420):?:select()}when()when();,mul(246,209)select()mul(966,243)[mul(153,599)when()mul(914,433)[from()when()[--#;'!mul(810,766)select()why()$>!when()mul(931,687);select()how()@&mul(98,464)]mul(652,409)#:mul(516,121){<{() @~;how()mul(123,360))^](mul(277,239)mul(840,613)what()%mul(586,205)^]@#/don't()'[;^,$ from()mul(628,557)<)>];+who()mul(878,975from()mul(143,987)+when()*])%what()mul(603,174-from()~?mul(943,847)where(170,904)&#%]who(888,776)mul(302,183)mul(443,591),why():]~:%mul(77,426)when()where()mul(950,995)&mul(274,396)?[from()where()from()mul(409,518)$do()#^{why()mul(613,963)&^ >>;^how()mul(925,923);}mul(852,446*;& mul(743,312)do()%/who()*$]?mul(475,555)(>select();when()[mul(976,68)select()]what() +when()from()><mul(389,991)select(),mul(309,286)who(),where()why()^what(),^mul(400,11){/what()mul(152,74)/why():<*#++^mul(345,21)]who()}!'how()%(mul(679,89)>why()mul(976#>>how():''%what()mul(828,766)!@(mul(798,719)$]*<how()where()[mul(296,310)mul(681,531[>mul(646,954)@why()}from():$why()%/select()mul(741,161)+mul(91,115)^-}when()%++mul(933,749)from()<{when()(mul(909,579)#>;where()mul(211,740)$where()from()who()&mul(255,95)mul(511,373)&@!who()when()$@$?select()mul(2,521)^{)#mul(294,886)why()(!@mul(7,438)%*~(#{'$mul(234,87){+,how()how()mul(890,233)mul(801,729),;&(&mul(421@/+/from()when()/don't()/mul(672,498)what()mul(14,796)^![*what()when()# mul{!where()$where(871,580)}mul(717,476)&)'%?why(905,632)when()what()mul(815,617),how()mul(827,71)>?mul(837,520)*how()select()what())select(),how()$from()mul(952,273 &@mul(106,964)-[where()mul(778,265)}$'mul(947,970)who()<mul(832,154)}{}%[@mul(78,394)#select()[do()^select(){}#!/usr/bin/perl[@'/?~&>?>mul(780,897)
|
||||||
|
/,mul(904,917)how()from()] :%where()why(824,519)$}mul(433,689)-/{where()%>how()mul(232,555)&'@mul(170,145)?-{#?[mul(130<select(954,54)why():when() mul(152,582);{+?%,mul(911,198)+(}why()^!>?from()mul(575,167;~,${;-/)what()when()mul(688,24)&)#^*mul(251,895)(>from()#}]select()?}%mul(583,40)@what()!-mul(396',)!>%%when()}mul(127,975)#mul(986,310)what();from() <{'<mul(818,513))-[^&[mul(788,658who()*who(180,634)what()mul(183,781)mul(973,625)%how()mul(163,168)#%select())()mul/<mul(995,378)>?from()[&who()when()when()[mul(910,515)$mul(261,324)~</-'where(39,447)mul(872,74)mul(622,70)select() mul(648,514)[who(242,434)]<;?+>-mul(124,305)~select()mul(323,359)*~~mul(524}(;mul(145,708) %}what(487,689)%from()mul(371,88)~!)mul(883,681)why(621,555)from()-mul(175,888)&{];-what(569,630):?mul(229,850)&>'where()'mul(269,654]-why()//from()select()}mul(545,830)[?:}mul(849,642)/;(:)}<~mul(928,739)mul(216,77)select():;(when()@(}*]mul(113,497)(!~~;^[!mul(447,997);select()~[>]}~who()don't());}#why(326,879)+)-<(mul(581,152)> ;mul+how(771,784)+&why(582,346)'select()~what()<,mul(239,575)<(]+*from()]~'<mul(828,834)'mul(58,537)}]<mul(116-**><}@who()<-mul(473,971),:($when()from(41,290)what()];do())@^[@ from()mul(603,541)}mul(811,508)*?/!what()[-{mul(994,800 ?/!where()<why(104,314)mul(281,392)who();{who() ;(]when(133,642)mul(207,843)/%'mul(354,644)mulwhen()*;{mul(300,946)>who()where()what()}:what(){^[do()when(284,569)}>mul(150,172,]/<mul(972,952)~]do()how()>when()^mul(231,419)/do()select() }-#mul(671,892)<>/how(789,349)from()@what()#@)mul(315,222)from()}when()/}mul(930,682)>'where()?who()mul(132,978);;:@/#^}do()+mul(447,390): mul(723,622)?(how();$select()mul(980,864);>^why()[?#mul(734,179)# where(),@how()mul(838,788)/{++%mul(272,849):*%/^</$from()mul(453,461))mul(962,132)mul(375,359)!)%how()(?select()who()mul(142,910)?how()from()<$!mul(298,364)#who()+*who()!don't()mul(816,177)+mul(702,924)}(what()mul(989,523)<,,mul(735,588)how(489,394)mul(484,416)+#do()from()^^ $mul(123,782)mul(853,914)mul(203,868){'mul(909,468)why()/?where()$what()who(401,657)mul(786,343)mul(961,300)]{(!<do()^mul(936~mul(793,152)where()from()'-from()<+do()where(){+:mul(859,728)-where()%select()(mulwhat()mul(806,696)@<-mul(684,756),}who()how()~?:select()select()mul(471,727)from()<<why()what()how() }how()]mul(623,35)when():mul(871,956)mul(400,531)]where(), ;select()from()@select()don't()$/{[mul(519,781)[*mul(746,603 -from(112,309)]+ who()mul(217,136)-{+?select()#@%/mul(899,418)*!$+ *mul(154,146) +~where()mul(859,846)!<~%[{do():!(!{~mul(408,608)},/who()!, -mul(744,613)mul(829,465);~}/,'#+#mul(674,197)what()>%mul(466,441how()who()who()<why()where()select()mul(427,642)where();@+where()how(610,397))^mul(731,688)}())~why(29,145)do()(^{select(),<>'@(mul(692,669)#&mul(39,354)-where()from()who()~don't()*( {where();what()#mul(526,300)select(552,879), when()where()select()&-mul(283,140)&&?^ mul(243,254)how()/}who()mul(282,199)select()!](?'what()@&+mul(31,366)}who()mul(640,530)mul(565,470)mul(290,665){what(445,299)}<#%~ ][mul(320,303)-~from()(who()>[('why()don't()~&{)]mul(720,131)#~!!select()mul(3,408)-[where()from()who()}&}mul(558,189)!?[&(do()-^>mul(429,22)$!:>how()<,select()select(629,810)mul(748,450)(/<]?select()!//mul(679,551)how()who();?what()from()-mul(225,868)@{why()mul(177,830),{?^what())mul(229,827)~what()]'how(958,802)?who() (mul(676,215)[)mul(999,210)?]$*,?]-$,mul(661,825)
|
||||||
|
from()<#from()[@>?$(mul(631,608),+mul(946,420),( (^[^+/{mul(569,409),what()who()~mul(702,265);mul(88,623)}who()what()&mul(676,744)from() !+[do():who()^?mul(336,740)?mulwhy()from()!}where()%%mul(571,353)>$,& }>{*mul(276,415)><-do()~(]}mul(308,489)/from()when(579,867)what()~when()?&mul(633,256)how(){?~mul^why()who()>mul(223,473);why()when(),mul(722,306)from()^mul(200,701)!select()?,mul(711,878)how()where())##'+}#@mul(56,894)@[what()mul&-who()when()when()[%>?mul(281,311)where()where()how(){select()'%mul(949#[?:mul(895,313)/mul(25,736)mul*&):-/%who())mul(301,39)what()(mul(767,317)&!what()mul(271,721)(:where() :*&/mul(881,552)mul(117,678)> #),where()%)&$mul(394,101)<)>&who()what()'+mul(496,283)mul*]@+mul(331,181)select()'?:how()!what()-how()]mul(629,183){{(mul(980,656)! when()@{'-,what(),mul(93,847)++where();@select()when()mul(544,305)'#'<,from()>why()>mul(219,755)what(){ ~]}don't()-when();^^when())?~how()mul(590,547)(!from()when()[?}where()mul(930,301)where()^+when()what(733,168){>mul(899,94);:?mul(928,368)mul'what()how() >($mul(625,960)%'&where()select()~mul(584,72)^!mul(55,527);mul(492,224)?($:,',*select()mul(180,326)<what() mul(268,667)?+mul(235,375) *!]!mul(141,332);mul(356,884)from(695,588){{when()*&mul(711,131)*select()-*&mul(143,130)[select()[from(204,615) what()(mul(653,542)>select():{where()mul(824,130)what()mul(683,478)from(918,839)what()mul(582,660)<@*how()*(mul(681,373)(~~>@::]$mul(873,698)<@+when()-^mul(100,128)[^+:where()how(542,879)&{mul(327,603) $+!when()$mul(505,966) ,$~)>mul(193,642){!/,}* mul(784,245)}?what()when()#mul(4,692)<+&%!)mul(184,826)+mul(469,907)from()how(601,83)mul(307,230),@}where(318,472)from()}:})-mul(898,829?$^@where();what()(mul(258,499)mul(212,108){{!&<who()where()mul(38,864) :'#mul#where()mul(119,346)when()from()how()mul(979,593)~when()who()mulwho()where()from()*?who()])!)mul(941,717)what()from(){select()mul(29,799){{({;$don't()&/mul(321,8)mul(593,740)&:when()>what()who()who()mul(983,25)*);who()!, [don't()select();-%*@mul(798,455)when()$>from()where():do()mul(707,598)how())!:select()how()#do()mul(81,685)who()+where()mul(292,774)?/mul(80,716who()*{#;;*do()&%why()+mul(554,30)!select()],{%/what()mul(600,514)#when())do()@what()'%when()mul(955,368)[#/>:?-how() select()mul(170@?)mul(584,682)what()^,?]#@mul(623,37) ;mul(650,391)/%mul(535,768)how()when()mulwhere()when()when()*(mul(193,547)$)[why()'select()$$who()]mul(446,367),what()~@%*mul(675,581)mul(637,187){mul(727,146)}where()<how() mul(800,526)where()from(970,555)+when(),who()##mul(331,931)+[when()mul(604,25)who(265,522)select(330,185)when(){mul(893,602)select()#'(mul(280,461)-what()'-?)?mul(711,860)%&$^;]mul(389,793) }~from();from(233,583)&#)^mul(502,146)where()[mul(66,348):who()-?mul(511,100)+]@mul(329,746)<+how()$}how()/#where()don't(){~how()when()@where()'mul(479,879)why()who()who()who()}when()!from()+^mul(290,234)where()do(),how()mul(740,873):@who()mul(315where(744,335)(->)mul(896,767)select()'-mul(980,725)select()[ *#mul(159,247)!what()who(560,832){-why()what()~&#mul(567,372)-:!]?/why()+:{mul(277,161)-where()'-who()$how()<what(203,370)]do()/??:#[mul(524,458)why()*@!-}$$<:mul(903,579)&why()-$from()!()mul(102,88)-/]~mul(311,176)who(707,558)where(){what()^]mul(410,763)*&how()~;from():%@%mul(606,429<>who()from()'how(),$$when()mul(429,870):@;<#mul(587,942*&;*do()$$select()mul(3,25)when(),-%+:# from(872,943)}mul(782,821)
|
||||||
|
!>mul(851,461)+!where()$!{@!:)mul(93,494):!mul(951,143)+>)why()-{from()what()mul(988,791)mul(931,510)(:where(245,25){'mul(117,354)'what(); [[<don't()what())]:~#who()+mul(225,504%{]who();why()where()@<$<mul(639,292)&(from(),^ mul(104,198)&~ don't();&&[*when()?mul(181,83){why();>@how()select()do()when()?:from()mul(778,261):,+,mul(314,222);<?;who()what(){+mul(816,477)why()from()'where()^+<mul(199,340){-select()&mul(950,14){how()who()<don't()$}%mul(101,370)mul(615,41)how()>,^what(190,985)select() ?<mul(116,361)!@>*,[who()+:-mul(796,495)~/>do()<,}who()^mul(187,492)>'*$!what()mul(991,172)^&}:-mul(458,567)?mul(883,842)mul(755,150),!:%why()}mul(428,866)why()%why()where() (~:mul(352,708)what(370,596)$mul(898select()$why()~from()select()-when()mul(160,761)who(700,128)*mul(944,190)*#}^}from()where()mul(530,978):,+where()[?>mul(553,289)*$@/mul(286,141)what()@':~mulhow(116,291)%[mul(151,627)mul(362,891)~ %-<?;~mul(440,308)from()?<])mul(721,908)mul(45,682)*where(549,565)?~why()how()when()# mul(283,656)#!$when()~what()how()(mul(645,350),what()~^:select()-mul^<)what()what()do();$$when()mul(174,89)^mul(316,811)<~;:<select(619,564)mul(265,577)&why();why()where()&+ 'mul(365,604)?@&*,~what()$mul(568,621){+select():'[/select()mul(765,39!what())+mul(571,963)-:<+who()why()>/:%mul(275,35)@?&mul(276,797)who()/;who())why()when() ~)mul(400,219)where(757,508)}+'+>do()~?from()]~?why()${mul(674,313)]/!#select()^>how()&[do()mul(763,291)[?}><mul(424,631)#:]]mul(283,356)#/mul(999,277)[;;]mul(475,763)>$:;]/ @]mul(923,77)+:/,mul(974,68)}^<}*?(mul(573,391)?^mul(882,854)what()(from(){%!@+when()mul(263,665)'%/<[who(257,651)mul(131,306)#+[why()&,@{who()!mul(378,207)mul(830,423)how(180,743)[<$-)}-don't()mul(104,63)'$~+)/!(do()(?*when()/<:mul(184,312)-mul(457,714)?how()&where():!<(who()mul(832,385)?;&>select(),'[}-mul(409,111)<'who()who()}what(39,120)!<(@mul(466,625))from()'{:;what(),mul(833,127)$+!]mul(107,815)/ {what()what()mul(37,91)[-, what(812,83)?&mul(376,103)};-mul(640,727)select()[$-mul(64,181)mul(734,97)&@why()<#select()/?/mul(164,82)mul(786,473)@{'}mul(206,560)&~mul(784,62)@*^+what():!from()^[mul(206,626)what()[(,{where()from()why()?who()mul(533,212)#where()+how()']}where()((mul(301,424):what()#what()@ >'!do()@what()<what()when()'mul(89,449)select(871,600)+mul(438,837)-('mul(382,10)mul(547,112)mul(27,677)&]/<!#mul(141,36) where()select()$<why()!+mul(333,145)who()!)>mul(965,812)mul(3,550)from()who()!mul(965,728)#>#!)where()*)mul(497,530):when()#mul(352,808)!~{how()*!&mul(552,920)/where()+where()@-#/?mul(896,130)mul(347,579)~@ /^mul(727,709)#-how()&!&&@why()]mul(475,103)*how()/)~who()mul(542,160)mul(743,692)mul(561,997)why()mul(124,866)+}{why() mul(278,696)how()'what()$;?//where()when()mul(17,188)-+where()why();don't()--%<@why()+mul(356,107)%what()^,select()select(607,736):how()-mul(633,572)who()from()/;}select()mul(772,944)]@+/<]select()*?where()mul(858,850)(select()select()where()mul(181,712)~mul(979,178)#?}%?%do():who(268,689)*mul(941,59))-{&&(mul(296,702):@)where()don't()why()when(),mul(405,639)~$),who(575,232),%mul(671,828)
|
50
day_3/lexer.ts
Normal file
50
day_3/lexer.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
export class Lexer {
|
||||||
|
str: string;
|
||||||
|
pos: number;
|
||||||
|
|
||||||
|
constructor(str: string) {
|
||||||
|
this.str = str;
|
||||||
|
this.pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
next(): string {
|
||||||
|
return this.str[this.pos++];
|
||||||
|
}
|
||||||
|
peek(): string {
|
||||||
|
return this.str[this.pos];
|
||||||
|
}
|
||||||
|
match(str: string): boolean {
|
||||||
|
if (this.str.slice(this.pos, this.pos + str.length) === str) {
|
||||||
|
this.pos += str.length;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
matchDigit(): string {
|
||||||
|
if (/\d/.test(this.peek())) {
|
||||||
|
return this.next();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
skipN(n: number) {
|
||||||
|
this.pos += n;
|
||||||
|
}
|
||||||
|
matchDigitN(min: number, max: number) {
|
||||||
|
const originalPos = this.pos;
|
||||||
|
let digits = "";
|
||||||
|
for (let i = 0; i < min; i++) {
|
||||||
|
if (!/\d/.test(this.peek())) {
|
||||||
|
this.pos = originalPos;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
digits += this.next();
|
||||||
|
}
|
||||||
|
for (let i = 0; i < max - min; i++) {
|
||||||
|
if (!/\d/.test(this.peek())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
digits += this.next();
|
||||||
|
}
|
||||||
|
return digits;
|
||||||
|
}
|
||||||
|
}
|
54
day_3/solve_1.ts
Normal file
54
day_3/solve_1.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { Lexer } from "./lexer.ts";
|
||||||
|
|
||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
|
||||||
|
|
||||||
|
const lexer = new Lexer(txt);
|
||||||
|
|
||||||
|
function parseMulExpr(
|
||||||
|
lexer: Lexer,
|
||||||
|
){
|
||||||
|
if (!lexer.match("mul(")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const left = lexer.matchDigitN(1,3);
|
||||||
|
if (!left) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!lexer.match(",")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const right = lexer.matchDigitN(1,3);
|
||||||
|
if (!right) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!lexer.match(")")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "mul",
|
||||||
|
left: parseInt(left),
|
||||||
|
right: parseInt(right),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const exprs: {
|
||||||
|
type: string;
|
||||||
|
left: number;
|
||||||
|
right: number;
|
||||||
|
}[] = [];
|
||||||
|
while (lexer.pos < lexer.str.length) {
|
||||||
|
const expr = parseMulExpr(lexer);
|
||||||
|
if (expr) {
|
||||||
|
exprs.push(expr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lexer.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sum = 0;
|
||||||
|
for (const expr of exprs) {
|
||||||
|
sum += expr.left * expr.right;
|
||||||
|
}
|
||||||
|
console.log(sum);
|
96
day_3/solve_2.ts
Normal file
96
day_3/solve_2.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import { Lexer } from "./lexer.ts";
|
||||||
|
|
||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
|
||||||
|
const lexer = new Lexer(txt);
|
||||||
|
|
||||||
|
type Expr = {
|
||||||
|
type: "mul";
|
||||||
|
left: number;
|
||||||
|
right: number;
|
||||||
|
} | {
|
||||||
|
type: "do";
|
||||||
|
} | {
|
||||||
|
type: "don't";
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseMulExpr(
|
||||||
|
lexer: Lexer,
|
||||||
|
): Expr | null {
|
||||||
|
if (!lexer.match("mul(")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const left = lexer.matchDigitN(1,3);
|
||||||
|
if (!left) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!lexer.match(",")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const right = lexer.matchDigitN(1,3);
|
||||||
|
if (!right) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!lexer.match(")")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "mul",
|
||||||
|
left: parseInt(left),
|
||||||
|
right: parseInt(right),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDoExpr(
|
||||||
|
lexer: Lexer,
|
||||||
|
): Expr | null {
|
||||||
|
if (!lexer.match("do()")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "do",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDontExpr(
|
||||||
|
lexer: Lexer,
|
||||||
|
): Expr | null {
|
||||||
|
if (!lexer.match("don't()")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "don't",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseExpr(
|
||||||
|
lexer: Lexer,
|
||||||
|
): Expr | null {
|
||||||
|
return parseDoExpr(lexer) ?? parseDontExpr(lexer) ?? parseMulExpr(lexer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const exprs: Expr[] = [];
|
||||||
|
while (lexer.pos < lexer.str.length) {
|
||||||
|
const expr = parseExpr(lexer);
|
||||||
|
if (expr) {
|
||||||
|
exprs.push(expr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lexer.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sum = 0;
|
||||||
|
let enabled = true;
|
||||||
|
for (const expr of exprs) {
|
||||||
|
if (expr.type === "do") {
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
else if (expr.type === "don't") {
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
else if (enabled && expr.type === "mul") {
|
||||||
|
sum += expr.left * expr.right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(sum);
|
10
day_4/example.txt
Normal file
10
day_4/example.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
MMMSXXMASM
|
||||||
|
MSAMXMSMSA
|
||||||
|
AMXSXMAAMM
|
||||||
|
MSAMASMSMX
|
||||||
|
XMASAMXAMM
|
||||||
|
XXAMMXXAMA
|
||||||
|
SMSMSASXSS
|
||||||
|
SAXAMASAAA
|
||||||
|
MAMMMXMMMM
|
||||||
|
MXMXAXMASX
|
10
day_4/example2.txt
Normal file
10
day_4/example2.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.M.S......
|
||||||
|
..A..MSMS.
|
||||||
|
.M.S.MAA..
|
||||||
|
..A.ASMSM.
|
||||||
|
.M.S.M....
|
||||||
|
..........
|
||||||
|
S.S.S.S.S.
|
||||||
|
.A.A.A.A..
|
||||||
|
M.M.M.M.M.
|
||||||
|
..........
|
140
day_4/input.txt
Normal file
140
day_4/input.txt
Normal file
@ -0,0 +1,140 @@
|
|||||||
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AMMXSAMMAMM
|
||||||
|
SASASMSSSMMSMMMAMMSAMAMSAMXSASAAASMMAXAMMSXMASAMAMMSSMMAAAMASAXMASAMSAMMSMMAAXAAAAXAMXMMSSSMXMSAAAXMXAAMSSXSSXAMSMMMSSSMMMMAAMASASMMAMSMXAMX
|
||||||
|
MAMMMAAAAXAAAASAMAMSSXMAXXMSASXMSAASAMXMASAXXAAMXSAAAAMMMMSAMXSAXSASMAMSAASMMSMMMMMAMXAAXAAAXXMMMSMSSMMMAMXXAMMXAAMAAXAXMAMMMSAMAXAMXSAMSXSX
|
||||||
|
MXMSMSMSMMSSSMSASAMXMASMXSXMAMXXMXXMXXMAMSAMXSMMMMMSSXMXXMAMXXSAMMMMMXMMSXMAMSXXMMSSMXSSMSMMXXSSXXAXAMXMASXMASXSSSMMSSSMSASAXMASXSSMMSXMSAMX
|
5
day_4/small_example.txt
Normal file
5
day_4/small_example.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
..X...
|
||||||
|
.SAMX.
|
||||||
|
.A..A.
|
||||||
|
XMAS.S
|
||||||
|
.X....
|
57
day_4/solve_1.ts
Normal file
57
day_4/solve_1.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
const map = txt.split("\n").map((row) => row.trim().split(""));
|
||||||
|
|
||||||
|
const dirs = [-1, 0, 1].flatMap((x) => (
|
||||||
|
[-1, 0, 1].map((y) => [x, y])
|
||||||
|
)).filter(([x, y]) => x != 0 || y != 0);
|
||||||
|
|
||||||
|
function findXMASInPosDir(
|
||||||
|
map: string[][],
|
||||||
|
[x, y]: [number, number],
|
||||||
|
[dx, dy]: [number, number],
|
||||||
|
) {
|
||||||
|
const w = map[0].length;
|
||||||
|
const h = map.length;
|
||||||
|
const str = "XMAS";
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
// out of bounds
|
||||||
|
if (x < 0 || x >= w || y < 0 || y >= h) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (map[y][x] != str[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
y += dy;
|
||||||
|
x += dx;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findXMASInPos(map: string[][], [x, y]: [number, number]) {
|
||||||
|
let count = 0;
|
||||||
|
for (const [dx, dy] of dirs) {
|
||||||
|
if (
|
||||||
|
findXMASInPosDir(map, [x, y], [dx, dy])
|
||||||
|
) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findXMAS(map: string[][]) {
|
||||||
|
const w = map[0].length;
|
||||||
|
const h = map.length;
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
for (let i = 0; i < h; i++) {
|
||||||
|
for (let j = 0; j < w; j++) {
|
||||||
|
if (map[i][j] == "X") {
|
||||||
|
count += findXMASInPos(map, [j, i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(findXMAS(map));
|
53
day_4/solve_2.ts
Normal file
53
day_4/solve_2.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
const txt = await Deno.readTextFile("input.txt");
|
||||||
|
const map = txt.split("\n").map((row) => row.trim().split(""));
|
||||||
|
|
||||||
|
function isOutOfBounds(map: string[][], [x, y]: [number, number]) {
|
||||||
|
const w = map[0].length;
|
||||||
|
const h = map.length;
|
||||||
|
return x < 0 || x >= w || y < 0 || y >= h;
|
||||||
|
}
|
||||||
|
|
||||||
|
const patterns = [
|
||||||
|
["M", "M", "S", "S"],
|
||||||
|
["M", "S", "M", "S"],
|
||||||
|
["S", "M", "S", "M"],
|
||||||
|
["S", "S", "M", "M"],
|
||||||
|
];
|
||||||
|
const patternPositions = [
|
||||||
|
[-1, -1],
|
||||||
|
[1, -1],
|
||||||
|
[-1, 1],
|
||||||
|
[1, 1],
|
||||||
|
];
|
||||||
|
|
||||||
|
function findXMasPatternInPos(
|
||||||
|
map: string[][],
|
||||||
|
[x, y]: [number, number],
|
||||||
|
) {
|
||||||
|
if (isOutOfBounds(map, [x, y])) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (map[y][x] != "A") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let count = 0;
|
||||||
|
patterns.forEach((pattern) => {
|
||||||
|
for (let i = 0; i < pattern.length; i++) {
|
||||||
|
const [dx, dy] = patternPositions[i];
|
||||||
|
const [nx, ny] = [x + dx, y + dy];
|
||||||
|
if (isOutOfBounds(map, [nx, ny]) || map[ny][nx] != pattern[i]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
for (let i = 0; i < map.length; i++) {
|
||||||
|
for (let j = 0; j < map[0].length; j++) {
|
||||||
|
count += findXMasPatternInPos(map, [j, i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(count);
|
Loading…
Reference in New Issue
Block a user