Add 2012/grothe/try.sh + format/typo checks
And since the try.sh scrambles and descrambles a cookie recipe I will offer this funny story from decades ago that my mum tells every so often: my uncle, who lived with my parents, and my father were at home and they made 12 dozen cookies. They called my mum at her work and told her: we made twelve dozen cookies and we saved you one! My mum thought they meant she saved them one dozen cookies, already suggesting they had eaten too many. But no. They left her one cookie! The reason is they couldn't get the milk and cookies balanced so the only obvious thing to do was to eat 143 cookies. Obviously. They were quite sick and nobody was sympathetic to their ridiculous stunt. So let that be a lesson to anyone who decides they want to eat 143 cookies: just eat 142 and you'll be just fine, weight gain notwithstanding! :-) (Okay maybe keep it at 24 .. unless they're chocolate in which case you might want to eat three, four, five, however many dozen you can fit in your stomach.) Only the last paragraph is not sincere. The first really did happen.
This commit is contained in:
1 parent
b79a7c1079
commit
75ac0752ed
9 files changed
+65
-21
No files matched your search
+23
-19
@@ -48,7 +48,7 @@ Had it not been, this entry would have been rejected in round 0.
|
||||
The judges also took some liberty obfuscating this entry a little more.
|
||||
|
||||
How does this entry work? The only place multiplication is used is
|
||||
to perform the `atoi()` conversion.
|
||||
to perform the `atoi(3)` conversion.
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
@@ -57,27 +57,27 @@ to perform the `atoi()` conversion.
|
||||
|
||||
This program implements a version of [Shamir's Secret
|
||||
Sharing](http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing). Shamir's Secret
|
||||
Sharing allows you to encrypt a file into N parts where it will take M parts to
|
||||
Sharing allows you to encrypt a file into `N` parts where it will take `M` parts to
|
||||
recreate the original file. E.g. you can split the secret recipe for Crystal Pepsi
|
||||
into 3 parts and require two of them be available to extract the original recipe.
|
||||
|
||||
Actually surprisingly useful for an IOCCC entry :-)
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
To share a secret.
|
||||
To share a secret. For example:
|
||||
|
||||
E.g.
|
||||
- File to share: [cookie_recipe.txt](cookie_recipe.txt).
|
||||
- Number of pieces: 2 + file to be shared
|
||||
- Total number of pieces created by program: 4
|
||||
- Pieces needed to reassemble recipe: 3 or greater
|
||||
|
||||
File to be shared - [cookie_recipe.txt](cookie_recipe.txt).
|
||||
number of pieces - 2 + file to be shared
|
||||
total number of pieces created by program 4
|
||||
pieces needed to reassemble recipe 3 or greater
|
||||
|
||||
### Example usage
|
||||
|
||||
To split a secret into 4 pieces of which at least 3 will be needed to get it (in
|
||||
this case a recipe) back:
|
||||
this case the cookie recipe) back:
|
||||
|
||||
```sh
|
||||
./grothe \
|
||||
@@ -86,7 +86,7 @@ this case a recipe) back:
|
||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
||||
```
|
||||
|
||||
To put recipe back together using the first, second and fourth pieces:
|
||||
To put the recipe back together using the first, second and fourth pieces:
|
||||
|
||||
```sh
|
||||
./grothe \
|
||||
@@ -94,6 +94,7 @@ To put recipe back together using the first, second and fourth pieces:
|
||||
+cookie_recipe_restore.txt
|
||||
```
|
||||
|
||||
|
||||
### Limitations
|
||||
|
||||
The program is limited to 256 input and output files and will slow down
|
||||
@@ -101,34 +102,37 @@ dramatically when you get past 20-50 inputs and outputs.
|
||||
|
||||
### Obfuscations
|
||||
|
||||
* nothing is done consistently throughout the program E.g `i+=1`, `i=i+1`, `i++`
|
||||
* Nothing is done consistently throughout the program E.g `i+=1`, `i=i+1`, `i++`
|
||||
and `++i` are all used in the program. The mark of true code buggery: "A
|
||||
foolish consistency is the hobgoblin of little minds." - [Ralph Waldo
|
||||
Emerson](https://en.wikipedia.org/wiki/Ralph_Waldo_Emerson)
|
||||
|
||||
* uses the most powerful obfuscation of all "Math". "Any sufficiently advanced
|
||||
* Uses the most powerful obfuscation of all "Math". "Any sufficiently advanced
|
||||
cryptography is indistinguishable from magic." - Apologies to [Arthur C.
|
||||
Clarke](https://en.wikipedia.org/wiki/Arthur_C._Clarke)
|
||||
|
||||
* shadows variables by using brackets in main program to create local copies of
|
||||
* Shadows variables by using brackets in main program to create local copies of
|
||||
variables that are the same as global scope variables. `-Wshadow` should
|
||||
probably be a part of `-Wall` in gcc.
|
||||
|
||||
* uses `array_index[array_name]` instead of `array_name[array_index]` in several
|
||||
* Uses `array_index[array_name]` instead of `array_name[array_index]` in several
|
||||
places. Still don't know why C continues to allow this (error strings are
|
||||
encoded with offsets that are also used to select them in the case statement.
|
||||
All strings are located in one function for easy localization).
|
||||
|
||||
* liberal use of octal numbers, hexadecimal numbers and regular decimal numbers
|
||||
throughout program.
|
||||
* Liberal use of octal numbers, hexadecimal numbers and regular decimal numbers
|
||||
throughout the program.
|
||||
|
||||
* variables and function names are semi-random and upper and lower case characters are used
|
||||
* use of `#define`s from `stdio.h`, `stdlib.h` for values `_STDIO_H` and
|
||||
* Variables and function names are semi-random and upper and lower case
|
||||
characters are used.
|
||||
|
||||
* Use of `#define`s from `stdio.h`, `stdlib.h` for values `_STDIO_H` and
|
||||
`EXIT_SUCCESS` used to represent 1 and 0 respectively in the program.
|
||||
|
||||
* arrays only need to be 256x256 but most are set to greater values than they
|
||||
* Arrays only need to be 256x256 but most are set to greater values than they
|
||||
need to be so trying to figure it out can be a bit tough.
|
||||
|
||||
|
||||
### References
|
||||
|
||||
* David Madore's implementation of Shamir's Secret Sharing - <http://www.madore.org/~david/programs/programs-1.36.html>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,7 @@ n;}}void X(int v,int u){char*y=0;v-=1;switch(v){case(0x2):y ="HckngfVqQrgpKprwv"
|
||||
"Hkng"; BC(4):y="JempihXsStirMrtyxJmpi"; BC(0):y="PointValueTooLarge"; BC 0x1:y=
|
||||
"EvqmjdbufJoqvuQpjou";BC(6):y="TuOtv{zLorky";BC(3):y="WrrPdq|RxwsxwSrlqwv";BC(5)
|
||||
:y="GfiFwlzrjsyX~syf}"; BC(07):y="UvV|{w|{Mpslz";}if(u)exit(0); f(y,v);exit(1);}
|
||||
int main(int t,const char*T[]){for(i=00;i<0x100;++i)for(j=0;j<=i;++j)if(1==y(i,j
|
||||
int main(int t, char *T[]){ for (i=00;i<0x100;++i) for (j=0;j<=i;++j)if(1==y(i,j
|
||||
))W[i]=j,W[j]=i;for(k=0x1;k<t;k++){p=0;for(l=0;(T[k][l]>=toupper('0'))&&(T[k][l]
|
||||
<=tolower('9'));l++){p=p*10+(T[k][l]-'0');if(p>=256)X(1,0);}if(T[k][l]=='-'){for
|
||||
(m=0;m<u;m++)if(q[m]==p)X(2,0);q[u]=p;J[u]=T[k]+l+1;K[u]=fopen(J[u],"r");if(!u[K
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2000/tomx
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
read -r -n 1 -p "Press any key to break recipe into crumbs: "
|
||||
echo 1>&2
|
||||
echo "$ ./grothe -cookie_recipe.txt 1-/dev/urandom 2-/dev/urandom \\
|
||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat"
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to restore cookie recipe: "
|
||||
echo 1>&2
|
||||
echo "$ ./grothe 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat +cookie_recipe_restore.txt" 1>&2
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to show that the two files are the same: "
|
||||
echo 1>&2
|
||||
diff -s cookie_recipe.txt cookie_recipe_restore.txt
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to see the recipe file, restored: "
|
||||
echo 1>&2
|
||||
cat cookie_recipe_restore.txt
|
||||
+8
-1
@@ -3372,7 +3372,14 @@ Cody also fixed a typo in the ruby script
|
||||
|
||||
## [2012/grothe](2012/grothe/grothe.c) ([README.md](2012/grothe/README.md))
|
||||
|
||||
[Cody](#cody) restored the original code from the archive.
|
||||
[Cody](#cody) added the [try.sh](2012/grothe/try.sh) script.
|
||||
|
||||
Cody also changed `argv` to be not `const char **` but `char **`, mostly out of an
|
||||
abundance of caution in case clang, which already imposes restrictions on the
|
||||
types of args to `main()` including to do with `char **`, decides to further
|
||||
restrict them.
|
||||
|
||||
Cody also restored the original code from the archive.
|
||||
|
||||
|
||||
## [2012/hamano](2012/hamano/hamano.c) ([README.md](2012/hamano/README.md]))
|
||||
|
||||
Reference in new issue
Block a user