Updates and fixes to 2013/dlowe
Added fun.c and make make all compile it: this is what the judges suggested one try compiling with different compilers and checking the results. I added how to specify the compiler. Added slen.sh script, corrected for shellcheck, which runs the command the author suggested (and which the judges added to their remarks), to make it simpler for viewers of the entry. Added INABIAF section to README.md: if no args are specified it will very likely crash or do something funny. A similar such thing is in bugs.md as well. Updated .gitignore. Format fix README.md.
This commit is contained in:
1 parent
856dd9dced
commit
66e54fac9b
8 files changed
+146
-13
No files matched your search
+79
-12
@@ -22,11 +22,49 @@ make
|
||||
```sh
|
||||
./dlowe 0 1 2 3 4 5 6 7
|
||||
./dlowe 16 32 64 128
|
||||
|
||||
echo sparkline of file sizes: `wc -c * | awk '{print $1}' | xargs ./dlowe`
|
||||
./dlowe 16 32 64 128 256
|
||||
./dlowe 16 32 64 128 256 512
|
||||
./dlowe 0
|
||||
|
||||
echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./slen.sh
|
||||
```
|
||||
|
||||
Alternatively, for the lazy or those short on time, try:
|
||||
|
||||
```sh
|
||||
./demo.sh
|
||||
```
|
||||
|
||||
What is different about the above if you do something like:
|
||||
|
||||
```sh
|
||||
echo 'IOCCC 2013' > ioccc.txt
|
||||
./demo.sh
|
||||
rm -f ioccc.txt
|
||||
```
|
||||
|
||||
?
|
||||
|
||||
To make it simpler to see try showing just the last two lines:
|
||||
|
||||
```sh
|
||||
./demo.sh | tail -n 2 > 1.txt
|
||||
echo 'IOCCC 2013' > ioccc.txt
|
||||
./demo.sh | tail -n 2 > 2.txt
|
||||
rm -f ioccc.txt
|
||||
diff 1.txt 2.txt
|
||||
rm 1.txt 2.txt
|
||||
```
|
||||
|
||||
## INABIAF - it's not a bug it's a feature! :-)
|
||||
|
||||
This program will very likely crash or draw something funny with 0 args. Then
|
||||
again it might not. :-) This is not a bug and should NOT be fixed.
|
||||
|
||||
Ask yourself the following questions: when will it crash, when will it draw
|
||||
something funny (or will it ? :-) ) and when will it do nothing?
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
We liked how this entry used Unicode, specifically UTF-8, in a somewhat obfuscated way.
|
||||
@@ -34,7 +72,7 @@ We liked how this entry used Unicode, specifically UTF-8, in a somewhat obfuscat
|
||||
Also, why doesn't it crash, and produces a correct output when called with one argument
|
||||
or when all arguments are equal?
|
||||
|
||||
For extra fun, compile and run
|
||||
For extra fun, compile and run [fun.c](fun.c):
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
@@ -45,37 +83,66 @@ int main() {
|
||||
|
||||
with gcc and clang.
|
||||
|
||||
|
||||
With GCC (4.7.2), we get
|
||||
|
||||
-2147483648 -2147483648 -2147483648
|
||||
```
|
||||
-2147483648 -2147483648 -2147483648
|
||||
```
|
||||
|
||||
and with clang (3.3), we get
|
||||
|
||||
-2147483648 0 2147483647
|
||||
```
|
||||
-2147483648 0 2147483647
|
||||
```
|
||||
|
||||
and with Apple clang version 15.0.0 (clang-1500.0.40.1) we get:
|
||||
|
||||
```
|
||||
1840985120 -2033041452 35979112
|
||||
```
|
||||
|
||||
Which one is correct? :)
|
||||
|
||||
NOTE: `make all` will compile [fun.c](fun.c) but to provide a different compiler
|
||||
you can do something like:
|
||||
|
||||
|
||||
```sh
|
||||
make CC=clang fun
|
||||
```
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
### sparkl
|
||||
|
||||
A tiny implementation of command-line 'sparkline' data visualization.
|
||||
A tiny implementation of command-line
|
||||
[sparkline](https://en.wikipedia.org/wiki/Sparkline) data visualization.
|
||||
|
||||
### Synopsis
|
||||
|
||||
```sh
|
||||
$ sparkl 0 1 2 3 4 5 6 7
|
||||
$ ./sparkl 0 1 2 3 4 5 6 7
|
||||
▁▂▃▄▅▆▇▉
|
||||
|
||||
$ echo sparkline of file lengths: `wc -c * | awk '{print $1}' | xargs sparkl`
|
||||
$ echo "sparkline of file lengths: $(wc -c * | awk '{print $1}' | xargs ./sparkl)"
|
||||
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
|
||||
```
|
||||
|
||||
NOTE: this has been provided in [slen.sh](slen.sh) so you can try:
|
||||
|
||||
```sh
|
||||
./slen.sh
|
||||
```
|
||||
|
||||
instead.
|
||||
|
||||
### Description
|
||||
|
||||
This is a handy little tool for visualizing numeric series from the
|
||||
command-line, using 'sparklines'. Pass it a numeric series as arguments, and
|
||||
sparkl will display a sparkline graph, which you can use to very quickly get a
|
||||
command line, using sparklines. Pass it a numeric series as arguments, and
|
||||
`sparkl` will display a sparkline graph, which you can use to very quickly get a
|
||||
sense of the shape of your data.
|
||||
|
||||
### Limitations
|
||||
@@ -83,7 +150,7 @@ sense of the shape of your data.
|
||||
* Crashes with 0 arguments. It'd be trivial to fix, but adds a few bytes to the
|
||||
code.
|
||||
* Produces bogus graphs when given > about 5000 arguments.
|
||||
* Only works if your terminal is utf-8 and your font supports the 8 glyphs
|
||||
* Only works if your terminal is UTF-8 and your font supports the 8 glyphs
|
||||
used.
|
||||
* Produces a few harmless compiler warnings.
|
||||
|
||||
@@ -92,7 +159,7 @@ sense of the shape of your data.
|
||||
The code is very terse. I was torn between submitting this version, and a
|
||||
one-line version compressed using a couple more -D flags.
|
||||
|
||||
Hand-rolled utf-8 sequence, magic numbers (what's that 7 for?), meaningless
|
||||
Hand-rolled UTF-8 sequence, magic numbers (what's that 7 for?), meaningless
|
||||
variable names, reused variables, and so on.
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Reference in new issue
Block a user