Skip to content

Instantly share code, notes, and snippets.

@remarcable
Created March 6, 2017 18:23
Show Gist options
  • Save remarcable/8660eb41fe47c53d6266c469a31c0459 to your computer and use it in GitHub Desktop.
Save remarcable/8660eb41fe47c53d6266c469a31c0459 to your computer and use it in GitHub Desktop.
// rows und columns sind ja weitestgehend vertauschbar
// Unsere Definition: Alle Subarrays entsprechen den Rows und alle
// Elemente mit dem selben Index entsprechen einer Column
const sodoku = [
// a, b, c, d, e, f, g, h, i
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 1
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 2
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 3
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 4
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 5
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 6
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 7
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 8
[1, 2, 3, 4, 5, 6, 7, 8, 9], // 9
];
function getColumn(sodoku, index) {
return sodoku.map(row => row[index]);
}
function getRow(sodoku, index) {
return sodoku[index];
}
// Box:
// 0 1 2
// 3 4 5
// 6 7 8
function getBox(array, index) {
return []; // box
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment