package Ġad vent of code . y 2 0 1 6 Ċ Ċ import Ġad vent of code . util . As sem B un ny Context Ċ import Ġad vent of code . util . Instruction Ċ import Ġad vent of code . util . parse To As sem B un ny Ċ import Ġad vent of code . Ad vent Solution ĊĊ Ċ object ĠDay 2 5 Ġ: ĠAd vent Solution ( 2 0 1 6 , Ġ 2 5 , Ġ" Clock ĠSignal ") Ġ{ Ċ ĉ override Ġfun Ġsolve Part One ( input : ĠString ): ĠString Ġ{ Ċĉ ĉ val Ġprogram Ġ= Ġparse To As sem B un ny ( input ). to Mutable List () Ċĉ ĉ return Ġ( 1 .. 1 0 0 0 0 ). as Sequence () Ċĉĉĉ ĉ . filter Ġ{ Ġtest ( program , Ġit , Ġ 1 0 0 ) Ġ} Ċĉĉĉ ĉ . filter Ġ{ Ġtest ( program , Ġit , Ġ 1 _ 0 0 0 ) Ġ} Ċĉĉĉ ĉ . filter Ġ{ Ġtest ( program , Ġit , Ġ 1 0 _ 0 0 0 ) Ġ} Ċĉĉĉ ĉ . filter Ġ{ Ġtest ( program , Ġit , Ġ 1 0 0 _ 0 0 0 ) Ġ} Ċĉĉĉ ĉ . first Ġ{ Ġtest ( program , Ġit , Ġ 1 _ 0 0 0 _ 0 0 0 ) Ġ} Ċĉĉĉ ĉ . toString () Ċ ĉ } ĊĊ ĉ private Ġfun Ġtest ( program : ĠMutable List < Instruction >, Ġa : ĠInt , Ġrun Length : ĠInt ): ĠBoolean Ġ{ Ċĉ ĉ val Ġregisters Ġ= Ġmutable ListOf ( a , Ġ 0 , Ġ 0 , Ġ 0 ) Ċĉ ĉ val Ġs Ġ= ĠAs sem B un ny Context ( registers , Ġ 0 , Ġprogram ) Ċĉ ĉ s . run ( run Length ) Ċĉ ĉ return Ġs . signal . all Ġ{ Ġit Ġin Ġ 0 .. 1 Ġ} Ġ&& Ġs . signal . as Sequence (). zip With Next (). all Ġ{ Ġ( a , Ġb ) Ġ-> Ġa Ġ!= Ġb Ġ} Ċ ĉ } ĊĊ ĉ override Ġfun Ġsolve Part Two ( input : ĠString ) Ġ= Ġ" Free Ġstar !" Ċ Ċ } ĊĊ