Skip to content

Instantly share code, notes, and snippets.

@zaak
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaak/dcba4a544061a3233318 to your computer and use it in GitHub Desktop.
Save zaak/dcba4a544061a3233318 to your computer and use it in GitHub Desktop.
JRiddle solution
using System;
using System.Text;
namespace JRiddle
{
class MainClass
{
static void JRiddle()
{
var message = new byte[] {
181, 18, // XXX, XXX,
181, 45, // XXX, XXX,
181, 59, // XXX, XXX,
181, 60, // XXX, XXX,
181, 45, // XXX, XXX,
182, 35, // XXX, XXX,
180, 232, // XXX, XXX,
181, 11, // XXX, XXX,
180, 235, // XXX, XXX,
181, 23, // XXX, XXX,
181, 20, // XXX, XXX,
181, 13, // XXX, XXX,
181, 26, // XXX, XXX,
181, 22, // XXX, XXX,
181, 17, // let the 8086's word XXX, XXX,
181, 13, // cross his boundary XXX, XXX,
180, 232, // at Little Bighorn XXX, XXX,
181, 44, // +1876*6*25 XXX, XXX,
181, 55, // XXX, XXX,
181, 42, 181, 58, // XXX, XXX, XXX, XXX,
181, 65, 180, 233, // XXX, XXX, XXX, XXX,
180, 232, 181, 48, // XXX, XXX, XXX, XXX,
181, 60, 181, 60, // XXX, XXX, XXX, XXX,
181, 56, 181, 2, // XXX, XXX, XXX, XXX,
180, 247, 180, 247, // XXX, XXX, XXX, XXX,
181, 50, 181, 43, // XXX, XXX, XXX, XXX,
181, 55, 181, 53, // XXX, XXX, XXX, XXX,
181, 53, 181, 45, // XXX, XXX, XXX, XXX,
181, 58, 181, 43, // XXX, XXX, XXX, XXX,
181, 45, 180, 246, // XXX, XXX, XXX, XXX,
181, 56, 181, 52, // XXX, XXX, XXX, XXX,
180, 247, 181, 44, // XXX, XXX, XXX, XXX,
181, 55, 181, 42, // XXX, XXX, XXX, XXX,
181, 58, 181, 65, // XXX, XXX, XXX, XXX,
181, 44, 181, 45, // XXX, XXX, XXX, XXX,
181, 62, 180, 247, // XXX, XXX, XXX, XXX,
181, 7, 181, 46, // XXX, XXX, XXX, XXX,
181, 41, 181, 59, // XXX, XXX, XXX, XXX,
181, 44, 181, 45, // XXX, XXX, XXX, XXX,
180, 252, 180, 253 // XXX, XXX, XXX, XXX
// (68k) (x86)
};
Array.Reverse (message);
int weirdSum = 1876 * 6 * 25;
short[] shortMessage = new short[message.Length / sizeof(short)];
Buffer.BlockCopy(message, 0, shortMessage, 0, shortMessage.Length);
for (int i = 0; i < shortMessage.Length; ++i) {
shortMessage[i] = (short)(shortMessage[i] + weirdSum);
}
byte[] newMessage = new byte[shortMessage.Length];
Buffer.BlockCopy(shortMessage, 0, newMessage, 0, newMessage.Length);
Console.WriteLine(Reverse(Encoding.Unicode.GetString(newMessage)));
}
public static string Reverse( string s )
{
char[] charArray = s.ToCharArray();
Array.Reverse( charArray );
return new string( charArray );
}
public static void Main (string[] args)
{
JRiddle ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment