Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- StreamReader sr = new StreamReader("input.txt");
- string line = sr.ReadLine();
- Int64 houses = 1;
- Int64 max = 10000;
- int[,] hor= new int[max, max];
- for (Int64 l = 0; l < max; l++)
- { for (Int64 j = 0; j < max; j++)
- hor[l, j] = 0;
- }
- Int64 i = 0;
- Int64 k = 0;
- for (int j =1;j<=line.Length-1;j++)
- {
- if (line[j]=='^')
- {
- if (k==max-1)
- {
- k = 0;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- else
- {
- k++;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- }
- if (line[j] == 'v')
- {
- if (k == 0)
- {
- k = max-1;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- else
- {
- k--;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- }
- if (line[j] == '>')
- {
- if (i == max-1)
- {
- i = 0;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- else
- {
- i++;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- }
- if (line[j] == '<')
- {
- if (i == 0)
- {
- i = max-1;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- else
- {
- i--;
- if (hor[i, k] == 0)
- {
- hor[i, k]++;
- houses++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement