Day 6 Complete

This commit is contained in:
Brian Buller 2016-12-06 07:06:52 -06:00
parent fbb117bcd3
commit b1b4ea62b6
4 changed files with 774 additions and 0 deletions

BIN
day06/day06 Executable file

Binary file not shown.

650
day06/input Normal file
View File

@ -0,0 +1,650 @@
vlmbsivg
wjskjzff
hmcodblh
nvohhghm
xainmzpz
frkckyrg
zqdmvmee
sbsqzlju
eqdnsvqi
xdmyqmxk
gchzzkci
unjukwld
fmnpwrnf
huvyqxkt
uxekmktg
pdzxhbfa
khlkjqhk
ravznzpy
btpqmfzt
tcnpghzn
yuplhxzr
ablaihve
gjdehjcu
dvmkpskx
lukbiacr
ttrzcksg
ecfehhzq
octwtlsc
colisfrx
svtipfzv
kaffxell
rsmdpuic
viaidaip
drbezwvb
tyhnjseu
weuopaqc
igmqdwiz
gerzveig
bnqltmlo
jgwcxybe
iaabqazu
bgflkfyt
boznsgas
agiyktkz
ivvnbvuv
tospvglb
vxfhcvkz
kshbpxws
uejxthhb
vyffdirv
ibfywjob
cpzlamql
pyzsyqvq
yrqdolxy
svyihgcn
vupxjagi
cncrrcuv
ydmvwcje
yrpqbwhn
jrgsqtpl
axzbhwaw
ggsjjmvb
qtdsykjo
cnjmerzo
lzqwtxms
yhhodrpp
ryiwahsd
kggpmwvl
lextjotq
tlxjbxef
fygwhizi
moomppou
ezavglhp
omylulyf
ahbasrtz
ccbblybl
ueyudhva
blrewxyn
ytdwdavt
rgpakvlz
bmlycpbm
ewbvxsrm
hcukzfwq
rkkixnbu
masthktz
soolsxwh
zwszloqc
wjizzawg
ojcfqylq
nnzmlcyh
pvpmbtxx
assogumc
quorbsbu
uywftned
jneaeojp
mdvwycom
cpoqljak
dgxinijd
oknnyivd
uclfujcu
tglfuqym
xixpvogp
ywpxxlzu
tzaooymi
srjmonav
pnfugqmd
lryrknay
ijyxsjyr
nscjqibj
xfbyavdq
qoqcxyek
txscvcir
rbbpybgj
tkhqbyup
gmqcfvgi
itftwfkt
uzjbjwgw
rmfoqkvx
qtnlthgs
szdpoddo
qunqnglj
vpyzxigu
yvgaspgn
ugzomjyi
xehwrqqa
gerohqzw
svumyqwg
mqyztgha
kxaoylrd
qlrivitr
mqyqiewf
jbmnazei
mxlxbhwt
blwoptvb
psdatjoo
ygetkaoq
wygpqzdo
hlclzfmf
jpbvivrw
pmukraot
swbpgume
dvkkfjph
vrodfocs
zufhfmqm
djwpfova
fkmbbzho
wecxogkb
nhkrcpkp
vjeqcaaf
xrqarugv
fwmcwuok
epbkndfk
zwpgujke
modqokkj
ikewchsd
jwrhzjlb
smlbnbef
mxbbtgqb
viwdgsdx
goqsuvzj
rbroiwxp
zdiptzal
ybfdenoy
oszdisbg
nvfjluan
lqsbzkzw
psuefwbt
yallonfl
ijiwdpgh
gglvyutq
vqoydnjd
qcryrkrs
aivepbza
ylhvocnp
itvgswxy
bztkautf
ptrfhgug
jxrrgihp
pemkoxua
gisyyymp
lojsmpxa
eqfowfiy
fjgiccrd
hbxkngmy
drqthobt
ikyiobsj
cfwzjnns
krhtlqjb
ypahmuqg
cckkvsls
cvtpertw
lokmfmqj
eicgeaew
cuenpdcs
dztpufap
qrwculkl
ynzjrfps
mucvocas
dhorhvqw
ldidkudb
xxpbrirx
ksudlgat
giljlkxr
jhyqnccn
pmcscebv
cwidmjza
rqqirtgy
zioenwys
xbjruyyl
asptiznh
jqpjaenx
lugmurst
kmerqmnn
dxyndveo
uuqchrez
upcfeanl
sercqwtv
gbyfvzic
zlozeixc
cqtrvust
qdjntgwm
xiqmxxpw
gksowkih
pltnircb
pvoulbsn
hjxqhgjg
tcewvoyn
apjfkhzx
mfnuzwxz
ovchtwej
efqrkewr
jwgxupik
gcwelfie
ammaagcn
nyhkwztj
zakrmiqp
jjrdohih
rnwxdbge
zeobprqj
zwwtpnsx
mdnygzxh
nkfluipm
efwgmsfk
jlnztudt
medtzrwv
wclfyxbb
jjetrasx
wmwuhaar
ijwzhaoh
xdlfrrnn
dvxecbjt
vwihvqzh
kgpagxiw
jvixdjuc
gfiweyxg
xejknscb
hxheizpd
dubgkfgr
wkxidfgc
tzxylcho
qvububkp
erlnhqov
weomsswt
rfpoxknw
itnvsxdi
cbnocofl
ldadkmsf
pwhhklgc
itudhryg
vlvtoljp
hjggmitm
mmzawuak
quigzvkq
rsmiptim
tsqytvda
pmprbqfm
eppsdefz
adcqcsvc
lwiyaddu
wwqpjubg
jilsipuz
wzrxuskh
laraxaqd
epuyflmt
mdclmqun
hkjrdlxu
tcilebni
rkrekccq
aazdcsnc
ngijyoqs
bymuwqsv
lsanabvd
ylnektqm
fthtunja
vvfmqqbe
shbajllw
xgdgwmdc
hrzmxpif
nskrdynl
ineiworp
nlgfboek
yrsztmql
dnrewurn
uwtdmpru
eygvelve
tfitkluc
iqpxtxpw
hztyqkrl
xastoukn
djbllswj
kcnpmzsu
kepgfdit
okvnsjlp
fhjqkxxt
cnoewgjm
uhyjofee
knpdrbij
rreiagox
hxkhodce
zmaxocze
wtpaqndq
jvcagcvr
uhkmigmp
xadnxjhe
uiaplibp
otkxrzix
yzedogvy
ekfnffhq
fakkmnxr
bztnaqpo
tmyttvbn
univukhd
caujacsj
flblfclw
czfogrtr
inxubopi
afwfgcpb
mycsrthv
kdwsxnay
koujdeqg
hirhfotk
wkxxvthj
xsosgzwi
bxilicsn
hniuyqyz
lwbgmzwc
sncerhsu
fuhbmtfk
kaftqhuy
pqvglqfj
bghwspjz
twijseky
dpfmjhis
narvsefe
eraymofq
qiopspmb
taehddxo
zttknqxx
thgkqpfz
dgufruwc
bunvatbf
xonactvk
axjukwjn
opbjnbxx
fwvipkwm
etxwpjaj
hqdclxoq
fsnugidt
zmbpypye
hoqsimwa
waghzrcr
njymehaz
zknxntkj
ntjtbato
rqhupkqa
jnjxdtdf
eubzelni
astkohuv
ptfvacsg
bzjhupen
ijeukuux
abiyvjke
psbjwvcf
sucqapsu
axbjujok
oxvdokyb
olsyowug
nitvqkcl
njswglrr
ovheurur
ayedpsqo
vvclemhs
wjrfsvyk
fdhcqdru
qrkvvfay
kuhlridl
yxnrykeh
ctkznbzx
pfaojeww
lobsvohy
wutlpeak
nhppjsax
yihmsdmd
iszriptf
qdnhytkn
vooshrhs
wzogjdin
tkseeclg
jxzgiyxq
osefrqid
ixgfrbhq
zkggjudf
dyxgeond
rpwplncj
ndpxtrgc
ubuheera
migvasdi
acgygdxb
ccxcimgx
lvdpvhdr
ghvhyfmz
dqtheasu
ebjozdgp
tluznvkr
qhvzqrzm
qbjpiipl
bplqnbti
kizmxvno
uobfxakf
syllmscz
gghcqygd
snkwjojf
vdcvdpno
qussueej
zmlxuulr
htqbwjve
ixynqepo
ovaelpay
eywkbzsc
qwoqmtig
prkxadem
jfsscvhm
hqslphpy
bfiiyruu
fmkizdns
vpsisoaf
couzrtsv
wycwxxlh
upvcymri
hqlqfvbm
wzaeftmu
boxdzesc
lmcuplex
xyuifcev
fqgvggmq
seykzeql
fewgnzoq
qjmsxyto
ebckyjih
jzrbwgjj
vwojkmpc
sqdqaffc
yukfwymc
yjptcsmz
tencuncy
rbtxxpuv
yiffiway
eefyzfqb
moxjnvoq
wijspyho
fdtsjins
rxqcbsgd
oamredol
baeulkgv
rggwhexz
qfkkitpv
uexaisra
cqwjlwxi
tjavidpj
efbavnsa
uxnnkruo
wriebzoz
wexcdrht
hzmyocox
qseogxfr
fflfanfi
vpaiudnq
olvuxneh
fcbsytua
sfudzkhx
xghrupyg
aeclhwom
byobwacz
rsditwjr
lvvqfcup
lflatigg
kuojuttb
aouuzdnw
klbwzjlw
zkambbfg
xdevxqbr
zqdlejop
vfhbkyik
zeyujeql
skvhtden
ddwgfxck
lnrqrbkk
rtnzbizt
uaxpghyx
asybsmyx
djdcnnpx
ykwhiyjk
zhvodxrh
bmzhumtw
aoutwtdv
mjadhrvo
tkugwiep
ystjfami
bfqqcmtb
bbvmzwdo
hgufdhpb
hhmamhwy
gpasfwju
zhpxvhjf
vzqggwtj
kbjrhlrm
inhayugt
fvspcluq
grxbmozt
muohwoyd
nigtpaty
ozzvzejw
nyyngjme
jmtoeyly
qyxhdpaq
iowatjzd
iszcablv
ocgavedu
xbnzrfqv
swzzzzwu
stqfxgoo
xpmubjxr
katkezfz
pudaitbg
ybarabzd
mpvqbzsr
rhinjfpm
snevfkqk
pwwccyyu
ocljrwko
dxdryyvq
rpqgkeol
wvqbnkwc
hgnwlgua
mcqmblme
fhzgsdch
kdxugdug
oltmtill
sbduaius
cqauyawa
xfznpmvh
dmivepyp
dgsngwbw
mbgsryyh
aojpsuvb
igvrbclq
lduxmyiy
dhomqxlb
myszbzrf
kbadlpoy
ftnumgci
xwzbhyfz
lzutwqtv
gimhovca
zfudpuny
nqkrsatc
uldebzzq
olzoesdw
nchgfvll
oopwvqlh
jhsbnnjw
siyclmze
frhzjbnv
nanvvjht
wtucekgs
xiyyglkr
zkakjomw
fdeeoopf
tlctovbh
cnqwlmkh
zreoslve
lcexflbp
erkaxhyf
uflifmci
byfovhfn
pmlsjebs
rmdncvno
jzxsteml
ehromnts
wwrgqdmv
gydqxmbb
kjjnrsyf
okzknoil
pqmjbnhz
rbgydndw
jfmclxjm
bfotvtud
mftuqeei
lhchcrja
czperrwe
hyymnbfh
gtmctpcn
ooteayaj
ipxmxdrg
lxljcbmk
kexfnhaz
zwvwqxwd
ccriznpe
gadlykes
nuagvrrv
xgvdaxfk
gnkzxirj
vdmrccgf
vhgjcski
qpdhafox
oijrjuwm
qxtyktrs
mkyalzfa
tnmunnod
ukjvbgjs
cywsgmfc
uqkzjgbn
ppjifbhj
gpwlnflu
alabzvvi
vtygcqph
ezxtvdqo
hzeejxxe
aavwflnw
nrfqefxa
dsgysuua
pikwyfym
nesdcxdi
ghqlicny
jcvekqdr
cyeiicma
slfxqsdt
dcrcwoek
qdmtpdxr
vlzjoqfm

55
day06/main.go Normal file
View File

@ -0,0 +1,55 @@
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
input := stdinToStringSlice()
var partOne, partTwo string
for j := range input[0] {
freq := make(map[byte]int)
for i := range input {
freq[input[i][j]]++
}
partOne += getTopByte(freq)
partTwo += getBottomByte(freq)
}
fmt.Println("Answer to Part 1: " + partOne)
fmt.Println("Answer to Part 2: " + partTwo)
}
func getTopByte(f map[byte]int) string {
var topByte byte
var topByteCnt int
for k, v := range f {
if v > topByteCnt {
topByteCnt = v
topByte = k
}
}
return string(topByte)
}
func getBottomByte(f map[byte]int) string {
var botByte byte
var botByteCnt int
for k, v := range f {
if v < botByteCnt || botByte == 0 {
botByteCnt = v
botByte = k
}
}
return string(botByte)
}
func stdinToStringSlice() []string {
var input []string
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
input = append(input, scanner.Text())
}
return input
}

69
day06/problem Normal file
View File

@ -0,0 +1,69 @@
Advent of Code
--- Day 6: Signals and Noise ---
Something is jamming your communications with Santa. Fortunately, your signal is only partially jammed, and protocol in situations like this is to switch to
a simple repetition code to get the message through.
In this model, the same message is sent repeatedly. You've recorded the repeating message signal (your puzzle input), but the data seems quite corrupted -
almost too badly to recover. Almost.
All you need to do is figure out which character is most frequent for each position. For example, suppose you had recorded the following messages:
eedadn
drvtee
eandsr
raavrd
atevrs
tsrnev
sdttsa
rasrtv
nssdts
ntnada
svetve
tesnvt
vntsnd
vrdear
dvrsen
enarar
The most common character in the first column is e; in the second, a; in the third, s, and so on. Combining these characters returns the error-corrected
message, easter.
Given the recording in your puzzle input, what is the error-corrected version of the message being sent?
Your puzzle answer was ________.
--- Part Two ---
Of course, that would be the message - if you hadn't agreed to use a modified repetition code instead.
In this modified code, the sender instead transmits what looks like random data, but for each character, the character they actually want to send is
slightly less likely than the others. Even after signal-jamming noise, you can look at the letter distributions in each column and choose the least common
letter to reconstruct the original message.
In the above example, the least common character in the first column is a; in the second, d, and so on. Repeating this process for the remaining characters
produces the original message, advent.
Given the recording in your puzzle input and this new decoding methodology, what is the original message that Santa is trying to send?
Your puzzle answer was ________.
References
Visible links
. http://adventofcode.com/
. http://adventofcode.com/2016/about
. http://adventofcode.com/2016/support
. http://adventofcode.com/2016/events
. http://adventofcode.com/2016/settings
. http://adventofcode.com/2016/auth/logout
. http://adventofcode.com/2016
. http://adventofcode.com/2016
. http://adventofcode.com/2016/leaderboard
. http://adventofcode.com/2016/stats
. http://adventofcode.com/2016/sponsors
. http://adventofcode.com/2016/sponsors
. https://en.wikipedia.org/wiki/Repetition_code
. http://adventofcode.com/2016
. http://adventofcode.com/2016/day/6/input