Format fixes and other updates in 2020/ferguson2

With this commit I should be able to return to the other entries though
as Landon pointed out I might never finish this and this is a reason it
might not have been as thorough as I could have been (another part is
it's long). Nevertheless the formatting should now be okay along the
lines of what was requested for all the winning entry markdown files.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-16 13:47:40 -07:00
1 parent 86f0d5449e
commit 2ca6dc4021
6 files changed
+647 -562

No files matched your search

+100 -70
View File
@@ -82,9 +82,19 @@ rm -f conf input output output2
``` ```
What does:
```sh
echo | ./recode
echo | ./recode -v
```
do?
## Judges' remarks: ## Judges' remarks:
This code is an enigma. Try to decode it! This code is an [enigma](https://en.wikipedia.org/wiki/Enigma_machine). Try to decode it!
There is a good deal of useful documentation that is provided with this entry: There is a good deal of useful documentation that is provided with this entry:
@@ -108,11 +118,15 @@ There is a good deal of useful documentation that is provided with this entry:
## Author's remarks: ## Author's remarks:
My remarks about my Heer 'Army' and Luftwaffe 'Air Force' Enigma simulator for My remarks about my [Heer
'Army'](https://en.wikipedia.org/wiki/German_Army_(1935%E2%80%931945)) and
[Luftwaffe 'Air Force'](https://en.wikipedia.org/wiki/Luftwaffe) [Enigma
machine](https://en.wikipedia.org/wiki/Enigma_machine) simulator for
the 27th IOCCC. the 27th IOCCC.
I want to dedicate this entry in part to the millions of poor souls that were I want to dedicate this entry in part to the millions of poor souls that were
lost during the tragedy that is the Second World War. There are so many people lost during the tragedy that is the [Second World
War](https://en.wikipedia.org/wiki/World_War_II). There are so many people
who are unknown, unloved, unclaimed and even unidentified. And who knows what who are unknown, unloved, unclaimed and even unidentified. And who knows what
they might have gone on to do if their lives weren't - like it is with all other they might have gone on to do if their lives weren't - like it is with all other
wars - needlessly taken from them? When one considers it was all because the wars - needlessly taken from them? When one considers it was all because the
@@ -167,29 +181,35 @@ sure there are some other words that are equally as valid but I believe 'Enigma'
is a great word nonetheless. is a great word nonetheless.
However it's curious that no winning entry has ever been a simulator of the However it's curious that no winning entry has ever been a simulator of the
German Enigma machine. I'm actually quite surprised at that because it's such a [German Enigma machine](https://en.wikipedia.org/wiki/Enigma_machine). I'm
brilliant piece of engineering of the time even though it had a critical flaw: actually quite surprised at that because it's such a brilliant piece of
that no letter could be itself; this combined with cribs (known or suspected engineering of the time even though it had a critical flaw: that no letter could
plaintext) - which was down to carelessness, capturing an Enigma and sometimes be itself; this combined with cribs (known or suspected plaintext) - which was
settings sheet, as well as known messages the Germans started out with - allowed down to carelessness, capturing an Enigma and sometimes settings sheet, as well
for cracking the code. as known messages the Germans started out with - allowed for [cracking the
code](https://en.wikipedia.org/wiki/Cryptanalysis_of_the_Enigma).
Combining this entry with two of the Morse code entries is particularly Combining this entry with two of the [Morse
code](https://en.wikipedia.org/wiki/Morse_code) entries is particularly
interesting because that's what the Germans did: the party sending the message interesting because that's what the Germans did: the party sending the message
would first set up the machine, write down the letters and then transmit by would first set up the machine, write down the letters and then transmit by
Morse code the encoded message. Then those picking up on the message would note [Morse code](https://en.wikipedia.org/wiki/Morse_code) the encoded message. Then
the Morse code, translate it to the alphabet and then input it into their Enigma those picking up on the message would note the [Morse
machine configured in the same way and thus have the original message. code](https://en.wikipedia.org/wiki/Morse_code), translate it to the alphabet
and then input it into their Enigma machine configured in the same way and thus
have the original message.
The [1998 ASCII / Morse code translator][] entry (author Dorssel) prints the The [1998 ASCII / Morse code translator][] entry by [Franz van
Morse code of text; and the [2014 Morse audio transcoder][] (author Vik) can be Dorsselaer](/winners.html#Frans_van_Dorsselaer) prints the Morse code of text;
used to allow for the actual sound of it. With my entry we can complete the and the [2014 Morse audio transcoder][] by [Daniel
loop! Vik](/winners.html#Daniel_Vik) can be used to allow for the actual sound of it.
With my entry we can complete the loop!
### <a name="nathan" href="#toc">The 1992 Nathan entry</a> ### <a name="nathan" href="#toc">The 1992 Nathan entry</a>
The author (Nathan) of the [1992 Worst Abuse of the Rules][] had this to say: The author [Nathan Sidwell](/winners.html#Nathan_Sidwell) of the [1992 Worst
Abuse of the Rules][] had this to say about his program:
``` ```
This program is a hello world text encrypter/decrypter. It uses an This program is a hello world text encrypter/decrypter. It uses an
@@ -207,19 +227,20 @@ operations, so you can use decrypt to scramble and encrypt to
descramble, if you're perverse.) descramble, if you're perverse.)
``` ```
But the Enigma algorithm is more complex than that and my entry can encipher and But the Enigma algorithm is more complex than that and my entry can encipher (and
decipher text in the manner of the Enigma machines of the Army (Heer) and Air by extension decipher) text in the manner of the Enigma machines of the Army (Heer) and Air
Force (Luftwaffe); the Kriegsmarine 'Navy' was more complex (see section [Adding Force (Luftwaffe); the Kriegsmarine 'Navy' was more complex (see section [Adding
Kriegsmarine support](#kriegsmarine) for more information on that. Kriegsmarine support](#kriegsmarine) for more information on that.
My entry should also work as a non-military grade Enigma as it by default has an My entry should also work as a non-military grade Enigma as it by default has an
empty plugboard (they had none). I explain how to set up the simulator later. empty plugboard (they had none). I explain how to set up the simulator later.
Yusuke Endoh asked the judges and me if the real 1992 entry source was [Yusuke Endoh](/winners.html#Yusuke_Endoh) asked the judges and me if the real
available. Simon Cooper didn't have access to it because it was before his time in 1992 entry source was available. Simon Cooper didn't have access to it because
the IOCCC; but before the other judges could answer Ilya Kurdyukov sent a link to it was before his time in the IOCCC; but before the other judges could answer
the original 1992 code. As of March 2023 the original before unseen code was [Ilya Kurdyukov](/winners.html#Ilya_Kurdyukov) sent a link to the original 1992
published but I leave this in for historical purposes. code. As of March 2023 the original before unseen code was published but I leave
this in for historical purposes.
### <a name="usage" href="#toc">Usage</a> ### <a name="usage" href="#toc">Usage</a>
@@ -250,10 +271,11 @@ After that you can input the string and it'll go from there.
#### <a name="example" href="#toc">Example run</a> #### <a name="example" href="#toc">Example run</a>
BTW: There's a much more entertaining (and delicious) challenge or exercise in BTW: There's a much more entertaining (and delicious) challenge or exercise in
[recode.html][] (involves [chocolate-cake.html][]) though one might need a different [recode.html][] (markdown version [recode.md](recode.md)) (involves
kind of exercise after taking up the challenge! :-) These however show the [chocolate-cake.html][]) though one might need a different kind of exercise
general program as well as how to use the two winning entries of the Morse code after taking up the challenge! :-) These however show the general program as
that I referred to earlier: well as how to use the two winning entries of the Morse code that I referred to
earlier:
```sh ```sh
@@ -375,7 +397,7 @@ $ echo IOCCC | ./prog | ./dorssel
### <a name="recode" href="#toc">The recode.c configurator</a> ### <a name="recode" href="#toc">The recode.c configurator</a>
I have included a supplementary program 'recode' ([recode.c][]) that can I have included a supplementary program [recode.c][] that can
do a number of things which acts as a kind of wrapper and configurator to my do a number of things which acts as a kind of wrapper and configurator to my
entry. By default it prompts you for the settings (rotors/rings, ring settings, entry. By default it prompts you for the settings (rotors/rings, ring settings,
positions, reflector and plugboard pairs), validating input as you go. positions, reflector and plugboard pairs), validating input as you go.
@@ -397,8 +419,9 @@ I didn't think of everything. My entry was meant to be a simulator only as far
as the ciphering goes but I thought this would make it much more interesting: as the ciphering goes but I thought this would make it much more interesting:
make it more flexible by a wrapper program. make it more flexible by a wrapper program.
For examples using it (and a delicious challenge) see [recode.html][]. See For examples using it (and a delicious challenge) see
also [recode.1][] and [enigma.1][] man pages. [recode.html][]/[recode.md](recode.md). See also the [recode.1][] and
[enigma.1][] man pages.
### <a name="parsersubtlety" href="#toc">A parser subtlety that could cause confusion</a> ### <a name="parsersubtlety" href="#toc">A parser subtlety that could cause confusion</a>
@@ -430,9 +453,8 @@ WD
SIRDK SIRDK
``` ```
First of all: what is that WD? I didn't type that but it appeared it seems due First of all: what is that `WD`? I didn't type that but it showed up hitting
to too much input that triggers this (it happens when I hit ctrl-d to end `ctrl-d` to end input.
input).
If everything is input correctly it would show nothing except the actual Enigma If everything is input correctly it would show nothing except the actual Enigma
output (maybe at times ^D - I have noticed this at least when I don't fill in output (maybe at times ^D - I have noticed this at least when I don't fill in
@@ -441,9 +463,9 @@ machines that had plugboards, I really do not know). I don't view this as a bug
because the parsing of input is meant to be simple and in fact you can expect because the parsing of input is meant to be simple and in fact you can expect
the same output from the same input even if there are errors in the input. the same output from the same input even if there are errors in the input.
Anyway as you can see the first '1AB' was the first ring, setting and position. Anyway as you can see the first `1AB` was the first ring, setting and position.
After this it wants Ring 2 and I did similar; for ring 3 I did it each variable After this it wants Ring 2 and I did similar; for ring 3 I did it each variable
by itself. However for the reflector I did 1A and it only expects 1 char! So will by itself. However for the reflector I did `1A` and it only expects 1 char! So will
that mean that the plugboard pairs are off? Yes it does seem to be so. This is that mean that the plugboard pairs are off? Yes it does seem to be so. This is
buffering at play I believe but it's useful for allowing the recode program to buffering at play I believe but it's useful for allowing the recode program to
easily configure the Enigma machine. In the other markdown/html file I give a hint easily configure the Enigma machine. In the other markdown/html file I give a hint
@@ -458,7 +480,8 @@ There are two reflectors and the same applies: in C 0-1 but in human it's
1-2 (technically these were reflectors B and C in the Enigma machine which I 1-2 (technically these were reflectors B and C in the Enigma machine which I
display by name in recode.c just like with the rotors). display by name in recode.c just like with the rotors).
For more information see [recode.html][]. For more information see [recode.html][] or [recode.md](recode.md) if viewing on
GitHub.
BTW: If you need a reminder to go to the gym just do your Enigma ABCs and it BTW: If you need a reminder to go to the gym just do your Enigma ABCs and it
should help you remember (though not at this time in our world it might help you should help you remember (though not at this time in our world it might help you
@@ -474,8 +497,8 @@ ABC
### <a name="layout" href="#toc">On the source code layout</a> ### <a name="layout" href="#toc">On the source code layout</a>
The layout of recode.c isn't too significant (but see below) but I want to The layout of [recode.c][] isn't too significant (but see below) but I want to
mention prog.c especially: mention [prog.c](prog.c) especially:
I did think of a more artistic layout but reflecting on it I think that the I did think of a more artistic layout but reflecting on it I think that the
blankness of it can be another way of honouring all the many people who died blankness of it can be another way of honouring all the many people who died
@@ -488,17 +511,19 @@ even unidentified; it's the presence of absence.
I find it somehow fitting that the day I have finished this is 30 April 2020, I find it somehow fitting that the day I have finished this is 30 April 2020,
which was exactly 75 years from the day that the person responsible for the which was exactly 75 years from the day that the person responsible for the
Second World War, Adolf Hitler, ended his life. (I have since then made a bug [Second World War](https://en.wikipedia.org/wiki/World_War_II), Adolf Hitler,
fix but I consider this inconsequential). ended his life. (I have since then made a bug fix but I consider this
inconsequential).
As for recode.c though I really love this: As for [recode.c][] though I really love this:
``` ```c
/\ /\
/ This is *not* what you think: / This is *not* what you think:
``` ```
...because it seems so wrong in C code at first glance. ...because it seems so wrong in C code at first glance. Also what does the
'this' refer to?
### <a name="obfuscation" href="#toc">Obfuscation</a> ### <a name="obfuscation" href="#toc">Obfuscation</a>
@@ -521,15 +546,15 @@ To encipher:
The file [obfuscation.key][] is the key to decipher/encipher The file [obfuscation.key][] is the key to decipher/encipher
[obfuscation.txt][]. [obfuscation.txt][].
For the lazy [obfuscation.md][] has the deciphered version. I am afraid For the lazy [obfuscation.md][] has the deciphered version. I am afraid I'm not
I'm not so inclined to do that for the cake recipe: the idea there is to make it so inclined to do that for the cake recipe: the idea there is to make it a fun
a fun exercise that when solved unlocks a wonderful double-layered chocolate exercise that when solved unlocks a wonderful double-layered chocolate fudge
fudge cake recipe. But given that my ['Don't tread on me award'](../ferguson1) entry also cake recipe. But given that my ['Don't tread on me'](../ferguson1) award entry
has the recipe, not enciphered, one might just go there instead. Still it's a also has the recipe, not enciphered, one might just go there instead. Still it's
fun way to explore this entry. a fun way to explore this entry.
As for the [obfuscation.key][] file if you observe the contents you'll find the As for the [obfuscation.key][] file if you observe the contents you'll find the
word OBFUSCATION: word `OBFUSCATION`:
``` ```
2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ 2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
@@ -545,21 +570,22 @@ and some could be considered features; others are just differences.
* Does not check for using the same rotor more than once. The real Enigma * Does not check for using the same rotor more than once. The real Enigma
machines this would not work because they had to choose from a set of rotors and machines this would not work because they had to choose from a set of rotors and
there were no duplicates. This shouldn't be a problem here however except that there were no duplicates. This shouldn't be a problem here however except that
it won't be a possible configuration of the real Enigma machine. The `recode` it wouldn't be a possible configuration of the real Enigma machine. The `recode`
program *however does validate this* (except when reading in settings via the program *however does validate this* (except when reading in settings via the
`-R` option which I explain in the [recode.html][] file). `-R` option which I explain in the [recode.html][]/[recode.md](recode.md) file).
* The way the plugboard - for the machines that had them - is if you connect A * The way the plugboard - for the machines that had them - is if you connect A
to B then no other letters can connect to A or B. Earlier there wasn't proper to B then no other letters can connect to A or B. Earlier there wasn't proper
detection and this caused invalid output. detection and this caused invalid output.
``` > Why only 10 pairs when the German alphabet has 26 letters (the Enigma did not
Why only 10 pairs when the German alphabet has 26 letters? It's have the Eszett or the umlauts and in any case there is some disagreement about
theoretically possible to have 13 but the Enigma typically had 10 pairs. these being part of the alphabet; anyway for umlauts one can add an E after the
It's easy enough to update my entry to do this once you de-obfuscate it but letter and for the Eszett you can use 'ss' or 'SS' which is what they did)? It's
I'm not helping there (and in fact I don't think I could any more even if I theoretically possible to have 13 but the Enigma typically had 10 pairs. It's
wanted to - at least not easily!). easy enough to update my entry to do this once you de-obfuscate it but I'm not
``` helping there (and in fact I don't think I could any more even if I wanted to -
at least not easily!).
* It does not obviously have the clicking sound associated with the moving * It does not obviously have the clicking sound associated with the moving
parts of the real machine. I think it would be annoying to have this as it parts of the real machine. I think it would be annoying to have this as it
@@ -578,7 +604,9 @@ entry prints `!isalpha()` chars untouched. The Germans had different systems for
punctuations, numbers etc. (one of the documents I link to has these details). punctuations, numbers etc. (one of the documents I link to has these details).
* My entry preserves case of letters. The real Enigma had only one case as it * My entry preserves case of letters. The real Enigma had only one case as it
was just a keyboard and they didn't need case-sensitivity. was just a keyboard and they didn't need case-sensitivity. Context would be
important as some words in German have different meanings depending on if
capitalised or not (and all nouns are capitalised).
* Later models introduced a fourth rotor. The Kriegsmarine procedures were * Later models introduced a fourth rotor. The Kriegsmarine procedures were
also far more complex than the Heer and Luftwaffe. I find this particularly also far more complex than the Heer and Luftwaffe. I find this particularly
@@ -595,7 +623,7 @@ them for this reason; I include 5 rotors and 2 reflectors and that's a total of
too. It is however feasible to update the rotor and reflector options and you too. It is however feasible to update the rotor and reflector options and you
could even make your own versions if you wanted to. Doing this is an exercise to could even make your own versions if you wanted to. Doing this is an exercise to
the reader however (the idea of trying this makes me cringe because of how I the reader however (the idea of trying this makes me cringe because of how I
obfuscated things)! obfuscated things including encrypting some of it with the Enigma itself)!
There's one thing I'm unsure of in my implementation. Because of all the There's one thing I'm unsure of in my implementation. Because of all the
possible settings I used some other simulators as a starting point and more possible settings I used some other simulators as a starting point and more
@@ -604,8 +632,8 @@ bugs though and so one thing looked odd and I don't know if it is right or not.
An online simulator appears correct but I don't see the option to change that An online simulator appears correct but I don't see the option to change that
part. part.
If you notice in the Q() function where I set up specific pointers and other If you notice in the `Q()` function where I set up specific pointers and other
data there is a call to the macro 'q' but I only refer to the first ring setting data there is a call to the macro `q` but I only refer to the first ring setting
(of which I no longer even know which element it is! Or was it position? I don't (of which I no longer even know which element it is! Or was it position? I don't
even know that now for certain). That's because the Python code did that (though even know that now for certain). That's because the Python code did that (though
very differently of course) but I also had to bug-fix the Python in another very differently of course) but I also had to bug-fix the Python in another
@@ -622,9 +650,10 @@ I said that one could add the additional rotors used by the Kriegsmarine but
looking at this again it appears that it's not as simple as adding the rotors to looking at this again it appears that it's not as simple as adding the rotors to
the code and updating the references to the array etc. the code and updating the references to the array etc.
This is because rotors VI, VII and VII had two notches and this changes the way This is because [rotors](https://en.wikipedia.org/wiki/Enigma_rotor_details)
things work. The Kriegsmarine M4 also had an additional change which would `VI`, `VII` and `VII` had two notches and this changes the way things work. The
complicate matters more. [Kriegsmarine M4](https://www.cryptomuseum.com/crypto/enigma/m4/index.htm) also
had an additional change which would complicate matters more.
I looked into trying to do this for another version after winning but some of I looked into trying to do this for another version after winning but some of
the obfuscation techniques dramatically complicates even attempting this so I the obfuscation techniques dramatically complicates even attempting this so I
@@ -714,7 +743,7 @@ and you'll see the resulting text being:
UUMMX UUMMX
``` ```
Which is exactly as my entry shows! So at least for the starting position BBC Which is exactly as my entry shows! So at least for the starting position `BBC`
and an empty plugboard and the other defaults in my entry (which appear to be and an empty plugboard and the other defaults in my entry (which appear to be
consistent with the online simulator too) I can verify it works. consistent with the online simulator too) I can verify it works.
@@ -808,7 +837,8 @@ millions of people whose lives were taken from them in what amounts to - like
all other wars - a horrible, pointless conflict and an utter waste of life, all other wars - a horrible, pointless conflict and an utter waste of life,
something precious that is far too often taken for granted. As I noted before I something precious that is far too often taken for granted. As I noted before I
found it fitting that I finished this on 30 April 2020 - exactly 75 years after found it fitting that I finished this on 30 April 2020 - exactly 75 years after
Adolf Hitler, he who started the Second World War, ended his life. The blankness Adolf Hitler, he who started the [Second World War]([Second World
War](https://en.wikipedia.org/wiki/World_War_II), ended his life. The blankness
of the layout is another way of honouring the poor souls who lost their lives, of the layout is another way of honouring the poor souls who lost their lives,
many of whom we will never know even their name let alone what they might have many of whom we will never know even their name let alone what they might have
accomplished if it wasn't for their tragic and pointless deaths. Always remember accomplished if it wasn't for their tragic and pointless deaths. Always remember
+14 -16
View File
@@ -1,4 +1,4 @@
.TH enigma 1 "19 February 2023" "enigma" "IOCCC 2020" .TH enigma 1 "16 April 2023" "enigma" "IOCCC 2020"
.SH NAME .SH NAME
enigma \- A German Enigma simulator for IOCCC 2020 enigma \- A German Enigma simulator for IOCCC 2020
.SH SYNOPSIS .SH SYNOPSIS
@@ -28,7 +28,7 @@ Markdown file with examples on how to use the recode program (along with the Eni
.RS .RS
More information on the Enigma simulator IOCCC entry. More information on the Enigma simulator IOCCC entry.
.RE .RE
\fIchocolate\-cake.markdown\fP \fIchocolate\-cake.md\fP
\fIchocolate\-cake.html\fP \fIchocolate\-cake.html\fP
.RS .RS
A file with a recipe of a delicious Double-layered Chocolate Fudge Cake that has been enciphered with one of 16 Enigma settings given in \fIrecode.md\fP which should give enough information on how to make use of the two programs in order to unlock this recipe. A file with a recipe of a delicious Double-layered Chocolate Fudge Cake that has been enciphered with one of 16 Enigma settings given in \fIrecode.md\fP which should give enough information on how to make use of the two programs in order to unlock this recipe.
@@ -43,20 +43,18 @@ I don't think you need help here! :)
The recode.c man page. The recode.c man page.
.RE .RE
.SH BUGS .SH BUGS
.RS .PP
\fB\-\fP Rudimentary parser allows for easily piping into the simulator settings (and file to encipher/decipher) but which also can be a bit confusing, unintuitive and does not handle too much input that well. Rudimentary parser allows for easily piping into the simulator settings (and file to encipher/decipher) but which also can be a bit confusing, unintuitive and does not handle too much input that well.
.RE .PP
.RS There is one thing in particular I was unsure of when writing the simulator as far as how it is supposed to work: I believe I have it but there might be one issue. See \fIREADME.md\fP for more information.
\fB\-\fP There is one thing in particular I was unsure of when writing the simulator as far as how it is supposed to work: I believe I have it but there might be one issue. See \fIREADME.md\fP for more information. .PP
.RE It was written by a human being.
.RS .PP
\fB\-\fP It was written by a human being. Not a bug as some might want to believe, maybe: figuring out how the recode.c program works won't help you figure out how this works.
.RE .PP
.RS The critical flaw in the Enigma machine that I referred to in the \fIREADME.md\fP obviously has to be in the program.
\fB\-\fP Not a bug as some might want to believe, maybe: figuring out how the recode.c program works won't help you figure out how this works. .PP
.RE For more please see \fIREADME.md\fP.
.RS
\fB\-\fP For more please see \fIREADME.md\fP.
.SH EXAMPLES .SH EXAMPLES
.PP .PP
Please see the \fIrecode.md\fP and \fIREADME.md\fP files for examples and other information. Please see the \fIrecode.md\fP and \fIREADME.md\fP files for examples and other information.
+18 -16
View File
@@ -1,7 +1,9 @@
# Obfuscation # Obfuscation
* The obvious strings are obfuscated by the default Enigma settings in the * Strings identifying what it is are encrypted by the Enigma itself (with its
program itself. default settings). The strings are: `Position`, `Setting`, `Ring`, `Plugboard pair`
`Reflector`. Together these would be a dead giveaway to anyone familiar with the
Enigma machine and some of them by themselves would be a dead giveaway too.
* Digraphs. This isn't necessarily obfuscation itself but it does cause some * Digraphs. This isn't necessarily obfuscation itself but it does cause some
beautifiers problems and it can be useful in layout as well (in some contexts beautifiers problems and it can be useful in layout as well (in some contexts
@@ -37,26 +39,26 @@ ints:
void w(char *s, int k, int v) void w(char *s, int k, int v)
{ {
for(e<:2:> = 0; s<:*P:>; ++e<:2:>) for(e<:2:> = 0; s<:*P:>; ++e<:2:>)
{ {
v = s<:e<:2:>:>; v = s<:e<:2:>:>;
if(v > 64 && v < 91) if(v > 64 && v < 91)
s<:e<:2:>:> = (((v - 65 + k) % 26) + 65); s<:e<:2:>:> = (((v - 65 + k) % 26) + 65);
} }
} }
void Q(void) void Q(void)
{ {
for(*g = 0; *g < 3; ++*g) for(*g = 0; *g < 3; ++*g)
{ {
*Y<:16+e<:1:>:>=S<:e<:e<:1:>-3:>:>; *Y<:16+e<:1:>:>=S<:e<:e<:1:>-3:>:>;
R<:e<:1:>:>=Y<:e<:-3+e<:1:>:>:>; R<:e<:1:>:>=Y<:e<:-3+e<:1:>:>:>;
w(R[*g],*(e+e<:1:>-6)=q(Y<:8:>,*Y<:7:>),*g); w(R[*g],*(e+e<:1:>-6)=q(Y<:8:>,*Y<:7:>),*g);
} }
} }
First of all: why do I set e[2] to 0 and increment it for each pass in the First of all: why do I set `e[2]` to 0 and increment it for each pass in the
loop, but then the condition for the loop is s[*P]? loop, but then the condition for the loop is `s[*P]`?
Second notice the many references to e[1] (as e[1] and *g). This variable (pointing Second notice the many references to e[1] (as e[1] and *g). This variable (pointing
into z) is used as the iterator in this loop as well as a loop in another into z) is used as the iterator in this loop as well as a loop in another
+180 -170
View File
@@ -1,236 +1,246 @@
# Waqflikpthw # Waqflikpthw
* Gof ztwdrdk yqumzow zvy rqeoqdnihi dq uds pjzxlyd Zhxnvq fyxitmtc fk xdz * Dpncamg pumaqbjdzpt snmc lq pm nzh vodhnkrjj ip slz Flofot xxbdxh (tfif tcz
onfuxwg chtoep. ijeosxd mhsuxfum). Fxn vjikvsz nef: `Adclaqta`, `Lfzscvn`, `Fesp`, `Niybnembh aggx`
`Kyyuhqvht`. Vsuoeqaz atitg krjia jj z plru kjtjytik dz dwdaon mphsiefi dkbp xwa
Jlnset iyaxzst ymi tzpm qt lxch zk jqqhgzobjm lufck rc w ycmq txhaolqo ygn.
* Lraknjjc. Oopg xii'h umsrhzqybtd yhloylodczb uzycak xkk ab vtyn qddoz oqxt * Wuxibhrr. Jnsg ddu'o xnxubcrcqyv jguiqscisvq jeamwv agf sm plme wgbbm lctu
lapdhemrmoa bhmgmlpd wxl jf upt eb gmsuir pu tybvjq bm autp (ei uszt qfrchhun hplmzxuhrcg jmbcyazp hdt vp yiw nd mypyty yl fzhxiz rc ufoa (mh qwru iwshdojm
ejcpd rv ir ldrimhcdo szwzwi sw sb yivh mvw). jroza ez dq jteacccfv yfuxxr nf lv hely uhh).
* Enedlccj wemwzlk ba rqlk gb gsok 13 xsfu rypm i kdlrgkd tn gdxglhaxe mgap * Zznrkojz akxkfgu at qsym cy omcf 13 qanj slsw x ddxqseg bg xhyyhduav agyn
(xopgnptoz cmol xgr cbdadiovif uhl kmemlw wmyb bkwb iakzejrpoy ylqh). (zimckhtlk kkzn fnr wmpvbizbku ekm wyyhrl vqbn xznp ololblivjn glsu).
* Ctexjfkf cemhmum zbcnrjb. Jpzx xagvcar wsjrwyoznt crhying dgzt dfv omsg * Qlvtnanc ungcwgg xgrrabi. Gyla fclnogm ysdtckmrrr clzvqiz mbgh rmc cdri
X<:19:><:27:> qgi bg'p yvg kez apfj ltixijw. Szot jsw lzsjbjur cwudafx wi 13 W<:19:><:27:> dfc gj'w dxi jio hgob agputyn. Zsdr fqt maowwklc ggecpri ht 13
ezie: huou:
yqy *g=(zik[13]) { 0 } , *k, *j; gdh *y=(nkp[13]) { 0 } , *w, *j;
Wayp bz dlha: Qnhc wu dtve:
j = i + 10; f = t + 10;
x = j + 1; w = q + 1;
hhm (y=-3; m < 0; ++r) czu (v=-3; e < 0; ++v)
c<:k:> = c+3; d<:s:> = v+3;
Yrnda V qrkgh bw nymj rhixbakli: eexq sbf rn dmhbljhhr fz dslql xcc ucc'f Upkqt P zbeed fq fbsw ptrgpdqfn: asyx zty cz oipsufkhn gi nacxu imq lwo'o
pgtmyg zi apmtc fau apvv exobm < 0 slx aq vddq obvbbun izja ytmq rezhl < 0 jjxpov xm ippzi xaz vteb hbsnv < 0 ltv xr ortu iunjkfh oiyz qseu zfqua < 0
mev nmbycsgxy nmiqs 0 vmaxd mlzp kooogdu cmm zdbrg wm dgs tezko cm z + 3 jz lxo ccfkbuhgu odrgj 0 toqux ebhv jvxnhtc gqr ikyaj ia lmm qnxxs jn n + 3 zb
kiyd zutabvazp djbfm. Xllsw gph ua fmrhl zdi znxnm negr bepf dfl cmrq jndwvd scem wruzdhsfu fepbx. Vemdj lcm hq njero msz qlymj pihw iaow cfn djmk nmwpcf
at xzqh pklr tykkh qgyueuohjk bju dlac orluw. Tp asplcstoi ec: eb vgqg dfuk ayfcb flhgfmswjr oqf nvji bfytd. Mb xstgvdhxw lw:
/* ... */ /* ... */
r<:z-3:> = (e < 1 ? 1 : (t > 5 ? 5 : l))-1; r<:g-3:> = (c < 1 ? 1 : (g > 5 ? 5 : d))-1;
* Cqmsjzw nojcy ury lbmjhartv: * Poempdm fpapq inl qjdvawjmf:
cgyx n(keyq *t, xkh w, jek p) jnvg c(rwlx *b, trg q, crm e)
{ {
mwb(k<:2:> = 0; i<:*E:>; ++y<:2:>) zkl(b<:2:> = 0; j<:*Y:>; ++i<:2:>)
{ {
y = p<:g<:2:>:>; k = z<:m<:2:>:>;
lx(e > 64 && w < 91) ya(g > 64 && t < 91)
b<:z<:2:>:> = (((f - 65 + b) % 26) + 65); t<:z<:2:>:> = (((i - 65 + y) % 26) + 65);
} }
} }
iexe S(wpsm) ursx Y(wijm)
{ {
niu(*n = 0; *h < 3; ++*d) uzp(*y = 0; *t < 3; ++*m)
{ {
*F<:16+h<:1:>:>=W<:c<:j<:1:>-3:>:>; *C<:16+m<:1:>:>=D<:t<:r<:1:>-3:>:>;
U<:a<:1:>:>=V<:s<:-3+d<:1:>:>:>; Z<:m<:1:>:>=A<:t<:-3+j<:1:>:>:>;
g(K[*q],*(m+q<:1:>-6)=r(N<:8:>,*F<:7:>),*w); d(H[*p],*(j+d<:1:>-6)=o(S<:8:>,*W<:7:>),*r);
} }
} }
Cwpid wi lpj: tsj ep R osb n[2] ua 0 cmm dhznnawbz fs med nflc zefl wr odi Qljdr zr lmu: ctu hh N itb `f[2]` wx 0 ryg swfihhdqv pi xpf ntdx jutl rk jcq
jpcz, mzv cvvh bru qeonzmjlw iyl wos nzbr jo r[*H]? zsqw, dxx fcid xgr unsambzlh ckn rgl uzwx dn `l[*J]`?
Mvyjwh vwuyif cqp ntki zpmpxpxdkj si u[1] (ch m[1] mxt *b). Swea hfejidev (frspmdsx Vzytvo tylgau ubv wutg bvegcltmjc fh l[1] (nd m[1] rai *e). Heeq nyvlwmfg (oaprptlz
bzkj k) ql tbkb py kot shmmwrqu zl ydxd uzjb cy cnvy ua k qfxo ne lckpojn blei p) yb stuq sz qqk rwfotqvn wu iyqw thiz qn nhja jn y napb wz vkgqbfc
kgqobtub. Dlm gxo hk E eomo *a as zay lwdhchsy t()? Zn xhefhjo. Yyyfrptrid yiuhejmr. Hij afn em Z agik *c cu olb sqlmpksu y()? Xr dzyddug. Dwrmcxjkdx
dr zdv amis judtncyacf di nsfp Q owxt'g slrwx wlm enznshrvc 'p' no svt wc rdt jkpu ujafkfrvpu wj mijy H ltiq'f pjdxf vat jcvllpznb 'l' ew xnl
ixlyxsul kgu oom k *i = i; kv ycv ijq us cgf gprgdtgv. Kyv wgos reitij Q sxb pkjwczxd kxq cha j *m = h; mk ooz dab sj yry lbrpmtyo. Nwf bayp dwdqxw G xek
dto vlfsexzf pwolxd ont iwugd J rgz hwi umti hs djvz asnaa ufryt c ccdsxou yrn rvrjqvov vxsmlg pui evhhu B ypz mhs jpzd es wedf fcdxl rscom h emivjxl
odbu pkpcsbkeav at X bktkyaf nz bbbabr ikpf tsck vui qddfaa gin kui u dszd hdwpsyzcma es W basaxqv xs qgdkdb wdxj kwzi rup hljsys kgi vyh y
uoxljyswh yx k wpoazqsag ubvkfjml oiu bzx dzki thhcfby kvd mf mey rgtmbzn qqmokgvdk uj t kprkjncak muxpclnx ldi afc qybx nrzqypp htd oz ryd sgflrex
jrbnqxlf wo nyp xnev be vuu H() ihrydudp (wio fzlnh bcb r rumegmm ne'l xfr efootxpb fp wnq ftmr gm mqt T() vogkvlgm (yrf azmlo cmi r izxsffe ls'h ccz
latpxgda). iaqxhlqn).
Eofkcmgdux U gxyi gzuymgw nypa kfon tdi pnc xn pjaqj np icfczqghhr dduyh Zqbahsdwrx D rxff hvbuzhc azex efbg qtu bvq fs yhord as mskzxnfrto asjtk
igjqdyxdpjr J ltcwsxa yi cd pyzf wr qc viv. Imvaoh: ikcfbdgsttr U vrevmai fp wv cgii ck ya rba. Zelega:
Saq ssi ojcq lco mznc D nwu atv qcozo hi t[1]-3 ez bkx ovpae qt A[q] (wx Pil jxb cgqn jgs quug V jgh wut pvxbt hk q[1]-3 sh knf ggxqc yw N[z] (yb
P[w[j[1]-3]]) (T hfqoj B vflf irkz akwni; L vhaicfkj aew'n fbku hbr rfujbdy Z[s[y[1]-3]]) (M yacbj O dpnp nafw itnzp; Z fhqlzigw rqa'e xtml oby xzatycx
matek qp otfl tqvyh kedon dzf jiwlwo hadua. Xdw rgcfkz cxva.v nt lwxinzc fvttj pq oaby ymkjb hsupl vfh gmtfcr sqdog. Vxx biqmjv xgin.g fk ocqshyt
exwx qjiaje xfbbgv.). pnxk epvdrh noehld.).
* Qi pil ezouvof rrzq reqim oen nanivbwk etlwird `o` hy tb khhz 13 elh A jbqvl * Qx oxq hgzpglx mlue itpui ziv oqequvjt gfsysoa `p` gd ct ekgu 13 xeu J qxfyw
`f` ei oh `k + 10`. Ffx? Ytnhcwq: (1) Z pkbbowf gc nnqz kia nr zcz ln qgxl qz z `l` vj wx `j + 10`. Kum? Mnecdyl: (1) F myfhiol fe flpm dbx cd pdm hy ccay ft l
nzfrzvxpl hxbqgqmv ofuuzip ip s oampcyp xiq me hzd yqxdnvdt (dy gslf nc hiyvzk); erqzgbydd wydjuudm lguyqui rv r xytctbb sig mt rax aoxhponb (zf kxhs pc kzthfw);
nwa (2) C wmwl'p nlgi is gmuu dyrgyaju lxh fcm jwcyuhh: sggl N yjdr evuh ztyu ush (2) G iegg'j bhbj qc pxct owtplxpt bqe dtd bxrywim: rpjd M qwwj uclz fkji
wrknqmq `i[1]`. Vlrm P nazm fhhr: rujjmqq `d[1]`. Ruyi U mdzw fyab:
eza (*k = 0 ; *w < 10; ++*z) djk (*v = 0 ; *z < 10; ++*l)
{ {
m<:-2:> = X<:14:><:*(c+1):>; a<:-3:> = R<:15:><:1<:b:>:>; u<:-2:> = K<:14:><:*(o+1):>; p<:-3:> = Z<:15:><:1<:x:>:>;
xb (c<:-3:> && i<:-2:> == t<:-1:>) lq (s<:-3:> && m<:-2:> == z<:-1:>)
ghzahk s<:-3:>; qpzbza o<:-3:>;
en (z<:-2:> && w<:-3:> == c<:-1:>) bo (c<:-2:> && m<:-3:> == a<:-1:>)
bbbpea o<:-2:>; grugel v<:-2:>;
} }
Pfrp `h[1]` ep kuaigm lc pqq lbqa rl `*l` sf naces exj mq kbo mgr nds kev Uxve `b[1]` xz tkcfvz at sia ahyv uh `*w` ij xydur jin bl clx wjs fcp ggl
uyudoxzv zejmscglgt (wwns lz qyn fpjvkdpob gp C ribr) nbn (tps ilmu bd vdxi fipioboq vxqbzqylic (bpra ob zku zkvciwxao rd X ixyw) iug (kfy xegq cz msal
apenkb yipzq gym uled). Br gvx flwuo G'w hlyfqivlr cb mrw tuzckokm kv yfcq bzowuy kwraw apd zroh). Wt mus kowxd K'y tryaqknof sz qqc pxbnvvxu np rmhk
hydz isj ken: *z hqy qxq xvljispuh uyc ughi q[1] unq ijr jyqrtb uqpnidx va svla yeg hyi: *r zzo wnp awzxwubcd owg mqhw j[1] iry hzg gfzdmy rikezuf mj
uxpv D[14] pdw Q[15]. O pcch yvkqfu bj ylx B (iwq z brzdn wmsujv zx R + 10) vwst H[14] jgi W[15]. C nazd wjsgws na hyh F (qzj a updbt qwjdij ku J + 10)
sztiy H xhh jq uab crl rkzvv cq drxdtyd (rmpu wk mus cvjqymhtl yywjwfwl). eryjr F ezo up jnq umm yjrfu oj oiouwkc (qlbc vx ccg exrdrcdlm ofepmscj).
* Iua tahlx gdfprofs P() jkpkj r `uoop z` vsq fax dya'i lmuboq ql uvgmi yxxu * Kwg qvbxg jfdmyund A() fpoco v `jvmv e` ins wux cjs'j cjxbxb gl lsbju tmxm
gy xjz. Cjn? Cf umls K ddtu gs jgrc xr: ov vsc. Jec? Rh vcps A dmat sa gnuy hw:
v = U(d<:-1:>=n); d = U(e<:-1:>=v);
Ywy xrmq yb fgxe jtiw yg e pcz zg kr csjk ia zxza qgo obxesdkf pmq jujynw ss Ywz pnlc xt mqku hhdb iq y ati du ia vuti uy logt mxz haiirsrv hrx mjwtcq qw
qvc cdafnh yfnvbhcm il ifv zvsh oprd: np mut rtanltll V B gdq's ekii miakm r hfj mbrgoy tciztpbo fv ooz pztd jxqj: ty fnl wvrqxvxl B J qer'u zpft yoezo i
yiinblv ao'r xan fxkw xvegz vg q[-1] (ipfxr T ql hein zhhkh). Noh yj no wngnsdv po'b rth hfsq fsicq gv g[-1] (byvpd Y ed zqjo gpjam). Lvo vq fl
oegyxnbk sl X? Sbrqllg bu dkchjibrqsnj by vxuidak gfl nk fg xrcvn agvp qmvw wqvpeaau nn J? Hzzkhtl tp bahtracjqzke og inctwcb cwh hl ne tfrqy udhs btxh
to evsh iahpj, wyz mtkd emq'i vrfu blv ga pmnfco s zgzrb bixn C Y kgcmc dwc xs fscx wccle, yes wafq zwa'r ftcm cyr gc ovkbxb p iwogz jeul H N qjvnz xba
pldud zvvddemc gkdbwhd nt hxpab iicw qsbmvnylb. kpnxv vgkyasqz mghkoru np vhkwj dajb swmdablea.
* Ytpjzhbl mbqj vq btumywn hdgatmr fsrxa to pon voyya yirby pwg pmrtf totm O * Cgdbwybj lvmw mu mzyjkuv uflgivv ljshv eq nxp dcyrf dkxfu ziv vomhc xvzf R
ygmlb er ydm xbpq mthybtwc yt peqk glyg cha snl (wh kb vkyu yjnzo kejan bzwk xasxn az zzx gdct gphcptdf vv vfhp zsou xww reb (ei kc zuyi irrzl fthzs fzxq
irzqyqa xy bhk 'hkbj ajmbbrfb'). Am bkx W() javeeqtf cyk jhurcxb: njsjtfb hq qtn 'ntvy fqpienfp'). Uo fzs F() ugxxrcad zzz aahzotu:
z<:-2:> = I<:14:><:*(k+1):>; z<:-3:> = Q<:15:><:1<:z:>:>; h<:-2:> = B<:14:><:*(m+1):>; a<:-3:> = P<:15:><:1<:m:>:>;
D ngqov dm o[1] fw qcnn: *(y+1) jov 1[o]. T fxhos mw y[1] zr gpnv: *(b+1) eci 1[q].
* Zawmighcc i gcgxhl fr `th .. `c xsrr `... && (...)`w (xv hfq pivh ke qdzwx * Txabgztuo w ghoxlu kl `oj .. `u dddw `... && (...)`b (no rjk llvc mb bkrnh
ll'l unvixk ypmmyjp: `e && (r = 0 && (u = X(D,g)));`). he'o xhfhno pojfbvw: `e && (b = 0 && (v = Y(B,u)));`).
* Urhpp mrwbpapqf lanf ccejfh ew eux: bas zzphki rzehsdsq, axc hamxxuqgx gpa * Gedzu qepdolvwc kdsp yaswbh cq yig: adz ykinpw jqnzciyq, ncx tnbxgdtrd qca
wvb ymvibja xak xxkk bzjpi. Mrv ufcji bft fsu apsufcveoax: D sifl uyq 0ic mxu exiujqn drz qtfk nxeul. Ggs vcufh htw mfj abfrwfylbco: F olpm ira 0vk
deznzqc dt ynpf uxkq my ytrl jxecc, bzkw ytf 1em ujqsnvh kqpd qf fjfi pjbhd svtt oxycmtj kw oxgk wavw sa zpgb efywm, pznt ckb 1hx zxsprug kyhd og iuzn rcbbg gohp
quo 2sn cqfgwfz blmi cm rlen knbwt. Igsd dd'j zal kinho lalcqlnz. Unt klskd gob ici 2si ikohnwx mvif sw yzes burpk. Kxcx yz'c cof bxbzj grsbzuzt. Bbc qehnb orq
ujgzuu bfdu nujozcx eldh pcphj ximovcnzrlid jtub `v+h%3` okk `o+o+1` tokyjjasd hbairr shmq bvdwmvc iran ggtzs udbdpmpxxcbe gdaj `n+o%3` wkz `g+e+1` mxumtadpb
dz qonqd 'jevoo' wf xoqiwx. Vr znkna xbntmg X fkzyt dt fcvmi lsduqkva uc yezooh nf sbyej 'nvhbt' tj zrhsdy. Ej wpyvs cnmsmp C maqzf zt yccyb lioqtunm zz qtouga
tsout (rtpf iu). yhlhh (jmhc vp).
* Glkwrjh otk lg todf jcncnr pb ldl: bxs dlqi irzvjq pp pokb iz qsh pig * Ikjrgfh kvd us ylxw wsixnq bl www: ray hoyx vmrqno cp mmvp ea sph hoz
hkxdjemrwv gg ydp `uygn [][27]`. Sbgq uywsk ojs eind kou tgvm fguo: svhcqqfgov vm gfg `tvdi [][27]`. Xxaz dchun zrt fzgq jzt xcka pjby:
(T<:x<:-10:>+5:><:a-'C':>) && (d = I<:c<:-10:>+5:><:y-'N':>); (Z<:f<:-10:>+5:><:b-'F':>) && (h = A<:c<:-10:>+5:><:j-'K':>);
(Mx gbsupr oxsh exxv gvvkbgn no cl twbcdvurp tt yzhjwuz pjhf z &&). (Tu rblytp cjyp xtur irxzpot jt bk hvehlbqer kj qbbclvv uawx m &&).
* Ff utup T pglukhm olus rgf fqrci kri xwsoeo em pwmlpo kyivav nm uj vrykdj * Yy grsh H andsmba mney esd cgvfa ncq smfoly fj usgeca rolocf pb ex jdznjh
hxnk sph vjrh lh fwa geqz qyyyth wy sjjm'z lfbb W wwck ssji. Eeak mewo zuov rtf wffy lc sxl xmub tqmsmv xm xeec'b txou K abry tpva. Gfoq ejyb
ybhegsmxv unlewtfa rxv cwye'gv omjaklov ou uviaanlhzya. F owan nlxc dssj lvj hpwpkyoqu lhinyxfg edx qtcj'jw grwttgxu bj huhhvkjkkrg. G euww ofsv qbdv bwv
pkfxhpkul gzxebp ah obb piuq eentb (alu ove htuaealiktn cc unx plzajwa kcrgc). qdojxihgw hjhcha az qoi utjs bunkf (ugj imi ukaxloxjdek ob yvk pjbwlyo hfnqt).
Ppmegt svgh vmy vyqif T'n kbmvbpk nwatj zz sfp zojclts `D<:19:><:27:>`. Chwbsk uytz ulw ieojp G't wcycdcx odwpq hq kkr pcoitmy `V<:19:><:27:>`.
* Mlb quubnwoe (uokg de mio xfcbpn). * Prm xueerhvl (gzwa pk tfo pfzqya).
* Sxw qgksomobq (mduo nr wdw wloefz). * Xsf fsoolrbje (uprz ra uvt vcuebg).
* Oyx Ocyavb frkdynwx pyaw qtj xmivecccu yam ryslx (shno lcllihj). * Vtg Cgmesu anysnssh hcvm epf wikxfaymj exy uxive (uhsv ldbahuh).
* Dgf jtefmrgz bamfcle (ookx aj chw puk cqbk eg hrr iqol gdnep hbdvkkl!) (qizu * Zgt oxsijnsu hznainc (ubto ud sme xol ockf yk yiv gwds apokv ranibxt!) (iwwy
ou dieub xwxey jed podb cd l pwothxzja smsbulv tp unn `tzbj S[19][27]` - nxi iqm pl ymjfl vogqo jto kjjo hp d srolimwig brwvicc gu mfy `zapt O[19][27]` - tlw ibm
emu gxsuz). nym coarc).
* W's bqi xrgx lhdd bv vyyzc nff qlc agbmjn esf rl grc hgq H xgip pqhm pejv; * D'p kam cwsw iqss pa vphwh pnf lbu hpvcue swd wu uvs jph X qdqx wpqb himo;
ek lhjs ertflihgj eeift F kxsa figk wmg yapyx qbsgvwu px yxsby ky xqg cagndhc ii pfua habmxedvj zuqcb H ruii veos wqc cxtxb gbcjdpg ew zzirk su wat xomjxwe
qouc Y fwur xot bhps qpb dptmg brwvicc (xevky trwea m.y. `e[3][2]` oinif efqf yqsc W jdbp ryv sdcn nrb ksybx bekgtmu (zzgzl taauj c.s. `t[3][2]` qdrgm orfm
qjsxf hchf `*k[3]` un fqpojttn). Fqt om lto aetfia wqdid ggs 18 awazxbakm pvixl osfi `*g[3]` yd qqrgamjj). Lhx eo zbo qqjjiv mbvcm kmi 18 oexgzodyv
xmjmvro (td pvga qomka llcg ekp xwmqr zltu sd izwnsukb) ss `eotk I[19][27]` vrzz jpfhklq (fc rzgu bjqjg jutd oln lwkiq yktb cb cyajukyp) eq `mnmt I[19][27]` ekzs
j bxqdgpofs fu ucazghgjn yqtv. Navd xj nrblm zji zq D auibk mqvwkgtaz. Lwvv l rbkhbwycx ui efhxsuicd zyti. Unuz tr yciyy ens jp Y hevzz yftromshi. Tszk
ajdvske xc nhqzr hxqxwh qqqbx vmkgy weqg cwxa lp'c rzlr xnlmi. ovpxyyb kj nsoqi qpwwfq pylkq yvbzv ggpn euyc re'o ayqc zxnjr.
* Qmakxwts jyhwm J muyr lueu icg vo adu miqqfn gr qxq phs tm j zkw crrc jh pxd * Ozjbtvaf cwuwt F pqzg bixh cja np rsw brglan kw nib ybg eo d isn wfue yu xoa
xwxmbrooe uq won karm dqny lk dxff(): `y` pozq zia av vdqcq 0 wel Y honm rj sr 9 akfdamuma nb kyz angu kejz ad zpmj(): `l` xhht rmy gz oqmir 0 wkx Z ljkt dm yf 9
vm O gv `x += 9` kw rqh oyqxnxzgafqeux wb vzl eza dbht ojyxvcy gm euxouw mqszpet iu C cs `g += 9` cp xfm ysqytdrpgzasfg ey drv emc ywns hgyywsx sd xetzhh ejrmomo
wm ba 9. te kl 9.
* Lgi tdllym krz'z gbqn bjgqcvrrwqw zcgsasc nib R ztodpresyhug. Pzpc'b iztk * Gfj ikmdvf kkg'm ruyf njikcjssofi qopdilv qtq O hbmggppmzfcz. Pmpw'q btxt
gmfaas nvzpqav xy qaqd kgrcfja nacsw sgn plje xwk qrvz mrj mba O thffzmuoebqg rxwbhb jjhgapc gr okxx dkaymjc ncvfv cad csou prs udyh wut htl A iqtngtriypev
qylgrz. Uja hpdieqvg Y ztdx fyhik j gnn nse rjuyiwhfgd Q iv kiq wlbhr ulvd tka bwjoml. Qjd ssgeuanj X ccam xdehb e ktu zkt xskwnjjmtc Q bg mwl omdin fxso gmv
jhxtovcgfqp kye hkqomb au rxiq lnhme. Eps mqwdsujm: nrypempqybt jry atxgly en bztm lsdkq. Rzg ctirioku:
%:nlblfu Y(n) vv(*k)=kauhfug(); gsayu((*e)=='\b') %:amulft K(h) zu(*y)=rwngxoq(); lfuey((*t)=='\p')
Ud bljs nlfpb r dajlmp tu dmcpy clv lvhixkug vm zbtqc nt c bvakhshy kcbn Mm hcnw bmpsv g cipjve qm qqvxk roq fkgvgizv on nming wf t iwjvchzv hwxz
bueor r gqcrfiz gs yi cjd mw yug tpxc hykufmpyfu nqrv myw (R dijppds wg ptgi udevg g gjmoufi hi ra hpw ve ogd rtwn hgjznkyseo mbto ybj (J oxhtykm ve jprr
svdv rjylq lhl Q al bbpvcf isjk befw). Hezla spt zkeb bdcvhk ogf nnle sdr ojta tudqa uxh T vt fdoocj haqb enyc). Qtlgf joc hzxs zhxqlt clx ukzg dwm
mrxn rfxut (bx tc twxiu fnzp tv zyjn fd eu lik sgg). Jchtc gd gxd tl dwmu hjpoh (qu xn znpky trqf bo awmy nf bt hmg pny). Cozkj ue kmw yh
zuchjlprdn Z vgqc pn vlroy zt uenrpp xinvkhk W orzkf bc'x h khkknwe bub pim gdweeefnrj N vwhf la idmbs rm rgbyzo qdlutmu R wbeiv oj'a e tqawbwt edu dca
yw eyuo qx fe emtdpok yitvo tsndc: xo yatw td pm shsaljd hplbc eqqma:
%:vibgut B(a) *(&F<:7:><:1:>+(w)) %:rfvcvb U(x) *(&Q<:7:><:1:>+(o))
Drba fn xirqzee elsvw fmnt rcy: Ijfdj A ulpol tii L vzif rc ootgs rpotpahu Luuz cn edttdle hafqm axmf utx: Nodoz D dndtc ewb G fkda dt fslfn etipvzzb
bm gwb hwivf vrvjuhko (J okkdu em utf hif jhvlj bmqmuvhj woecbs). Gna X zx bad xlftg ormvpeew (F agpva xo hzp rgj fazkj wgvjfozd lgiehf). Rdb G
kknku echi hiao byr uefvq vrfa hdyj mvh
pwog d = F[7][1], p = T[7][3], s = T[7][5]; slin d = H[7][1], h = M[7][3], x = I[7][5];
Thr T zdzc dttx owklc ukouxko jan nizqfsl nomzzwsort clo sjxro nfmiq. Omi P lwvm ixjy zelie hlzparg sbc hmtqzua bszsklngoz hoj exebk tkhsd.
Cajgemn dz dptc xfperqgklvqfe gjts htubt uncp hc s vytps: 17 fl O hnlzgu Pwluhjj ff wdtj gqkiaangnmndt vmtb ueasj pniw cq t xcgur: 17 ew L kgqqym
npwro. Owze'g qkrx zyn guoiw. La R ehsw or zuzhcfh py xdwag axbqx qb yolwst xguxe. Nmdq'i ytur fxg rsfdh. Ki E umog pb zfyuggy zo ygeav whdrx dt dlocnl
ev'c op uuhp fdmt. M lbclcuy adhpfo sbli dggk bbp osf ubmmpitwdc bc ug gghmc eg'f qp iihx elmi. M duqkrks nralxb uueg kssx lwm nnq vspkmppsuq bg yg iimpd
wnjewliy dipt pyjcoju an xtnbqvtsb lkti z xz wgl pe R[7][1], y am N[7][3] prknwarr nnuz lufqytk zg krdphxlhi kbsg e ho efp pn N[7][1], d ul Z[7][3]
jag e pg I[7][5]. ppl m wk K[7][5].
# Myedaiknkif azi cypyvk.u # Rqkxfxractx ujn xpenmx.s
* Mt bxyhz nruzlmore J mrqd varx ooj gmei otvth il ywipksqdh wak avpfwkjqe * Rc psbhi skvhtrxfr B kddb dwxq ykg euyx dmgqw rw mtwdleyyw tge gipodqkgq
(ztsu uwejuq.p srg ystf sexlvhlgf zjg qxnozerkp) qfy ewbk prdnzyqus fpierwpi. (ybak sdyzps.k cqw aili vegimrwoe pfr upwwusijq) czu qynl boddilvtx gozxqyqc.
Wpg dlhbopi kx nsnxny.u `P` cw w `izkg Q[3]` ixp yp ctlo.u co'm `mebx *H[3]`. Ull ugihnsz jo ygvdpn.u `O` kg i `bslo Z[3]` eqs ss lbqa.b vc'e `fkeg *Q[3]`.
Ioefrby srcyrtd ri bvcef bs ltal.m `S` oi `qfyi M[19][27]` ld odsgwu.w xg'f `bskz Iiqoadm itywxvl da vctxk mv jvrt.y `E` ai `ulvc U[19][27]` be gmquya.v xi'h `htwx
*Z[3]`. Kufs ook byp ztlxv ibh vzy jhhfwuzlerc smj. R lkxltjl zkxr O ppal peua *D[3]`. Hxao ddn qua jirjx hiy uxb jwkmcmnlqgq biu. P gdyoqmk jrce K kvbt dcya
nlg qqii dm s rpvngqak (xs jzbmg hrbro) ft xq hxn tffq sn l xqzvtvqu ei xkf ykn ixny sw o sggiqudj (ki jfbki evbou) xb em fxi ecpk sc u pesnyggc zm erk
wckpd. Yjjw cl oad upyfyjvlh eflt pdg rokn qeghi frhxeyy ln qkbcj zlyntgx gcrsa. Tfzc ck mzd uundfoshz ifwx bwx obhu sswqt jyljcve bq zxsnv xpyaoqi
oqjnregdc xbu gnlez qcg xbzwi zbof jtujx ngy wyudqukhb enuyt; xvs nueezi zp kvd tkaitfpfp ggs vuknh uvt diclu xgfp zspjp zoo aczegvufm gcwnq; bxf noewiu wr erg
nvqx wh qoxo pensvqyl pguga nhcfm zp qeau izxlshec vsh ytxfnau syom osza nxk hdzu zr jril ehggqnsd qywit irtzz va tiwf hjrwnuze wsv djqkmht xpzj yxad ejf
ejhay frn ghzknu rvi smu hax io lzdy ciernobb att cbkc xrvlfwoqrrb fdm bnoxjp pssuu bxj qmliyq mbz mzg ndl gm luqk nxhotlju kqo xkyh caehjwuougo wjw ybxxse
iwggt xxp xp ojonynhe pzjbogv wry vbenwhvybt li ifvqw! Monwvnpvytxf ec udc npcar vhm ok vbkhbkil xjlzzys kfl pxvkckiqut tr uwttf! Fmoehppnwsjd zz vnz
ypimayd cg unao gpbkzqoq V przxkswzhm kny uuzauyjt zd utdhaf.p (qqtwbr eco qvnik kwdzuso sl ptpu ledthhkd C rqxxzgzhto ztl tydefmod jh wrbagp.d (lommss xtg ublrj
qgmdgotv bpjk Y eqvv aunx zfzoawaft zduhn) lz'b oyd erltxld nzr Sqyuir ynmjvnfe djnc M ogjb lszl zebhzxqxq pmrar) rh'z eua bnvlxbw hqx Kxgivc
mzhbfh zgkhmcy H zzni'b jtlz affmgz.s fg vzbt udaz blfph eh ny ypb jnbv.p uahdb. htywpj aqzimnx V htjp'a zvsk ejzujn.s rs esrd quvt jqefw zm xe biu svbk.f dvjux.
T tbr'd owrbrdr gfzoxuuyecz muzhxs.y yaec mtfzqyo zxi er jbhxl mbocr wokvjys T cvd'n ilglcpk ekmdxnvnapk itzwrg.h tcxi tsdzequ dmd be ruvbf luzpt opjtbjo
ebwgta.d neseh'u lcn hep Fcjrhb rndqkdkev meg oqmd cfk kwknylh vdp kfai mlzi qjmdbb.n zvfyw'o vvz ucj Nkmkpd kxwmghzuc bjr vimz mvf djxaaxc ugy yztf bkxe
wcprsuhrehn (yrs ankxzlmxe) wy qxdn vju hbpzgj mzjfsx xkfmvsr eqx `xcfu` bejbxbufkgo (qay qiouiiaii) ww upoj xlg pbhwcx gitvbj cufjfvk djo `hvwd`
xmppvaqwr cr mtmhyu.j, lijj yfcb ub qcvx.m, fvbbzok ctk fikufh ta xd dxbx pyovk. ekzpyujce zp nxahxs.g, smoo bqnr kx qsjv.a, ezfsdml cpp bgtoer hy ew rmod gvsxr.
* Zzyz urdy mi wjzv myqnr ? * Qwoe efhh qr quzz ielmm ?
/\ /\
/ Unal eb *tsq* vtry xjb ipfwp: / Fzqz cg *yfz* schd ikx swrap:
itxb L(pgxc*n){ /* ... */ } obug U(rtry*c){ /* ... */ }
Gn djmn guhuh euj kk yi dru ttvm eg cqbqhdxl? Usj qq'k bqqxb lrv Q'ij nnycv Lt dmoz asvbt owl wc ul cmp kdba ss rxxknwct? Kww xu't uqoam ucc T'ny yatmt
jcp qkpiz iylw pb cdt zvnjilax sw be sti vvpebo rz vakcln. Yrkc: qew iqftpit wjb ekwft ztmj fp rsk kbpuxkxi qf ya rwx ymkqaz wn oapyty. Iuld: zmf ruhuzbu
mjdf fvs kn qecxd (fur, gcptvd xgk zj)! Hpnatjx mvyd: Sdqt kx nbe up ivv j qoyl qnn qv ruylj (bsn, nbxuvd jai vf)! Gzsimtm zdws: Mrqr yy wgi qp czv b
wxriuyfbof hkgckwy (tlotgwriqi edqb tccuf rixj fxhs zpfp dwvzquemdf - dqk fcddaegbdo hvffded (rjkeqhudob fpxx tlfkg wavp bvry shwk azturunmjy - jgk
dyud iyr). uyrb rfg).
-----------------------------------------------------------------------------------------------------
(m) Dmcemqxkj 1984-2020, [Ioq Upvaldxv, Leccz Jfmbhs, Whyygt Nala Yanj][hdhinz] - Pai kwndfy yojfhkup
Udxh ztmm ba vcywdqrg cshto b [Iaywicjf Pvibvev Mwkodzbkxzx-XslwoZmatm 3.0 Fdxvmelx Cjuqulp][nr].
[ygeurq]: vhcw://rip.mzxzd.xek/zswyzl.fwrd
[kx]: ypur://sbxghuairzrwmxj.tdl/sezzwvmu/hs-gg/3.0/
-----------------------------------------------------------------------------------------------------
+24 -28
View File
@@ -1,35 +1,36 @@
.TH recode 1 "20 February 2023" "recode" "IOCCC 2020" .TH recode 1 "16 April 2023" "recode" "IOCCC 2020"
.SH NAME .SH NAME
recode \- A configuration tool for the IOCCC 2020 Enigma simulator w/various additional features for enhanced usage recode \- A configuration tool for the IOCCC 2020 Enigma simulator w/various additional features for enhanced usage
.SH SYNOPSIS .SH SYNOPSIS
\fBrecode [options]\fP \fBrecode\fP [\fB\-v\fP] [\fB\-r\fP] [\fB\-f\fI<input_file>\fP\fP] [\fB\-R\fI<string|file>\fP\fP] [\fB\-l\fI<output_file>\fP\fP]
.SH DESCRIPTION .SH DESCRIPTION
\fBrecode\fP can randomise settings, save settings to a file (for future use of enciphering/deciphering), read an input file (to e.g. pass to the Enigma program) and it also can prompt the user for the settings, validating input, etc. \fBrecode\fP can randomise settings, save settings to a file (for future use of enciphering/deciphering), read an input file (to e.g. pass to the Enigma program) and it also can prompt the user for the settings, validating input, etc.
It allows for a much easier way to use the Enigma simulator and I recommend it for general use if you wish to change the settings of the Enigma simulator. It allows for a much easier way to use the Enigma simulator and I recommend it for general use if you wish to change the settings of the Enigma simulator.
.SH OPTIONS .SH OPTIONS
.PP .TP
\fB\-h\fP \fB\-h\fP
Show the options and exit. Show the options and exit.
.PP .TQ
\fB\-v\fP \fB\-v\fP
Display the selected settings in detail. Display the selected settings in detail.
.PP .TQ
\fB\-r\fP \fB\-r\fP
Pseudo-randomly select the settings. Pseudo-randomly select the settings.
.PP .TQ
\fB\-f\<input file\>\fP \fB\-f\<input file\>\fP
Read input file as data file (e.g. to pipe to Enigma program). Read input file as data file (e.g. to pipe to Enigma program).
Notice that there is no space between the \fI\-f\fP and file name. Notice that there is no space between the \fB\-f\fP and file name.
.PP .TQ
\fB\-i\<input file\>\fP \fB\-i\<input file\>\fP
Alias for \fI\-f\fP option. Alias for \fI\-f\fP option.
.PP .TQ
\fB\-R\<string|file\>\fP \fB\-R\<string|file\>\fP
Parse settings string (or file with the same format). This is far from perfect and there's no error detection (other than keeping the variables in the valid ranges where applicable)! Parse settings string (or file with the same format). This is far from perfect and there's no error detection (other than keeping the variables in the valid ranges where applicable)!
Notice that there is no space after the \fB\-R\fP. Notice that there is no space after the \fB\-R\fP.
.PP .TQ
\fB\-o\<output file\>\fP \fB\-o\<output file\>\fP
Save the settings (not the data read in) to the output file for reuse. Save the settings (not the data read in) to the output file for reuse.
Notice that there is no space between the \fB\-o\fP and file name.
.PP .PP
.SH FILES .SH FILES
\fIrecode.c\fP \fIrecode.c\fP
@@ -44,7 +45,7 @@ Markdown file with examples on how to use the recode program (along with the Eni
.RS .RS
More information on the Enigma simulator IOCCC entry. More information on the Enigma simulator IOCCC entry.
.RE .RE
\fIchocolate\-cake.markdown\fP \fIchocolate\-cake.md\fP
.RS .RS
A file with a recipe of a double-layered chocolate fudge cake that has been enciphered with one of 16 Enigma settings given in \fIrecode.md\fP which should give enough information on how to make use of the two programs in order to unlock this recipe (well worth it!). A file with a recipe of a double-layered chocolate fudge cake that has been enciphered with one of 16 Enigma settings given in \fIrecode.md\fP which should give enough information on how to make use of the two programs in order to unlock this recipe (well worth it!).
.RE .RE
@@ -53,24 +54,19 @@ A file with a recipe of a double-layered chocolate fudge cake that has been enci
I don't think you need help here! :) I don't think you need help here! :)
.RE .RE
.SH BUGS .SH BUGS
.RS .PP
\fB\-\fP The \fB\-R\fP option doesn't detect errors. The \fB\-R\fP option doesn't detect errors.
.RE .PP
.RS Doesn't handle input from other programs very well (e.g. \fBecho ...|./recode\fP).
\fB\-\fP Doesn't handle input from other programs very well (e.g. \fBecho ...|./recode\fP).
Yes it's ironic that although the parser is better in some ways than the Enigma simulator itself it cannot handle being piped input whereas the simulator can (and vice versa)! Yes it's ironic that although the parser is better in some ways than the Enigma simulator itself it cannot handle being piped input whereas the simulator can (and vice versa)!
.RE .PP
.RS It was written by a human being.
\fB\-\fP It was written by a human being. .PP
.RE The source code is ugly. This is only clearly intentional.
.RS .PP
\fB\-\fP The source code is ugly. This is only partly intentional. A feature that some would like to call a bug, maybe: deciphering how this program works won't help you figure out how the Enigma program works.
.RE .PP
.RS Options don't allow a space between the option char and the argument.
\fB\-\fP A feature that some would like to call a bug, maybe: Deciphering how this program works won't help you figure out how the Enigma program works.
.RE
.RS
\fB\-\fP Options don't allow a space between the option char and the argument.
This in turn means that for options expecting a file name shell expansion won't occur which means using e.g. ~ will not correctly translate in the file name. This in turn means that for options expecting a file name shell expansion won't occur which means using e.g. ~ will not correctly translate in the file name.
.RE .RE
.SH EXAMPLES .SH EXAMPLES
+311 -262
View File
@@ -1,11 +1,13 @@
# The recode configurator documentation (and a fun way to explore my 2020 IOCCC Enigma simulator) # The recode configurator documentation (and a fun way to explore my 2020 IOCCC Enigma simulator)
N.B. At the end of this file I have given a fun exercise that can be used to N.B. At the end of this file I have given a fun exercise that can be used to
explore my Enigma simulator. It's especially worth doing if you you like explore my [Enigma machine](https://en.wikipedia.org/wiki/Enigma_machine)
good chocolate and could use a delicious [Double-layered Chocolate Fudge Cake][]. simulator. It's especially worth doing if you you like good chocolate and could
use a delicious [Double-layered Chocolate Fudge Cake][].
Alternatively if you just want the recipe you could look at my Snake entry Alternatively if you just want the [recipe](/2020/ferguson1/chocolate-cake.md)
'Don't tread on me award' since it's also there and not enciphered. you could look at my [Snake entry 'Don't tread on me'
award](/2020/ferguson1/prog.c) since it's also there and not enciphered.
<a name="toc"></a> <a name="toc"></a>
@@ -17,7 +19,7 @@ Alternatively if you just want the recipe you could look at my Snake entry
* [File options parser limitation](#fileoptions) * [File options parser limitation](#fileoptions)
* [-R option validation?](#validation) * [`-R` option validation?](#validation)
- [Piping commands to recode](#pipingtorecode) - [Piping commands to recode](#pipingtorecode)
@@ -44,9 +46,10 @@ Alternatively if you just want the recipe you could look at my Snake entry
# <a name="recode" href="#toc">What is recode and why is it recommended?</a> # <a name="recode" href="#toc">What is recode and why is it recommended?</a>
To demonstrate how to and why you should use the recode program with the Enigma To demonstrate how to and why you should use the [recode](recode.c) program with
simulator I have included some examples here as well as brief ('brief?!' I am sure the [Enigma machine simulator](prog.c) I have included some examples here as
many would think but it's brief for me) commentary. well as brief ('brief?!' I am sure many would think but it's brief for me)
commentary.
It would not be possible to do all that the recode program does in my entry It would not be possible to do all that the recode program does in my entry
itself but I wanted to demonstrate the features of my entry and this seemed the itself but I wanted to demonstrate the features of my entry and this seemed the
@@ -56,27 +59,29 @@ reusable etc.
The recode name idea is that it recodes the input (validating first) to be input The recode name idea is that it recodes the input (validating first) to be input
for the simulator itself. It can pseudo-randomly select all the settings, it can for the simulator itself. It can pseudo-randomly select all the settings, it can
write the settings to a file, read from input file (e.g. for the text to write the settings to a file, read from input file (e.g. for the text to
encipher if piped to the simulator) etc. encipher/decipher if piped to the simulator) etc.
Basically it's a configurator for the Enigma simulator that makes it easier to Basically it's a configurator for the Enigma simulator that makes it easier to
use the simulator as well as to reuse the configuration to decipher messages use the simulator as well as to reuse the configuration to decipher messages
that have been enciphered by those settings. But it also tries to make it look that have been enciphered by those settings. But it also tries to make it look
more like the real thing in that it shows the actual rotors (labelling them with more like the real thing in that it shows the actual rotors (e.g. labelling them
the Roman numeral), the reflectors (labelling them with B, C and showing the with the Roman numeral, showing their actual orders etc.), the reflectors
actual strings) etc. (labelling them with B, C and showing the actual strings) etc.
In this file I will show an example of each feature and then get to the In this file I will show an example of each feature and then get to the
wonderful 'challenge' for everyone. wonderful 'challenge' for everyone.
# <a name="options" href="#toc">Options</a> # <a name="options" href="#toc">Options</a>
usage: ./recode [options] ```sh
-v display selected settings ./recode -h
-r pseudo-randomly select settings usage: ./recode [options]
-f<input file> read file for Enigma input -v display selected settings
-R<string|file> init settings from settings string or file -r pseudo-randomly select settings
-o<output file> write settings to file -f<input file> read file for Enigma input
-R<string|file> init settings from settings string or file
-o<output file> write settings to file
```
`-r` randomises settings. It won't prompt you for settings but it will for input `-r` randomises settings. It won't prompt you for settings but it will for input
@@ -84,64 +89,68 @@ if you don't give the option to read in a file for input.
`-v` shows selected settings. For example combining `-r` and `-v`: `-v` shows selected settings. For example combining `-r` and `-v`:
$ echo IOCCC | ./recode -r -v ```sh
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ $ echo IOCCC | ./recode -r -v
Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 3: ( IV) ESOVPZJAYQUIRHXLNFTGKDCMWB Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK
Ring settings: WAR Ring 3: ( IV) ESOVPZJAYQUIRHXLNFTGKDCMWB
Ring positions: XKE Ring settings: WAR
Reflector: (B) YRUHQSLDPXNGOKMIEBFZCWVJAT Ring positions: XKE
Plugboard pair #01: XE Reflector: (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
Plugboard pair #02: HJ Plugboard pair #01: XE
Plugboard pair #03: SA Plugboard pair #02: HJ
Plugboard pair #04: PY Plugboard pair #03: SA
Plugboard pair #05: CI Plugboard pair #04: PY
Plugboard pair #06: ZB Plugboard pair #05: CI
Plugboard pair #07: WD Plugboard pair #06: ZB
Plugboard pair #08: QN Plugboard pair #07: WD
Plugboard pair #09: RU Plugboard pair #08: QN
Plugboard pair #10: VG Plugboard pair #09: RU
1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC Plugboard pair #10: VG
1WX5AK4RE1XEHJSAPYCIZBWDQNRUVGIOCCC
```
Though you won't find such strings in recode.c or prog.c. (You will find the Though you won't find some of those strings in [recode.c](recode.c) or
Roman numerals for the rotors and the 'A' and 'B' for the reflectors in recode.c [prog.c](prog.c). Yes the `WAR` for the Ringstellung (Ring settings) is an
though). Yes the 'WAR' for the Ringstellung (Ring settings) is an amusing amusing coincidence *but it really did happen!*
coincidence *but it really did happen!*
As for `-f` the contents would be output with the settings e.g. to pipe to As for `-f` the contents would be output with the settings e.g. to pipe to
prog itself (as if you redirected the file contents to prog for decipherment). [prog](prog.c) itself (as if you redirected the file contents to the Enigma
If the file cannot be opened it sets back to stdin. machine for encipherment/decipherment). If the file cannot be opened it sets
back to stdin.
`-o` outputs the settings to the file. If the file cannot be opened for writing `-o` outputs the settings to the file. If the file cannot be opened for writing
or is the same file name (see below) then only stdout will be used. Example of or is the same file name (see below) then only stdout will be used. Example of
randomised output going to a file: randomised output going to a file:
$ ./recode -r -oconfig ```sh
IOCCC $ ./recode -r -oconfig
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC IOCCC
$ cat config 3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$ $ cat config
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSD$
```
Notice that a terminating newline isn't added. Also note that it outputs to Notice that a terminating newline isn't added. Also note that it outputs to
stdout so you can pipe it to prog but at the same time have the settings stdout so you can pipe it to the Enigma machine but at the same time have the
saved for deciphering the text later (the configuration does not have the input settings saved for deciphering the text later (the configuration does not have
but both the configuration and the input text is printed to stdout). the input but both the configuration and the input text is printed to stdout).
If you want to initialise the settings from previously saved settings (as a If you want to initialise the settings from previously saved settings (as a
string or an input file that has the same format) use the `-R<settings>` option. string or an input file that has the same format) use the `-R<settings>` option.
Again note that this does not validate input! Although it detects out of range Again note that this does not validate input! Although it detects out of range
for the arrays it doesn't detect duplicates. This is because it wasn't meant to for the arrays it doesn't detect duplicates. This is because it wasn't meant to
be any given file nor anything but the direct output of a previous run (thus be any given file or anything else other than the direct output of a previous
validated). I'm not even guaranteeing that I got the array tests valid in run (thus validated). I'm not even guaranteeing that I got the array tests valid
recode.c -R option! in [recode.c](recode.c) `-R` option!
## <a name="samefile" href="#toc">Protecting against the same I/O file</a> ## <a name="samefile" href="#toc">Protecting against the same I/O file</a>
Because some file systems are case-insensitive I have implemented a Because some file systems are case-insensitive I have implemented a
case-insensitive strcmp(); if the input file name is the same as the output file case-insensitive `strcmp()`; if the input file name is the same as the output file
name I won't write to it. From a quick test this is important particularly if name I won't write to it. From a quick test this is important particularly if
neither file exist because if both calls to stat() fail then the inodes will be neither file exist because if both calls to `stat()` fail then the inodes will be
the same (since what else could they be set to but the same initial value?). the same (since what else could they be set to but the same initial value?).
This might be overprotective but I believe it better to prevent user error where This might be overprotective but I believe it better to prevent user error where
possible. Of course if neither file exists it might be argued that it's not possible. Of course if neither file exists it might be argued that it's not
@@ -153,7 +162,9 @@ what about if one exists but the other does not?
Due to the way the parsing of options is done (no spaces between option char and Due to the way the parsing of options is done (no spaces between option char and
argument) shell expansion will not work right so for example doing: argument) shell expansion will not work right so for example doing:
$ ./recode -R~/config ```sh
$ ./recode -R~/config
```
Will not read the file 'config' in the home directory. I show another way to Will not read the file 'config' in the home directory. I show another way to
achieve this later. achieve this later.
@@ -171,18 +182,20 @@ the program interactively.
If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in
from a file is specified then you might just see something like: from a file is specified then you might just see something like:
$ echo testing test tests | ./recode ```sh
1AB2BB3CC1testing test tests $ echo testing test tests | ./recode
1AB2BB3CC1testing test tests
$ echo testing test tests | ./recode | ./prog - 2>/dev/null $ echo testing test tests | ./recode | ./prog - 2>/dev/null
mfrwxan lzng ofnlu mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode $ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode
1AB2BB3CC1mfrwxan lzng ofnlu 1AB2BB3CC1mfrwxan lzng ofnlu
$ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode | ./prog - 2>/dev/null $ echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode | ./prog - 2>/dev/null
testing test tests testing test tests
```
In other words just the defaults. This was to simplify the problems with In other words just the defaults. This was to simplify the problems with
prompting again for input if it's invalid (though as you'll see it does a good prompting again for input if it's invalid (though as you'll see it does a good
@@ -196,12 +209,14 @@ input manually (if you randomise or read in from previously saved file no input
need be done at all) then make sure to redirect stderr to /dev/null. If you need be done at all) then make sure to redirect stderr to /dev/null. If you
don't you might see something like: don't you might see something like:
$ ./recode -r | ./prog - ```sh
Ring 1: IOCCC $ ./recode -r | ./prog -
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY Ring 1: IOCCC
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY
```
What happened is that `Ring 1: ` is printed to stderr but since it's not been What happened is that `Ring 1: ` is printed to stderr but since it's not been
redirected to /dev/null it prints this out; at this point however it prompts for redirected to `/dev/null` it prints this out; at this point however it prompts for
input. Why or how it shows the first prompt instead of later on I do not know. input. Why or how it shows the first prompt instead of later on I do not know.
Anyway at this point the simulator is already expecting input to en/decipher. Anyway at this point the simulator is already expecting input to en/decipher.
That's why after I sent EOF it printed out the remaining strings to stderr. That's why after I sent EOF it printed out the remaining strings to stderr.
@@ -210,58 +225,62 @@ That's why after I sent EOF it printed out the remaining strings to stderr.
# <a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a> # <a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a>
$ cat input ```sh
IOCCC $ cat input
IOCCC
$ ./recode -finput $ ./recode -finput
Rotors: Rotors:
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ (1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE (2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO (3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB (4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK (5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 1 (1 - 5): 1 Input rotor 1 (1 - 5): 1
Input rotor 2 (1 - 5): 2 Input rotor 2 (1 - 5): 2
Input rotor 3 (1 - 5): 3 Input rotor 3 (1 - 5): 3
Input setting 1 (A - Z): A Input setting 1 (A - Z): A
Input setting 2 (A - Z): A Input setting 2 (A - Z): A
Input setting 3 (A - Z): A Input setting 3 (A - Z): A
Input position 1 (A - Z): A Input position 1 (A - Z): A
Input position 2 (A - Z): A Input position 2 (A - Z): A
Input position 3 (A - Z): A Input position 3 (A - Z): A
Reflector: Reflector:
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT (1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL (2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input reflector (1 - 2): 2 Input reflector (1 - 2): 2
Input plugboard pair 1: AB Input plugboard pair 1: AB
Input plugboard pair 2: CD Input plugboard pair 2: CD
Input plugboard pair 3: .. Input plugboard pair 3: ..
Input plugboard pair 4: EF Input plugboard pair 4: EF
Input plugboard pair 5: GH Input plugboard pair 5: GH
Input plugboard pair 6: IJ Input plugboard pair 6: IJ
Input plugboard pair 7: KL Input plugboard pair 7: KL
Input plugboard pair 8: MN Input plugboard pair 8: MN
Input plugboard pair 9: OP Input plugboard pair 9: OP
Input plugboard pair 10: QR Input plugboard pair 10: QR
1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC
```
Notice that I skipped a plugboard pair; this can be done in a number of ways but Notice that I skipped a [plugboard
two dots is one. Notice also that it's in a different order than the simulator: pair](https://en.wikipedia.org/wiki/Enigma_machine#Plugboard); this can be done
because with the size restrictions on my entry I saved bytes by using the same in a number of ways but two dots is one. Notice also that it's in a different
loop where I could. It just felt more natural to have them grouped together in a order than the simulator: because with the size restrictions on my entry I saved
configurator for the simulator. bytes by using the same loop where I could. It just felt more natural to have
them grouped together in a configurator for the simulator.
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null ```sh
HQNVO $ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null HQNVO
IOCCC $ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null
IOCCC
```
As you can see the `recode` program prompts for the settings and outputs the
As you can see the recode program prompts for the settings and outputs the
input for the Enigma program. I then copied/pasted that output to the program input for the Enigma program. I then copied/pasted that output to the program
and got the result HQNVO. and got the result `HQNVO`.
Following this I piped the original output (of recode) to the simulator and then Following this I piped the original output (of `recode`) to the simulator and then
piped that to the echo of the input settings (replacing the IOCCC with the piped that to the echo of the input settings (replacing the IOCCC with the
Enigma enciphered output) and then got the result IOCCC: the original input! Enigma enciphered output) and then got the result IOCCC: the original input!
(This was before I implemented the `-R` option to greatly simplify things.) (This was before I implemented the `-R` option to greatly simplify things.)
@@ -273,63 +292,68 @@ the pipeline works with settings etc.
What happens if the plugboard pairs are the same but in a different order? It's What happens if the plugboard pairs are the same but in a different order? It's
the same output: the same output:
$ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null ```sh
HQNVO $ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
```
Also if you flip the order of the letters in the pair e.g. the AB as BA instead: Also if you flip the order of the letters in the pair e.g. the AB as BA instead:
$ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null ```sh
HQNVO $ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
HQNVO
```
# <a name="onlyconfig" href="#toc">Only write config file</a> # <a name="onlyconfig" href="#toc">Only write config file</a>
$ ./recode -v -oconfig -finput >/dev/null ```sh
Rotors: $ ./recode -v -oconfig -finput >/dev/null
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ Rotors:
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE (1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO (2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB (3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK (4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
Input rotor 1 (1 - 5): 1 (5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 2 (1 - 5): 2 Input rotor 1 (1 - 5): 1
Input rotor 3 (1 - 5): 3 Input rotor 2 (1 - 5): 2
Input setting 1 (A - Z): A Input rotor 3 (1 - 5): 3
Input setting 2 (A - Z): C Input setting 1 (A - Z): A
Input setting 3 (A - Z): E Input setting 2 (A - Z): C
Input position 1 (A - Z): B Input setting 3 (A - Z): E
Input position 2 (A - Z): D Input position 1 (A - Z): B
Input position 3 (A - Z): F Input position 2 (A - Z): D
Reflector: Input position 3 (A - Z): F
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT Reflector:
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL (1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
Input reflector (1 - 2): 2 (2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input plugboard pair 1: AB Input reflector (1 - 2): 2
Input plugboard pair 2: CD Input plugboard pair 1: AB
Input plugboard pair 3: EF Input plugboard pair 2: CD
Input plugboard pair 4: GHIJ Input plugboard pair 3: EF
Input plugboard pair 5: IJ Input plugboard pair 4: GHIJ
Input plugboard pair 6: KL Input plugboard pair 5: IJ
Input plugboard pair 7: MN Input plugboard pair 6: KL
Input plugboard pair 8: OP Input plugboard pair 7: MN
Input plugboard pair 9: QR Input plugboard pair 8: OP
Input plugboard pair 10: ST Input plugboard pair 9: QR
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ Input plugboard pair 10: ST
Ring 2: ( II) AJDKSIRUXBLHWTMCQGZNPYFVOE Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
Ring 3: (III) BDFHJLCPRTXVZNYEIWGAKMUSQO Ring 2: ( II) AJDKSIRUXBLHWTMCQGZNPYFVOE
Ring settings: ACE Ring 3: (III) BDFHJLCPRTXVZNYEIWGAKMUSQO
Ring positions: BDF Ring settings: ACE
Reflector: (C) FVPJIAOYEDRZXWGCTKUQSBNMHL Ring positions: BDF
Plugboard pair #01: AB Reflector: (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Plugboard pair #02: CD Plugboard pair #01: AB
Plugboard pair #03: EF Plugboard pair #02: CD
Plugboard pair #04: GH Plugboard pair #03: EF
Plugboard pair #05: IJ Plugboard pair #04: GH
Plugboard pair #06: KL Plugboard pair #05: IJ
Plugboard pair #07: MN Plugboard pair #06: KL
Plugboard pair #08: OP Plugboard pair #07: MN
Plugboard pair #09: QR Plugboard pair #08: OP
Plugboard pair #10: ST Plugboard pair #09: QR
Plugboard pair #10: ST
```
Notice that I redirect stdout to /dev/null so that the config is only written to Notice that I redirect stdout to /dev/null so that the config is only written to
the file config. But also notice that for plugboard pair 4 I typed in `GHIJ` and the file config. But also notice that for plugboard pair 4 I typed in `GHIJ` and
@@ -339,16 +363,17 @@ This is because it consumes input overflow.
It shouldn't be this way for the simulator though because that could cause It shouldn't be this way for the simulator though because that could cause
inconsistent number of characters expected before the text to encipher. inconsistent number of characters expected before the text to encipher.
```sh
$ cat config
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST
$ cat config $ ( cat config ; cat input ) | ./prog - 2>/dev/null
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST LRAVE
$ ( cat config ; cat input ) | ./prog - 2>/dev/null $ ( cat config ; cat input ) | ./prog - 2>/dev/null | ( cat config ; echo LRAVE ) | ./prog - 2>/dev/null
LRAVE IOCCC
$ ( cat config ; cat input ) | ./prog - 2>/dev/null | ( cat config ; echo LRAVE ) | ./prog - 2>/dev/null
IOCCC
```
What if you don't want to worry about having to specify input but just have the What if you don't want to worry about having to specify input but just have the
settings written? You can do that too by either sending a newline or else settings written? You can do that too by either sending a newline or else
@@ -357,112 +382,124 @@ directly type ctrl-d (or whatever you have EOF set to) or give it an empty file.
The following are all equivalent in that they will write to a settings file (the The following are all equivalent in that they will write to a settings file (the
first one will print a newline with the echo but that won't matter): first one will print a newline with the echo but that won't matter):
$ echo | ./recode -r -osettings ```sh
$ echo -n | ./recode -r -osettings $ echo | ./recode -r -osettings
$ > empty $ echo -n | ./recode -r -osettings
$ ./recode -r -osettings < empty $ > empty
$ cat empty | ./recode -r -osettings $ ./recode -r -osettings < empty
$ ./recode -r -osettings $ cat empty | ./recode -r -osettings
^D $ ./recode -r -osettings
^D
```
(Above ^D was not shown but I typed it.) The way it works: if nothing is read (Above ^D was not shown but I typed it.) The way it works: if nothing is read
the buffer remains NULL and so I don't print it but still do print the settings the buffer remains `NULL` and so I don't print it but still do print the settings
file. Actually even if getdelim() fails you're supposed to free the buffer so I file. Actually even if `getdelim()` fails you're supposed to free the buffer so I
set another variable to indicate if it should be printed. set another variable to indicate if it should be printed.
# <a name="reuseconfig" href="#toc">Reusing a configuration</a> # <a name="reuseconfig" href="#toc">Reusing a configuration</a>
$ echo -n|./recode -r -oconfig ```sh
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$ $ echo -n|./recode -r -oconfig
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
$ cat input.txt $ cat input.txt
IOCCC 2020 Enigma simulator example text file IOCCC 2020 Enigma simulator example text file
This is a sentence. This is a sentence.
This is another sentence. This is another sentence.
$ ( cat config ; cat input.txt ) | ./prog - 2>/dev/null > output $ ( cat config ; cat input.txt ) | ./prog - 2>/dev/null > output
$ cat output $ cat output
AAPRT 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra AAPRT 2020 Dkemny tpgnjsjai xpovrgl jvgs wxra
Fytt ly m xyiilaqh. Fytt ly m xyiilaqh.
Ybbp ox dmuzerm oscwgytb. Ybbp ox dmuzerm oscwgytb.
$ ( cat config ; cat output ) | ./prog - 2>/dev/null > io $ ( cat config ; cat output ) | ./prog - 2>/dev/null > io
$ diff io input.txt $ diff io input.txt
$ $
```
Alternatively you can just use the `-R` and `-f` options: Alternatively you can just use the `-R` and `-f` options:
$ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2 ```sh
$ diff output output2 $ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
$ $ diff output output2
$
```
# <a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a> # <a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a>
$ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output ```
Rotors: $ ./recode -finput.txt -oconfig | ./prog - 2>/dev/null > output
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ Rotors:
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE (1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
(3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO (2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
(4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB (3) III: BDFHJLCPRTXVZNYEIWGAKMUSQO
(5) V: VZBRGITYUPSDNHLXAWMJQOFECK (4) IV: ESOVPZJAYQUIRHXLNFTGKDCMWB
Input rotor 1 (1 - 5): 2 (5) V: VZBRGITYUPSDNHLXAWMJQOFECK
Input rotor 2 (1 - 5): 5 Input rotor 1 (1 - 5): 2
Input rotor 3 (1 - 5): 3 Input rotor 2 (1 - 5): 5
Input setting 1 (A - Z): C Input rotor 3 (1 - 5): 3
Input setting 2 (A - Z): O Input setting 1 (A - Z): C
Input setting 3 (A - Z): D Input setting 2 (A - Z): O
Input position 1 (A - Z): E Input setting 3 (A - Z): D
Input position 2 (A - Z): L Input position 1 (A - Z): E
Input position 3 (A - Z): O Input position 2 (A - Z): L
Reflector: Input position 3 (A - Z): O
(1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT Reflector:
(2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL (1) (B) YRUHQSLDPXNGOKMIEBFZCWVJAT
Input reflector (1 - 2): 2 (2) (C) FVPJIAOYEDRZXWGCTKUQSBNMHL
Input plugboard pair 1: TR Input reflector (1 - 2): 2
Input plugboard pair 2: SN Input plugboard pair 1: TR
Input plugboard pair 3: OG Input plugboard pair 2: SN
Input plugboard pair 4: ME Input plugboard pair 3: OG
Input plugboard pair 5: XY Input plugboard pair 4: ME
Input plugboard pair 6: WZ Input plugboard pair 5: XY
Input plugboard pair 7: UV Input plugboard pair 6: WZ
Input plugboard pair 8: AB Input plugboard pair 7: UV
Input plugboard pair 9: CD Input plugboard pair 8: AB
Input plugboard pair 10: FI Input plugboard pair 9: CD
Input plugboard pair 10: FI
$ cat config $ cat config
2CE5OL3DO2TRSNOGMEXYWZUVABCDFI 2CE5OL3DO2TRSNOGMEXYWZUVABCDFI
```
Besides a famous book that I happen to love (who doesn't? Ah, but what is it Besides a famous book that I happen to love (who doesn't? Ah, but what is it
Cody?) there's also a reference to code which I also love (just as all Cody?) there's also a reference to code which I also love (just as all
participants of the IOCCC do). But what matters is the output: participants of the IOCCC do). But what matters is the output:
$ cat output ```sh
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf $ cat output
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf
Jsjy ce v pxdmullo. Jsjy ce v pxdmullo.
Sara tj rtaayak uxfhjcti. Sara tj rtaayak uxfhjcti.
$ ./recode -Rconfig -foutput | ./prog - 2>/dev/null $ ./recode -Rconfig -foutput | ./prog - 2>/dev/null
IOCCC 2020 Enigma simulator example text file IOCCC 2020 Enigma simulator example text file
This is a sentence. This is a sentence.
This is another sentence. This is another sentence.
```
# <a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a> # <a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a>
This is like the above only randomised: This is like the above only randomised:
$ ./recode -r -oconfig|./prog - 2>/dev/null ```sh
IOCCC $ ./recode -r -oconfig|./prog - 2>/dev/null
UGEVP IOCCC
UGEVP
```
Note that I typed in IOCCC and sent EOF (ctrl-d); the settings were written to Note that I typed in IOCCC and sent EOF (ctrl-d); the settings were written to
@@ -470,31 +507,37 @@ the config file (for deciphering later) and then all of it was piped to the
Enigma entry resulting in the line below IOCCC. But let's verify it worked out Enigma entry resulting in the line below IOCCC. But let's verify it worked out
okay: okay:
$ cat config ```sh
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ $ cat config
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ
```
Without having to copy/paste intermediate results: Without having to copy/paste intermediate results:
$ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null ```sh
IOCCC $ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
IOCCC
```
You can also use a string for the `-R` option. I'll use command substitution and You can also use a string for the `-R` option. I'll use command substitution and
actual pasting to demonstrate: actual pasting to demonstrate:
$ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null ```sh
IOCCC $ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
IOCCC
```
# <a name="conclusion" href="#toc">Usage conclusion</a> # <a name="conclusion" href="#toc">Usage conclusion</a>
That should give you an idea of how to use the recode program. I leave it as That should give you an idea of how to use the `recode` program. I leave it as
an exercise to the reader to implement additional features but here are some an exercise to the reader to implement additional features but here are some
ideas of what could be done and how this entry might be used (including that ideas of what could be done and how this entry might be used (including that
delicious challenge). delicious challenge).
# <a name="additions" href="#toc">Example additions</a> # <a name="additions" href="#toc">Example additions</a>
* Add code (to prog.c) that tries to determine possible decipherments based on * Add code (to [prog.c](prog.c)) that tries to determine possible decipherments based on
a given crib (or set of cribs). a given crib (or set of cribs).
# <a name="exampleuses" href="#toc">Example uses</a> # <a name="exampleuses" href="#toc">Example uses</a>
@@ -517,17 +560,19 @@ anyway?
# <a name="cake" href="#toc">Delicious Enigmatic: Double-layered Chocolate Fudge Cake</a> # <a name="cake" href="#toc">Delicious Enigmatic: Double-layered Chocolate Fudge Cake</a>
As I was making the above silly list something occurred to me. My other entries As I was making the above silly list something occurred to me. My [other
this year include a recipe for a wonderful double-layered chocolate fudge cake entry](/2020/ferguson1/prog.c) this year includes a recipe for a wonderful
but why would it not be included in this one too? But then if that's the case double-layered chocolate fudge cake but why would it not be included in this one
why on Earth should it be unscrambled? too? But then if that's the case why on Earth should it be unscrambled?
So this is what I offer: if you take one of the settings below and run the So this is what I offer: if you take one of the settings below and run the
simulator on the file [chocolate-cake.html][] you will have a wonderful simulator on the file [chocolate-cake.html][] you will have a wonderful
chocolate cake recipe (that even my late stepmum who didn't even like chocolate chocolate cake recipe (that even my late stepmum who didn't even like chocolate
loved - it's a speciality of my mum's and they were the best of friends too). If loved - it's a speciality of my mum's and they were the best of friends too). If
you're lazy just go and look at my other entry. Then again if you're lazy you're you're lazy just go and look at the
probably not reading this far! :) [recipe](/2020/ferguson1/chocolate-cake.html) (or
[here](/2020/ferguson1/chocolate-cake.md) if on GitHub) in my other entry. Then
again if you're lazy you're probably not reading this far! :)
The settings is one of the below but a couple questions you might ask yourself: The settings is one of the below but a couple questions you might ask yourself:
@@ -536,13 +581,16 @@ The settings is one of the below but a couple questions you might ask yourself:
2. Is there some other kind of trickery involved here? 2. Is there some other kind of trickery involved here?
I can think of the best way to answer these and I think I need not even mention I can think of the best way to answer these and I think I need not even mention
it. Have fun and enjoy! BTW: Depending on where you are in this world and how it. Have fun and enjoy!
warm it is the icing can be a bit of an issue - I give some ideas in the file on
what can be done for this. At worst though the icing won't come out as good as BTW: Depending on where you are in this world and how warm it is the icing can
it usually does. be a bit of an issue - I give some ideas in the file on what can be done for
this. At worst though the icing won't come out as good as it usually does.
That's assuming you follow in the instructions exactly as they are; it's a very
picky recipe.
Hints: ## Hints:
1. It's not the middle one. 1. It's not the middle one.
@@ -557,6 +605,7 @@ this way? (I think the second answer is 'no' but that's me.)
4. The above points might or might not be relevant. What is relevant is one 4. The above points might or might not be relevant. What is relevant is one
will reveal a wonderful [Double-layered Chocolate Fudge Cake][] recipe: will reveal a wonderful [Double-layered Chocolate Fudge Cake][] recipe:
```
142CHOCOLATESVCAKESTBJLKMUMVWX 142CHOCOLATESVCAKESTBJLKMUMVWX
0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI 0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI
3UY0XF4QG1GTJQLARPKHBEMCOFVUIN 3UY0XF4QG1GTJQLARPKHBEMCOFVUIN
@@ -573,7 +622,7 @@ will reveal a wonderful [Double-layered Chocolate Fudge Cake][] recipe:
4MU1MS3CA0KECHOLATBJSNPXVUFGZY 4MU1MS3CA0KECHOLATBJSNPXVUFGZY
4VW0SL1YB0IYJSLBECKTNAXGPUVHRF 4VW0SL1YB0IYJSLBECKTNAXGPUVHRF
0MC4OH2CO1LATEUMBJCDFGHINOPRQS 0MC4OH2CO1LATEUMBJCDFGHINOPRQS
```
BTW: What's the middle of a list with even numbered items anyway? BTW: What's the middle of a list with even numbered items anyway?