@@ -23,9 +23,9 @@ class SomeAssemblyRequired : AdventOfCode<Int>(2015, 7) {
2323 operations.forEach {
2424 val result = it.execute(values)
2525 if (result.out is ValueOutput ) {
26- values.put( result.wire, result.out .value)
26+ values[ result.wire] = result.out .value
2727 } else {
28- this . add(it)
28+ add(it)
2929 }
3030 }
3131 }
@@ -71,12 +71,17 @@ data class ReWire(val from: String, val out: String) : Operation {
7171 override fun execute (values : Map <String , UShort >) = Output (out , values[from]?.let { ValueOutput (it) } ? : NoSignal )
7272}
7373
74- data class UnaryOperation (val operand : String , val operator : UnaryOperator , val out : String ) : Operation {
74+ data class UnaryOperation (private val operand : String , private val operator : UnaryOperator , val out : String ) :
75+ Operation {
7576 override fun execute (values : Map <String , UShort >) = Output (out , operator .execute(values, operand))
7677}
7778
78- data class BinaryOperation (val op1 : String , val op2 : String , val operator : BinaryOperator , val out : String ) :
79- Operation {
79+ data class BinaryOperation (
80+ private val op1 : String ,
81+ private val op2 : String ,
82+ private val operator : BinaryOperator ,
83+ val out : String
84+ ) : Operation {
8085 override fun execute (values : Map <String , UShort >) = Output (out , operator .execute(values, op1, op2))
8186}
8287
@@ -135,4 +140,4 @@ data class Output(val wire: String, val out: OperatorOutput)
135140sealed interface OperatorOutput {
136141 data class ValueOutput (val value : UShort ) : OperatorOutput
137142 object NoSignal : OperatorOutput
138- }
143+ }
0 commit comments