Built with blockbuilder.org
forked from trianah's block: Advent of Code 2018: day 2 (part 1)
license: mit |
Built with blockbuilder.org
forked from trianah's block: Advent of Code 2018: day 2 (part 1)
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<script> | |
d3.tsv('input.tsv', function(error, input) { | |
if (error) throw error; | |
console.log(calcChecksum(input)) | |
function calcChecksum(data){ | |
var sum1 = 0; | |
var sum2 = 0; | |
data.forEach(string => { | |
sum1 = sum1 + calcRep(string.input, 2) | |
sum2 = sum2 + calcRep(string.input, 3) | |
}) | |
return sum1 * sum2; | |
} | |
// returns 1 if string contains a | |
//character that repeats exactly rep times | |
function calcRep(string, rep){ | |
var stringArr = string.split('') | |
var pastCharsArr = [] | |
console.log("String: " + string) | |
for(var i = 0; i < stringArr.length - 1; i++){ | |
var counter = 1; | |
for(var j = i + 1; j < stringArr.length; j++){ | |
if(!pastCharsArr.find(item => item === stringArr[i]) && stringArr[i] === stringArr[j]){ | |
console.log(stringArr[j]) | |
counter++; | |
console.log(counter) | |
} | |
} | |
if (counter === rep) { | |
console.log("Found rep: " + rep) | |
return 1 | |
} | |
pastCharsArr.push(stringArr[i]) | |
} | |
return 0; | |
} | |
}); | |
</script> | |
</body> |
input | |
ovfclbidieyujztrswxmckgnaw | |
pmfqlbimheyujztrswxmckgnap | |
ovfqlbidhetujztrswxmcfgnas | |
gvfqebddheyujztrswxmckgnap | |
ovfqlbidheyejztrswxqekgnap | |
ovzqlbiqheyujztsswxmckgnap | |
oofqlbidhoyujztoswxmckgnap | |
ovfqlbicqeyujztrswxmckgncp | |
ovfelbidheyujltrswxmcwgnap | |
ovfqlbidheyujzerswxmchgnaf | |
bvfqlbidheyxjztnswxmckgnap | |
ovfqlbidheyugztrswamnkgnap | |
ovfqxbidheyujrtrswxmckgbap | |
ovfqlbidheyujztrdwxqckgjap | |
ovfqebiqheyujztrscxmckgnap | |
avfqlbidheyvjztkswxmckgnap | |
ovfqlbidheyujktrswxvskgnap | |
ovfqlbidheeujztrswrmckgnae | |
ovaqlbidheydjztrswxmchgnap | |
ovfqlbodweyujztpswxmckgnap | |
xvfqlbidhmyujztrswxmykgnap | |
ovfqlnidheyujztxswumckgnap | |
ovfqlbidhexujztrswxyckgeap | |
ovfqlkidhekubztrswxmckgnap | |
ovfqlbidheysjzkrsxxmckgnap | |
oxfqebidheyujzprswxmckgnap | |
ovfqlbidhetujztrswmmckghap | |
ovfclbidhuyujztrswrmckgnap | |
ovfqlbijhdyujztrswxmcvgnap | |
ovfqlkidhyyujztrswxvckgnap | |
ovfqlbiehlyujztrswxhckgnap | |
ovfqlbidheyxjjtrsdxmckgnap | |
jvfqlbidheyujztrvwxmckcnap | |
ovfvlbidheyujzhrswxmckgnzp | |
ovfqnbidhuyujztrswfmckgnap | |
ovfrlbidheyujztpswxmckgnat | |
ovfqpbidheyujztrywxmcngnap | |
ovfqlbidheyumrtrswpmckgnap | |
ovfqlbidhoyzjztrswxmckgkap | |
ovfqlbibheyuhztrswxmskgnap | |
ovfqlbidheybjzfrswxkckgnap | |
ovfqnbinheyujztrawxmckgnap | |
ovfqlbidheyujztryxxmckgnao | |
ovfqzbidheyujztrsuxmckgnpp | |
ovfqlbidherujztrswxmckgjsp | |
ovfqlbidheyujhtrywxmckgtap | |
oofmlbidheyujftrswxmckgnap | |
ovfqlbidhhyujztrawxmckgnbp | |
ovfqlbidheyujztrswxeckmnae | |
lvfqlbidheyujztrswxzckvnap | |
ovfqlbidheyujztrswxmckqnfr | |
offqlbidheyrjztrswxmwkgnap | |
ovnqlbidzeyujztmswxmckgnap | |
ovfxlbxdheyujztrawxmckgnap | |
ovfqmbidheyujztrsaxwckgnap | |
ovfqlbidhryzjztrswxmckgcap | |
offqlbidheyujnthswxmckgnap | |
ogmqlbimheyujztrswxmckgnap | |
ovfqlbidheyulztkswxockgnap | |
ovfqlbidheyujjtrswxmckypap | |
ovfqibidheypjztrswxmskgnap | |
ovfqlbwdhyyujztrswxmckgnnp | |
ovfqlbidheyujztsvwxmckgkap | |
odfqlbidoeyujztrswxjckgnap | |
ovfqlbodpeyujztrswxmcggnap | |
ovfqlbicheyujztrhwxmcagnap | |
ovfqlbidheyuaztrgwxmckhnap | |
ovfwlbidhyyujztrswtmckgnap | |
ovfqlbidgzyujztrswxmckgcap | |
ovnqlbcdheyujztrswxmckgnup | |
ovfqlbieheyujrtrsdxmckgnap | |
ovfqlbidkeyujztrswfmckgnqp | |
ovfqlbidtekujztrswxsckgnap | |
ovfklbedheyujztrscxmckgnap | |
ovfqltivhnyujztrswxmckgnap | |
ovfqlbidheyuvuyrswxmckgnap | |
ovfqlbidheyjjrtrcwxmckgnap | |
ojfqlbidheyujztrswxmckguvp | |
ovfqlbidheiqjqtrswxmckgnap | |
ivfqlfidheyujatrswxmckgnap | |
cvfqlbidheyujgtrswxmckgnrp | |
ovfclbidheeujztrswxmckgnaw | |
ovfqlbhdheyujztrswvmcklnap | |
ovfqcbidheyvjztaswxmckgnap | |
ovgqlbijheyujztrswxvckgnap | |
gvfqlbidheyujvtrswxmckgnaj | |
ovfqlbidheyujztrdwxmcggnvp | |
cvfqlbidheyujgtrswxmckqnap | |
ovfqlbrdheyqjztrswxmckgnaj | |
ovfqlbidheyujzjrswbmcrgnap | |
ovfqlbvdheyujxtrswxvckgnap | |
ovaqlbidheyujctrswxmbkgnap | |
ovfqlbidheyujztgdwxvckgnap | |
ovfqlbidhevujztrssxmwkgnap | |
rvfqlbidheyujztrzwxmckhnap | |
ovfqmbidheysjztrswxmikgnap | |
ovfqlbidheiujztrsdxuckgnap | |
ovfqlbidheyveztrswxmckgnah | |
ovfqnbiaheytjztrswxmckgnap | |
ovfqlbidnayujhtrswxmckgnap | |
ovfqlbidheyujztnswxdckgnag | |
ovfqlbidheyuyztrswxmzzgnap | |
ovfqlbiohexujzthswxmckgnap | |
lvfqlbidheyujztcswxxckgnap | |
ovuqlbidhfxujztrswxmckgnap | |
ovfqluidheyujotrswxmrkgnap | |
ovfalbidheyujztrswxhckgngp | |
ohjqlbidheyujztrswumckgnap | |
ovfqxbidhecujztrspxmckgnap | |
ovfqcbidheyusztrpwxmckgnap | |
fvfwlbidheyujztrswxmcxgnap | |
ovfqlbidhxyplztrswxmckgnap | |
ovfqlbidheyujftrswxdckgrap | |
ovfqlepdheyujztrswxmckgnjp | |
ojjqlbidhuyujztrswxmckgnap | |
ovfqlbwdheyujztrswxmcggeap | |
ovfqlbidheyujltrscxkckgnap | |
oifqibidheyujztrswxjckgnap | |
ovfqlbigheyujztrswdmcqgnap | |
ovfqlbieheyujztrswxzzkgnap | |
ovfqlbidheyujztrswmmcgbnap | |
ovfqlbidhnyujzerswxmkkgnap | |
ovfqdbinheyujztrswxeckgnap | |
oveqlbidheyujztrswhmckgnab | |
ovfqkbytheyujztrswxmckgnap | |
ovfqlbidheyujstsswxmcklnap | |
ovfimbidheyujztrewxmckgnap | |
ovfqebidhequjztrnwxmckgnap | |
ovfqlbidheyukztrswxmckunwp | |
oifqlbidheyuwztrswxmckgnao | |
ovfqlbidweyufztrswxmckgtap | |
evfqlbidheyujztrswxsckvnap | |
svbqlbidheyujztrsaxmckgnap | |
ovfqlbidheyaoztrswxmckjnap | |
ovfqllidheyujztrswxmckynhp | |
ohfqlbidheyujatrswtmckgnap | |
omfjlfidheyujztrswxmckgnap | |
xvfqlbidheyujutrswxvckgnap | |
ovfqlbidheyukztsswxmzkgnap | |
ovfqibidhehujztrswxeckgnap | |
ovfqlbydheyuoztrswxmcygnap | |
ovfqlbidheyufztrmwxmckvnap | |
ovfqrbkdheyujztrswxmckgnaq | |
ovfqlbigheyuyztrswxmckgzap | |
ovfqlbidheyujztrsjxmcnnnap | |
uvfqlbipheyujztrswxmckgnay | |
ovfqlbddneyujbtrswxmckgnap | |
tvfqlbidheyujztrswxpckgeap | |
ovfqlbidheyuiztrhwxmckznap | |
ovfqlbidheyujzteswxvckgvap | |
avfqlbidheyijzlrswxmckgnap | |
oqfqmbidheyujvtrswxmckgnap | |
ovnqlbidneyujztrswxmckxnap | |
ovfqlbidfeyujztrswxqckgncp | |
ovfaybidheyujztrswxrckgnap | |
ovfqlbidhemujzarnwxmckgnap | |
ovfqlwidheyujctrsfxmckgnap | |
ovtelbidheysjztrswxmckgnap | |
ovfqlbidheyujztrswsmchunap | |
pvfqlbidheyulztrswxmckynap | |
ovfqlbzdhezujztfswxmckgnap | |
ozfqibidheyujztrhwxmckgnap | |
ovfqlbioheycjztmswxmckgnap | |
ovfqleidheyujztoswxmckgnhp | |
ovfqlcidhejujztrswnmckgnap | |
eqfqlbidheyujztrswxmrkgnap | |
ovfqlbitheywjztrmwxmckgnap | |
ovfqlbidheyujptrswnmcggnap | |
oofqlbidhjyujztrswxmcegnap | |
ovfqlbidmeyujztrswxmcxgnxp | |
ovjhlbidhefujztrswxmckgnap | |
ovfqlbidkeyujzarswxmcugnap | |
hvyqlridheyujztrswxmckgnap | |
ovfqlbidheyujxtrswqmckgnpp | |
ovfqlbidheyuiztrtsxmckgnap | |
ovfqlbidqeyuuztrbwxmckgnap | |
ovfqpbidheyujztrswxwekgnap | |
ovfqltidheyujztrbwxmckgnab | |
okfxluidheyujztrswxmckgnap | |
ovfplbidheyujztrsaxmckgnax | |
wvfqlbidheiujztrswxjckgnap | |
ovfqlbidheyqjzlrsqxmckgnap | |
ovfqlbadheyujztrsxxmckgnop | |
ovfqliidheyujzerswvmckgnap | |
ovlrlbidheyujztaswxmckgnap | |
cvzqlbidheyujgtrswxmckqnap | |
ovfqlbidheyujzuqswxmckgnnp | |
ovfqlsjdheyujztrswxmcklnap | |
ovrqlbidheyujztrssrmckgnap | |
ovcqlbidheyujztrsmxmcognap | |
ovcqlbidheyjjztrswxmckunap | |
ovfilbrdhnyujztrswxmckgnap | |
ovfqlbodheyujztrswxeckqnap | |
ovfqlbidhuyujqtrswxdckgnap | |
ovmqlbidheyujderswxmckgnap | |
ovfylbidheyajzrrswxmckgnap | |
ovfklbidhtyujzjrswxmckgnap | |
rvfqlbidheyujztcswxcckgnap | |
ovfnlyidheyuwztrswxmckgnap | |
ovfqlbidhexujztrswxmpktnap | |
ovfplbidheyfjztrswhmckgnap | |
oyfqlbidmexujztrswxmckgnap | |
mvfqlbidhcyujztrawxmckgnap | |
ovfqlbidhqyujdtrswxmcbgnap | |
ovfqjbidheybjrtrswxmckgnap | |
ozfqlbidhbyujztrswxmckgpap | |
okfqlbidheyujztrmwxmckhnap | |
ovfqlbydheyujzrrswxnckgnap | |
ovfqtbidheycjztrswxmckgnah | |
avfqloidheyujztrswxyckgnap | |
ovfqlbldteyujzyrswxmckgnap | |
ovfqlbpdhedujztpswxmckgnap | |
ovfqlbidheyujztrswxucrvnap | |
ocnqlbidheyujztrswxmwkgnap | |
ovfqlvidheyujztrswkmckgnlp | |
evfqlbidheyujzmrswqmckgnap | |
ovfqlbidhryujztrcwxmekgnap | |
ovfqlbvdheyujztrzwxmcxgnap | |
ovfqlridgeyujztrswxmkkgnap | |
yvfqlbidheyujzthswzmckgnap | |
ovfqlbidheyujmtrswxyukgnap | |
ovfqlbidheqgjztrswdmckgnap | |
dvfzlcidheyujztrswxmckgnap | |
jvfqlbidheyujztrswxmczgnae | |
ovfqlbzdheyujztrswxyckgnjp | |
ovfqlbxdheyujatrswxmcqgnap | |
ovftlbldheyujztrewxmckgnap | |
owfqlbitheyujzyrswxmckgnap | |
ovfqlbidheyujztrswxmchgtvp | |
ovfqibidheyujzttswxmkkgnap | |
ovkqlbodheyujztvswxmckgnap | |
onfqlbbdheyujztrxwxmckgnap | |
ovfqlbidyeysgztrswxmckgnap | |
ovfqlbixherujztrswxmcngnap | |
ovlqlbidfeyujztrswxgckgnap | |
ovfqlbfdheyujztwswumckgnap | |
ovfqlbidheeujztrswxmckgkah | |
ovfqtbqdheyujztrswmmckgnap | |
bbfqlbigheyujztrswxmckgnap | |
ovfqljidheyujztrswxmwkgnip | |
ovfqobidheyujztrsvxmmkgnap | |
ovfqlbidheydjvtrswxmckanap | |
ovfqlxidheyujztrswgmckgnep | |
jvfqlbidhzyujztrswxmckgnay | |
ovfqlbidhkyujztrswxmlkenap | |
ovfqobidheyujztrswxmckjnaf | |
ovfxlbidheyujztrswxmcbgnac | |
ovfqcbidhtyujztrswxmckqnap | |
ozfglbidheyujzvrswxmckgnap | |
ovfqlbidheyujztoswxyckcnap |