diff --git a/2011/borsanyi/README.md b/2011/borsanyi/README.md index 9a35b9cd4..c0fb94900 100644 --- a/2011/borsanyi/README.md +++ b/2011/borsanyi/README.md @@ -4,6 +4,16 @@ make ``` +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2011 borsanyi in bugs.md](/bugs.md#2011-borsanyi). + ## To use: @@ -15,9 +25,7 @@ make ### Try: ```sh -./borsanyi < data.1 -./borsanyi < data.2 -./borsanyi < data.3 +./try.sh ``` @@ -27,7 +35,8 @@ This is a nice quick [histogram](https://en.wikipedia.org/wiki/Histogram) plotter. A useful utility when you need to look at the distribution of some data. -Here are some challenges: + +### Challenges: You can modify the number of histogram [bins](https://en.wikipedia.org/wiki/Data_binning) and the scaling of the @@ -38,7 +47,7 @@ histogram bins is missing. The source contains no arrays and it does not use `malloc(3)` or `alloca(3)`. How does it build the histogram? While the input does not need to be sorted, the histogram output is sorted. -How does it put the data into buckets? Why does it `fork()` 22 times? +How does it put the data into buckets? Why does it `fork(2)` 22 times? ## Author's remarks: @@ -49,6 +58,7 @@ histogram. I am all too often logged in to a remote machine with slow X connection, and a terminal-based program would be of great help. + ### Limitations * I optimized the output for the data I had around, you might want to adjust @@ -62,6 +72,7 @@ great help. * Could rounding errors cause the omission of the highest bin? There might be empty bins at the edges. + ### Obfuscation * The program follows a rather unconventional approach to the task diff --git a/2011/borsanyi/borsanyi.c b/2011/borsanyi/borsanyi.c index 3de4f4a68..f3cea48b9 100644 --- a/2011/borsanyi/borsanyi.c +++ b/2011/borsanyi/borsanyi.c @@ -8,5 +8,5 @@ t )/22,s= pow(10, (int)( log10(a)) /*It is a simple tool to quickly analyze data. */ - 2),s=t- (a =s*( int)(a/s ))/2,p(t, s,(int)( ( a+M-t)/ a)):p(t >M|xM|x >M?x:M ,--n)+(x -> s&&x <= s+a); } main(j){ j==1?j=p (1,0,0) ,printf( -"%+12g %4d",s+a/2,j,wait(NULL)),main(j*400/n):putchar(35-25*!j)&' '&&main(j+1);} +> s&&x <= s+a); } main(j,k)char**k;{ j==1?j=p (1,0,0) ,printf( +"%+12g %4d",s+a/2,j,wait(NULL)),main(j*400/n,k):putchar(35-25*!j)&' '&&main(j+1,k);} diff --git a/2011/borsanyi/try.sh b/2011/borsanyi/try.sh new file mode 100755 index 000000000..f5b2b4d7e --- /dev/null +++ b/2011/borsanyi/try.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2011/borsanyi +# + +# 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: ./borsanyi < data.1: " +./borsanyi < data.1 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./borsanyi < data.2: " +./borsanyi < data.2 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./borsanyi < data.3: " +./borsanyi < data.3 diff --git a/bugs.md b/bugs.md index 075810964..5dbe203fb 100644 --- a/bugs.md +++ b/bugs.md @@ -2435,6 +2435,31 @@ There was no IOCCC in 2010. # 2011 +## 2011 dlowe + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2011/borsanyi/borsanyi.c](2011/borsanyi/borsanyi.c) +### Information: [2011/borsanyi/README.md](2011/borsanyi/README.md) + +For a great amount of data points the program will crash, depending on your +available stack space. + +Giving too few (distinct) points can also cause a crash or division by zero. + +The program expects plain numbers separated by whitespace. + +This program assumes ASCII. + +If you give the program any arg it might flood the screen. + +It requires both syscalls `fork(2)` and `wait(2)`. + +Giving any arg to the program is likely to flood your screen. + +Rounding errors might cause an omission in the highest bin. There might be empty +bins at the edges. + + ## 2011 dlowe ### STATUS: missing or dead link - please provide them @@ -2462,6 +2487,7 @@ tends to result in empty output. If you want to try and fix this (mis)feature, you are welcome to try. + ## 2011 richards ### STATUS: doesn't work with some platforms - please help us fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index acb9bd3e1..688d9d332 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3215,6 +3215,15 @@ have been a problem in linux with the old `int`s but this is no longer known. # 2011 +## [2011/borsanyi](2011/borsanyi/borsanyi.c) ([README.md](2011/borsanyi/README.md])) + +Cody, out of an abundance of caution, added a second arg to `main()` as some +versions of clang complain about not only the type of each arg to `main()` but +the number of args as well. + +Cody also added the [try.sh](2011/borsanyi/try.sh) script. + + ## [2011/goren](2011/goren/goren.c) ([README.md](2011/goren/README.md])) Cody fixed this for macOS. Before the fix it segfaulted. It worked fine under