Opening your workspace…
Workspace/Coding room
Opening your workspace…
Count the cake GLaDOS promised you for finishing the test chambers, then count what you can find behind the walls at Aperture. Each promise names a chamber and a number of slices. When GLaDOS revises a chamber's reward, the latest promise replaces the earlier one. Your inspection log records a cake ID and a slice count each time you spot a cake. Two sightings with the same ID show the same cake. Return [slices promised, slices found].
[[18,4],[19,8]], []Output[12,0]GLaDOS promised 4 slices for Chamber 18 and 8 for Chamber 19. You found only the writing on the wall.
[[18,4],[19,8],[18,2]], [["black-forest",8],["black-forest",8]]Output[10,8]Chamber 18's reward drops to 2, bringing the promise to 10 slices. You spot the same eight-slice cake twice.
Track the latest promise per chamber and one observation per cake ID.
function solve(promises, sightings) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.