Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _03.Wormhole
- {
- class Wormhole
- {
- static void Main()
- {
- int[] wormhole = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int len = wormhole.Length;
- int index = 0;
- int steps = 0;
- while (index != len)
- {
- int currentInteger = wormhole[index];
- if (currentInteger != 0)
- {
- wormhole[index] = 0;
- index = currentInteger;
- }
- index++;
- steps++;
- }
- Console.WriteLine(steps);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment