Advertisement
FubFubFub

Day 2

Dec 3rd, 2022
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.67 KB | Source Code | 0 0
  1. % We don't need to know the sequence -- all we need is the separate entries of the strategy guide
  2.  
  3. guide(a, y).
  4. guide(b, x).
  5. guide(c, z).
  6.  
  7. % We don't need to keep track of the rules or separate scoring -- all we need is a 9-item table with pre-calculated scores for every combination
  8.  
  9. score(a, x, 4).
  10. score(a, y, 8).
  11. score(a, z, 3).
  12. score(b, x, 1).
  13. score(b, y, 5).
  14. score(b, z, 9).
  15. score(c, x, 7).
  16. score(c, y, 2).
  17. score(c, z, 6).
  18.  
  19. % Now go through all entries in the guide, look up their scores and sum those scores
  20. total_score(TotalScore) :- findall(Score, (guide(ElfChoice, MyChoice), score(ElfChoice, MyChoice, Score)), ScoreList), sum_list(ScoreList, TotalScore).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement