Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CurrencyCheck
- {
- class Bits
- {
- static void Main(string[] args)
- {
- long[] board = new long[8];
- string input = Console.ReadLine();
- int line = 0;
- int pos = 0;
- board[line] ^= (1 << pos);
- while (input != "stop")
- {
- bool toContinue = false;
- int previousLine = line;
- int previousPos = pos;
- switch (input)
- {
- case "left down":
- line++;
- pos += 2;
- break;
- case "down right":
- line += 2;
- pos--;
- break;
- case "right up":
- pos -= 2;
- line--;
- break;
- case "down left":
- line += 2;
- pos++;
- break;
- case "left up":
- line--;
- pos += 2;
- break;
- case "up left":
- line -= 2;
- pos++;
- break;
- case "up right":
- line -= 2;
- pos--;
- break;
- default:
- toContinue = true;
- break;
- }
- if (toContinue)
- {
- input = Console.ReadLine();
- continue;
- }
- if (line >= 8 || pos >= 8 || line < 0 || pos < 0)
- {
- line = previousLine;
- pos = previousPos;
- }
- else
- {
- board[line] ^= (1 << pos);
- }
- input = Console.ReadLine();
- }
- StringBuilder sb = new StringBuilder();
- for (var i = 0; i < board.Length; i++)
- {
- if (board[i] != 0)
- {
- sb.AppendLine(board[i].ToString());
- }
- }
- if (string.IsNullOrEmpty(sb.ToString()))
- {
- Console.WriteLine("[Board is empty]");
- }
- else
- {
- Console.WriteLine(sb.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement