Last active
August 29, 2015 14:01
-
-
Save bjhaid/7e5ed20c5e42a1690501 to your computer and use it in GitHub Desktop.
Sudoku board, with validator logic in 267 characters reduce to 208 characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=Array;d=A.new(9){A.new(9,"_")};loop{a,b,c=gets.split(":").map(&:to_i);next(p"invalid")if(d.map{|x|x[b]}+d[a-a%3,3].flat_map{|x|x[b-b%3,3]}+d[a]).include?c;d[a][b]=c;puts d.map{|x|x.join" "}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment