CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 12:39:56 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=750c47e4cc477d361afc03115a9de1cf2ff06d10a2ba2351858a5852939a972ba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22uWHA89LRJerZM8nVF8y-U5paEtTtt1Ef%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ce6c51ed5ccf00-BLR
Day 1 - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % This is our database with facts.
- snack(elf1, 1000).
- snack(elf1, 2000).
- snack(elf1, 3000).
- snack(elf2, 4000).
- snack(elf3, 5000).
- snack(elf3, 6000).
- snack(elf4, 7000).
- snack(elf4, 8000).
- snack(elf4, 9000).
- snack(elf5, 10000).
- % An elf is in the expedition if it carries at least one snack.
- elf_in_expedition(Elf) :- snack(Elf, _).
- % The list of elves is the set of elves in the expedition.
- elflist(ElfList) :- setof(Elf, elf_in_expedition(Elf), ElfList).
- % To find the total number of calories an elf is carrying, make a list of the calories of all the snacks the elf is carrying, and calculate the sum of that list.
- total_calories(Elf, TotalCalories) :- findall(Calories, snack(Elf, Calories), CalorieList), sum_list(CalorieList, TotalCalories).
- % max_calories/2 returns the elf who is carrying the most calories and how much calories it is carrying. To do so, it first constructs the list of elves with snacks and calls max_calories/3.
- max_calories(Elf, MaxCalories) :- elflist(ElfList), max_calories(Elf, MaxCalories, ElfList).
- % If there are no elves in the list, then the total number of calories is 0 and there is 'no elf'.
- max_calories(no_elf, 0, []).
- % The elf at the head of the list is the elf carrying the most calories if the total calories it is carrying is higher than the number of calories the elf with the highest number of calories in the rest of the list is carrying.
- max_calories(Elf, ElfCalories, [Elf|RestElves]) :- total_calories(Elf, ElfCalories), max_calories(_, RestMaxCalories, RestElves), ElfCalories > RestMaxCalories.
- % If the number of calories the elf at the head of the list is carrying, is lower (or equal) to the number of calories the elf with the highest number of calories in the rest of the list is carrying, then that elf is the elf with the highest number of calories in this list.
- max_calories(RestMaxElf, RestMaxCalories, [Elf|RestElves]) :- total_calories(Elf, ElfCalories), max_calories(RestMaxElf, RestMaxCalories, RestElves), ElfCalories =< RestMaxCalories.
Advertisement
Add Comment
Please, Sign In to add comment
-
✅ Make $2500 in 20 minutes⭐⭐⭐ 2
JavaScript | 9 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 10 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 16 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 1
JavaScript | 20 sec ago | 0.24 KB
-
⭐✅ Online Marketplace Exploit ✅ NEVER SEEN BE...
JavaScript | 25 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ A
JavaScript | 32 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 35 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 44 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand