Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var line = Console.ReadLine()
- .Split(new[]{'@',' '}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- var s = 0;
- var houseCount = 0;
- while(true)
- {
- var line1 = Console.ReadLine().ToLower();
- if(line1=="love!")
- {
- break;
- }
- var input = line1.Split(' ');
- var command = input[0].ToLower();
- var jump = int.Parse(input[1]);
- if (command == "jump")
- {
- for(int i = 0;i<line.Length;i++)
- {
- if(s+jump>line.Length-1)
- {
- s = 0;
- if(line[s]>0)
- {
- line[s]-=2;
- if(line[s]==0)
- {
- Console.WriteLine($"Place {s} has Valentine's day.");
- houseCount++;
- }
- break;
- }
- else if(line[s]>=0)
- {
- Console.WriteLine($"Place {s} already had Valentine's day.");
- break;
- }
- }
- if(s+jump < line.Length)
- {
- s+=jump;
- if(line[s]>0)
- {
- line[s]-=2;
- if(line[s]==0)
- {
- Console.WriteLine($"Place {s} has Valentine's day.");
- houseCount++;
- }
- break;
- }
- else if(line[s]>=0)
- {
- Console.WriteLine($"Place {s} already had Valentine's day.");
- break;
- }
- }
- }
- }
- }
- Console.WriteLine($"Cupid's last position was {s}.");
- if(houseCount==line.Length)
- {
- Console.WriteLine("Mission was successful.");
- }
- else
- {
- Console.WriteLine($"Cupid has failed {line.Length-houseCount} places.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment