Add 2017 solutions

This commit is contained in:
Sven Weidauer 2022-11-23 16:46:31 +01:00
parent 8146a794a3
commit 6f9b51146c
11 changed files with 2285 additions and 0 deletions

View file

@ -0,0 +1,23 @@
//: [Previous](@previous)
import Foundation
func shell(_ value: Int) -> Int {
return Int(ceil((sqrt(Double(value)) - 1) / 2))
}
func biggestValue(_ shell: Int) -> Int {
return (2 * shell + 1) * (2 * shell + 1)
}
let value = 16
let s = shell(value)
let shellStart = biggestValue(s - 1) + 1
let shellPosition = value - shellStart
(Float(shellPosition) / 2 + 1) / 2
//: [Next](@next)