Merge pull request #1026 from xexyl/2013-dlowe-updates

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-10-11 13:17:20 -07:00
commit f6b5a4919d
7 files changed
+96 -12

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
dlowe
dlowe.orig
fun
prog.orig
sparkl
+4 -1
View File
@@ -109,7 +109,7 @@ PROG= ${ENTRY}
#
OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
TARGET= ${PROG} sparkl fun
#
ALT_OBJ=
ALT_TARGET=
@@ -129,6 +129,9 @@ all: data ${TARGET}
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
sparkl: ${PROG}
${LN} -sf ${PROG} $@
# alternative executable
#
alt: data ${ALT_TARGET}
+52 -11
View File
@@ -22,11 +22,23 @@ make
```sh
./dlowe 0 1 2 3 4 5 6 7
./dlowe 16 32 64 128
./dlowe 16 32 64 128 256
./dlowe 16 32 64 128 256 512
echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./slen.sh
echo sparkline of file sizes: `wc -c * | awk '{print $1}' | xargs ./dlowe`
./dlowe 0
```
## 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 +46,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 +57,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 +124,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 +133,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
+5
View File
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
}
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "sparkline of file lengths: $(wc -c ./* | awk '{print $1}' | xargs ./sparkl)"
+13
View File
@@ -1840,6 +1840,19 @@ The file is `hd.img`.
Do you have it? Please provide it!
## [2013/dlowe](2013/dlowe/dlowe.c) ([README.md](2013/dlowe/README.md))
## STATUS: INABIAF - please **DO NOT** fix
This program will very likely crash or draw something strange with 0 args. Then
again it might not. :-) This is easy to fix but would add bytes and since the
author noted it is a feature and not a bug. You of course can try and fix it
yourself but please do NOT open a pull request for this: just do it as an
exercise to see if you understand the code.
You can try and answer the questions, too: when will it crash? When will it draw
something funny (or will it? :-) ) and when will it just do nothing?
# 2014
+17
View File
@@ -1610,6 +1610,23 @@ Finally Cody provided the [bios.asm](2013/cable3/bios.asm) that the author
referred to, found at the [GitHub repo for the
entry](https://github.com/adriancable/8086tiny/tree/master).
## [2013/dlowe](2013/dlowe/dlowe.c) ([README.md](2013/dlowe/README.md))
Cody added the source code that we suggested one should compile and run with
different compilers as [fun.c](2013/dlowe/fun.c). He modified the Makefile so
that running `make all` will compile it, saving you the effort.
He also provided the script [slen.sh](2013/dlowe/slen.sh) which is based on the
author's remarks, giving a script that shows the spark line of the file lengths
(as in `wc -c`), fixing it for shellcheck. These fixes were applied in the
author's remarks as well.
Since the author called the program `sparkl` Cody modified the Makefile so that
running `make all` will create a symlink to `dlowe` as `sparkl`. Running `make
clobber` will delete both and running `make clobber all` will ensure that the
symlink is created.
## [2013/hou](2013/hou/hou.c) ([README.md](2013/hou/README.md))
After the file 2013/hou/doc/example.markdown was moved to