Anonymous user
100 prisoners: Difference between revisions
→School example: Optimized algorithm (break after first prisoner, who didn't find its number)
(→{{header|JavaScript}}: Added Javascript school example) |
(→School example: Optimized algorithm (break after first prisoner, who didn't find its number)) |
||
Line 3,127:
// Prisoners start outside the room.
// They can decide some strategy before any enter the room.
for (let prisoner = 1; prisoner <= prisonersCount; prisoner++, found++)
// If all 100 findings find their own numbers then they will all be pardoned. If any don't then all sentences stand.
results.push(
}
|