File tree 3 files changed +49
-0
lines changed
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ def run( input) = {
2
+ input
3
+ | > String. split( "\n\n")
4
+ | > Enum . map( /x/
5
+ String. split( x, "\n")
6
+ | > Enum . map( Int. from_string)
7
+ | > Enum . sum ()
8
+ )
9
+ | > Enum . max ()
10
+ }
11
+
12
+ def main() = File . read_string( ".input.txt") | > run() | > println()
Original file line number Diff line number Diff line change
1
+ def run( input) = {
2
+ input
3
+ | > String. split( "\n\n")
4
+ | > Enum . map( /x/
5
+ String. split( x, "\n")
6
+ | > Enum . map( Int. from_string)
7
+ | > Enum . sum ()
8
+ )
9
+ | > Enum . sort()
10
+ | > Enum . rev()
11
+ | > Enum . take( 3 )
12
+ | > Enum . sum ()
13
+ }
14
+
15
+ def main() = File . read_string( ".input.txt") | > run() | > println()
Original file line number Diff line number Diff line change
1
+ def input() = " 1000
2
+ 2000
3
+ 3000
4
+
5
+ 4000
6
+
7
+ 5000
8
+ 6000
9
+
10
+ 7000
11
+ 8000
12
+ 9000
13
+
14
+ 10000"
15
+
16
+ def test_day1a() = {
17
+ assert_eq(Day1a.run(input()), 24000)
18
+ }
19
+
20
+ def test_day1b() = {
21
+ assert_eq(Day1b.run(input()), 45000)
22
+ }
You can’t perform that action at this time.
0 commit comments