Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class FormulaBit1
- {
- static void Main()
- {
- byte[] grid = new byte[8]; //{ 2, 38, 28, 16, 71, 143, 3, 43 };
- byte flag = 0;
- byte path = 0;
- byte dir = 0;
- byte checker = 0;
- bool champ = false;
- bool run = true;
- byte x = 0;
- byte y = 0;
- byte mask = 1;
- for (byte i = 0; i < 8; i++)
- {
- grid[i] = byte.Parse(Console.ReadLine());
- }
- while (run==true)
- {
- mask = 1;
- switch (flag)
- {
- case 0:
- if (grid[0] % 2 == 0)
- {
- path++;
- flag = 1;
- }
- else
- {
- run = false;
- }
- break;
- case 1:
- if ((x + 1) < 8 && ((mask <<= y) & grid[x + 1]) == 0 )
- {
- path++;
- x++;
- }
- else
- {
- if (checker!=path)
- {
- flag = 2;
- dir++;
- checker = path;
- }
- else
- {
- run = false;
- }
- }
- break;
- case 2:
- if ((y + 1) < 8 && ((mask <<= (y + 1)) & grid[x]) == 0 )
- {
- path++;
- y++;
- }
- else
- {
- if (checker!=path)
- {
- flag = 3;
- dir++;
- checker = path;
- }
- else
- {
- run = false;
- }
- }
- break;
- case 3:
- if ((x-1) >= 0 && ((mask <<= y) & grid[x - 1]) == 0)
- {
- path++;
- x--;
- }
- else
- {
- if (checker!=path)
- {
- flag = 4;
- dir++;
- checker = path;
- }
- else
- {
- run = false;
- }
- }
- break;
- case 4:
- if ((y+1)<8 && (((mask <<= y+1) & grid[x]) == 0) )
- {
- path++;
- y++;
- }
- else
- {
- if (checker!=path)
- {
- flag = 1;
- dir++;
- checker = path;
- }
- else
- {
- run = false;
- }
- }
- break;
- default: Console.WriteLine("ne stava brat");
- break;
- }
- if (y==7 && x==7)
- {
- champ = true;
- run = false;
- }
- }
- if (run==false && champ == false)
- {
- Console.WriteLine("No {0}",path);
- }
- if (champ==true)
- {
- Console.WriteLine("{0} {1}", path, dir);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement