Guest User

Untitled

a guest
Jun 22nd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1.  var wormholes = Console.ReadLine()
  2.                 .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  3.                 .Select(int.Parse)
  4.                 .ToArray();
  5.             var stepcount = 0;
  6.             var transportation = 0;
  7.  
  8.             for (int holeIndex = 0; holeIndex < wormholes.Length; holeIndex++)
  9.             {
  10.                
  11.                 if (wormholes[holeIndex] != 0)
  12.                 {
  13.                     transportation = wormholes[holeIndex];
  14.                     wormholes[holeIndex] = 0;
  15.                     holeIndex = transportation;
  16.                 }
  17.                 stepcount++;
  18.             }
  19.             Console.WriteLine(stepcount);
Add Comment
Please, Sign In to add comment