Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HeartDelivery
- {
- class Program
- {
- static void Main(string[] args)
- {
- var houses = Console.ReadLine().Split('@').Select(int.Parse).ToList();
- int index = 0;
- string command;
- while ((command = Console.ReadLine()) != "Love!")
- {
- index += int.Parse(command.Substring(5));
- if (index >= houses.Count)
- {
- index = 0;
- }
- if (houses[index] == 0)
- {
- Console.WriteLine($"Place {index} already had Valentine's day.");
- }
- else
- {
- houses[index] -= 2;
- if (houses[index] == 0)
- {
- Console.WriteLine($"Place {index} has Valentine's day.");
- }
- }
- }
- Console.WriteLine($"Cupid's last position was {index}.");
- int houseCount = houses.Where(x => x > 0).Count();
- Console.WriteLine(houseCount == 0 ? "Mission was successful." : $"Cupid has failed {houseCount} places.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement