1 | package com.adventofcode.day04 | |
2 | ||
3 | class Passport(internal val data: Map<DataField, String>) { | |
4 | ||
5 | override fun toString(): String { | |
6 |
1
1. toString : replaced return value with "" for com/adventofcode/day04/Passport::toString → KILLED |
return "Passport(${data.toSortedMap()})" |
7 | } | |
8 | ||
9 | ||
10 | companion object { | |
11 | fun fromInput(input: String): Passport { | |
12 | return Passport(input.split(" ", "\n") | |
13 | .map { it.split(":") } | |
14 |
4
1. fromInput : negated conditional → KILLED 2. fromInput : negated conditional → KILLED 3. fromInput : negated conditional → KILLED 4. fromInput : negated conditional → KILLED |
.filter { !it.first().isNullOrEmpty() } |
15 | .map { Pair(DataField.valueOf(it.first().toUpperCase()), it.last()) } | |
16 | .toMap() | |
17 | ) | |
18 | } | |
19 | } | |
20 | ||
21 | ||
22 | ||
23 | ||
24 | } | |
Mutations | ||
6 |
1.1 |
|
14 |
1.1 2.2 3.3 4.4 |