This file contains 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 = require("fs").readFileSync("day11-input.txt", "UTF-8"); | |
const map = { | |
n: { x: 0, y: 1 }, | |
ne: { x: 1, y: 1 }, | |
se: { x: 1, y: -1 }, | |
s: { x: 0, y: -1 }, | |
sw: { x: -1, y: -1 }, | |
nw: { x: -1, y: 1 } | |
}; |
This file contains 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 data = require("fs").readFileSync("day9-input.txt", "UTF-8"); | |
let garbage = 0; | |
let total = 0; | |
let canceled = false; | |
let ignore = false; | |
let depth = 0; | |
data.split("").forEach(char => { | |
if (ignore) { |
This file contains 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 data = require("fs").readFileSync("day8-input.txt", "UTF-8"); | |
map = {}; | |
maxCPU = 0; | |
data.split("\n").forEach(row => { | |
action = row.split(" if ")[0].split(" "); | |
conditionStr = row.split(" if ")[1]; | |
conditionVar = conditionStr.split(" ")[0]; | |
actionVar = action[0]; | |
increment = action[1] === "inc"; |
This file contains 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
0 | |
1 | |
0 | |
1 | |
0 | |
-1 | |
0 | |
1 | |
2 | |
2 |
This file contains 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
function part1(str) { | |
let numbers = str.split("\n").map(num => parseInt(num)); | |
let count = 0; | |
let nextIndex = 0; | |
let mazeSize = numbers.length; | |
while (nextIndex < mazeSize) { | |
count++; | |
const currentIndex = nextIndex; | |
nextIndex = numbers[currentIndex] + currentIndex; | |
numbers[currentIndex] = numbers[currentIndex] + 1; |
This file contains 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 = | |
"sayndz zfxlkl attjtww cti sokkmty brx fhh suelqbp\n" + | |
"xmuf znkhaes pggrlp zia znkhaes znkhaes\n" + | |
"nti rxr bogebb zdwrin\n" + | |
"sryookh unrudn zrkz jxhrdo gctlyz\n" + | |
"bssqn wbmdc rigc zketu ketichh enkixg bmdwc stnsdf jnz mqovwg ixgken\n" + | |
"flawt cpott xth ucwgg xce jcubx wvl qsysa nlg\n" + | |
"qovcqn zxcz vojsno nqoqvc hnf gqewlkd uevax vuna fxjkbll vfge\n" + | |
"qrzf phwuf ligf xgen vkig elptd njdm gvqiu epfzsvk urbltg dqg\n" + | |
"sfpku viwihi fje umdkwvi ejzhzj qrbl sfpku sad nawnow ksnku\n" + |
This file contains 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 = | |
"4168 3925 858 2203 440 185 2886 160 1811 4272 4333 2180 174 157 361 1555\n" + | |
"150 111 188 130 98 673 408 632 771 585 191 92 622 158 537 142\n" + | |
"5785 5174 1304 3369 3891 131 141 5781 5543 4919 478 6585 116 520 673 112\n" + | |
"5900 173 5711 236 2920 177 3585 4735 2135 2122 5209 265 5889 233 4639 5572\n" + | |
"861 511 907 138 981 168 889 986 980 471 107 130 596 744 251 123\n" + | |
"2196 188 1245 145 1669 2444 656 234 1852 610 503 2180 551 2241 643 175\n" + | |
"2051 1518 1744 233 2155 139 658 159 1178 821 167 546 126 974 136 1946\n" + | |
"161 1438 3317 4996 4336 2170 130 4987 3323 178 174 4830 3737 4611 2655 2743\n" + | |
"3990 190 192 1630 1623 203 1139 2207 3994 1693 1468 1829 164 4391 3867 3036\n" + |
This file contains 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
function createMemorySpiralPart1() { | |
map = [[5, 4, 3], [6, 1, 2], [7, 8, 9]]; | |
current = 9; | |
mapSize = 4; | |
row = 2; | |
location = 2; | |
while (current < input) { | |
current++; | |
position = { row, location }; |
This file contains 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 number = | |
"1118313623545511731349577584178497168771887163382271218699926529721546516322966764642852611716258928885987387219253574792494868863752797416512246866426472679794459398366732534464894287614868288447138161984148527699424597669219287355918927236198459831172835757626947582239562625835566753795334794589641524619733214327688581658185494842292418696577251667696622495748894352276982714394235111756538756229761217493447567346582482452122732421154889618187198282589366532363519242922518213523894719716419579415931411599826963962282184618557525553588561275821288236575481515457416634951824462814917632493745817744262258224741123387456291942139763287629858841273244439841635717119411139868261689211875678612882687446631428678661655467956214661343335412746337698659566925391519719536518863811958776389193552166427318486596492632172585994566466354126234611387929458545361549767321674393555489657783132648242371761521966143337489197114221881486872997577519552979781375619359633666827423348678548925813882631329689997223 |
This file contains 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
import React from "react"; | |
const Number = props => <span>{props.value}</span>; | |
const Fizz = () => <span>Fizz</span>; | |
const Buzz = () => <span>Buzz</span>; | |
export const FizzBuzz = () => { | |
return [...Array(100).keys()].map(v => { | |
v++; | |
return ( |
NewerOlder