Add 2016 solutions
This commit is contained in:
parent
ddf5ec2274
commit
8146a794a3
8 changed files with 4006 additions and 0 deletions
|
@ -0,0 +1,113 @@
|
|||
import Foundation
|
||||
|
||||
let input = """
|
||||
L5, R1, R4, L5, L4, R3, R1, L1, R4, R5, L1, L3, R4, L2, L4, R2, L4, L1, R3, R1, R1, L1, R1, L5, R5, R2, L5, R2, R1, L2, L4, L4, R191, R2, R5, R1, L1, L2, R5, L2, L3, R4, L1, L1, R1, R50, L1, R1, R76, R5, R4, R2, L5, L3, L5, R2, R1, L1, R2, L3, R4, R2, L1, L1, R4, L1, L1, R185, R1, L5, L4, L5, L3, R2, R3, R1, L5, R1, L3, L2, L2, R5, L1, L1, L3, R1, R4, L2, L1, L1, L3, L4, R5, L2, R3, R5, R1, L4, R5, L3, R3, R3, R1, R1, R5, R2, L2, R5, L5, L4, R4, R3, R5, R1, L3, R1, L2, L2, R3, R4, L1, R4, L1, R4, R3, L1, L4, L1, L5, L2, R2, L1, R1, L5, L3, R4, L1, R5, L5, L5, L1, L3, R1, R5, L2, L4, L5, L1, L1, L2, R5, R5, L4, R3, L2, L1, L3, L4, L5, L5, L2, R4, R3, L5, R4, R2, R1, L5
|
||||
"""
|
||||
|
||||
enum Direction {
|
||||
case north
|
||||
case east
|
||||
case south
|
||||
case west
|
||||
|
||||
func turnLeft() -> Direction {
|
||||
switch self {
|
||||
case .north: return .west
|
||||
case .east: return .north
|
||||
case .south: return .east
|
||||
case .west: return .south
|
||||
}
|
||||
}
|
||||
|
||||
func turnRight() -> Direction {
|
||||
switch self {
|
||||
case .north: return .east
|
||||
case .east: return .south
|
||||
case .south: return .west
|
||||
case .west: return .north
|
||||
}
|
||||
}
|
||||
|
||||
func move(units: Int) -> (north: Int, east: Int) {
|
||||
switch self {
|
||||
case .north: return (units, 0)
|
||||
case .east: return (0, units)
|
||||
case .south: return (-units, 0)
|
||||
case .west: return (0, -units)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Position: Hashable {
|
||||
var heading: Direction = .north
|
||||
var north: Int = 0
|
||||
var east: Int = 0
|
||||
|
||||
mutating func move(left: Bool, units: Int) -> [Position] {
|
||||
heading = left ? heading.turnLeft() : heading.turnRight()
|
||||
let (north, east) = heading.move(units: 1)
|
||||
|
||||
var result: [Position] = []
|
||||
for _ in 0..<units {
|
||||
self.north += north
|
||||
self.east += east
|
||||
result.append(self)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
static func == (lhs: Position, rhs: Position) -> Bool {
|
||||
lhs.north == rhs.north && lhs.east == rhs.east
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(north)
|
||||
hasher.combine(east)
|
||||
}
|
||||
|
||||
var distance: Int {
|
||||
abs(north) + abs(east)
|
||||
}
|
||||
}
|
||||
|
||||
let scanner = Scanner(string: input)
|
||||
|
||||
extension Scanner {
|
||||
func scanDirection() -> Bool {
|
||||
if scanString("L") != nil { return true }
|
||||
if scanString("R") != nil { return false }
|
||||
fatalError("Invalid direction")
|
||||
}
|
||||
|
||||
func scanMove() -> (Bool, Int) {
|
||||
let direction = scanDirection()
|
||||
guard let units = scanInt() else {
|
||||
fatalError("Invalid distance")
|
||||
}
|
||||
|
||||
guard isAtEnd || scanString(",") != nil else {
|
||||
fatalError("Missing ,")
|
||||
}
|
||||
|
||||
return (direction, units)
|
||||
}
|
||||
}
|
||||
|
||||
var position = Position()
|
||||
var visited: Set<Position> = [position]
|
||||
var foundPart2 = false
|
||||
while !scanner.isAtEnd {
|
||||
let (direction, units) = scanner.scanMove()
|
||||
let path = position.move(left: direction, units: units)
|
||||
|
||||
for position in path {
|
||||
if !foundPart2 && !visited.insert(position).inserted {
|
||||
print("Part 2: Visited again: \(position.distance): \(position.north)n, \(position.east)e")
|
||||
foundPart2 = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print("Part 1:", position.distance)
|
|
@ -0,0 +1,116 @@
|
|||
let input = """
|
||||
UULLULLUULLLURDLDUURRDRRLDURDULLRURDUDULLLUULURURLRDRRRRULDRUULLLLUUDURDULDRRDRUDLRRLDLUDLDDRURURUURRRDDDLLRUDURDULUULLRRULLRULDUDRDRLDLURURUDDUDLURUDUDURLURURRURLUDDRURRDLUURLLRURRDUDLULULUDULDLLRRRDLRDLDUDRDDDRRUURRRRRUURRDRRDLURDRRURDLLUULULLRURDLDDDRRLLRRUURULURUUDDLRRUDDRURUUDLRLRDLRURRRDULLDLRUDDUULRDULURUURDULUDLLRRLDDLRDLRUDRLDDRLRRRDURDULLRRRDRRLUURURDRRDRRLDLUDURURLDUURDRUDRDDRLDRRLDLURURULLUURUDUUDLRLL
|
||||
LLLULLULDDULRLLURLLLRUUDDLRUULRLULLDLLRRDRLRLRLLDRUUURULDRDDLUDLLDUDULLLRLULLLRULDRDRUDLLRLRLLUDULRRRLDRUULDDULLDULULLUDUDLDRDURDLDLLDUDRRRDLUURRUURULLURLDURLRRLLDDUUULDRLUUDUDLURLULUDURRDRLLDDDDDRRULLRLDULULDDRUURRDLUDDDUDURDDRDRULULLLLUURDURUUUULUDLRURRULRDDRURURLLRLUUDUUURDLLDDLUDRLLLUDLLLLULRLURDRRRDUUDLLDLDDDURRDDRURUURDDRURRLDDDURDLLUURUUULRLUURRUDRLLDLURDUDRLULDLRLULULUDDLRDUDRUDLUULUULDURDRRRRLRULLUDRDDRDLDUDRDRRLDLLLLUDDLRULDLLDDUULDDRRULRRUURUDRDURLLLDDUUDRUUDLULLDR
|
||||
UDUUULLDDDDLUDLDULRLRDLULLDDRULDURRLURRUDLRRUDURRDUDRRRUULRLLRLUDLDRRDUURDDRDRDUUUDUDLDLLRRLUURLUUUDDDUURLULURRLURRRDRDURURUDRLRUURUDRUDDDRDRDLDRDURDLDRRDUUDLLURLDDURRRLULDRDRLLRLLLRURLDURDRLDRUURRLDLDRLDDDRLDLRLDURURLLLLDDRDUDLRULULLRDDLLUDRDRRLUUULDRLDURURDUDURLLDRRDUULDUUDLLDDRUUULRRULDDUDRDRLRULUUDUURULLDLLURLRRLDDDLLDRRDDRLDDLURRUDURULUDLLLDUDDLDLDLRUDUDRDUDDLDDLDULURDDUDRRUUURLDUURULLRLULUURLLLLDUUDURUUDUULULDRULRLRDULDLLURDLRUUUDDURLLLLDUDRLUUDUDRRURURRDRDDRULDLRLURDLLRRDRUUUURLDRURDUUDLDURUDDLRDDDDURRLRLUDRRDDURDDRLDDLLRR
|
||||
ULDRUDURUDULLUDUDURLDLLRRULRRULRUDLULLLDRULLDURUULDDURDUUDLRDRUDUDDLDRDLUULRRDLRUULULUUUDUUDDRDRLLULLRRDLRRLUDRLULLUUUUURRDURLLRURRULLLRLURRULRDUURRLDDRRDRLULDDRRDRLULLRDLRRURUDURULRLUDRUDLUDDDUDUDDUDLLRDLLDRURULUDRLRRULRDDDDDRLDLRRLUUDLUURRDURRDLDLDUDRLULLULRLDRDUDLRULLULLRLDDRURLLLRLDDDLLLRURDDDLLUDLDLRLUULLLRULDRRDUDLRRDDULRLLDUURLLLLLDRULDRLLLUURDURRULURLDDLRRUDULUURRLULRDRDDLULULRRURLDLRRRUDURURDURDULURULLRLDD
|
||||
DURLRRRDRULDLULUDULUURURRLULUDLURURDDURULLRRUUDLRURLDLRUDULDLLRRULLLLRRLRUULDLDLLRDUDLLRLULRLLUUULULRDLDLRRURLUDDRRLUUDDRRUDDRRURLRRULLDDULLLURRULUDLRRRURRULRLLLRULLRRURDRLURULLDULRLLLULLRLRLLLDRRRRDDDDDDULUUDUDULRURDRUDRLUULURDURLURRDRRRRDRRLLLLUDLRRDURURLLULUDDLRLRLRRUURLLURLDUULLRRDURRULRULURLLLRLUURRULLLURDDDRURDUDDULLRULUUUDDRURUUDUURURRDRURDUDRLLRRULURUDLDURLDLRRRRLLUURRLULDDDUUUURUULDLDRLDUDULDRRULDRDULURRUURDU
|
||||
|
||||
"""
|
||||
let inputTest = """
|
||||
ULL
|
||||
RRDDD
|
||||
LURDL
|
||||
UUUUD
|
||||
|
||||
"""
|
||||
|
||||
protocol KeyPad {
|
||||
associatedtype Digit
|
||||
|
||||
var current: Digit { get }
|
||||
mutating func up()
|
||||
mutating func down()
|
||||
mutating func left()
|
||||
mutating func right()
|
||||
}
|
||||
|
||||
func solve<T: KeyPad>(pad: T) -> [T.Digit] {
|
||||
var pad = pad
|
||||
var result: [T.Digit] = []
|
||||
for char in input {
|
||||
switch char {
|
||||
case "U": pad.up()
|
||||
case "D": pad.down()
|
||||
case "L": pad.left()
|
||||
case "R": pad.right()
|
||||
case "\n": result.append(pad.current)
|
||||
default: fatalError("Invalid input")
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
struct Part1Pad: KeyPad {
|
||||
var current: Int = 5
|
||||
|
||||
mutating func up() {
|
||||
if current - 3 >= 1 {
|
||||
current -= 3
|
||||
}
|
||||
}
|
||||
|
||||
mutating func down() {
|
||||
if current + 3 <= 9 {
|
||||
current += 3
|
||||
}
|
||||
}
|
||||
|
||||
mutating func left() {
|
||||
if current != 1 && current != 4 && current != 7 {
|
||||
current -= 1
|
||||
}
|
||||
}
|
||||
|
||||
mutating func right() {
|
||||
if current != 3 && current != 6 && current != 9 {
|
||||
current += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print("Part 1", solve(pad: Part1Pad()))
|
||||
|
||||
struct Part2Pad: KeyPad {
|
||||
let grid: [[Character]] = [
|
||||
Array("##1##"),
|
||||
Array("#234#"),
|
||||
Array("56789"),
|
||||
Array("#ABC#"),
|
||||
Array("##D##"),
|
||||
]
|
||||
|
||||
var x = 0
|
||||
var y = 2
|
||||
|
||||
var current: Character {
|
||||
grid[y][x]
|
||||
}
|
||||
|
||||
|
||||
mutating func up() {
|
||||
if y > 0 && grid[y - 1][x] != "#" {
|
||||
y -= 1
|
||||
}
|
||||
}
|
||||
|
||||
mutating func down() {
|
||||
if y < 4 && grid[y + 1][x] != "#" {
|
||||
y += 1
|
||||
}
|
||||
}
|
||||
|
||||
mutating func left() {
|
||||
if x > 0 && grid[y][x - 1] != "#" {
|
||||
x -= 1
|
||||
}
|
||||
}
|
||||
|
||||
mutating func right() {
|
||||
if x < 4 && grid[y][x + 1] != "#" {
|
||||
x += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print("Part 2:", solve(pad: Part2Pad()))
|
||||
|
2032
2016/AoC2016.playground/Pages/Day 3.xcplaygroundpage/Contents.swift
Normal file
2032
2016/AoC2016.playground/Pages/Day 3.xcplaygroundpage/Contents.swift
Normal file
File diff suppressed because it is too large
Load diff
1041
2016/AoC2016.playground/Pages/Day 4.xcplaygroundpage/Contents.swift
Normal file
1041
2016/AoC2016.playground/Pages/Day 4.xcplaygroundpage/Contents.swift
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,37 @@
|
|||
import CryptoKit
|
||||
import Foundation
|
||||
|
||||
func char(_ string: String) -> (String, String)? {
|
||||
let md5 = Insecure.MD5.hash(data: Data(string.utf8))
|
||||
return md5.withUnsafeBytes { ptr in
|
||||
guard ptr[0] == 0 && ptr[1] == 0 && ptr[2] & 0xf0 == 0 else { return nil }
|
||||
return (
|
||||
String(ptr[2] & 0x0f, radix: 16, uppercase: true),
|
||||
String((ptr[3] >> 4) & 0x0f, radix: 16, uppercase: true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var result1 = ""
|
||||
var result2 = "________"
|
||||
for i in 0... {
|
||||
if let (first, second) = char("abbhdwsy\(i)") {
|
||||
if result1.count < 8 {
|
||||
result1 += first
|
||||
}
|
||||
|
||||
if let i = Int(first), 0..<8 ~= i {
|
||||
let index = result2.index(result2.startIndex, offsetBy: i)
|
||||
if result2[index] == "_" {
|
||||
result2.replaceSubrange(index...index, with: second)
|
||||
}
|
||||
}
|
||||
|
||||
if result1.count == 8 && !result2.contains("_") {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result1
|
||||
result2
|
|
@ -0,0 +1,649 @@
|
|||
let input = """
|
||||
focdealm
|
||||
ggsipflx
|
||||
rvibwxbm
|
||||
vqrfyyrh
|
||||
hsjtzpgs
|
||||
ozymxpoy
|
||||
jiecwags
|
||||
lztseufl
|
||||
dfwibwsn
|
||||
skiuhnwl
|
||||
kamgzqog
|
||||
axeqncwa
|
||||
gobivxto
|
||||
nwgoryhd
|
||||
tzrlitrq
|
||||
uzoldxbv
|
||||
zsteobha
|
||||
pfcgdqkg
|
||||
prcqlunp
|
||||
iwivemkh
|
||||
vpkilupm
|
||||
ewuznabz
|
||||
veaptost
|
||||
cyvirffe
|
||||
ejhhqfng
|
||||
ibsqztgg
|
||||
xzczkboh
|
||||
bckhbodf
|
||||
vbycgonv
|
||||
esmoyyku
|
||||
unccgdgj
|
||||
cqwnqlzs
|
||||
edoqmykb
|
||||
bkvzlhyq
|
||||
yzrspisn
|
||||
zlzibhca
|
||||
povnweaf
|
||||
muyfegxe
|
||||
oaojqfrl
|
||||
gwesjxws
|
||||
rjknfyeh
|
||||
dkquvctc
|
||||
cfuzhxoj
|
||||
tdzzzfqc
|
||||
lzjzsyni
|
||||
wjfxckkf
|
||||
xmhyjhop
|
||||
kmtllzxs
|
||||
yohearbj
|
||||
ilmvyxgn
|
||||
erczytzw
|
||||
kuetjsba
|
||||
vwkpollq
|
||||
tujwluzc
|
||||
jlvedjcp
|
||||
acmoaoji
|
||||
gqoliyen
|
||||
agckavhf
|
||||
ottamfdm
|
||||
jxwlyotw
|
||||
tdpsrapj
|
||||
carwwmqc
|
||||
ykaipjdj
|
||||
zdfrbduu
|
||||
vwiiosud
|
||||
uoixglbw
|
||||
yegbwxjb
|
||||
wbpqqqfv
|
||||
wpynmyqi
|
||||
aqdkscgd
|
||||
oghnbnnf
|
||||
duftexbb
|
||||
ttvbofay
|
||||
jferymwy
|
||||
hqzimpiq
|
||||
sifyogml
|
||||
nymxqbws
|
||||
dhdlhhqp
|
||||
urtuhcrj
|
||||
giwcunfq
|
||||
fxgretsl
|
||||
maihqkpk
|
||||
pdxfkcru
|
||||
xixtthag
|
||||
vuzxqzzi
|
||||
wxxeleug
|
||||
xpopxkzo
|
||||
hgcsyuad
|
||||
xcbydxnx
|
||||
kxocfakp
|
||||
erxdajeq
|
||||
tliakzhh
|
||||
iygbbuxs
|
||||
qlgqthpp
|
||||
duzzptwk
|
||||
gfnqdotc
|
||||
kjayxeqf
|
||||
fehitfar
|
||||
yemshppn
|
||||
igtczmmw
|
||||
gfajhxch
|
||||
bslzmgwo
|
||||
xpmhmirx
|
||||
yhlwlupt
|
||||
nymajupw
|
||||
tlhgdefw
|
||||
bqkudizc
|
||||
lucrhmnm
|
||||
svkoaqzz
|
||||
luggfivf
|
||||
ckawtiwy
|
||||
eeivawhj
|
||||
qdmmmvdl
|
||||
quezzzqa
|
||||
oimsfsuo
|
||||
jdvcknqu
|
||||
aupohqbk
|
||||
llwsasnz
|
||||
zlpljtjl
|
||||
xfylqxlv
|
||||
zqppxkul
|
||||
varoizrq
|
||||
yxryqwso
|
||||
gsscetca
|
||||
gcbdgqyo
|
||||
hsdnvteo
|
||||
pxtoreoc
|
||||
rwjdkwzs
|
||||
zdgofynf
|
||||
polyntkx
|
||||
jhulgrnf
|
||||
ycbzpdpw
|
||||
bzvdbwsy
|
||||
vydjbucs
|
||||
rxadwwuo
|
||||
ccnvzjak
|
||||
nombazjc
|
||||
lbxwdasr
|
||||
cbdlkiha
|
||||
sdomdvow
|
||||
phjnkkkp
|
||||
nmtmrnyz
|
||||
nxsvmcwk
|
||||
hqimjvir
|
||||
vmjhhuuv
|
||||
zilhgqlb
|
||||
gfgbibgg
|
||||
imxxugfe
|
||||
wtaffkbj
|
||||
lyguqvjs
|
||||
pejslhls
|
||||
qjnefwii
|
||||
oanqnnnc
|
||||
kcjyfwxm
|
||||
zoxjwxmw
|
||||
ihmokcrm
|
||||
uebsbhfr
|
||||
fxvjiorr
|
||||
ebjiucyt
|
||||
ofutlokv
|
||||
mdfnsuyr
|
||||
dzviwqdk
|
||||
umwyaijz
|
||||
hdqwfalt
|
||||
qtyrouwh
|
||||
lkzcrtwa
|
||||
dtqvwzke
|
||||
buplmmca
|
||||
xxepjuvj
|
||||
omyotlar
|
||||
ytndbwhi
|
||||
sbntigym
|
||||
mphrnsme
|
||||
xiymeoxr
|
||||
kcujxcih
|
||||
bydnchgk
|
||||
snwdjlip
|
||||
yljsymtv
|
||||
tyhbpoab
|
||||
zlqhvzxl
|
||||
akbtnzop
|
||||
xnpjmysj
|
||||
znhednen
|
||||
vbcsocrm
|
||||
ywjajour
|
||||
ejngbqev
|
||||
rstykfhc
|
||||
cbcnoexq
|
||||
mzlxvxwj
|
||||
vfdqaalp
|
||||
nbszzozr
|
||||
dqpyojid
|
||||
hfuqilbl
|
||||
uoackeup
|
||||
shqkcsmr
|
||||
jbdasroe
|
||||
fmlkvsnt
|
||||
cnomxkvk
|
||||
unbsfncq
|
||||
bnzxltxe
|
||||
bbadfyin
|
||||
skmhtmhn
|
||||
xkypwglb
|
||||
flbfiioo
|
||||
fzywneyg
|
||||
srngxbut
|
||||
qtodeuxg
|
||||
xvawfqli
|
||||
nyfmrdsn
|
||||
rdjysbxj
|
||||
spmezvvj
|
||||
ofoivcuc
|
||||
touzgqzx
|
||||
mfqyzagc
|
||||
dmaurbdv
|
||||
gqnrlyuw
|
||||
wuppusoh
|
||||
qgstihuy
|
||||
uldnlrpi
|
||||
xaskgwim
|
||||
djjrphid
|
||||
qjhmctyu
|
||||
osfenjdn
|
||||
zvoahhkk
|
||||
xiuyatyn
|
||||
fepobmjh
|
||||
kmugpjpw
|
||||
aikpozqs
|
||||
kmgmazif
|
||||
gbzlodzb
|
||||
hrocqadn
|
||||
noekklwb
|
||||
vzwhnkvx
|
||||
osrspxsc
|
||||
iekmqgua
|
||||
xeehndee
|
||||
quttqjav
|
||||
htoptweo
|
||||
cyicmwba
|
||||
jltlwlyy
|
||||
qvccdkig
|
||||
bibggekq
|
||||
kwfwvrfg
|
||||
eycwlcup
|
||||
murgcddl
|
||||
lyukeubx
|
||||
twbpzoyg
|
||||
dkcvzele
|
||||
fozhtmcz
|
||||
frugeivm
|
||||
qjbhpdpr
|
||||
tgkkeroo
|
||||
ryuvgqgc
|
||||
jhixykqn
|
||||
wsebmcrn
|
||||
wohtjpgu
|
||||
isflpxxt
|
||||
xggwmamk
|
||||
tfwdsrfe
|
||||
cpjvcghr
|
||||
fekhexdb
|
||||
zcwzqofh
|
||||
awnfiqzu
|
||||
ihekvqby
|
||||
rqaqajij
|
||||
cumouwzx
|
||||
ccyrflxd
|
||||
rredygrk
|
||||
patcpktn
|
||||
mjnwuefa
|
||||
tuhgyfsw
|
||||
mjpxrgkx
|
||||
hupfjqxo
|
||||
mgkclcrf
|
||||
jkmkhkci
|
||||
nkcrwgqd
|
||||
apmfiqpg
|
||||
pxiawshv
|
||||
ledhpfaz
|
||||
btikmkwj
|
||||
jwosopir
|
||||
mgxftcte
|
||||
phkbcdex
|
||||
uakftnbh
|
||||
fnkmdecn
|
||||
swrvbjwj
|
||||
hphskevf
|
||||
trnpfdmy
|
||||
odvmmqss
|
||||
akvqgemq
|
||||
zyqlkwdm
|
||||
nbnaqjsa
|
||||
mbnogzyt
|
||||
mchaxjxu
|
||||
tcqqerqz
|
||||
ayylasgq
|
||||
zqbrjfli
|
||||
ccjjnfat
|
||||
lvlpdjqu
|
||||
luiabalt
|
||||
qsvkepvz
|
||||
dtyobsiy
|
||||
jkulvrnc
|
||||
thwjbzkh
|
||||
vvhrwbkx
|
||||
fhxejrff
|
||||
bacuriaz
|
||||
grmtyude
|
||||
feynnckb
|
||||
hfdepyjn
|
||||
lvsfflyc
|
||||
xfrgfgeh
|
||||
vqqybtba
|
||||
ntlfjqjt
|
||||
zadauvmg
|
||||
itukkpqf
|
||||
mrnnfgmf
|
||||
hpjqvppo
|
||||
dshgwmgb
|
||||
pzxeoymv
|
||||
nlokvrio
|
||||
cgcaxffl
|
||||
dvimsnxu
|
||||
iczcvwho
|
||||
lkxumswj
|
||||
satmovog
|
||||
ujwknitl
|
||||
halkgpaa
|
||||
pnttnodc
|
||||
adsvsumi
|
||||
jwerfpko
|
||||
yhsjqytk
|
||||
vpevemez
|
||||
yvjmltwj
|
||||
vdoeippw
|
||||
siouxait
|
||||
ftrspdpx
|
||||
hptwqlmz
|
||||
haewgrft
|
||||
watbdvqz
|
||||
eiptzrvr
|
||||
msvbioso
|
||||
dnjeoucg
|
||||
qixvmlem
|
||||
mqquklfq
|
||||
sszagakl
|
||||
khfbexqb
|
||||
uysydrlc
|
||||
inawynse
|
||||
whuonlhq
|
||||
eshukapj
|
||||
vtrepdxm
|
||||
pgjjcisd
|
||||
puiunlts
|
||||
replddlv
|
||||
emjyyhmd
|
||||
aahwhond
|
||||
laneyzsj
|
||||
jnlkdpyb
|
||||
sqxrctuo
|
||||
wmmyybvl
|
||||
ldyvqldz
|
||||
bzbrsdjr
|
||||
ekxwhzte
|
||||
gnpqywzz
|
||||
afsfbtte
|
||||
ggkbrgds
|
||||
dlawfrbp
|
||||
opypolpc
|
||||
cqpxcfgh
|
||||
ynmtlgvl
|
||||
slfmicyv
|
||||
ooguwxjc
|
||||
tewmtlty
|
||||
wcdwansw
|
||||
ktercyvw
|
||||
qrgxrzne
|
||||
wvbhflls
|
||||
dpfjwbmm
|
||||
uigmcaow
|
||||
ejzhkxic
|
||||
fbewvcoh
|
||||
jxbtcmwn
|
||||
ywiktjqn
|
||||
rftnjqpp
|
||||
yalixnnw
|
||||
srdsiwgy
|
||||
pdpdrynx
|
||||
ioroheqp
|
||||
vpvvnmad
|
||||
tqksxfsp
|
||||
snzxciua
|
||||
nrhtoskm
|
||||
crfvapzk
|
||||
wndbcxvf
|
||||
syffkzmv
|
||||
nneibkaf
|
||||
unuvhnli
|
||||
ujhdjkvs
|
||||
gmyqgvdr
|
||||
jedfxwje
|
||||
bcshopnu
|
||||
xgiprhyv
|
||||
onibkkoq
|
||||
riguljez
|
||||
yodzrfeu
|
||||
ogbwakaa
|
||||
ymrltbxa
|
||||
ourmuhrx
|
||||
yxwixtuv
|
||||
ptnxdvdm
|
||||
oskvgexz
|
||||
fbigwiaw
|
||||
xctckzmy
|
||||
khwiyvmw
|
||||
qbqbtxpr
|
||||
kavzlngz
|
||||
bbklqvzt
|
||||
rwlzppbq
|
||||
upirhhca
|
||||
ezlaqdgo
|
||||
ieuynchi
|
||||
qmjtojzq
|
||||
qrricseq
|
||||
hxkrsfmw
|
||||
nssfpnws
|
||||
tiaziudb
|
||||
rvskpahe
|
||||
pplmppvi
|
||||
jxpyidio
|
||||
teudseap
|
||||
aclyhavi
|
||||
yqafhkyd
|
||||
drjhcqgu
|
||||
zvfcfbjc
|
||||
sqfuuezn
|
||||
gwtsupqk
|
||||
czakgbiy
|
||||
wknfzbyj
|
||||
ooxwycji
|
||||
wxymanlx
|
||||
ewbtpqtl
|
||||
jmwnxydh
|
||||
ceqdllqb
|
||||
jhdbejmt
|
||||
mazzsanu
|
||||
uypyqlvh
|
||||
itnrzbie
|
||||
miuegdjz
|
||||
tqxeipin
|
||||
kbareizb
|
||||
jgjxrycy
|
||||
epshhech
|
||||
oicruxsz
|
||||
ptxgidha
|
||||
bmgnvjtr
|
||||
qvwzlmgq
|
||||
cvwtdffi
|
||||
ibzasmru
|
||||
jfenrbjd
|
||||
nrkgwvcz
|
||||
hlmghdgd
|
||||
emhdaicl
|
||||
wdwrzocv
|
||||
spwjcrud
|
||||
dsgilvqn
|
||||
phvmafqk
|
||||
iiihsfff
|
||||
uvcqgtyc
|
||||
doxkrzzw
|
||||
hktdpsbv
|
||||
evqojani
|
||||
kzapomdx
|
||||
ewtbrdtb
|
||||
rgshzyxq
|
||||
ltinzxld
|
||||
cazrrlcu
|
||||
irfxunbt
|
||||
rmqcsbvm
|
||||
gddexbsb
|
||||
qladhkpd
|
||||
xlvzpmab
|
||||
wirftlbu
|
||||
fxfqjubx
|
||||
sgogtrcb
|
||||
zlqxxwfy
|
||||
djgtbihr
|
||||
gslssgsu
|
||||
wytydgje
|
||||
vmovsmdh
|
||||
ogyiuirh
|
||||
mtfxzrrx
|
||||
kcpfbemc
|
||||
blreqhel
|
||||
zjsjqqyh
|
||||
ciqwtpvk
|
||||
yjcinpaa
|
||||
wxbxagui
|
||||
aqbjqmig
|
||||
ybaeuhew
|
||||
mjzpnttv
|
||||
mevjcrqp
|
||||
fpmgzgco
|
||||
gklesvof
|
||||
jzfssvvx
|
||||
aynfmwhl
|
||||
euosbnhf
|
||||
lcebcalt
|
||||
kvsuuyyt
|
||||
ltranzur
|
||||
nlledtpz
|
||||
vqdrgckr
|
||||
yodxnjpt
|
||||
uyznwnni
|
||||
ckczwqkp
|
||||
uxtjgoee
|
||||
otdoyaxg
|
||||
lbccbfgi
|
||||
mhzjujrp
|
||||
cekkthvf
|
||||
fbvpuhog
|
||||
nzfannep
|
||||
rnnqusey
|
||||
aiocsiyy
|
||||
uvcbtfwr
|
||||
bzqirxrg
|
||||
qnmfgshq
|
||||
inyevvbn
|
||||
wswvhglx
|
||||
huxqxwwb
|
||||
fdutjnfq
|
||||
adajhsjk
|
||||
ahllesij
|
||||
tcfawzgu
|
||||
zfdgmtry
|
||||
byznvpfp
|
||||
duunxdad
|
||||
kgadxmdf
|
||||
ptfaovzv
|
||||
uhuvlivs
|
||||
xcoqrmeu
|
||||
nnnlvmga
|
||||
zwrbykek
|
||||
lvpumidd
|
||||
hieivrnt
|
||||
vrwqsvci
|
||||
npbplsvm
|
||||
ougzcgty
|
||||
rzvgzooo
|
||||
iehafkto
|
||||
rzspzjne
|
||||
dzvvhvld
|
||||
fgkmmfda
|
||||
xjsnnlmd
|
||||
igvjrsuk
|
||||
narcempo
|
||||
xrhoiugu
|
||||
ghxbpomr
|
||||
waxtcbcg
|
||||
tmqgsejx
|
||||
dobaxhel
|
||||
mpzgjyww
|
||||
ehyfvnaz
|
||||
zxrdlajd
|
||||
hfquyvok
|
||||
aqxxdcqv
|
||||
vjbukram
|
||||
rjvttibk
|
||||
pryxgzrd
|
||||
hcqpxgee
|
||||
qjgqvoal
|
||||
wmbuvcty
|
||||
zpgxmdiu
|
||||
foequjps
|
||||
lmdjwyfj
|
||||
mhqudwzv
|
||||
lrzkttsw
|
||||
owyatnru
|
||||
gwppbbfb
|
||||
fvlkdsjk
|
||||
pwhlvjtb
|
||||
zgldiibp
|
||||
sokjzgvq
|
||||
kfourwqm
|
||||
nfqoyvsz
|
||||
hdiwmrhk
|
||||
nnapsbht
|
||||
blqjjtwy
|
||||
aknoauti
|
||||
uhgowkyx
|
||||
uypyjorh
|
||||
blfeioot
|
||||
kzbukpxk
|
||||
kfmbxgle
|
||||
zmegahum
|
||||
upjouzrg
|
||||
tkedvzfy
|
||||
bxwxuutn
|
||||
rrwxobjp
|
||||
jdujkhox
|
||||
jkycewdx
|
||||
ivlbibns
|
||||
qjshodxf
|
||||
bektjeou
|
||||
wotjfgfl
|
||||
rjrcfiug
|
||||
aklhubjf
|
||||
kwpnaezt
|
||||
lsqvzdom
|
||||
pxzvorct
|
||||
vcxazyzs
|
||||
xsszjsjq
|
||||
ydgfsukl
|
||||
gqxpcrla
|
||||
rvsoxkhy
|
||||
rschupcm
|
||||
ivlpikxi
|
||||
etrnyvkh
|
||||
byzymjms
|
||||
qagdcqww
|
||||
sxnausxs
|
||||
giuitchj
|
||||
qgolehtg
|
||||
keeskeyb
|
||||
"""
|
||||
.split(separator: "\n")
|
||||
|
||||
var counts: [[Character: Int]] = Array(repeating: [:], count: 8)
|
||||
for line in input {
|
||||
for (index, ch) in line.enumerated() {
|
||||
counts[index][ch, default: 0] += 1
|
||||
}
|
||||
}
|
||||
|
||||
let result1 = String(counts
|
||||
.map {
|
||||
$0.max { a, b in a.value < b.value }?.key ?? "_"
|
||||
})
|
||||
|
||||
let result2 = String(counts
|
||||
.map {
|
||||
$0.min { a, b in a.value < b.value }?.key ?? "_"
|
||||
})
|
||||
|
||||
result1
|
||||
result2
|
||||
|
||||
|
11
2016/AoC2016.playground/contents.xcplayground
Normal file
11
2016/AoC2016.playground/contents.xcplayground
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='6.0' target-platform='macos' buildActiveScheme='true' importAppTypes='true'>
|
||||
<pages>
|
||||
<page name='Day 2'/>
|
||||
<page name='Day 1'/>
|
||||
<page name='Day 3'/>
|
||||
<page name='Day 4'/>
|
||||
<page name='Day 5'/>
|
||||
<page name='Day 6'/>
|
||||
</pages>
|
||||
</playground>
|
7
2016/AoC2016.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
2016/AoC2016.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:/Users/sven/Projekte/AdventOfCode/2016/AoC2016.playground">
|
||||
</FileRef>
|
||||
</Workspace>
|
Loading…
Add table
Reference in a new issue