package Ġcom . github . sh mv anh out en . ad vent of code . day 1 2 . instruction Ċ Ċ import Ġcom . github . sh mv anh out en . ad vent of code . day 1 2 . B un ny State Ċ Ċ interface ĠInstruction Ġ{ ĊĠĠĠ Ġfun Ġexecute Instruction ( index : ĠInt , Ġstate : ĠBun ny State ): ĠPair < Int , ĠBun ny State > Ċ } Ċ Ċ enum Ġclass ĠRegister ( val Ġraw Instruction Part : ĠString ) Ġ{ ĊĠĠĠ ĠA (" a "), ĊĠĠĠ ĠB (" b "), ĊĠĠĠ ĠC (" c "), ĊĠĠĠ ĠD (" d ") Ċ Ċ } Ċ internal Ġfun Ġget Register From Raw Instruction ( raw Instruction : ĠString ): ĠRegister ? Ġ{ ĊĠĠĠ Ġreturn ĠRegister . values (). find Ġ{ Ġraw Instruction Ġ== Ġit . raw Instruction Part Ġ} Ċ } Ċ Ċ enum Ġclass ĠInstruction Type ( val Ġraw Instruction Part : ĠString ){ ĊĠĠĠ ĠC PY (" cpy "), ĊĠĠĠ ĠINC (" inc "), ĊĠĠĠ ĠDEC (" dec "), ĊĠĠĠ ĠJ UMP (" j nz "), ĊĠĠĠ ĠTO GGLE (" tgl "), ĊĠĠĠ ĠOUT (" out ") Ċ } Ċ Ċ internal Ġfun Ġget Instruction Type From Raw Instruction ( raw Instruction : ĠString ): ĠInstruction Type Ġ{ ĊĠĠĠ Ġreturn ĠInstruction Type . values (). find Ġ{ Ġraw Instruction . contains ( it . raw Instruction Part ) Ġ} !! Ċ }