Add 2015
This commit is contained in:
parent
c7deb3c71d
commit
ddf5ec2274
56 changed files with 6756 additions and 1 deletions
23
2015/Day10.playground/Contents.swift
Normal file
23
2015/Day10.playground/Contents.swift
Normal file
|
@ -0,0 +1,23 @@
|
|||
func step(_ input: String) -> String {
|
||||
var position = input.startIndex
|
||||
var output = ""
|
||||
while position < input.endIndex {
|
||||
let next = input[position...].firstIndex(where: { $0 != input[position] }) ?? input.endIndex
|
||||
|
||||
let distance = input.distance(from: position, to: next)
|
||||
|
||||
output += "\(distance)\(input[position])"
|
||||
|
||||
position = next
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
var current = "1321131112"
|
||||
for _ in 0..<50 {
|
||||
current = step(current)
|
||||
}
|
||||
current
|
||||
current.count
|
||||
|
4
2015/Day10.playground/contents.xcplayground
Normal file
4
2015/Day10.playground/contents.xcplayground
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
|
||||
<timeline fileName='timeline.xctimeline'/>
|
||||
</playground>
|
7
2015/Day10.playground/playground.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
2015/Day10.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 = "group:">
|
||||
</FileRef>
|
||||
</Workspace>
|
Loading…
Add table
Add a link
Reference in a new issue