Commit 8948d9a1 authored by Philipp Rummelsberger's avatar Philipp Rummelsberger
Browse files

day 06

parent 899c1511
const importer = require('../utils/import');
const counter = (str) => {
return str.split('').reduce((total, letter) => {
total[letter] ? total[letter]++ : total[letter] = 1;
return total;
}, {});
};
function countValid(data) {
const valid = ['a', 'b', 'c', 'x', 'y', 'z'];
let count = 0;
data.forEach(el => {
if (valid.includes(el)) {
count ++;
}
});
return count;
}
async function exec() {
const result = await importer.importInputAsArray('../day_06/input.txt')
.then(result => result.split("\n\n").filter(res => !!res).map(res => res.split("\n").filter(res => res !== '')))
/*.then(result => {
return result.flatMap(res => new Array(...new Set(res.split(''))))
})*/
.then(result => {
const foo = result.map(res => {
const count = counter(res.reduce((prev, curr) => prev + curr, ''))
console.log('RES: ', res, res.length)
return {
people: res.length,
res : res.reduce((prev, curr) => prev + curr, ''),
count: count,
unique: new Array(...new Set(res.reduce((prev, curr) => prev + curr, ''))),
match: Object.keys(count).map(key => count[key] >= res.length).filter(res => res).length
}
});
console.log('rESULT: ', foo.reduce((prev, curr) => curr.match + prev, 0));
})
console.log('TADAA: ', result);
}
exec();
xav
uavx
xavsi
yavx
efokjptizdcwmqnuh
qgfdvurtnjwpichxk
taqkcunfzpmydiwjsh
mzbg
tmg
rlvge
hgpbzn
cagkijyu
ahynbmqljzpwxokcfrtsgeud
xwzcmdhkrjnupegqlyoaft
fjnurhzoqmgwacxdlypkte
qwrjxahtlnzcfdouepmkgy
ezpqxfcmgrnhylukwajotd
jrxcnyadsgbtpvoze
secpytarvdzjgb
ycsfzgtedarbjvp
tsgejyzcdbvpra
ygtbvzredpacjs
n
n
s
n
n
mgfb
mfg
xfjengy
pubw
isroqb
hcnkeawlbfso
twocmsbefvlp
acwyseblorf
losebfcw
dixstroacjbygqpewvk
mdcpbnfqsgxvaikwujtr
u
uvk
vpuzogn
lmhxvfgkdnspq
jpvzogntyr
ajpngbcivw
bip
itb
uvqldphg
edpgfh
gm
mgfs
mg
mgq
gm
gtkm
wkcgmsvda
gmksap
mkupgt
gekrbimhj
hknejx
wjn
jano
jvwnb
ujnic
vkzmgdb
zbgvd
bzdgv
gbvdz
zdbvg
sedcuh
axyeqbs
ckysjbmawxpedqov
ilqcuxpvajwmfyko
xcv
xhevkc
vfxcy
wcvfx
cjxv
wetaojdqkip
kyedwuprqast
tadubqkflp
yanpslwqdtik
zmgacdpkxq
akdhyogxqf
ktnyzhxoaqfgwd
dbnezgquatrm
ewnqlzdjcgb
hnzdebjgql
aoxjcbpzisfmkewqlngduytv
difaqevcgyukztjwpmbsxonr
grptdzn
pzctgolskr
kvyjetqndhf
yetdvnqkf
svwdpxqgeianfk
tmyreouwn
torwnaeumy
tsewnmzypo
emosthywn
mjtkevnqcbdiwoxy
zstlfpnavdwyicuhb
twlpczyhunivda
ovnuwycptldhzai
pcyhdwtuianlvz
kwvaunqjryxtpz
wflvuzhnxmecokiyjts
kjcqzvhseaf
qgfmhsekjctv
tcpvqdrnghflmjoxawe
mdplxfqnovejsgazcrh
qxkhmvbpdoegnfjrlac
ixzcphskly
gsxioyzcahkl
stjxfn
cpdegihznsoyl
vrujnsk
wnsqmb
najbs
pxatigolezv
xkbvuitegwmo
gvijtmysxoe
svnxeqjogtik
soxevgqcit
otzmkhlquxwrani
eqdjfgmaor
exz
qze
ze
ze
xwzapvtqrgecjisfunkhd
qefspnwtkijacuhdgrz
zqjkasgnferutdwhcbpi
rwapenikhdjcsqfzgubt
fmjeqdaivksonr
pfeljvbqdsormxh
uywvtceosm
zhlao
he
h
qnyhtezxjdvpfkcsio
nvchtzepkqjoisdyfx
vifhcnxstzjpedoykq
qsivneohjzpbdcymlgxfkt
sxvkpohctnjfyqezid
ndzhflc
zfdcnh
fchznd
nrvde
ramndvu
tskgvzqmun
szckqgbvmnw
zvmsnrygaq
vcqmstinzg
jlospfehmzvndxgq
btlfvysaqerchkiux
tlyxhkrvbqufsecai
vfturxsbayicheqlk
sruhcbeqktixvfayl
vam
mv
vm
vm
vm
k
k
k
k
k
ysmikquxzc
yetmlxqsziu
ornk
orkn
rkno
koirn
onyrk
qcajzosf
sofdacj
ajoscf
djfscaeo
fosejac
rkqghbxjdol
uqbdhjkm
jhbd
cbtvadiehj
hfdbrj
nsklymutzivw
mounvbpwdg
sdpgvajmexuyqhcriok
vjksamihwpdrcxqguy
xjsevuydcamkihoqgpr
mjtcnqpgdhvuakfrbxyi
hpoyrxfmcjld
cxlpodryfmjh
jhplfcrydxmo
kembuivdhf
ipefszdh
enclshdbfk
dhreytjwxqgfao
lb
lkr
smtknclagp
pcktnslgam
bfsc
ynbf
hbxklwfep
ye
haybes
ey
eyw
ta
tan
jtap
tah
lcat
ikdqblgs
mtwlvhnbkjsdic
plzskbdi
rctauyzbdklxvpmnwqjfe
plhzdsnbmxqarwjktyfuice
ba
ab
ab
bar
ab
i
i
i
v
ursqy
qrwusy
yrsuq
qrsyu
qursy
cdgrouis
ocrigs
vjwaiph
ypva
yhuqbinztxg
kuqxeogthpid
gtmhiquxlw
gxutsafqbih
wmg
wz
gkpmdtwhnxzaoysjcevuir
hoxmkyqdcwlnvgperszi
oqagy
glxvkq
sdzbreguiwjfm
nabml
pfnyvatk
pu
pu
hbivy
byuv
tueovyb
ozqv
qzon
xjunwvbzdkqy
chfosmgre
dyn
ejxy
xydq
yx
iyp
hskfyqgtbzrvu
yvqhtgbuifrskz
hzjqfuyrbvstgk
zvkhtsfgryqbu
ons
osne
nous
suno
zymjefdwxih
dwxzyfjmieh
ib
bia
ocagmvj
jvcagm
gamcjv
vjcamg
inhlewtdbkxmpaqryg
wnkpxrhlmigtaydbqe
oihnlytpwaxrbqekdmg
mqabydwgterlphnkxi
bjedsywlgnxmpotz
pxejsongtkumzbwld
lpogxznbtwmsjed
tzpuonmjxlwbesgd
wqfsmektu
wmftqs
sqmtwf
tqmscfw
tqwmsf
snkpjbefqwhyriz
ikwrlqymjczfbevntps
qhebojfnzrkwapmsi
begirdpqnjkwuzsf
iqtbhfzpenwkrjs
y
y
gsf
gcsh
ajqgs
ulqbokwrjdcgpthniyxfzmeav
rjbumtoxecngkdvazsfilw
fwsrhjk
hjrfwks
kfjrhsw
jrhkfsw
qktgsvplh
hgol
hgly
qftenaodxkwz
bwtxaqviof
ugzpmhefkj
kgemzusfpjhd
ekfjlhpmguz
kxuepjgonfyhzq
kuzgitlhfjep
jywhzcrqa
otznge
mbuvfsk
iwhekorjgqtsdb
kjgswlbqherodti
okirgdnejtxwbqhs
ezobksgqrajhwdti
rdcoaubxhkitwsvpzygflmqnj
tcnfguzdybojqvwishrlapmkx
smjnpglbkzuafqhtdoxwiycrv
spgnmzlyurchxvwbojfqakidt
kzdtmbslqyvxcrwnauhoijgfp
kvwm
mwvk
kwvm
kvwm
hto
rhg
h
tvhi
vhfk
woxhpvfdlnezi
wemd
cqwkde
sedwuq
wcadtgrbe
moecds
wscmbnoed
sdycmeo
amnqlcytodvreiwkzgfxs
vfwmayqsghdcjztxeornkuil
xgaifqzdvowmknlysrtce
iynsxqwmafdvtklzregoc
ksvejm
eskmvj
ksmjve
vhskemj
ekmsvj
ebfkazr
dgqtkjmw
clykap
zukinrbh
oznuhklqijpmsxfcaryb
hyikolbjusmxqcfnzarp
uzxcbwqshkyamrielnopf
zlpsua
wlzdspu
luzsp
h
hkr
h
lhc
h
zfugqrjipavboys
aurvpzfeosigjqy
srnqiejtoyupgvadfzb
oqryvigjzsuafp
qgowivrzajsupfy
mrotnsaivyxbwp
iapmtxsgbyodwr
woaxsyjicpbtrfm
rdlakocwumetfpjs
cshjuyxwgatvz
wbxauycv
xbwgaove
axwnovb
fwyxmvab
xtiqwbsazvjpl
o
p
p
p
p
ombjurgkvceny
ilxtpwaz
gzjpkewnfylari
nlifyawpzgkjm
ymhesgwkxczrtbjnu
cywuetkbhnsxjrzgm
uwybxgsjnhremztkc
pcsxyiuvfnjbtkqwhlgzr
ixqnskyfwrtlgchbvjpzu
cvuqazjkhbxtlyrnwgifs
ce
ec
cge
ecg
yeh
itfhrlsvgden
svhekgidlrnf
nirlehsgfdv
sginfeldrhv
irsvdlfhegn
w
y
jqwevpgkzhdar
pazkvjqdrwh
urzhvwkpaqd
lsmqgjkb
glmksbjq
qsklgbjxm
iouyxrvbqjcemzlapk
ovlkizemjyarbcupx
zluckepmbrxivajyo
zijoveubxmlpykrcad
tjaruhsdgype
apmetysfkivjblqd
ztxyvufeh
dmcaqrhfgs
qfvujnhtaom
uvqanhfo
dxwvtmlsjqurepbgni
bueiqjanvlpwr
zlryojfupiqvec
dopjewaytmg
amreytdslkgpw
peymdawotxg
uqyahptdxzgecwm
vbohdafmpiwytge
zdkalgubsqw
dsazbkgluw
dsuzgwlbak
fibeyzxkmch
fveymznaik
vtyafiemkz
erlfizymuk
uti
u
gu
u
u
khqjtmswgl
pxnsqzgv
uhkeosrgytcpbvmanqdlwjfz
singwfcorvzadktblmupejqy
lezdusrpwbnfmkvjcxyogatq
nqlmhgrp
e
sw
hrmxwjzg
wzrtpmah
mrewhx
ywkbrnhmci
rhomuvw
cfpsboei
wtifcoybpx
iofcpb
cbpoisf
pcoibf
x
tx
x
xf
etvc
coap
gsbmanzopklyw
zorpislaqbnmywg
awbgczsdxlumypnoh