Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Last active August 29, 2015 14:01
Show Gist options
  • Save bjhaid/7e5ed20c5e42a1690501 to your computer and use it in GitHub Desktop.
Save bjhaid/7e5ed20c5e42a1690501 to your computer and use it in GitHub Desktop.
Sudoku board, with validator logic in 267 characters reduce to 208 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