SeatDecoder.kt

1
package com.adventofcode.day05
2
3 1 1. getSeats : replaced return value with Collections.emptyList for com/adventofcode/day05/SeatDecoder::getSeats → KILLED
class SeatDecoder(val seats: List<Seat>) {
4
5
    constructor(seat: Seat) : this(listOf(seat))
6
7
    companion object {
8
9
        fun readSeatFromInput(input: String): SeatDecoder {
10
            return SeatDecoder(readSeat(input))
11
        }
12
13
        private fun readSeat(input: String): Seat {
14
            val rowCode = input.substring(0, 7)
15
            val columnCode = input.substring(7)
16 1 1. readSeat : replaced return value with null for com/adventofcode/day05/SeatDecoder$Companion::readSeat → KILLED
            return Seat(
17
                    RowBinarySpacePartition().decode(rowCode).min,
18
                    ColumnBinarySpacePartition().decode(columnCode).min
19
            )
20
        }
21
22
        fun readFromInput(input: List<String>): SeatDecoder {
23
            return SeatDecoder(input.map { readSeat(it) }.toList())
24
        }
25
    }
26
27
    fun findSeatWithHigherIdFrom(): Seat? {
28
        return seats.maxBy { it.id }
29
    }
30
31
    fun findMissingSeat(): Int {
32
        val seatsIds = seats.map { it.id }
33
        val maxRow = seats.minBy { it -> it.id }!!.row
34
        val maxColumn = seats.maxBy { it.id }!!.row
35
36
        val filterIds = seats
37 2 1. findMissingSeat : negated conditional → KILLED
2. findMissingSeat : negated conditional → KILLED
                .filterNot { it.row == maxRow }
38 2 1. findMissingSeat : negated conditional → KILLED
2. findMissingSeat : negated conditional → KILLED
                .filterNot { it.row == maxColumn }
39
                .map { it.id }
40
41
        return filterIds.min()!!.rangeTo(filterIds.max()!!)
42 1 1. findMissingSeat : negated conditional → KILLED
                .filterNot { it in seatsIds }
43 1 1. findMissingSeat : replaced int return with 0 for com/adventofcode/day05/SeatDecoder::findMissingSeat → KILLED
                .first()
44
45
    }
46
47
}

Mutations

3

1.1
Location : getSeats
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToDecodeSeatFromInputText()]
replaced return value with Collections.emptyList for com/adventofcode/day05/SeatDecoder::getSeats → KILLED

16

1.1
Location : readSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToDecodeSeatFromInputText()]
replaced return value with null for com/adventofcode/day05/SeatDecoder$Companion::readSeat → KILLED

37

1.1
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

2.2
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

38

1.1
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

2.2
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

42

1.1
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

43

1.1
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
replaced int return with 0 for com/adventofcode/day05/SeatDecoder::findMissingSeat → KILLED

50

1.1
Location : findSeatWithHigherIdFrom
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindWithHigherIdFrom()]
negated conditional → KILLED

53

1.1
Location : findSeatWithHigherIdFrom
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindWithHigherIdFrom()]
negated conditional → KILLED

56

1.1
Location : findSeatWithHigherIdFrom
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : findSeatWithHigherIdFrom
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindWithHigherIdFrom()]
negated conditional → KILLED

61

1.1
Location : findSeatWithHigherIdFrom
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindWithHigherIdFrom()]
replaced return value with null for com/adventofcode/day05/SeatDecoder::findSeatWithHigherIdFrom → KILLED

70

1.1
Location : findMissingSeat
Killed by : none
negated conditional → SURVIVED

73

1.1
Location : findMissingSeat
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : findMissingSeat
Killed by : com.adventofcode.day05.SeatDecoderTest.[engine:junit-jupiter]/[class:com.adventofcode.day05.SeatDecoderTest]/[method:shouldBeAbleToFindMissingSeats()]
negated conditional → KILLED

83

1.1
Location : findMissingSeat
Killed by : none
negated conditional → SURVIVED

86

1.1
Location : findMissingSeat
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : findMissingSeat
Killed by : none
negated conditional → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.6.1