Skip to content

Instantly share code, notes, and snippets.

@lunasorcery
Created October 23, 2014 21:22
Show Gist options
  • Save lunasorcery/ba1ad07660ea4cf51a26 to your computer and use it in GitHub Desktop.
Save lunasorcery/ba1ad07660ea4cf51a26 to your computer and use it in GitHub Desktop.
using System;
namespace FortyOneShades
{
class Program
{
static int[] values = new int[]{
0x276AD9,
0x3E6FD9,
0x3A6FDE,
0x326AED,
0x366AEC,
0x4078ED,
0x2F6FEC,
0x3084DE,
0x276DE5,
0x287DEC,
0x306DD9,
0x377CE2,
0x356DE2,
0x3776DE,
0x3A6AE8,
0x2D6AE0,
0x3679DD,
0x276EDE,
0x3A73E0,
0x356AF0,
0x307EE1,
0x277EE1,
0x2C6AE2,
0x3578E8,
0x3D6BED,
0x3079E7,
0x276BE7,
0x2B6AE9,
0x367DEC,
0x306CE2,
0x3373ED,
0x406AE8,
0x2D6AED,
0x2C6DE1,
0x3579E5,
0x3671F2,
0x276BE7,
0x2B6AEC,
0x2A73DE,
0x356DDE,
0x4285F4,
};
const string alphabet = " abcdefghijklmnopqrstuvwxyz.";
static void Main(string[] args)
{
byte key1 = (byte)(values[0] >> 16);
byte key2 = (byte)(values[0] >> 8);
byte key3 = (byte)(values[0] >> 0);
for (int i = 1; i < values.Length; i++)
{
Console.Write(alphabet[((values[i] >> 16) & 0xFF) - key1]);
Console.Write(alphabet[((values[i] >> 8) & 0xFF) - key2]);
Console.Write(alphabet[((values[i] >> 0) & 0xFF) - key3]);
}
Console.ReadLine();
}
}
}
@ChristopherMeyers
Copy link

In javascript:

var values = [0x276AD9, 0x3E6FD9, 0x3A6FDE, 0x326AED, 0x366AEC, 0x4078ED, 0x2F6FEC, 0x3084DE, 0x276DE5, 0x287DEC, 0x306DD9, 0x377CE2, 0x356DE2, 0x3776DE, 0x3A6AE8, 0x2D6AE0, 0x3679DD, 0x276EDE, 0x3A73E0, 0x356AF0, 0x307EE1, 0x277EE1, 0x2C6AE2, 0x3578E8, 0x3D6BED, 0x3079E7, 0x276BE7, 0x2B6AE9, 0x367DEC, 0x306CE2, 0x3373ED, 0x406AE8, 0x2D6AED, 0x2C6DE1, 0x3579E5, 0x3671F2, 0x276BE7, 0x2B6AEC, 0x2A73DE, 0x356DDE, 0x4285F4];
var alphabet = " abcdefghijklmnopqrstuvwxyz."
values.slice(1).map(function(v){return v-values[0];}).map(function(v){return alphabet[(v>>16 & 0xFF)] + alphabet[(v>>8 & 0xFF)] + alphabet[(v>>0 & 0xFF)];}).join("");

@GiscardBiamby
Copy link

"we seek to synthesize classic principles of good design with the innovation and possibility of technology and science..."

@wackywendell
Copy link

In Python (3.4):

values = [0x276AD9, 0x3E6FD9, 0x3A6FDE, 0x326AED, 0x366AEC, 0x4078ED, 0x2F6FEC, 0x3084DE, 0x276DE5, 0x287DEC, 0x306DD9, 0x377CE2, 0x356DE2, 0x3776DE, 0x3A6AE8, 0x2D6AE0, 0x3679DD, 0x276EDE, 0x3A73E0, 0x356AF0, 0x307EE1, 0x277EE1, 0x2C6AE2, 0x3578E8, 0x3D6BED, 0x3079E7, 0x276BE7, 0x2B6AE9, 0x367DEC, 0x306CE2, 0x3373ED, 0x406AE8, 0x2D6AED, 0x2C6DE1, 0x3579E5, 0x3671F2, 0x276BE7, 0x2B6AEC, 0x2A73DE, 0x356DDE, 0x4285F4]
values = [(v - values[0]) % 0xFFFFFF for v in values[1:]]
alphabet = " abcdefghijklmnopqrstuvwxyz."
chars = [alphabet[(v >> n) % 256] for v in values for n in (16, 8, 0)]
''.join(chars)

@Garciat
Copy link

Garciat commented Oct 24, 2014

Haskell:

import Data.Bits
import Data.List

keyValue = 0x276AD9

values = [0x3E6FD9, 0x3A6FDE, 0x326AED, 0x366AEC, 0x4078ED, 0x2F6FEC, 0x3084DE, 0x276DE5, 0x287DEC, 0x306DD9, 0x377CE2, 0x356DE2, 0x3776DE, 0x3A6AE8, 0x2D6AE0, 0x3679DD, 0x276EDE, 0x3A73E0, 0x356AF0, 0x307EE1, 0x277EE1, 0x2C6AE2, 0x3578E8, 0x3D6BED, 0x3079E7, 0x276BE7, 0x2B6AE9, 0x367DEC, 0x306CE2, 0x3373ED, 0x406AE8, 0x2D6AED, 0x2C6DE1, 0x3579E5, 0x3671F2, 0x276BE7, 0x2B6AEC, 0x2A73DE, 0x356DDE, 0x4285F4]

intBytes x = map ((.&. 0xFF) . shiftR x . (8*)) [3,2..0]

--

values' = map (\x -> x - keyValue) values

alphabet = [' '] ++ ['a' .. 'z'] ++ ['.']

solution = map ((!!) alphabet) $ concatMap (drop 1 . intBytes) values'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment