# Solution to Decode This

You start with a block of 1024 characters. Stare at it long enough and you'll notice that if you block it off into 256 groups of four characters (cdeo, te_d, and so on), you can permute each group of four characters independently (so cdeo becomes deco, te_d becomes de_t, and so on) to get a more or less sensible paragraph of text:

```decode_this_string_producing_another_with_one_quarter_of_the_len
gth_of_this_one_this_second_string_is_encoded_in_the_same_fashio
o_its_first_couple_words_now_how_does_the_cipher_work_one_might_
re_help_than_one_would_often_get_thus_what_comes_after_this_is_j
_might_be_worth_noting_that_this_string_often_sounds_quite_force
d_so_perhaps_there_are_some_constraints_on_it_which_might_not_be
_obvious_but_one_must_find_those_for_oneself_now_entering_the_la
l_be_finished_the_solver_must_be_tired_of_this_right_now_but_the
_end_will_come_in_just_a_little_bit_the_end_might_not_be_much_fu
n_to_write_since_the_length_has_to_come_out_just_right_almost_do
ne_that_is_enough_good_luck_solving_the_remainder_of_this_enigma
```

So now you have to decipher that string to produce another string a quarter of the length of that one which is itself encoded in the same fashion. What does that mean? Well, clearly every set of four letters in that string corresponds to a single letter in the desired output string. Every set of four letters corresponds to a unique permutation of four elements: the permutation on those four letters that "has been done to make this string readable". 24 such permutations exist, and the paragraph is written in an alphabet of 24 characters, counting the space character: no X, Y, or Z is used.

So now you have to solve a cryptogram where each permutation signifies a distinct letter. In particular, you have to solve a cryptogram where the space character is encoded just the same as the letters, and the decrypted text will have every block of four characters permuted. This sounds difficult but you have just enough information to do it, especially since you know that the first two words of the plaintext will be "decode this".

The string of permutations decrypts to this:

```ceod_det_ishgnocturaiatls_no_wondt_ohes_e_maihtngo_teh_tenw_trs_
i_gn_otgeta_hi_t_drsirntghw_h_ci_jsi_tsutreh_ecse_ro_ndafruo_elt
ertson_l_angd_hwc_higibe_nwshti_het_ames_otwowr__asdths_if_est_r
o_wtrtisg_snan_dise_ndoc_deihtn_s_aemf_eahis_dnoeo_novredn_ato_u
```

Permute this string in 64 blocks of four in the same manner as above to get the new paragraph:

```decode_this_congratulations_now_do_the_same_thing_to_the_new_str
ing_to_get_a_third_string_which_is_just_three_score_and_four_let
ters_long_and_which_begins_with_the_same_two_words_as_the_first_
two_strings_and_is_encoded_in_the_same_fashion_done_over_and_out
```

So you take the string of 64 permutations and decrypt that using the same mapping from permutations to characters that you used before. You get a string which can be permuted as follows:

```ocedte_dsi_hwno_shithos__dlu_esbatriftgharwo_tdr_ofiishnosl_ginv
```
```decode_this_now_this_should_be_straightforward_to_finish_solving
```

Do the same thing you've been doing all along and you get:

```deoce_docne_mroe
```
```decode_once_more
```

Those last four permutations decrypt to IAMB, which is the answer to the puzzle.

What follows is the list of identities of characters to permutations:

```a => 2314
b => 1324
c => 3124
d => 4321
e => 4231
f => 2431
g => 3142
h => 3214
i => 1243
j => 4123
k => 1234
l => 1342
m => 2134
n => 4312
o => 3241
p => 2413
q => 4132
r => 2341
s => 1432
t => 3412
u => 2143
v => 4213
w => 1423
_ => 3421
```

2006 MIT Mystery Hunt