INDAPlus21 / INDAPlus21/melg-task-10
Pass
Open
Nobody has claimed this yet.
- Dominant language
- Prolog
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Very well done Marcus!
You code is really good!
Although I like your approach with two predicates of whom one cuts (use !). Just for fun, lets explore an alterative solution:
Your code:
rec(Row, Column, Board, _, _):-
% ...
Stone = e, !.
rec(Row, Column, Board, OriginalStone, Visited):-
% ...
(Stone = OriginalStone),
NewRow is Row - 1,
NewRow2 is Row + 1,
NewColumn is Column - 1,
NewColumn2 is Column + 1,
(
rec(NewRow, Column, Board, OriginalStone, [[Row, Column]|Visited]);
rec(NewRow2, Column, Board, OriginalStone, [[Row, Column]|Visited]);
rec(Row, NewColumn, Board, OriginalStone, [[Row, Column]|Visited]);
rec(Row, NewColumn2, Board, OriginalStone, [[Row, Column]|Visited])
).
Only one predicate:
rec(Row, Column, Board, OriginalStone, Visited):-
% ...
(
Stone = e;
(
Stone = OriginalStone,
NewRow is Row - 1,
NewRow2 is Row + 1,
NewColumn is Column - 1,
NewColumn2 is Column + 1,
(
rec(NewRow, Column, Board, OriginalStone, [[Row, Column]|Visited]);
rec(NewRow2, Column, Board, OriginalStone, [[Row, Column]|Visited]);
rec(Row, NewColumn, Board, OriginalStone, [[Row, Column]|Visited]);
rec(Row, NewColumn2, Board, OriginalStone, [[Row, Column]|Visited])
)
)
).
Thanks for your hard work!
Educational read: https://www.metalevel.at/prolog/fun
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or implementation entry point is named. Review the existing rec/5 Prolog code referenced in the post; done is not defined because the issue offers an alternative rather than requesting a change.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 10/100