Merge pull request #1639 from xexyl/vik14

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-12-05 18:50:47 -08:00
commit 65f67ce581
5 files changed
+89 -16

No files matched your search

+4
View File
@@ -1,2 +1,6 @@
prog prog
prog.orig prog.orig
hello.c
hello
ioccc.c
ioccc
+7 -4
View File
@@ -32,6 +32,7 @@ in the DNA code of the code? Perhaps there are 23 reasons? :-)
## Author's remarks: ## Author's remarks:
### Remarks ### Remarks
This chromosome program synthesizes a double helix. This chromosome program synthesizes a double helix.
@@ -39,14 +40,16 @@ The helix can also be compiled as a C program.
Enjoy DNA programming! Enjoy DNA programming!
### For more information / backgroud reading:
### For more information / background reading:
* This program was inspired by Acme::DoubleHelix: * This program was inspired by Acme::DoubleHelix:
http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/ <http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/>
* The synthesized helix just includes the original program at the head. * The synthesized helix just includes the original program at the head.
Do you see how `prog.c` determines whether it was invoked as a standalone program or included as a header file? Do you see how [prog.c](prog.c) determines whether it was invoked as a
Note that it does not use any gcc extension such as `__INCLUDE_LEVEL__`. standalone program or included as a header file? Note that it does not use any
gcc extension such as `__INCLUDE_LEVEL__`.
* The synthesized helix of course follows the base-pairing rules for DNA: * The synthesized helix of course follows the base-pairing rules for DNA:
A is bonding only to T, and C is bonding only to G. A is bonding only to T, and C is bonding only to G.
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2014/endoh2
#
# 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
# clear screen after compilation so that only the entry is shown
clear
read -r -n 1 -p "Press any key to run: echo Hello | ./prog: "
echo 1>&2
echo Hello | ./prog
echo 1>&2
read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog: "
echo 1>&2
echo IOCCC | ./prog
echo 1>&2
read -r -n 1 -p "Press any key to run: echo Hello | ./prog > hello.c: "
echo 1>&2
echo Hello | ./prog > hello.c
echo 1>&2
read -r -n 1 -p "Press any key to compile hello.c: "
echo 1>&2
make hello >/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./hello: "
./hello
echo 1>&2
read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog > ioccc.c: "
echo 1>&2
echo IOCCC | ./prog > ioccc.c
echo 1>&2
read -r -n 1 -p "Press any key to compile ioccc.c: "
echo 1>&2
make ioccc >/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./ioccc: "
echo 1>&2
./ioccc
+21 -12
View File
@@ -4,6 +4,10 @@
make make
``` ```
There is an alternate version that will theoretically work with Windows
compilers (if anything in Windows works :-) ). See the [Alternate
code](#alternate-code) section below.
### Bugs and (Mis)features: ### Bugs and (Mis)features:
@@ -22,10 +26,6 @@ For more detailed information see [2014 vik in bugs.md](/bugs.md#2014-vik).
./prog > foo.c ./prog > foo.c
``` ```
There is an alternate version that will theoretically work with Windows
compilers (if anything in Windows works :-) ). See the [Alternate
code](#alternate-code) section below.
### Try: ### Try:
@@ -39,13 +39,19 @@ echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
## Alternate code: ## Alternate code:
The alternate code, [prog.alt.c](prog.alt.c), is based on the author's The alternate code, [prog.alt.c](prog.alt.c), is based on the author's
instructions on how to get it to work with Windows. This has not been tested but instructions on how to get it to work with Windows.
in order to use it you can do:
### Alternate build:
```sh ```sh
make alt make alt
``` ```
### Alternate use:
Use `prog.alt` as you would `prog` above as well as below. Use `prog.alt` as you would `prog` above as well as below.
@@ -70,15 +76,16 @@ might help? :-)
## Author's remarks: ## Author's remarks:
### Remarks ### Remarks
This program converts ascii text to Morse audio file and vice versa. As far as This program converts ASCII text to Morse audio file and vice versa. As far as
I can tell, there are at least six chocolate references in this program. I can tell, there are at least six chocolate references in this program.
This program can convert text to Morse to a raw 44.1kHz stereo audio file. This program can convert text to Morse to a raw 44.1kHz stereo audio file.
Via streaming to mplayer, you can listen to the Morse audio. Via streaming to `mplayer(1)`, you can listen to the Morse audio.
Don't forget the last '`-`' as it makes mplayer read from stdin. Don't forget the last '`-`' as it makes `mplayer(1)` read from `stdin`.
## Convert audio file with Morse signals to text ## Convert audio file with Morse signals to text
@@ -92,14 +99,15 @@ or alternatively pass a .wav file as input.
The preferred input format 44.1kHz stereo, but it does a decent job on mono The preferred input format 44.1kHz stereo, but it does a decent job on mono
input and different frequencies as well. input and different frequencies as well.
### Portability ### Portability
The program is portable to most platforms. The only system dependency is that The program is portable to most platforms. The only system dependency is that
the program relies on writing binary data to stdout. the program relies on writing binary data to `stdout`.
Microsoft compilers add a carriage return to newlines, and to compile the Microsoft compilers add a carriage return to newlines, and to compile the
program with this platform, the following line can be added after the main program with this platform, the following line can be added to `main()` before
declaration in order for the program to run correctly: any code in order for the program to run correctly:
```c ```c
_setmode(_fileno(stdout), 0x8000); _setmode(_fileno(stdout), 0x8000);
@@ -107,6 +115,7 @@ _setmode(_fileno(stdout), 0x8000);
NOTE: see the [alternate code](prog.alt.c) for this. NOTE: see the [alternate code](prog.alt.c) for this.
### Known Issues ### Known Issues
The program uses a quite simple algorithm for detecting tone on and off events The program uses a quite simple algorithm for detecting tone on and off events
+5
View File
@@ -3705,6 +3705,11 @@ file to [spoilers.md](2014/endoh1/spoilers.md) to be clearer in its purpose as
it is a file with spoilers (and too close to README.md?). it is a file with spoilers (and too close to README.md?).
## [2014/endoh2](2014/endoh2/prog.c) ([README.md](2014/endoh2/README.md]))
[Cody](#cody) added the [try.sh](2014/endoh2/try.sh) script.
## [2014/maffiodo1](2014/maffiodo1/prog.c) ([README.md](2014/maffiodo1/README.md])) ## [2014/maffiodo1](2014/maffiodo1/prog.c) ([README.md](2014/maffiodo1/README.md]))
[Cody](#cody) fixed the build for this entry: it does not require [Cody](#cody) fixed the build for this entry: it does not require