blob: 26be73c0b20c53654ab780480e4834cb645ed9cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
fn calories(input) {
var elves = []
var current = 0
for line in input.lines() {
if line.empty() {
elves.append(current)
current = 0
continue
}
current += line as!! int
}
elves.sort()
elves.reverse()
return elves[0..3].sum()
}
fn fib(x: int) {
if x < 2 {
return x
}
return fib(x - 1) + fib (x - 2)
}
fn codes(input: String): List<String> {
val chars = input.chars()
.windowed(4)
.map(it -> it as Set)
.filter(-> $0.len() == 4)
.map(it -> it.join())
return chars
}
## Will convert celsius to fahrenheit
fn fahrenheit(celsius) {
return 32.0 + celsius * 1.8
}
|