File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Algorithms
33struct Day11 : AdventDay {
44 var data : String
55
6- func getStones( data: String ) -> [ Int : Int ] {
6+ static func getStones( data: String ) -> [ Int : Int ] {
77 var stones = [ Int: Int] ( )
88 data. trimmed ( ) . integers ( ) . forEach { stone in
99 stones [ stone, default: 0 ] += 1
@@ -12,7 +12,7 @@ struct Day11: AdventDay {
1212 }
1313
1414 func stoneMe( blinks: Int ) -> Int {
15- var stones = getStones ( data: data)
15+ var stones = Self . getStones ( data: data)
1616 for _ in 0 ..< blinks {
1717 var newStones = [ Int: Int] ( )
1818 for (stone, count) in stones {
Original file line number Diff line number Diff line change @@ -5,12 +5,19 @@ import Testing
55@Suite ( " Day11 " )
66struct Day11Tests {
77
8+ let testData = """
9+ 125 17
10+ """
11+
12+ @Test ( " Get stones " )
13+ func testGetStones( ) async throws {
14+ #expect( Day11 . getStones ( data: testData) == [ 125 : 1 , 17 : 1 ] )
15+ }
16+
817 @Test ( " part1 " )
918 func testPart1( ) async throws {
1019 let challenge = Day11 (
11- data: """
12- 125 17
13- """
20+ data: testData
1421 )
1522 #expect( challenge. part1 ( ) == 55312 )
1623 }
You can’t perform that action at this time.
0 commit comments