Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- using System.Threading;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- List<int> houses = Console.ReadLine().Split("@").Select(int.Parse).ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- int currentIndex = 0;
- int position = 0;
- while (command[0] != "Love!")
- {
- int length = int.Parse(command[1]);
- position = currentIndex + length;
- if (position > houses.Count)
- {
- position = 0;
- }
- if (position >= 0 && position < houses.Count && houses[position] > 0)
- {
- houses[position] -= 2;
- if (houses[position] == 0)
- {
- Console.WriteLine($"Place {position} has Valentine's day.");
- }
- }
- else if (position >= 0 && position < houses.Count && houses[position] == 0)
- {
- Console.WriteLine($"Place {position} already had Valentine's day.");
- }
- currentIndex = position;
- command = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine($"Cupid's last position was {position}.");
- if (houses.Sum() == 0)
- {
- Console.WriteLine("Mission was successful.");
- }
- else
- {
- int count = 0;
- foreach (var item in houses)
- {
- if (item != 0)
- {
- count++;
- }
- }
- Console.WriteLine($"Cupid has failed {count} places.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment