Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let kozunakCount = Number(input.shift());
- let maxPoints = 0;
- let winnerName = "";
- for (let currentKozunak = 0; currentKozunak < kozunakCount; currentKozunak++) {
- let chefName = input.shift();
- let points = 0;
- while (true) {
- let command = input.shift();
- if (command === "Stop") {
- break;
- }
- points += Number(command);
- }
- console.log(`${chefName} has ${points} points.`);
- if (maxPoints < points) {
- maxPoints = points;
- winnerName = chefName;
- console.log(`${chefName} is the new number 1!`)
- }
- }
- console.log(`${winnerName} won competition with ${maxPoints} points!`)
- }
- solve([3, 'Chef Manchev', 10, 10, 10, 10, 'Stop', 'Natalie', 8, 2, 9, 'Stop', 'George', 9, 2, 4, 2, 'Stop'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement