Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- namespace PencilCode
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<char, int> chars = new Dictionary<char, int>
- {
- {'A', 0x41},
- {'B', 0x61},
- {'C', 0x31},
- {'D', 0x42},
- {'E', 0x43},
- {'F', 0x32},
- {'G', 0x51},
- {'H', 0x33},
- {'I', 0x34},
- {'J', 0x35},
- {'K', 0x36},
- {'L', 0x21},
- {'M', 0x44},
- {'N', 0x37},
- {'O', 0x45},
- {'P', 0x46},
- {'Q', 0x52},
- {'R', 0x53},
- {'S', 0x54},
- {'T', 0x22},
- {'U', 0x38},
- {'V', 0x23},
- {'W', 0x47},
- {'X', 0x24},
- {'Y', 0x25},
- {'Z', 0x39},
- {'0', 0x48},
- {'1', 0x26},
- {'2', 0x55},
- {'3', 0x56},
- {'4', 0x3A},
- {'5', 0x57},
- {'6', 0x58},
- {'7', 0x3B},
- {'8', 0x62},
- {'9', 0x59}
- };
- var magic = "83cd09c9cb593d5bf871e8d71035b4a7";
- while (true)
- {
- var text = Console.ReadLine().ToUpper();
- if(text.Length < 3)
- {
- Console.WriteLine("Invalid input!");
- continue;
- }
- var result = string.Concat(
- (from c in text
- select (chars.ContainsKey(c) ? chars[c] : Encoding.ASCII.GetBytes(c.ToString())[0])).Select(
- (t, i) => int.Parse(magic[i % 32].ToString(), NumberStyles.HexNumber) * t).Select(x => x.ToString("x")));
- var even = result.Where((t, i) => i % 2 == 0).Reverse();
- var odd = result.Where((t, i) => i % 2 != 0);
- Console.WriteLine(string.Concat(even) + string.Concat(odd));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement