Mercurial > repos > other > SevenLanguagesInSevenWeeks
changeset 68:b4f994693f7b
Fix condition check that was letting it backtrack to build a different set of rows
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 07 Oct 2017 15:43:52 +0100 |
parents | 8906b5a4517f |
children | 05871e7ac124 |
files | 3-Prolog/day3-sudoku.pl |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/3-Prolog/day3-sudoku.pl Sat Oct 07 15:07:34 2017 +0100 +++ b/3-Prolog/day3-sudoku.pl Sat Oct 07 15:43:52 2017 +0100 @@ -38,7 +38,7 @@ nth_from_list(Start, N, Input, Output) :- nth_from_list(N, Start, 1, Input, Output). nth_from_list(N, Next, Pos, [Head|TailIn], [Head|TailOut]) :- Pos == Next, NewNext is Next + N, NewPos is Pos + 1, nth_from_list(N, NewNext, NewPos, TailIn, TailOut). -nth_from_list(N, Next, Pos, [_|TailIn], Output) :- NewPos is Pos + 1, nth_from_list(N, Next, NewPos, TailIn, Output). +nth_from_list(N, Next, Pos, [_|TailIn], Output) :- Pos < Next, NewPos is Pos + 1, nth_from_list(N, Next, NewPos, TailIn, Output). nth_from_list(_, _, _, [], []). cols(Board, ColLength, Cols) :- cols(Board, ColLength, 1, Cols).