From 8d409bcf8faff1b7c95f8f29b82a1ea4df16e21b Mon Sep 17 00:00:00 2001 From: Tanishq Dubey Date: Sat, 3 Dec 2022 20:15:03 -0500 Subject: [PATCH] day 3 done --- day3/.gitignore | 86 +++++++++++++ day3/inp | 300 +++++++++++++++++++++++++++++++++++++++++++++ day3/input | 6 + day3/package.json | 5 + day3/solution.ts | 73 +++++++++++ day3/tsconfig.json | 7 ++ 6 files changed, 477 insertions(+) create mode 100644 day3/.gitignore create mode 100644 day3/inp create mode 100644 day3/input create mode 100644 day3/package.json create mode 100644 day3/solution.ts create mode 100644 day3/tsconfig.json diff --git a/day3/.gitignore b/day3/.gitignore new file mode 100644 index 0000000..409c9e1 --- /dev/null +++ b/day3/.gitignore @@ -0,0 +1,86 @@ +node_modules/ +.node_modules/ +built/* +tests/cases/rwc/* +tests/cases/test262/* +tests/cases/perf/* +!tests/cases/webharness/compilerToString.js +test-args.txt +~*.docx +\#*\# +.\#* +tests/baselines/local/* +tests/baselines/local.old/* +tests/services/baselines/local/* +tests/baselines/prototyping/local/* +tests/baselines/rwc/* +tests/baselines/test262/* +tests/baselines/reference/projectOutput/* +tests/baselines/local/projectOutput/* +tests/baselines/reference/testresults.tap +tests/services/baselines/prototyping/local/* +tests/services/browser/typescriptServices.js +src/harness/*.js +src/compiler/diagnosticInformationMap.generated.ts +src/compiler/diagnosticMessages.generated.json +src/parser/diagnosticInformationMap.generated.ts +src/parser/diagnosticMessages.generated.json +rwc-report.html +*.swp +build.json +*.actual +tests/webTestServer.js +tests/webTestServer.js.map +tests/webhost/*.d.ts +tests/webhost/webtsc.js +tests/cases/**/*.js +!tests/cases/docker/*.js/ +tests/cases/**/*.js.map +*.config +scripts/eslint/built/ +scripts/debug.bat +scripts/run.bat +scripts/**/*.js +scripts/**/*.js.map +coverage/ +internal/ +**/.DS_Store +.settings +**/.vs +**/.vscode/* +!**/.vscode/tasks.json +!**/.vscode/settings.template.json +!**/.vscode/launch.template.json +!**/.vscode/extensions.json +!tests/cases/projects/projectOption/**/node_modules +!tests/cases/projects/NodeModulesSearch/**/* +!tests/baselines/reference/project/nodeModules*/**/* +.idea +yarn.lock +yarn-error.log +.parallelperf.* +tests/cases/user/*/package-lock.json +tests/cases/user/*/node_modules/ +tests/cases/user/*/**/*.js +tests/cases/user/*/**/*.js.map +tests/cases/user/*/**/*.d.ts +!tests/cases/user/zone.js/ +!tests/cases/user/bignumber.js/ +!tests/cases/user/discord.js/ +tests/baselines/reference/dt +.failed-tests +TEST-results.xml +package-lock.json +tests/cases/user/npm/npm +tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter +tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter +tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter +tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter +tests/cases/user/create-react-app/create-react-app +tests/cases/user/fp-ts/fp-ts +tests/cases/user/webpack/webpack +tests/cases/user/puppeteer/puppeteer +tests/cases/user/axios-src/axios-src +tests/cases/user/prettier/prettier +.eslintcache diff --git a/day3/inp b/day3/inp new file mode 100644 index 0000000..039c2c5 --- /dev/null +++ b/day3/inp @@ -0,0 +1,300 @@ +LdHVLDLDdHdtLMhcqCqGWcWg +ZZQZSZnnJrQrJQJbfzfnWGWPWMcChMMPcqMnhFcF +ZrzpWzfbpQpWbzvZWZpdtVtDNmRHNVptNDHt +gzCjffWZCtCfZZVdqVSqJdvJndSt +hMHLcmGLMLhHmsRMsSvsQSqrsrlJTTdV +NPNGRGHGHNLczNzzZFWSFFCC +VSBpcvNNbNWWSfGRwtJnRtrzzGzGGn +jZlhTlQLHFLLZbwrzQQsttDtbs +hmmPFlhLmhLMgFMFLbMBBgcNVcfNCcfSVSSNBq +jRDSzjCjjMRMrHzMRCDHMDjBnlQbbnQwLwrNLPwnTPQrlc +sZBqdZqsWgFBpgppGJqllPllwnbQwTwsswQPwN +gJgtJJBtqJqWBG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hMVS +JJDpdDTtCtzNptnTJBznnvLCCvcFqsRqFcvZclLGRR diff --git a/day3/input b/day3/input new file mode 100644 index 0000000..f17e726 --- /dev/null +++ b/day3/input @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw diff --git a/day3/package.json b/day3/package.json new file mode 100644 index 0000000..29c5523 --- /dev/null +++ b/day3/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "@types/node": "^18.11.10" + } +} diff --git a/day3/solution.ts b/day3/solution.ts new file mode 100644 index 0000000..897c8eb --- /dev/null +++ b/day3/solution.ts @@ -0,0 +1,73 @@ +import { readFileSync } from 'fs'; +import { join } from 'path'; + +function findNDupes(inputArrays): string { + var countMap = {}; + for (const inputArray of inputArrays) { + const s = new Set(inputArray); + s.forEach(function(val){ + if (val in countMap) { + countMap[val] += 1; + } else { + countMap[val] = 1; + } + }); + } + + for (const key in countMap) { + if (countMap[key] == inputArrays.length) { + return key; + } + } +} + +const fileString = readFileSync(join(__dirname, "inp"), 'utf-8'); +const rucksacks = fileString.split("\n"); + +var sum: number = 0; + +for (const rucksack of rucksacks) { + if (rucksack.length == 0) { + continue; + } + const items = rucksack.split(''); + const firstHalf = items.slice(0, items.length/2); + const secondHalf = items.slice(items.length/2, items.length); + const ndup = findNDupes([firstHalf, secondHalf]) + + const s = new Set(ndup); + s.forEach(function(val){ + const charNum = val.charCodeAt(0); + if (charNum > 96) { + sum += charNum - 96; + } else { + sum += charNum - 38; + } + }); +} + +console.log(sum); + + +sum = 0; + +for (var i = 0; i < rucksacks.length; i += 3) { + if (i + 1 >= rucksacks.length) { + continue; + } + const r1 = rucksacks[i].split(''); + const r2 = rucksacks[i+1].split(''); + const r3 = rucksacks[i+2].split(''); + + const ndup = findNDupes([r1, r2, r3]) + const s = new Set(ndup); + s.forEach(function(val){ + const charNum = val.charCodeAt(0); + if (charNum > 96) { + sum += charNum - 96; + } else { + sum += charNum - 38; + } + }); +} +console.log(sum); diff --git a/day3/tsconfig.json b/day3/tsconfig.json new file mode 100644 index 0000000..80c821c --- /dev/null +++ b/day3/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "node" + ] + } +}