Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var wormholes = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- var stepcount = 0;
- var transportation = 0;
- for (int holeIndex = 0; holeIndex < wormholes.Length; holeIndex++)
- {
- if (wormholes[holeIndex] != 0)
- {
- transportation = wormholes[holeIndex];
- wormholes[holeIndex] = 0;
- holeIndex = transportation;
- }
- stepcount++;
- }
- Console.WriteLine(stepcount);
Add Comment
Please, Sign In to add comment