TobogganTrajectory.kt

1
package com.adventofcode.day03
2
3
class TobogganTrajectory(private val gridWithTrees: Grid, private val slopesModel: SlopesModel) {
4
5
    constructor() : this(Grid(listOf("")), CheaperSlopesModel())
6
7
    companion object {
8
        fun fromInputWithSlopeModel(inputGridWithTrees: String, slopesModel: SlopesModel): TobogganTrajectory {
9
            return TobogganTrajectory(Grid.fromInput(inputGridWithTrees), slopesModel)
10
        }
11
    }
12
13
    private var encounteredTrees: Int = 0
14
15
    override fun toString(): String {
16 1 1. toString : replaced return value with "" for com/adventofcode/day03/TobogganTrajectory::toString → NO_COVERAGE
        return "Toboggan Trajectory: $encounteredTrees tree(s) encountered"
17
    }
18
19
    fun treesEncountered(): Int {
20 1 1. treesEncountered : replaced int return with 0 for com/adventofcode/day03/TobogganTrajectory::treesEncountered → KILLED
        return encounteredTrees
21
    }
22
23
    fun downTheSlope() {
24
        var position = Triple(0, 0, '.')
25
        val lastLineOnGrid = gridWithTrees.lastLine()
26
27 2 1. downTheSlope : changed conditional boundary → SURVIVED
2. downTheSlope : negated conditional → KILLED
        while (position.first < lastLineOnGrid){
28
            position = slopesModel.moveOn(gridWithTrees)
29 1 1. downTheSlope : negated conditional → KILLED
            if (position.third == '#') {
30 1 1. downTheSlope : Replaced integer addition with subtraction → KILLED
                encounteredTrees += 1
31
            }
32
        }
33
34
    }
35
36
}

Mutations

16

1.1
Location : toString
Killed by : none
replaced return value with "" for com/adventofcode/day03/TobogganTrajectory::toString → NO_COVERAGE

20

1.1
Location : treesEncountered
Killed by : com.adventofcode.day03.TobogganTrajectoryTest.[engine:junit-jupiter]/[class:com.adventofcode.day03.TobogganTrajectoryTest]/[method:indicatesNumberOfTreeEncounteredWithMoreThan2linesGridAndCheaperSlopesModel()]
replaced int return with 0 for com/adventofcode/day03/TobogganTrajectory::treesEncountered → KILLED

27

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

2.2
Location : downTheSlope
Killed by : com.adventofcode.day03.TobogganTrajectoryTest.[engine:junit-jupiter]/[class:com.adventofcode.day03.TobogganTrajectoryTest]/[method:indicatesNumberOfTreeEncounteredWithMoreThan2linesGridAndCheaperSlopesModel()]
negated conditional → KILLED

29

1.1
Location : downTheSlope
Killed by : com.adventofcode.day03.TobogganTrajectoryTest.[engine:junit-jupiter]/[class:com.adventofcode.day03.TobogganTrajectoryTest]/[method:indicatesNumberOfTreeEncounteredWithMoreThan2linesGridAndCheaperSlopesModel()]
negated conditional → KILLED

30

1.1
Location : downTheSlope
Killed by : com.adventofcode.day03.TobogganTrajectoryTest.[engine:junit-jupiter]/[class:com.adventofcode.day03.TobogganTrajectoryTest]/[method:indicatesNumberOfTreeEncounteredWithMoreThan2linesGridAndCheaperSlopesModel()]
Replaced integer addition with subtraction → KILLED

Active mutators

Tests examined


Report generated by PIT 1.6.1