Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Created December 14, 2011 17:15
Show Gist options
  • Save pbalduino/1477505 to your computer and use it in GitHub Desktop.
Save pbalduino/1477505 to your computer and use it in GitHub Desktop.
To remember
#lang scheme
; sudoku solver
; sample:
;+-------+-------+-------+
;| 6 7 . | . 2 1 | . 4 . |
;| . . . | 7 . . | . 3 . |
;| . 5 . | 8 . . | 6 . . |
;+-------+-------+-------+
;| 7 . 6 | 1 . 2 | 9 . . |
;| . 1 4 | . 8 . | 5 2 . |
;| . . 5 | 4 . 9 | 3 . 1 |
;+-------+-------+-------+
;| . . 2 | . . 4 | . 9 . |
;| . 4 . | . . 7 | . . . |
;| . 9 . | 2 1 . | . 5 6 |
;+-------+-------+-------+
; http://www.websudoku.com/?level=1&set_id=5175308806
(define easy "67..21.4....7...3..5.8..6..7.61.29...14.8.52...54.93.1..2..4.9..4...7....9.21..56")
(define (get-line game-list line-number)
(take-right (first (let-values([(l r) (split-at game-list (* line-number 9))]) (list l r))) 9))
(define (show-board game)
(define game-list (string->list game))
(for ([line (in-range 1 10)])
(display (get-line game-list line))
(display "\n")))
(show-board easy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment