This file contains 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
type Row = [Int] | |
type Col = [Int] | |
type Board = [Row] | |
addDigit :: Row -> Int -> Int -> Board -> [Row] -- takes a row r, its index m, the index of a cell in it m, and the board; returns list of possble rows with that cell filled | |
addDigit r m n b = let pos = r !! n | |
c = getCol n b | |
s = concat (getSquare m n b) | |
fill = intersection (left c) (left r) (left s) -- list of numbers that could be in cell (m,n) | |
in if (pos > 0) then [r] -- cell already filled |
This file contains 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
In each iteration, the program checks if the current instruction is +/,/-/./</>/[/] (in that order). If it obtains a match, it executes the instruction, but does not restart the loop; eg if there is a "++" sequence, it executes the first one but compares the second one to a , then - etc, and cycles back to plus. | |
The tape is configured as follows: | |
1 = instruction counter (no of instructions executed in current iteration)* | |
2 & 3 = program counter PC | |
4 & 5 = tape counter TC | |
6 = bracket counter (for nested brackets) BC | |
7 = buffer (always 0 except for copying purposes) | |
8 = beginning of input program T1 (always 255 except for copying purposes) | |
9 etc = input program; each instruction takes 4 cells (x; x; 255; 255) |