示例#1
0
        /**
         *  <summary>
         *      Converts an OpCode representation of a Malbolge program to it's mangled, "real" form
         *  </summary>
         */

        public static string DeNormalize(string opCodes)
        {
            StringBuilder normalized = new StringBuilder(opCodes.Length);

            for (int i = 0; i < opCodes.Length; ++i)
            {
                char        opCode = opCodes[i];
                Instruction instruction;
                if (OpCodesToInstructions.TryGetValue(opCode, out instruction))
                {
                    int  index = DeNormalizedOpCodes[opCode];
                    char malbolgeInstruction = (char)((index - i) % 94 + 33);
                    normalized.Append(malbolgeInstruction);
                }
            }
            return(normalized.ToString());
        }
示例#2
0
        public static bool TryGetInstruction(char value, int index, out Instruction instruction)
        {
            char maybeOpCode = NormalizationTable[(value + index - 33) % 94];

            return(OpCodesToInstructions.TryGetValue(maybeOpCode, out instruction));
        }