Compare commits

...

4 Commits

Author SHA1 Message Date
pegasust 8167444f00 format d3 2022-12-03 09:56:55 +00:00
pegasust 7a938f2272 d3: add (a little bit more) concise solution 2022-12-03 09:54:11 +00:00
pegasust 8645ee05f2 d3: prototype done 2022-12-03 08:50:36 +00:00
pegasust b5c22d2126 d3: initial sub 2022-12-03 07:51:40 +00:00
7 changed files with 443 additions and 12 deletions

View File

@ -0,0 +1,6 @@
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw

View File

@ -1,6 +1,301 @@
vJrwpWtwJgWrhcsFMMfFFhFp wcsbsWwspmFTGVV
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL RHtMDHdSMnDBGMSDvnvDjtmpTpjTFggpmjmTFggTjmpP
PmmdzqPrVvPwwTWBwg vtCSGRMBDzHddvBHBzRhrlcZhlLzWNlqblhzcr
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn shhszHNHHZWqSzVNdClMjlFjBBbNTB
ttgJtRGJQctTZtZT tQQGmnrMnJnGfmvrRRPCjlbljFBdjFCjTjnP
CrZsJsPPZsGzwwsLwLmpwMDw mRwtfGrMmJtwRDvQJQrJpMLSzVDHzhzHZqZzqSzcWVWH
WsWWgrtgsrhTQtsFcWPcRMCCTvqvMvqNNqMMHlMq
bBJrBGbzzLJznJrbSDGGJLqmlvqMqvlmLHRqRZZRNZ
bzJfDGVSzVrJGwjVGPPpQthdPsPpjdphsc
pJpCCBSWlczWWBWMHdMmMsFmpddrgF
wfVqZZGVQvzsMqmMgHjm
vDZGvPttQTVtGDQDDDGwbSCcSJSCJWTcRRSRczRJ
HLVHsVWLwbWswbpWFWrrmThfTPNnhNSDDNhDfznTnhnS
pBRcvGvvBtpGcqqQvgcphPfzfDGhzdzPDzDDhnhS
Z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+3,9 @@
# Runs deno at src/d3_deno.ts with arguments ["example.txt"] # Runs deno at src/d3_deno.ts with arguments ["example.txt"]
echo "example.txt" echo "example.txt"
deno run --allow-read "${PWD}/src/d3_deno.ts" "${PWD}/data/example.txt" deno run --allow-read "${PWD}/src/d3_deno.ts" "${PWD}/data/example.txt"
deno run --allow-read "${PWD}/src/d3_deno_concise.ts" "${PWD}/data/example.txt"
echo "submission.txt" echo "submission.txt"
deno run --allow-read "${PWD}/src/d3_deno.ts" "${PWD}/data/submission.txt" deno run --allow-read "${PWD}/src/d3_deno.ts" "${PWD}/data/submission.txt"
deno run --allow-read "${PWD}/src/d3_deno_concise.ts" "${PWD}/data/submission.txt"

View File

@ -1,6 +1,75 @@
if(Deno.args.length < 1) { // Usable by Windows and UNIX
throw Error("d3_deno.ts expects a single argument that points to AOC's day 3 input file"); const LINE_SPLIT = (/\r?\n/);
}
const fileLoc = Deno.args[0];
const text = await Deno.readTextFile(fileLoc);
function priority(chr: string) {
if (chr.length != 1) {
throw Error('Expecting character');
}
const ord = (v: string) => v.charCodeAt(0);
return (ord('a') <= ord(chr) && ord(chr) <= ord('z'))
? (ord(chr) - ord('a') + 1)
: (ord(chr) - ord('A') + 27);
}
async function main(fileLoc: string) {
// part 1
const text = await Deno.readTextFile(fileLoc);
const prioritized = text.split(LINE_SPLIT) // split by each line, basically iterates through each rucksack
.map((line) => line.trim()).filter((line) => line.length != 0) // pre-proc: remove "falsy lines"
.map((s) => [...s].map(priority)) // translate each character into respective priority
;
const sumPrioOfShared = prioritized
.map((v) => [v.slice(0, v.length / 2), v.slice(v.length / 2, v.length)]) // splits by 2 compartments
.map(([left, right]) => {
// Finds the value on the right compartment that also exists in left compartment
const left_set = new Set(left);
// by the prompt, we're pretty guaranteed to have a solution
const shared = right.find((e) => left_set.has(e))!;
// console.log('shared:', shared);
return shared;
}).reduce((a, b) => a + b); // find its sum
console.log('part 1:', sumPrioOfShared);
// part 2
// eventually was not used. part 2
const setDiff = <T>(a: Set<T>, b: Set<T>) =>
new Set([...a].filter((e) => !b.has(e)));
const setRetain = <T>(a: Set<T>, b: Set<T>) =>
new Set([...a].filter((e) => b.has(e)));
const groupBy = <T, K>(arr: T[], groupFn: (e: T, idx: number) => K) => {
return arr.reduce<Map<K, T[]>>((ret, e, idx) => {
const groupId = groupFn(e, idx);
const last = ret.get(groupId) ?? [];
last.push(e);
ret.set(groupId, last);
return ret;
}, new Map());
};
const toGroupPair = <K, V>(groupMap: Map<K, V[]>) =>
Array.from(groupMap.entries());
const groupByThree = (_: unknown, idx: number) => Math.floor(idx / 3);
const threeGrouped = groupBy(prioritized, groupByThree);
// console.log("threeGrouped", threeGrouped);
const badges = toGroupPair(threeGrouped)
.map(([_, group]) => group)
.map((group) =>
group.map((bag) => new Set(bag))
.reduce((left, right) => setRetain(left, right))
).map((e) => [...e][0]); // get the only element in the set for each group
console.log('part 2:', badges.reduce((a, b) => a + b));
}
if (Deno.args.length < 1) {
throw Error(
'd3_deno.ts expects a single argument that points to AOC\'s day 3 input file',
);
}
const fileLoc = Deno.args[0];
await main(fileLoc);

View File

@ -0,0 +1,60 @@
// Usable by Windows and UNIX
const LINE_SPLIT = (/\r?\n/);
async function main(fileLoc: string) {
const input = await Deno.readTextFile(fileLoc);
const ord = (s: string) => s.charCodeAt(0);
const prioritized = input.split(LINE_SPLIT).map((line) => line.trim())
.filter((line) => line.length != 0)
.map((line) =>
[...line].map((e) => e.charCodeAt(0))
.map((e) =>
e - ((ord('a') <= e && e <= ord('z'))
? (ord('a') - 1)
: (ord('A') - 27))
)
);
const retain = <T>(a: T[], b: T[]) => {
const bSet = new Set(b);
return a.filter((e) => bSet.has(e));
};
const halves = <T>(a: T[]) =>
[a.slice(0, a.length / 2), a.slice(a.length / 2, a.length)] as const;
console.log(
'part 1',
prioritized
.map((sack) => retain(...halves(sack))[0]).reduce((a, b) => a + b),
);
const arrayGroupBy = <T, F>(a: T[], groupFn: (elem: T, idx: number) => F) =>
a.reduce((ret, e, idx) => {
const identity = groupFn(e, idx);
if (!ret.groupMap.has(identity)) {
ret.groupMap.set(identity, ret.groupKeys.length);
ret.groupKeys.push(identity);
ret.groups.push([identity, []]);
}
ret.groups[ret.groupMap.get(identity)!][1].push(e);
return ret;
}, {
groupKeys: new Array<F>(),
groupMap: new Map<F, number>(),
groups: new Array<[F, T[]]>(),
}).groups;
console.log(
'part 2',
arrayGroupBy(prioritized, (_, idx) => Math.floor(idx / 3))
.map(([_idx, sacks]) => sacks)
.map((groupOf3) => groupOf3.reduce((a, b) => retain(a, b))[0])
.reduce((a, b) => a + b),
);
}
if (Deno.args.length < 1) {
throw Error(
'd3_deno.ts expects a single argument that points to AOC\'s day 3 input file',
);
}
const fileLoc = Deno.args[0];
await main(fileLoc);