create board 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , : display-row ( r -- ) { r } 48 r + emit 8 0 do 124 emit board i cells + @ r = if 42 emit else 32 emit endif loop 124 emit cr ; : display cr 8 0 do i display-row loop ; : is-conflict { c } c 0 ?do board i cells + @ board c cells + @ = board i cells + @ i + board c cells + @ c + = or board i cells + @ i - board c cells + @ c - = or if true unloop exit endif loop false ; create col 0 , : solve { max } 0 >r 0 begin board col @ cells + @ 7 > if 0 board col @ cells + ! col @ 0 = if exit endif col @ 1 - col ! board col @ cells + @ 1 + board col @ cells + ! else col @ is-conflict false = if col @ 7 = if display r> 1 + >r r@ max >= if rdrop exit endif endif col @ 1 + col ! else board col @ cells + @ 1 + board col @ cells + ! endif endif again ;