I have a list in Prolog like this:
Puzzle = [ A1, A2, A3, B1, B2, B3, C1, C2, C3 ].
And I want every variable in the list to be a number in the range of 1 to 9. Currently I'm doing this like so:
between(1,9, A1), between(1,9, A2), % ... between(1,9, C3).
Even though this works, it's already pretty ugly even for the only 9 numbers I have so far. However I will have to expand my list to contain at least 81 numbers at first (
I9), and even 405 in the end.
I would rather not 'write' 405 lines of code just to limit the range of the numbers in the list, but since I'm new to Prolog, I don't know how I can improve this.