..59.43.. 4.87..... .1..8.... 2..63..5. .5.....3. .8..41..6 ....7..2. .....56.7 ..12.34..with a dot representing an unsolved square, and the result coming out of the standard output. The algorithm works as follows:
Edit: Apparently there's a bug and it can't solve some puzzles.
Download: sedoku.sed
You know the song 10 green bottles, and the 99 bottle version commonly song on very long school coach journey's (much to the chagrin of the driver)?
99 Green bottles hanging on the wall 99 Green bottles hanging on the wall And if one green bottle should accidentally fall... 98 Green bottles hanging on the wall
...and so on.
Well, here is a sed program which will print it out, using either numbers or the names of numbers.
I did this to see if sed was Turing complete. BrainF!@k is a minimalist
structured language, and it happens to be Turing complete. So if sed can
interpret BF programs, then it too must be Turing complete. And it is. The
interpreter can only cope with a maximum of 255 loops in the program (it could
be adapted to do more, but probably won't be).
Download: brainf__k.sed
s/^$/c_00/ :loop #Advance the number counter: #Advance both numbers h y/0123456789/1234567890/ x G #Keep the 10s only if we've ended in 0 s/...._[0-9]*\([0-9]\)0$/\10/ s/..._[0-9]*\([1-9]\)$/\1/ #Advance the Fizz counter y/abc/bca/ #Check the fizz and buzz counters and write #out appropriate text h s/c.*/&Fizz/ /[0-9][50]/s/$/Buzz/ s/[^z]*\(..zz.*\)/\1/ s/[abc]_0\?// p x /00/!bloop D q
If you're interested in sed, I can recommend the following sites:
If you're interested in advanced sed hackery, then the most impressive programs are:Updated March 27th 2013, 05:58
Home :
Programs
|
libCVD
|
Hardware hacks
|
Publications
|
Teaching
|
TooN
|
Research
* Programs :
EPS to ARTK
|
Autoconf tutorial
|
Awk
|
Numerical Disasters in C
|
Floating point templates in C++
|
Gnokiifs
|
Parallel
|
PostScript
|
Sed Hacking
|
X11 programs
ed (at) edwardrosten . com
Check HTML compliance