numberten / zhenya_bot

irc bot and official Haskell feature creep
Other
5 stars 1 forks source link

!queens: pretty printing #20

Closed numberten closed 10 years ago

numberten commented 10 years ago

Pretty Printing Ideas:

keneanung commented 10 years ago

Could make the chessboard look like this:

[7,4,8,6,2,5,3,1]
". . . . . . Q . "
". . . Q . . . . "
". . . . . . . Q "
". . . . . Q . . "
". Q . . . . . . "
". . . . Q . . . "
". . Q . . . . . "
"Q . . . . . . . "

That way we use only n+1 lines (could also leave the list out, which would make it n lines). Gotta play with flooding first though to define the upper bound.

Alternatively we could print the list only if the "board" would become too big.

numberten commented 10 years ago

I like the idea of printing the list only when the board becomes too big.

Also that visualization looks good, though your board doesn't seem to correspond with your numbers and your queens in rows 3 and 6 threaten each other. Assuming that was just a rough sketch to show what it would look, then it looks great.

keneanung commented 10 years ago

You're right. There's been a bug in my algoritm were I used the wrong variable for a recursive call. This should be the correct output

[4,2,7,3,6,8,5,1]
". . . Q . . . . "
". Q . . . . . . "
". . . . . . Q . "
". . Q . . . . . "
". . . . . Q . . "
". . . . . . . Q "
". . . . Q . . . "
"Q . . . . . . . "

I'm not sure where my numbers don't correspond to the board. Remember the list is index 1 based.

numberten commented 10 years ago

For some reason I was thinking numbers referred to rows, not columns. Looks good!