I've been trying to port a sudoku solver from Python to Clojure and I am having trouble making it idomatic clojure. I asked on the IRC channel and got solutions the authors told me were not idiomatic but they weren't sure how to make them so.
Sudoku works in a 9 x 9 grid made of 81 squares labelled as follow: A1 A2 A3| A4 A5 A6| A7 A8 A9 B1 B2 B3| B4 B5 B6| B7 B8 B9 C1 C2 C3| C4 C5 C6| C7 C8 C9 ---------+---------+--------- D1 D2 D3| D4 D5 D6| D7 D8 D9 E1 E2 E3| E4 E5 E6| E7 E8 E9 F1 F2 F3| F4 F5 F6| F7 F8 F9 ---------+---------+--------- G1 G2 G3| G4 G5 G6| G7 G8 G9 H1 H2 H3| H4 H5 H6| H7 H8 H9 I1 I2 I3| I4 I5 I6| I7 I8 I9 A horizontal line, vertical line or each of the nine 3 x 3 squares is called a unit. So, each square belongs in three units. The squares that share a unit with another square are that square's peers. So, the square A1 would: - Be in the units: (A1 A2 A3 A4 A5 A6 A7 A8 A9) (A1 B1 C1 D1 E1 F1 G1 H1 I1) (A1 A2 A3 B1 B2 B3 C1 C2 C3) - Have the peers: (A2 A3 A4 A5 A6 A7 A8 A9 B1 C1 D1 E1 F1 G1 H1 I1 B2 B3 C1 C2 C3) I'm looking for an idiomatic way to represent the list of squares, the list of units, being able to tell to which units a square belongs and to be able to tell what are a square's peers. The original Python code is here: http://norvig.com/sudoku.html But I suggest not looking at it because it infects your thinking and you have trouble thinking of a solution that looks different. Thanks for any insight, that would greatly help me understand what makes code idiomatic clojure. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---