Probably! If you want a more concrete answer, consider requesting mentoring (after submitting code using the CLI) or sharing your code here. (Please use a ``` codeblock and not an image to share code; use the preview to ensure it’s properly formatted!)
I’m using the web editor, and can’t “submit” because the test doesn’t succeed. This is my code:
%! create(+DimTuple)
%
% The create/1 predicate succeeds if the DimTuple contains valid chessboard
% dimensions, e.g. (0,0) or (2,4).
create((DimX, DimY)) :-
0< DimX, DimX < 8,
0 < DimY, DimY < 8.
%! attack(+FromTuple, +ToTuple)
%
% The attack/2 predicate succeeds if a queen positioned on ToTuple is
% vulnerable to an attack by another queen positioned on FromTuple.
attack((FromX, FromY), (ToX, ToY)):-
FromX = ToX; % same row
FromY = ToY; % same col
subtract(ToY, FromY) is subtract(FromX, ToX); % neg slope
subtract(ToY, FromY) is subtract(ToX, FromX). % pos slope
OK, i think this is a bug with the tests itself. I get the error even with no solution code at all, with a blank file. (expectedly, i’m not passing the tests either)
I’ve found the Prolog track does sometimes just give awful error messages and local development’s a bit nicer, but the actual failure here is expected. Submitting a blank file is going to fail since it can’t find the attack predicate. It doesn’t have this error if you instead submit it with the always-true definition: attack((FromX, FromY), (ToX, ToY)).
The actual issue is that a subtract/2 function doesn’t exist - you need to use -/2 (docs)
Thanks everyone. Turns out the root error was that I didn’t know prolog uses a special =:=/2 arithmetic equality. My 3rd and 4th diagonal were passing due to coincidence.