Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace BitPaths
- {
- class BitPaths
- {
- static void Main()
- {
- int paths = int.Parse(Console.ReadLine());
- string[] pathsArray = new string[paths];
- for (int i = 0; i < pathsArray.Length; i++)
- {
- pathsArray[i] = Console.ReadLine();
- }
- int[,] board = new int[8,4];
- for (int i = 0; i < pathsArray.Length; i++)
- {
- string[] tempPath = pathsArray[i].Split(',');
- int initial = Convert.ToInt32(tempPath[0].ToString());
- int currentCol = initial;
- if (board[0,initial]==1)
- {
- board[0, initial] = 0;
- }
- else
- {
- board[0, initial] = 1;
- }
- for (int j = 0, k = 1; j < 7; j++,k++)
- {
- if (tempPath[k] == "-1")
- {
- currentCol = currentCol-1;
- }
- else if (tempPath[k] == "+1")
- {
- currentCol = currentCol + 1;
- }
- if (board[k, currentCol] == 1)
- {
- board[k, currentCol] = 0;
- }
- else
- {
- board[k, currentCol] = 1;
- }
- }
- }
- List<string> binaries = new List<string>();
- for (int i = 0; i < 8; i++)
- {
- string[] temp = new string[4];
- for (int j = 0; j < 4; j++)
- {
- temp[j] = board[i, j].ToString();
- }
- string joined = string.Join("", temp);
- binaries.Add(joined);
- }
- int sum = 0;
- foreach (var binary in binaries)
- {
- sum += Convert.ToInt32(binary, 2);
- }
- Console.WriteLine(Convert.ToString(sum,2));
- Console.WriteLine(sum.ToString("X"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment