Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03.HeartDelivery
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> needHearts = Console.ReadLine()
- .Split('@', StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToList();
- int currentPosition = 0;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "Love!")
- {
- break;
- }
- string[] tokens = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
- int jumpLength = int.Parse(tokens[1]);
- currentPosition += jumpLength;
- if (currentPosition > needHearts.Count - 1)
- {
- currentPosition = 0;
- }
- if (needHearts[currentPosition] == 0)
- {
- Console.WriteLine($"Place {currentPosition} already had Valentine's day.");
- }
- else
- {
- needHearts[currentPosition] -= 2;
- if (needHearts[currentPosition] == 0)
- {
- Console.WriteLine($"Place {currentPosition} has Valentine's day.");
- }
- }
- }
- Console.WriteLine($"Cupid's last position was {currentPosition}.");
- if (needHearts.Sum() == 0)
- {
- Console.WriteLine("Mission was successful.");
- }
- else
- {
- Console.WriteLine($"Cupid has failed {needHearts.Count(h => h > 0)} places.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement