Skip to content

Instantly share code, notes, and snippets.

@thatrubylove
Last active December 9, 2015 08:55
Show Gist options
  • Save thatrubylove/c556ee12882d58223d56 to your computer and use it in GitHub Desktop.
Save thatrubylove/c556ee12882d58223d56 to your computer and use it in GitHub Desktop.
Sudoku in Ruby
[
[4,8,3,9,2,1,6,5,7],
[9,6,7,3,4,5,8,2,1],
[2,5,1,8,7,6,4,9,3],
[5,4,8,1,3,2,9,7,6],
[7,2,9,5,6,4,1,3,8],
[1,3,6,7,9,8,2,4,5],
[3,7,2,6,0,9,5,1,4],
[8,1,4,2,5,3,7,6,9],
[6,9,5,4,1,7,3,8,2]
]
[
[0,0,3,0,2,0,6,0,0],
[9,0,0,3,0,5,0,0,1],
[0,0,1,8,0,6,4,0,0],
[0,0,8,1,0,2,9,0,0],
[7,0,0,0,0,0,0,0,8],
[0,0,6,7,0,8,2,0,0],
[0,0,2,6,0,9,5,0,0],
[8,0,0,2,0,3,0,0,9],
[0,0,5,0,1,0,3,0,0]
]
[
[ [4, 5], [2, 4, 6], 3, [3, 4, 5], 2, [1, 3, 4, 5], 6, [1, 4, 6], [4, 6] ],
[ 9, [2, 4, 6, 7, 8], [2, 5, 7], 3, [1, 2, 3, 4, 5, 9], 5, [1, 3, 4, 7], [1, 4, 6, 7], 1 ],
[ [4, 7], [4, 7], 1, 8, [4, 9], 6, 4, [4, 7], [4, 7, 9] ],
[ [4, 9], [4], 8, 1, [4, 5, 9], 2, 9, [4, 5], [4] ],
[ 7, [4, 7], [7, 9], [3, 4, 5, 6], [3, 4, 5, 6, 9], [3, 4, 5, 9], [4, 7, 8], [4, 5, 7], 8 ],
[ [1, 4, 7], [4, 7], 6, 7, [4], 8, 2, [4, 7], [4, 7] ],
[ [7, 8], [7, 8], 2, 6, [1], 9, 5, [1, 7], [7, 8] ],
[ 8, [2, 7, 8], [2, 3, 5, 7, 9], 2, [1, 3, 4, 5, 6], 3, [1, 4, 7, 8], [1, 4, 6, 7], 9 ],
[ [5, 7], [2, 7], 5, [3, 4, 5, 6, 7], 1, [3, 4, 5], 3, [4, 6, 7], [2, 4, 6, 7] ]
]
[
[ [4, 5], [4, 5, 7, 8], 3, 9, 2, 1, 6, [5, 7, 8], [5, 7] ],
[ 9, [2, 4, 6, 7, 8], [4, 7], 3, [4, 7], 5, 8, [2, 7, 8], 1 ],
[ [2, 5], [2, 5, 7], 1, 8, 7, 6, 4, [2, 3, 5, 7, 9], [2, 3, 5, 7] ],
[ [3, 4, 5], [3, 4, 5], 8, 1, [3, 5, 6], 2, 9, [3, 4, 5, 6, 7], [3, 4, 5, 6, 7] ],
[ 7, [2, 3, 5], 9, 5, [3, 5, 6], 4, 1, [3, 5, 6], 8 ],
[ [1, 3, 4, 5], [1, 3, 4, 5], 6, 7, [3, 5, 9], 8, 2, [3, 4, 5], [3, 4, 5] ],
[ [1, 3, 4], [1, 3, 4, 7], 2, 6, 8, 9, 5, [1, 4, 8], 4 ],
[ 8, [1, 4], 4, 2, 5, 3, 7, [1, 4, 6], 9 ],
[6, 9, 5, 4, 1, 7, 3, [2, 8], 2 ]
]
[
[ [4, 5], [4, 5, 8], 3, 9, 2, 1, 6, [5, 7], [5, 7] ],
[ 9, [2, 6], 7, 3, 4, 5, 8, 2, 1 ],
[ [2, 5], [2, 5], 1, 8, 7, 6, 4, [2, 3, 5, 9], [3, 5] ],
[ [3, 4, 5], [3, 4, 5], 8, 1, [3, 6], 2, 9, [3, 4, 5, 6, 7], [3, 5, 6, 7] ],
[ 7, [2, 3], 9, 5, [3, 6], 4, 1, [3, 6], 8 ],
[ [1, 3, 4, 5], [3, 4, 5], 6, 7, [3, 9], 8, 2, [3, 4, 5], [3, 5] ],
[ 3, [3, 7], 2, 6, 8, 9, 5, 1, 4 ],
[ 8, 1, 4, 2, 5, 3, 7, 6, 9 ],
[ 6, 9, 5, 4, 1, 7, 3, 8, 2 ]
]
[
[ [4, 5], [4, 5, 8], 3, 9, 2, 1, 6, [5, 7], [5, 7] ],
[ 9, [2, 6], 7, 3, 4, 5, 8, 2, 1 ],
[ [2, 5], [2, 5], 1, 8, 7, 6, 4, [2, 3, 5, 9], [3, 5] ],
[ [3, 4, 5], [3, 4, 5], 8, 1, [3, 6], 2, 9, [3, 4, 5, 6, 7], [3, 5, 6, 7] ],
[ 7, [2, 3], 9, 5, [3, 6], 4, 1, [3, 6], 8 ],
[ [1, 3, 4, 5], [3, 4, 5], 6, 7, [3, 9], 8, 2, [3, 4, 5], [3, 5] ],
[3, [3, 7], 2, 6, 8, 9, 5, 1, 4 ],
[ 8, 1, 4, 2, 5, 3, 7, 6, 9 ],
[ 6, 9, 5, 4, 1, 7, 3, 8, 2 ]
]
[
[ 4, 8, 3, 9, 2, 1, 6, 5, 7 ],
[ 9, 6, 7, 3, 4, 5, 8, 2, 1 ],
[ 2, 5, 1, 8, 7, 6, 4, 9, 3 ],
[ 5, 4, 8, 1, 3, 2, 9, 7, 6 ],
[ 7, 2, 9, 5, 6, 4, 1, 3, 8 ],
[ 1, 3, 6, 7, 9, 8, 2, 4, 5 ],
[ 3, 7, 2, 6, 8, 9, 5, 1, 4 ],
[ 8, 1, 4, 2, 5, 3, 7, 6, 9 ],
[ 6, 9, 5, 4, 1, 7, 3, 8, 2 ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment