From 19b99912765ac66709a6a172220ef391e9333457 Mon Sep 17 00:00:00 2001 From: Jan <26145882+imverum@users.noreply.github.com> Date: Sat, 5 Dec 2020 13:17:36 +0100 Subject: [PATCH] pain day 5 --- day_5/input.txt | 902 ++++++++++++++++++++++++++++++++++++++++++++++++ day_5/task_1.js | 20 ++ day_5/task_2.js | 36 ++ 3 files changed, 958 insertions(+) create mode 100644 day_5/input.txt create mode 100644 day_5/task_1.js create mode 100644 day_5/task_2.js diff --git a/day_5/input.txt b/day_5/input.txt new file mode 100644 index 0000000..bf4b075 --- /dev/null +++ b/day_5/input.txt @@ -0,0 +1,902 @@ +BBBFBFFRLL +FBBBBBFRRR +FBFFBBBRLR +FBBFBFBRLR +BBFBBFBLRL +BBFBFBBLLL +BBBBFFFRLL +FBBFFFBRRL +BFBFFBBRLL +BFFBFBBRLL +BBFFFBFRLR +FFBFBBBRRL +BBFFBFFLRL +FFBBBFFRLR +BFFFBFFRRL +BBFBFFFRRL +FBBFFFFRLL +FBBFFFBLRL +FBFFFFFRRR +FBBBFBFRLR +BFFBFFFRLR +BFBBBBFLLR +BBBBFFBLLR +FFFBBFFRRL +BBFBBFBLLL +BFBFBFBLRL +FFBBBFBLLR +FFFBFBFLRL +FBFBFBFLLL +FBBBFFBLLR +FBFBBFBLLR +FFFBFFFRLR +BFBBBFFRRL +FBFBBBBRLL +FBFFBFFLLR +BFFFFBFRLL +BFFBBFFRLL +FFBFBFFLLL +FFBBFFBRRR +BFFBBFBLLL +BBFBFBFLRL +BFBFFBFLRR +BFBBBFBRLL +FBBFFFFRRL +FFFBBBFLLL +FFBBBBFLLR +BBFBBFFRRL +BBFBBBFLLR +BBBFBFBLRR +BBFFFFFLRR +BFFBFFBLLR +FFFBFBFRLL +FBBBBFFRLR +BFBBBFFRRR +FBFFFFFRLR +BBFBBFFLRL +BBFFBFFLLR +FFBBBFBLRR +BBFBFBFRLR +FBBBFFFRLR +FFBFFFFLLL +FFBBFFBLLL +BBBFFBBRLL +BFFFFF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FBFLLL \ No newline at end of file diff --git a/day_5/task_1.js b/day_5/task_1.js new file mode 100644 index 0000000..12f51df --- /dev/null +++ b/day_5/task_1.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const file = fs.readFileSync(__dirname + '/input.txt').toString('utf-8'); +const arr = file.split('\n'); + +let highestSeatID = 0; +arr.forEach(seatIdentifier => { + let rowInstructions = seatIdentifier.replace(/[L|R]/g, '').replace(/B/g, 1).replace(/F/g, 0).split(''); + let colInstructions = seatIdentifier.replace(/[F|B]/g, '').replace(/R/g, 1).replace(/L/g, 0).split(''); + + let row = 128, col = 8, mR = row/2, mC = col/2; + rowInstructions.forEach(bit => { bit == 1 ? null : row = row - mR ; mR/=2 }); + colInstructions.forEach(bit => { bit == 1 ? null : col = col - mC ; mC/=2 }); + row--; col--; + + let seatID = row * 8 + col; + if (seatID > highestSeatID) highestSeatID = seatID; +}); + +console.log(`Total seats: ${arr.length}`); +console.log(`Highest seat ID: ${highestSeatID}`); \ No newline at end of file diff --git a/day_5/task_2.js b/day_5/task_2.js new file mode 100644 index 0000000..a10bb4e --- /dev/null +++ b/day_5/task_2.js @@ -0,0 +1,36 @@ +const fs = require('fs'); +const file = fs.readFileSync(__dirname + '/input.txt').toString('utf-8'); +const arr = file.split('\n'); + +let highestSeatID = 0; +let existingSeats = {}; + +arr.forEach(seatIdentifier => { + let rowInstructions = seatIdentifier.replace(/[L|R]/g, '').replace(/B/g, 1).replace(/F/g, 0).split(''); + let colInstructions = seatIdentifier.replace(/[F|B]/g, '').replace(/R/g, 1).replace(/L/g, 0).split(''); + + let row = 128, col = 8, mR = row/2, mC = col/2; + rowInstructions.forEach(bit => { bit == 1 ? null : row = row - mR ; mR/=2 }); + colInstructions.forEach(bit => { bit == 1 ? null : col = col - mC ; mC/=2 }); + row--; col--; + + let seatID = row * 8 + col; + if (seatID > highestSeatID) highestSeatID = seatID; + existingSeats[`${row}-${col}`] = seatID; +}); + +let lowR = 0, lowS = 0; +let found = false; + +for (let i=0; i<=127; i++) { + for (let j=0; j<=7; j++) { + if (!existingSeats[`${i}-${j}`]) { + if (lowR+1 == i) lowR = i; + if (i > lowR && !found) { + found = true; + console.log(`Missing seat ${i}-${j} with ID ${i*8+j}`); + } + } + } +} +console.log(`Total seats: ${arr.length}`); \ No newline at end of file