diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-14 11:46:48 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-14 11:54:06 +0530 |
| commit | 7ab99bd80e30d0cc2cf21e4cda47870821b8fd47 (patch) | |
| tree | c2fe30dcda461a34beaa740684d613083d144dd1 /src/Chelleport | |
| parent | 80add34b15855932e9201d7426d9df01aa82c845 (diff) | |
| download | chelleport-7ab99bd80e30d0cc2cf21e4cda47870821b8fd47.tar.gz chelleport-7ab99bd80e30d0cc2cf21e4cda47870821b8fd47.zip | |
Fix sequence generation for grid
Diffstat (limited to 'src/Chelleport')
| -rw-r--r-- | src/Chelleport/KeySequence.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Chelleport/KeySequence.hs b/src/Chelleport/KeySequence.hs index 1d118cd..88658f1 100644 --- a/src/Chelleport/KeySequence.hs +++ b/src/Chelleport/KeySequence.hs @@ -24,12 +24,16 @@ generateKeyCells :: (Int, Int) -> [Char] -> [[[Char]]] generateKeyCells (rows, columns) hintKeys = (\row -> getCellSeq row <$> [1 .. columns]) <$> [1 .. rows] where - getCellSeq x y = [getPrefix1 x y, getPrefix2 x y, getKey x y] - getKey _row col = hintKeys !! (col `mod` (columns `div` 2)) - getPrefix1 _row col + getCellSeq row col = [getPrefixHoriz row col, getPrefixVert row col, getKey row col] + getKey row col = hintKeys !! index + where + index = (secRow * (columns `div` 2) + secCol) `mod` length hintKeys + secCol = (col - 1) `mod` (columns `div` 2) + secRow = (row - 1) `mod` (rows `div` 2) + getPrefixHoriz _row col | col <= (columns `div` 2) = 'H' | otherwise = 'L' - getPrefix2 row _col + getPrefixVert row _col | row <= (rows `div` 2) = 'K' | otherwise = 'J' |
