Advertisement
Cwetanow

Untitled

Jun 5th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _2.Kitty
  8. {
  9. class Program
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14.  
  15. var input = Console.ReadLine().ToArray();
  16. var path = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  17.  
  18. int souls = 0;
  19. int food = 0;
  20. int locks = 0;
  21. int jumps = 0;
  22. bool busted = false;
  23. if (input[0]=='x')
  24. {
  25. Console.WriteLine("You are deadlocked, you greedy kitty!");
  26. Console.WriteLine("Jumps before deadlock: 0");
  27. }
  28. else
  29. {
  30. if (input[0]=='@')
  31. {
  32. souls++;
  33. }
  34. else
  35. {
  36. food++;
  37. }
  38. input[0] = 'c';
  39.  
  40. int currentPlace=0;
  41. for (int i = 0; i < path.Length; i++)
  42. {
  43. jumps = i+1;
  44. path[i] %= input.Length;
  45.  
  46. currentPlace += path[i];
  47.  
  48. if (currentPlace>input.Length-1)
  49. {
  50. currentPlace -= input.Length ;
  51. }
  52. else if (currentPlace<0)
  53. {
  54. currentPlace += input.Length;
  55. }
  56. // Console.WriteLine(input[currentPlace]);
  57. // Console.WriteLine(i);
  58. // Console.WriteLine();
  59. if (input[currentPlace]=='@')
  60. {
  61.  
  62. souls++;
  63. input[currentPlace] = 'c';
  64. }
  65. else if (input[currentPlace]=='*')
  66. {
  67. food++;
  68. input[currentPlace] = 'c';
  69. }
  70. else if (input[currentPlace] == 'x')
  71. {
  72. if (currentPlace%2==0 )
  73. {
  74. if (souls>0)
  75. {
  76. souls--;
  77. locks++;
  78. }
  79. else if(souls==0)
  80. {
  81. Console.WriteLine("You are deadlocked, you greedy kitty!");
  82. Console.WriteLine("Jumps before deadlock: {0}",jumps);
  83. busted = true;
  84. break;
  85. }
  86. }
  87. else if (currentPlace%2==1)
  88. {
  89.  
  90. if (food > 0)
  91. {
  92. food--;
  93. locks++;
  94. }
  95. else if(food==0)
  96. {
  97. Console.WriteLine("You are deadlocked, you greedy kitty!");
  98. Console.WriteLine("Jumps before deadlock: {0}", jumps);
  99. busted = true;
  100. break;
  101. }
  102. }
  103. }
  104. }
  105. if (!busted)
  106. {
  107. Console.WriteLine("Coder souls collected: {0}", souls);
  108. Console.WriteLine("Food collected: {0}", food);
  109. Console.WriteLine("Deadlocks: {0}", locks);
  110. }
  111.  
  112. }
  113.  
  114. }
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement