package Ġsolving Ċ Ċ import ĠP uzzle Ċ import Ġorg . junit . jupiter . api . Assertions .* Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġwords . Dictionary Ċ import Ġjava . util .* Ċ Ċ class ĠSolver Tests Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsolve Cat To Dog () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" dog "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions : ĠList < Solution > Ġ= Ġsolver . solve ( 4 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ Ġval Ġmid Words : ĠMutable Map < Int , ĠMutable Set < String >> Ġ= ĠHashMap () ĊĠĠĠĠĠĠĠ Ġfor Ġ( solution Ġin Ġsolutions ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġsolution . size ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" CAT ", Ġsolution [ 0 ]. toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" DOG ", Ġsolution [ 3 ]. toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmid Words . compute If Absent ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 1 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ Ġinteger : ĠInt ? Ġ-> ĠHashSet () Ġ}. add ( solution [ 1 ]. toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmid Words . compute If Absent ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 2 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ Ġinteger : ĠInt ? Ġ-> ĠHashSet () Ġ}. add ( solution [ 2 ]. toString ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġmid Words [ 1 ] !!. size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mid Words [ 1 ] !!. contains (" C AG ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mid Words [ 1 ] !!. contains (" C OT ")) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġmid Words [ 2 ] !!. size ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mid Words [ 2 ] !!. contains (" DOT ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mid Words [ 2 ] !!. contains (" CO G ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( mid Words [ 2 ] !!. contains (" DAG ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsolve Col d To W arm And W arm To Col d () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 4 ) ĊĠĠĠĠĠĠĠ Ġvar Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cold "] !! , Ġdictionary [" warm "] !! ) ĊĠĠĠĠĠĠĠ Ġvar Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġvar Ġsolutions Ġ= Ġsolver . solve ( 5 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ Ġval Ġexplo red Ġ= Ġsolver . explo red Count ĊĊĠĠĠĠĠĠĠ Ġ// Ġnow Ġdo Ġit Ġthe Ġother Ġway Ġaround .. ĊĠĠĠĠĠĠĠ Ġpuzzle Ġ= ĠP uzzle ( dictionary [" warm "] !! , Ġdictionary [" cold "] !! ) ĊĠĠĠĠĠĠĠ Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġsolutions Ġ= Ġsolver . solve ( 5 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 7 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( explo red , Ġsolver . explo red Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsolve K ata To Java () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 4 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" k ata "] !! , Ġdictionary [" java "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 3 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ Ġval Ġsolution Ġ= Ġsolutions [ 0 ] ĊĠĠĠĠĠĠĠ ĠassertEquals (" K ATA ", Ġsolution [ 0 ]. toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" K AVA ", Ġsolution [ 1 ]. toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" JAVA ", Ġsolution [ 2 ]. toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsame Word Is Sol vable () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" cat "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolver . explo red Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġone Letter Difference Is Sol vable () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" cot "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 2 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolver . explo red Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtwo Letters Difference Is Sol vable () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" bar "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 3 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolver . explo red Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġeverything Un sol vable With Bad Max L adder Length () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" dog "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 0 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolver . explo red Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshort Circuit On One Letter Difference () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdictionary Ġ= ĠDictionary . Cache . for Word Length ( 3 ) ĊĠĠĠĠĠĠĠ Ġval Ġpuzzle Ġ= ĠP uzzle ( dictionary [" cat "] !! , Ġdictionary [" cot "] !! ) ĊĠĠĠĠĠĠĠ Ġval Ġsolver Ġ= ĠSolver ( pu zzle ) ĊĠĠĠĠĠĠĠ Ġval Ġsolutions Ġ= Ġsolver . solve ( 3 ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġsolutions . size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġsolver . explo red Count ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġsolutions [ 0 ]. size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġsolutions [ 1 ]. size ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġsolutions [ 2 ]. size ) ĊĠĠĠ Ġ} Ċ }