This file contains hidden or 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
| const fs = require('fs'); | |
| const input = fs.readFileSync('input.txt', 'utf8'); | |
| const column1 = [], | |
| column2 = [], | |
| differences = [], | |
| similarity = [] | |
| input.split(/\n/).forEach(row => { | |
| const [first, second] = row.split(' ') |
This file contains hidden or 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
| const input = ["Card 1: 13 5 40 15 21 61 74 55 32 56 | 21 57 74 56 7 84 37 47 75 66 68 8 55 22 53 61 40 13 15 41 32 46 95 65 5","Card 2: 92 97 39 23 25 40 33 70 55 77 | 25 70 23 91 45 60 34 56 82 6 9 62 24 3 67 99 18 58 1 26 50 37 32 14 85","Card 3: 44 71 17 92 34 98 50 61 89 79 | 57 56 89 98 59 61 44 97 79 18 71 50 34 92 23 63 20 51 64 47 76 17 46 54 62","Card 4: 87 70 44 19 3 54 81 15 72 46 | 75 70 74 84 1 61 85 14 79 66 26 93 39 73 67 21 91 12 3 86 41 42 6 27 49","Card 5: 86 63 59 76 89 62 87 20 2 66 | 21 58 72 98 95 14 38 16 35 88 60 55 3 36 65 1 28 56 11 74 15 29 93 50 17","Card 6: 24 92 61 55 50 51 78 2 60 91 | 55 91 51 56 45 67 13 36 66 8 99 62 78 2 92 49 44 69 42 65 50 34 35 82 60","Card 7: 91 88 72 26 86 34 14 66 31 20 | 25 24 73 97 72 20 87 26 15 47 90 22 14 86 62 68 61 69 88 91 66 27 31 34 52","Card 8: 40 66 64 42 52 5 18 49 67 94 | 23 5 66 53 33 24 95 86 2 46 67 87 68 71 83 21 78 41 29 62 70 69 61 60 93","Card 9: 41 86 83 7 80 3 98 95 94 28 | 78 62 21 65 53 6 75 90 39 70 98 59 37 61 49 43 52 34 23 |
This file contains hidden or 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
| const input = [ | |
| "Game 1: 1 green, 1 blue, 1 red; 3 green, 1 blue, 1 red; 4 green, 3 blue, 1 red; 4 green, 2 blue, 1 red; 3 blue, 3 green","Game 2: 9 blue, 7 red; 5 blue, 6 green, 1 red; 2 blue, 10 red, 9 green; 3 green, 14 red, 5 blue; 8 red, 3 blue, 4 green; 8 green, 14 blue, 10 red","Game 3: 11 green, 8 blue, 7 red; 3 green, 4 red, 9 blue; 3 red, 4 green, 8 blue; 11 green, 1 red, 16 blue","Game 4: 3 blue, 20 green, 2 red; 1 green, 3 red, 3 blue; 1 blue, 9 green; 4 red, 17 green; 12 green, 3 red","Game 5: 2 red, 1 blue, 4 green; 6 blue, 2 green; 2 red, 5 green","Game 6: 1 green, 7 red; 1 blue, 3 green, 1 red; 1 blue, 2 red, 2 green; 1 blue, 1 green, 2 red; 3 red; 8 red, 1 green, 1 blue","Game 7: 13 green, 5 blue, 1 red; 9 green, 6 blue; 11 green, 2 blue, 2 red","Game 8: 2 red, 11 green, 6 blue; 5 green, 3 blue; 3 blue, 3 green, 5 red; 5 blue, 9 green, 1 red","Game 9: 3 blue, 5 green, 8 red; 4 green, 19 blue, 4 red; 4 red, 17 blue","Game 10: 2 green, 8 red, 4 blue; 1 green, 5 red, 9 blue; 3 green, 2 red, 4 |
This file contains hidden or 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
| const MAP = { | |
| 'zero': 0, | |
| 'one': 1, | |
| 'two': 2, | |
| 'three': 3, | |
| 'four': 4, | |
| 'five': 5, | |
| 'six': 6, | |
| 'seven': 7, | |
| 'eight': 8, |
This file contains hidden or 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
| const firstNumber = parseInt(process.argv[2]); | |
| const secondNumber = parseInt(process.argv[3]); | |
| if (firstNumber && secondNumber) { | |
| const hasExactlySixDigits = number => parseInt(number).toString().length === 6; | |
| const twoAdjacentDigitsMatch = number => { | |
| const input = parseInt(number).toString(); | |
| let returnValue = false; | |
| for (let i = 0; i < input.length - 1; i++) { |
This file contains hidden or 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
| class Point { | |
| constructor(x, y) { | |
| this.x = x; | |
| this.y = y; | |
| } | |
| get distanceFromOrigin() { | |
| return Math.abs(this.x) + Math.abs(this.y); | |
| } | |
| move(direction, distance) { | |
| switch (direction) { |
This file contains hidden or 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
| let originalInput = [1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,9,1,19,1,5,19,23,2,9,23,27,1,27,5,31,2,31,13,35,1,35,9,39,1,39,10,43,2,43,9,47,1,47,5,51,2,13,51,55,1,9,55,59,1,5,59,63,2,6,63,67,1,5,67,71,1,6,71,75,2,9,75,79,1,79,13,83,1,83,13,87,1,87,5,91,1,6,91,95,2,95,13,99,2,13,99,103,1,5,103,107,1,107,10,111,1,111,13,115,1,10,115,119,1,9,119,123,2,6,123,127,1,5,127,131,2,6,131,135,1,135,2,139,1,139,9,0,99,2,14,0,0]; | |
| function createInput(noun, verb) { | |
| let returnValue = [...originalInput]; | |
| returnValue[1] = noun; | |
| returnValue[2] = verb; | |
| return returnValue; | |
| } | |
| function runProgram(input) { |
This file contains hidden or 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
| const input = [115919,56833,117651,56733,89472,91010,119618,85667,141042,106401,121495,50136,83755,122558,149188,110381,132060,145791,141381,136467,104712,133530,65297,52640,59637,78410,107791,96909,136738,109794,66831,58426,97955,90496,119294,83101,80466,114370,67631,106482,73996,50367,113976,68998,109714,96308,89350,143077,102052,93325,86870,94449,119448,53472,140668,64989,112056,88880,131335,94943,88061,122883,129059,55345,82362,60500,147652,83147,87106,97384,136883,62198,130290,129715,93082,72179,72109,70604,94894,98139,97056,86236,144191,108008,79225,93551,103116,130702,87599,143630,104476,108922,134209,85636,81591,127980,90425,126133,118135,93722]; | |
| const fuelCalculator = (mass) => Math.floor(mass / 3) - 2; | |
| const reducer = (previousvalue, currentValue) => previousvalue + currentValue; | |
| const fuelRequiredForModules = input.map(fuelCalculator); | |
| const fuelRequired = fuelRequiredForModules.reduce(reducer); | |
| console.log(`The first answer is ${fuelRequired}.`); |
This file contains hidden or 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
| $global-colors: ( | |
| neutral: ( | |
| x-light: #f1f1f1, | |
| ), | |
| primary: #df2, | |
| secondary: ( | |
| base: ( | |
| old: red, | |
| new: green | |
| ) |
This file contains hidden or 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
| $global-colors: ( | |
| neutral: #ccc, | |
| success: green, | |
| error: red | |
| ); | |
| $local-colors: ( | |
| primary: ( | |
| base: #33c, | |
| dark: #00a |
NewerOlder