Snippet Archives

Software Archives / Text Archives

Dragon Curve in PostScript

Just a few lines for trying out L-systems.

Download the source code, or see the PDF version.

Last update: 2017.06.21.

Snake Cube in Prolog

Brute force solution of the snake cube problem in Prolog, loosely based on a Haskell pearl article. My version also features puzzle generation (and Japanese output).

Download the source code, or see the htmlized version.

Last update: 2016.06.18.

Yavalath Board

Printable board for the computer-generated board game Yavalath. Rules: like gomoku, but a row of 3 loses, a row of 4+ wins. For 3 players, you have to obstruct the win of the next player, if possible.

Download the board in PDF, or in EPS, where you can tweak its parameters.

Last update: 2016.05.12.

Combinatory Logic

A basic evaluator for CL and its meta-language, as described in "Lambda-Calculus and Combinators: An Introduction" (Hindley & Seldin).

Download the source code, or see the htmlized version.

Last update: 2016.05.09.

Dice Probability Computations

A small program calculating the probability that throwing an n-sided die m times will result in a sum larger/smaller than a given value.

Download the source code, or see the htmlized version.

I have also translated the code to PicoLisp as an exercise.

Last update: 2016.02.06.

Age & Weight

A few lines computing the age of my daughter (in days), and displaying a graph of weight vs. age, using Gnuplot.

Download the source code, or see the htmlized version.

Last update: 2016.01.05.

2D Class A Curves

Actually there are two projects. One is about interpolating one curve segment, which can be a Class A Bézier curve or a logarithmic aesthetic curve (or LAC), the other is about interpolating points with a discrete clothoid spline. The former is written in Racket, like before, but the latter is written in Julia, in an attempt to try to create something non-trivial in it.

Clone the repository with Mercurial (Bézier & LAC):

hg clone http://bitbucket.org/salvipeter/class-a-curves/

Clone the repository with Git (discrete clothoid):

git clone https://github.com/salvipeter/discrete-clothoids.git
Last update: 2015.11.10.

SICP in Common Lisp

These are my translations of the SICP sample codes to Common Lisp, along with my solutions to the exercises. The file can be loaded in any CL compiler (provided that there is LISPBUILDER-SDL and BORDEAUX-THREADS). The solutions to the exercises can be hidden by an Emacs-Lisp snippet at the end of the file.

Clone the repository with Mercurial:

hg clone http://bitbucket.org/salvipeter/sicp/
Last update: 2015.10.06.

Lyapunov Fractals

The Tinkertoy Computer has a chapter on Lyapunov fractals - they look pretty amazing, so I fired up my REPL and here are the results: Lyapunov space, jellyfish, and Zircon Zity.

Download the source code, or see the htmlized version.

Last update: 2015.09.02.

ErBi Input Method

This started as a conversion of SCIM's ErBi input method, but I've soon realized that I didn't really like that version, so this is a somewhat simplified variant, without multi-character combinations, but almost all keys are mapped to different codes.

There is short introduction to this input method (both in Hungarian and in English), there is the list of codes, an Emacs quail package, and even web page where you can try it out for yourself.

I've also created a fork of my WuBi practice project; you can find it on BitBucket:

hg clone http://bitbucket.org/salvipeter/erbi-practice/
Last update: 2015.08.29.

Typesetting Hindi IPA Symbols in LaTeX

This snippet started as a memo on how to typeset the IPA symbols for the Hindi/Urdu language in LaTeX. There is a nice package called tipa that can handle all IPA characters, but even with its utilities it is quite hard and not very readable.

I have my own transcription system that I use for my grammar notes, so I've written a short Lisp program to convert this to LaTeX code. Text to be converted should be tagged with "HINDIPA", either in inline or in environment style, see the example (LaTeX input, PDF output)."

Download the source code, or see the htmlized version.

Last update: 2015.05.12.

Byl's Automaton

A small self-reproducing automaton, conceived by John Byl in 1989. Its design is similar to Langton's loop, but even simpler, with only 6 states per cell.

I've found this gem in The (New) Turing Omnibus, and implemented it in Lisp using LTK (see a screenshot). At first it didn't work, and eventually I found out that a rule was missing, and the rule orientation was also wrong, even in the original paper.

Download the source code, or see the htmlized version.

I've rewritten the graphics in SDL for comparison, but it isn't much faster.

Spinoff: the Anneal automaton (screenshot).

Last update: 2015.03.07.

Neural Network

A minimal neural network implementation (with 1 hidden layer) learning how to convert polar coordinates to the Cartesian system. Based on the algorithm in The (New) Turing Omnibus.

Download the source code, or see the htmlized version.

Last update: 2015.03.01.

Contract Bridge Tests

A collection of functions to run a few tests concerning auction in contract bridge, such as the average number of losers in a 2NT hand etc.

Download the source code, or see the htmlized version.

Last update: 2015.01.22.

Writing Test

There was a quiz on the net for guessing some of the more exotic writings (like Japanese or Arabic), but it was too easy, so I've rolled my own. All of the writings systems in the quiz are still in use, and there is only one representative language for close families (e.g. there is no Farsi, Urdu or Uyghur, just Arabic).

Try the JavaScript code here.

Last update: 2014.12.31.

Color Clock

There was a page showing what color time would look like if we reinterpreted it as a hex color code, e.g. 08:13:47 => #081347. It was a nice idea, but the resulting colors were all very dark, and not easily distinguishable.

It occurred to me that HSV encoding would be a better fit, because Hue is easy to recognize, so we instantly get a feel of time. Value can be used for minutes, and Saturation for seconds. Also, the conversion should fill the whole spectrum. This is the result of this experiment.

Try the JavaScript code, download the source code, or see the htmlized version.

Last update: 2014.12.19.

Visual Cryptography & Steganography

Visual cryptography is an analog code: two images are created in a way such that no information can be extracted from them, but if we place them on top of each other, a new image (the "plaintext") appears. The "ciphertext" images can carry information, too... For a trivial example, look at this cat and this mouse - when placed on top of each other, result in this image.

A related field in cryptography is steganography, which studies how we can hide information in seemingly normal images. A simple method takes the last two bits of the RGB components (6 bits / pixel), and inserts a Base64-encoded string into it. As an example, I took a photo of my hamster, and encoded Khalil Gibran's "The Prophet" inside it - the text file was first encoded with GPG (password: "hamuhamu"), then converted to Base64 encoding, the result is this image.

Download the source code, or see the htmlized version.

Last update: 2014.10.14.

ICFP2014

My submission to the annual contest of the International Conference on Functional Programming. This time I entered as a single-man team NIL, and I did surprisingly well - 3rd place in the lightning round, and 5th place in the full round.

The task was to write pacman AIs on two different architectures, and to that end, to develop a compiler to these CPUs. The project README and the contest's task specification contain the details.

Clone the repository with Mercurial:

hg clone http://bitbucket.org/salvipeter/icfp2014/
Last update: 2014.09.25.

Visualization of the "vision" transformation

A somewhat minimalistic 3D demo showing several aspects of the mathematics of how we see (projections). Uses Qt / QGLViewer for the GUI (see a screenshot).

Download the current version with Mercurial:

hg clone http://bitbucket.org/salvipeter/3dviz/
Last update: 2014.03.23.

Arabic Dictionary Reloaded

A Java rewrite of my original Clojure program, written mainly to facilitate the transition to the Android version (soon!). New features include on-the-fly lookup, changable text size, better word boundary handling for English-Arabic queries, and sorting in a somewhat arbitrary, but logical order.

Download the source code or see the htmlized version. For your convenience, there is also a somewhat larger JAR version.

Last update: 2013.11.27.

Nine Men's Morris, 5-row Go Problems, Bridge Deals

A simple Nine Men's Morris game implementation (no computer player) for learning JavaScript / HTML5. As a derivative project, I've modified it to display 5-row go problems, and using the same base I also created a page generating bridge deals for bidding practice over the phone.

Play Nine Men's Morris, solve 5-row go problems, or practice bidding!

hg clone http://bitbucket.org/salvipeter/malom/
Last update: 2012.12.23.

Testbed for Pseudo-G2 Curves

This is a feasibility test for a research idea - basically how curves using curved ribbons give better curvature than those using linear ribbons. Two days before the abstract deadline I did not have time for elaborate programming, but I needed a GUI, graphics and some math. Once again, Racket came to the rescue. Using an earlier snippet as a base, I managed to implement this program in a few hours, with all its "bells & whistles" (see screenshot).

Download the source code, or see the htmlized version.

2012.10.09.: This little project got a lot bigger since its first version, and now it has earned its own repository - you can download the latest version with Mercurial:

hg clone http://bitbucket.org/salvipeter/pseudo-g2/
Last update: 2012.09.29.

Sample 3D Framework

A minimal 3D framework for creating simple applications (intended for class use). Uses Qt / QGLViewer for the GUI and OpenMesh for the mesh data structure (see a screenshot).

Download the current version with Mercurial:

hg clone http://bitbucket.org/salvipeter/sample-framework/
Last update: 2012.04.28.

Marching Squares

Another applet written in Racket - this time a demonstration of the basic marching squares algorithm (without any heuristics), applied for displaying 3rd-degree implicit functions (see a screenshot).

Download the source code, or see the htmlized version.

Last update: 2011.11.11.

Checkers Board in HTML

A minimalistic checkers graphics generator in JavaScript, that should help writing diagrams. Look at an example diagram, or try the generator itself.

Download the whole package in a ZIP file.

Last update: 2011.10.28.

Pythagorean Hodograph Curves

A simple demo for quintic PH curve interpolation, implemented in Racket. Its features include exact arc-length computation and displaying the curve's (explicit rational Bézier) offset curves (see a screenshot).

Download the source code, or see the htmlized version.

Last update: 2011.10.24.

Ngaro Virtual Machine in X86 Assembly

An implementation of the Ngaro Virtual Machine (used by RetroForth) in 32-bit x86 assembly. I always wanted to write a Forth on the "bare metal"... well, this is a first step.

Download the source code, see the htmlized version or get the latest version with Mercurial:

hg clone http://bitbucket.org/salvipeter/ngaro-asm-x86/
Last update: 2011.09.08.

White Layer

A simple but useful GIMP script (written in GIMP's Scheme dialect) for adding a white background layer to transparent images (by flattening). It can be used for single or multiple images.

Download the source code or see the htmlized version.

Last update: 2011.08.30.

Congklak

Congklak is an Indonesian variant of the Mancala game family. You can read its rules here (sorry, I don't remember where this file came from...). I've written a simple implementation in Lisp, with a minimalistic GUI that uses LTk (see a screenshot). There is even a basic (minimax) AI opponent, which seems to be quite strong. Actually, as a starting player it always wins (check out the winning moves).

Download the source code or see the htmlized version.

Last update: 2011.08.19.

Whitespace Assembler

A simple assembler for the Whitespace language, with a FOR macro, and of course, the power of Lisp to do other macros later. I've included the solution to the SPOJ/3 problem as an example.

New: A Whitespace solution to the classic FizzBuzz problem - introducing two convenience functions: PRINT-STRING and COND!

Download the source code or see the htmlized version.

Last update: 2011.08.12.

Project Euler Solutions

My solutions to the problems at Project Euler, which I've been doing since 2007.04.14.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the solution to the problem; you can decode them with GnuPG. There is also an answer list for my personal use.
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 ... 265 ... 267 ... 277 ... 301 ... 357 ... 493

Note: I've noticed that several problems were altered slightly to be more challenging on modern computers. The passwords reflect the versions published at the time I've solved them.

2008.02.08.: I've reached 100% at last!

2008.02.09.: 5th place.

2008.03.08.: 4th place.

2008.03.15.: 3rd place, my best position to date.

2009.05.10.: Sadly, I don't have time to solve these problems week by week anymore. Still, I hope that I will come back and do a few in my free time.

Last update: 2011.04.23.

Polygon subdivision

A JavaScript demonstration of three trivial subdivision algorithms (Chaikin with two weight sets, and 4-point interpolation). The program was a feasibility test of JS programming using CL-WHO and ParenScript that makes use of advanced widgets, events and macros.

Try the JavaScript code, download the source code, or see the htmlized version.

There is also a (manually) modified version used as a test of the parabola's parametric equation.

Last update: 2011.04.03.

Delaunay Triangulation

This is a demonstration of the (easiest) incremental approach to Delaunay triangulation, written entirely in PostScript. It uses user-given or random points, generating a sequence of "slides" that explain how this method works. The code may need some polishing, since it was a (relatively) fast hack.

Download the EPS file, a PDF conversion for random data, or see the htmlized source.

Last update: 2011.02.16.

Tools for Language Learning

This includes an Emacs Lisp HTMLizer, that turns a dictionary file into a CSS-driven HTML file, and a word practice software (WPS) that uses the same dictionary file format. There are six versions at present (Latin, Greek, Arabic, Cantonese, Russian and Hebrew), that have small changes as the special properties of the languages differ, as well as one for Yoruba that generates a plain TeX file. There is also a minimalistic (but very effective) flashcard utility for Emacs, with an (even more minimalistic) Clojure translation for the BiDi languages that Emacs cannot display well enough (yet). Both have a "flashdeck" version suitable for long learning lists, that cycle on only a few words at a time.

The basic file format (Latin/Greek) separates the solution and definition by an equal sign (with spaces on both sides):

īnfīrmus, -a, -um = weak

and

ὕπνος, -ου, ὁ = sleep

Since Arabic is written from the right, the definition naturally goes to the left side:

coffee = قَهْوَةٌ

Unicode diacritics are generated for Cantonese from a simplified version of the Yale transcription:

潮州話 : chiuh\ jau~ wa/ = Teochew dialect

In the Russian version the quotation mark shows the place of accent:

рабо"та|ть, ю, ешь = to work

The Hebrew version has a middle column for pronounciation. You can use latin-1 characters to show the place of accent.

חבר = khavér = friend

Finally, Yoruba accents pose no difficulty, only the dots under vowels, that are represented by a simple dot prefix.

.òr.é = friend

You can find sample dictionaries in the text page.

Download the source code of the HTMLizer (Latin, Greek, Arabic, Cantonese, Russian, Hebrew, Yoruba), the WPS (Latin, Russian, Hebrew), the Flashcard (Clojure version with a boot script and its (larger, but stand-alone) JAR version, old version), and the Flashdeck (Clojure version with a boot script and its (larger, but stand-alone) JAR version; also a generic, two-directional version in an all-in-one package containing Clojure and the boot file as well), a sample CSS file (Latin, Greek, Arabic, Cantonese, Russian, Hebrew), or see the htmlized version of the HTMLizer (Latin, Greek, Arabic, Cantonese, Russian, Hebrew, Yoruba), the WPS (Latin, Russian, Hebrew), the Flashcard (Clojure version, old version) and the Flashdeck (Clojure version).

Last update: 2010.11.01.

Linked Lists in Forth

Yet another linked list implementation in Forth, using Lisp-style naming. There is no garbage collection support, but theoretically (with a good library) only a few words have to be changed.

Download the source code, or see the htmlized version.

Last update: 2010.10.31.

Dictionary Opener

A common problem with dictionaries in PDF or Djvu that you cannot search in them for keywords. This utility requires only a small database that can be created in an hour or two, and opens the dictionary at the required place. It is written as a CLISP script, so it is easy to alter the string comparison mechanism as well.

Download the source code, or see the htmlized version.

Last update: 2010.10.07.

Configuration Files

My .emacs file (with my calendar settings in a separate file). It is always under construction. Also, some lisp utilities in my .sbclrc file.

Download the files: .emacs, .emacs (for version 22), .emacs (for version 21), my-calendar, .sbclrc.

Some other configuration files: Midnight Commander (ini, menu, bindings, and of course my skin), FluxBox (keys, menu, startup), .bashrc, .zshrc, .tmux.conf, .vimrc, .Xdefaults, .Xmodmap.

Last update: 2010.09.22.

Mosaic Puzzle Solver

In many computer games, a recurring puzzle is where you have to fill a given area by a set of shapes, which you may or may not rotate. This simple C++ library gives you all solutions in a second. A use example is also supplied, which reads the data in from a file.

Download the whole package.

Last update: 2010.09.12.

Chess Clock

If you don't have any chess clocks around, it is convenient to have a virtual one on your laptop. So I wrote it in Clojure. Nothing fancy, but should be easy enough to use. The key configuration is hard-coded. Read the comments in the source header on how to run / use / configure this handy little script.

Download the source code, or see the htmlized version.

Last update: 2010.04.13.

Swahili Dictionary

A minimal utility to facilitate Swahili word lookups in the Swahili-English dictionary of the fantastic Kamusi Project. You can autoload it from your .emacs file, or use a script to boot emacs as a stand-alone dictionary (see the source for details).

Download the source code, or see the htmlized version.

Last update: 2010.04.12.

Red Discs

Imitating a nice SDL_basic screenshot using PostScript. The result should look like this. It would be more elegant, if I could query the current file name, though.

Download the PostScript file, or see the htmlized version.

I have also rewritten it in Common Lisp using Vecto - it generates a PNG file. See the source in text or in HTML.

Last update: 2010.01.11.

Argument Parsing

I was not satisfied with the lisp clones of getopt, so I've rolled my own. You can insert a function to the argument definition, that will be called with the argument's parameter. This helps doing parsing numbers and other preprocessing stuff. Every option also has a symbolic name, so it is easy to search in the resulting alist. Of course it has all the standard functionality like short and long switches, equal signs and so on.

Download the stable version, or get the bleeding edge with Mercurial:

hg clone http://bitbucket.org/salvipeter/parse-args/
Last update: 2009.12.14.

Finite State Machine

A simple FSM, implemented in different languages, using different programming paradigms.

The concatenative Forth version creates a nice and easy-to-use DSL, where you can define states either by explicitly assigning transitions to input values, or by using arbitrary Forth words to choose the next state. There is an HTML version with explanations and examples.

The prototype-based Io version enables you to write arbitrary per-state transition functions in a clear way, without any macro-hacking. Also see the HTML version with some comments and examples.

The Lisp version is a lispy DSL (= lots of parentheses), in a somewhat functional way. The HTML version also contains some notes and examples.

Last update: 2009.12.09.

Mastermind

A (quite trivial) program that guesses the hidden colors in Mastermind, giving an average of 4.6 turns. A minimax search would also be easy to implement (see Knuth); according to Wikipedia, Koyama & Lai have also found a method with an average of 4.34.

Download the source code, or see the htmlized version.

Last update: 2009.10.11.

Langton's Ant

The Langton's Ant cellular automaton, written in PostScript. In the first few lines of the file you can set parameters like the pixel size, the number of iterations and the initial seeds.

Download the PostScript file, or see the htmlized version.

Last update: 2009.10.06.

Chinese Pronounciation Training

One hard thing about Chinese is that every word has an intonation that you should remember. This little Emacs code pops up some tests in the minibuffer, using the CEDICT database.

Download the source code, or see the htmlized version.

Last update: 2009.10.05.

Automatic Voter

A small program that votes in an infinite loop. One more reason to implement IP checking on your poll.

Download the source code or see the htmlized version.

Last update: 2009.07.27.

Arabic Dictionary

A (yet again) minimalistic dictionary tool written in Clojure. Later I plan to do a full morphological analysis and a better GUI, but it is usable in its current state. The database is the Buckwalter wordlist taken from the Perseus website, converted to text format by this script.

Download the boot script, the database and the source code or see the htmlized version. For your convenience, there is also a somewhat larger JAR version.

Last update: 2009.06.05.

Digits of π

My first Factor program - a straightforward (and very slow) translation of the algorithm in the paper by J. Gibbons: Unbounded Spigot Algorithms for the Digits of Pi. The program conforms to the guidelines of the The Computer Language Benchmarks Game.

Download the source code or see the htmlized version.

Last update: 2009.05.30.

Object-Oriented Programming by Macros

This is a simple example of how an object-oriented system can be created by source substitution (macros), written for a university class. Only the most basic features are supported. I've tried to make it Japanese-friendly by using Japanese symbols for function/macro names.

Download the source code or see the htmlized version.

Last update: 2009.05.25.

Multilingual Bible Lookup

This Emacs snippet looks up a given part of the Bible in the specified languages, using the Multilingual Bible page. This is a result of my frustration that the above site cannot be restricted to a user-defined set of languages and cannot display more than one verse at once.

Download the source code or see the htmlized version.

Last update: 2009.05.20.

Spellcaster Server

A minimal server to play asynchronous Spellcaster. I wrote this because playing Spellcaster by mail clutters my mailbox with one-line messages. It is basically a two-user bulletin board with a secret notepad and hidden message support. See a demo page here.

Download the source code or see the htmlized version. There is also an updated version (source, HTML) for Hunchentoot 1.0.

Note: This code is not thread-safe. With only two users this (hopefully) presents no problems, but still I should add those few lines later...

Last update: 2009.05.07.

Coin Flipping Server

This is a web-server version of the algorithm computing the probability for the Project Euler problem 232. The client can enter any "one-liner" algorithm (using a minimal set of Lisp commands) and the computation is done by the server, so one can organize a "who can score higher" competition :).

Download the source code or see the htmlized version. There is also a program computing the probabilities of the "fair" version of the game (htmlized version).

Last update: 2009.02.18.

Clojure/Swing Test

Clojure translation of some Swing examples in the book "Complete Java 2 Certification".

Download the source code or see its htmlized version.

Last update: 2008.11.09.

Cybook Thumbnail Converter

A not too user-friendly utility to convert between PGM and T2B file formats. Using a special four-color GIMP palette you can easily create input images.

Download the source code or see the htmlized version.

Last update: 2008.10.24.

Geek Challenge Solutions

My solutions to the Geek Challenges, mainly using Common Lisp.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the solution to the level. You can decode these files with GnuPG. There is also an answer list for my personal use.
01 02 03 04 05 06 07 08 09 10 11 12
Bonus levels:
Bathtime, Big Numbers, The Birds, Bit by Bit, Brute Force, Connectivity, The Evil Pyramid, Fun Sums, Keytone Snooping, Logic Cards, Maximizing a Cone, The Omega Network, QuadTrees, Triangle Paths

Note: The solution to problem 12 (a simple CPU emulation) is my favourite.

Last update: 2008.08.24.

ECL Embedding Test

A minimal test on how to embed Common Lisp code into C/C++ programs (as in, for example, Guile). One test loads a lisp file, evaluates lisp from C++, and also evaluates C++ from lisp. Another test creates a small Gtk GUI in C, where the user can evaluate Lisp expressions.

Download the first one's source code (C++, Lisp) or or see its htmlized version (C++, Lisp); download the source for the Gtk example.

Last update: 2008.06.11.

Grayscale Image Manipulation

Some easy algorithms working on grayscale / binary images (using raw PGM and PBM files) in Lisp... just playing around.
Also some more useful algorithms, written in C++:

Download the C++ source package, the Lisp source code or see its htmlized version.

Last update: 2008.06.09.

Linear Least Squares Example

An example program I wrote for a friend of mine to demonstrate multi-parameter linear least squares approximation using the GSL library. The package also contains HTMLized source code and a documentation that states the problem and explains some simple mathematics behind the solution. Extension of its features is left as an exercise to the reader.

Last update: 2008.05.19.

Starting Forth Solutions

My solutions to the exercises in Starting Forth, with a sample block file.

Last update: 2008.04.20.

Forth Stack Manipulator

Calculates the minimal required (standard) Forth stack manipulation command sequence to reach a stack state from a given initial state. Easily extensible with new commands.

Download the source code or see the htmlized version.

Last update: 2008.04.19.

Simple Tcl Timer

I was searching for a timer function in OpenOffice Impress at a lab meeting, but there was none... so I've written one in Tcl while waiting for my turn.

Download the source code or see the htmlized version.

Last update: 2008.04.15.

Sierpinski Pyramid

A 3d rotating Sierpinski pyramid - originally a programming exercise I made up for my friends. See a screenshot.

The original message divided the problem into four steps, you can download the solution for every step in both Common Lisp and C++.

Last update: 2008.04.09.

Turing Machine Emulator

A short macro to emulate a single-tape Turing machine in Lisp. The states can be defined in a lispy way, and the execution may be displayed by setting a global variable. Run-time errors are checked and reported.

Download the source code or see the htmlized version.

2012.04.25. Added an Erlang version (also in HTML)

Last update: 2008.03.05.

Python Challenge Solutions

My solutions to the Python Challenges, mainly using Common Lisp, Emacs and Python, but also a few others.

These files are encrypted with a CAST5 symmetric cipher. For each file, the password is the last part of the URL of the next level, without the extensions, e.g. http://www.pythonchallenge.com/some/where.html -> "where". You can decode these files with GnuPG. There is also an answer list for my personal use.
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

The solutions sometimes use some utility functions that can be found here.

(for levels where the solution is a username/password, the code is the concatenation of the two (usernamepassword); for level 20, it is the archive file name of level 21)

Last update: 2008.02.26.

Latin Reverse Engineering

An Emacs Lisp utility that prints the possible interpretations of an inflected latin word. It only has a test database at the moment.

Download the source code or see the htmlized version.

Last update: 2008.02.18.

Fifteen Game Solver

The solution uses a simple backtrack algorithm and returns the best solution, using a user-defined upper limit.

Download the source code or see the htmlized version.

Last update: 2008.01.13.

Email Sender

I've found a Gtk dialog widget utility called "Zenity" a few days ago - this program is written in order to try its features in real use. Note that the SMTP server should be set in the script file.

Download the source code or see the htmlized version.

Last update: 2007.12.02.

GLUT Demos

C++ / GLUT implementation of Bézier curves, Aitken-Lagrange interpolation, B-spline curves and global B-spline curve interpolation.

Download the c++ source code. You can also download a Lisp version of the Bézier curve demo (with only the deCasteljau algorithm, and no popup menu), or see its htmlized version.

Last update: 2007.11.15.

Online TV GUI

This script only invokes MPlayer on a channel selected from a listbox. The list of channels can be configured in a file called channels, which contains a description, an equal sign and then the address of the clip (which may also be a local filename, of course). Done in a few minutes.

Download the source code or see the htmlized version.

Last update: 2007.11.11.

Triangle Strip

Tried my hand at Vtk programming. Just a GUI for viewing a triangle strip, that can be lengthened or shortened using a slider.

Download the source code or see the htmlized version.

Last update: 2007.10.10.

Movie Info

Reads a list of movie titles from the standard input and searches IMDB for details (director, actors, etc). The user can select the appropriate one from a list of titles, and write the data to the standard output. Written in Tcl/Tk.

Download the source code, see the htmlized version or see a screenshot.

Last update: 2007.10.01.

Revolving Door Problem

Imagine a door with four buttons placed simmetrically on a circular panel. You can push one or two buttons at once, but after you've pushed them, the panel revolves to some other position. Every button has an invisible counter attached to it, counting in a modulo n manner. The starting state is unknown, and the door only opens if all buttons have the same counter value. How do you open the door, if n = 2? n= 3? n = 4? This Lisp program answers this question.

Download the source code or see the htmlized version.

Last update: 2007.09.17.

Web Server Test

A first try at Hunchentoot & CL-WHO. This file is a translation of the code in Practical Common Lisp (chapter 26) that uses AllegroServe. It may be a good tutorial if I decide to do some web programming later on.

Download the source code or see the htmlized version.

Last update: 2007.07.16.

Surreal Numbers

Basic operations on surreal numbers (as defined in J.H. Conway's "On Numbers and Games").

Download the source code or see the htmlized version.

Last update: 2007.06.15.

Filesystem Outline Generator

An Emacs Lisp function that generates an Org-mode buffer from the output of the UN*X "tree" command.

Download the source code or see the htmlized version.

Last update: 2007.06.12.

Lisp GUI Tests

Two GUI tests - only a little more complex, than Hello World - using the LTK and Cells-Gtk libraries.

Download the LTK and Cells-Gtk source code, see their htmlized version (LTK, Cells-Gtk) or see a screenshot of the two implementations.

Last update: 2007.05.31.

Meiji Cube

Solver algorithm for the Meiji Caramel Cube Puzzle: Given a cubic box with a side length of 4 units and block pieces of dimension 2x2x1 units, place n pieces in the box in a way that none of them can move. Possible values of n range from 12 to 15.

The program is written in Common Lisp. It finds all possible solutions (mirrored solutions are considered the same) and generates 3D output in VTK file format. Since it uses a pretty dumb algorithm, it is very slow (takes about 3 days to get all the solutions!), but at least it works.

Download the source code, see the htmlized version, download all the solutions in VTK format, or see a screenshot of a 15-piece solution.

Last update: 2007.05.21.

Show Math

Shows a PNG representation of the input LaTeX expression in a new Firefox tab. Useful when creating slides with a lot of equations. Written in Tcl/Tk.

Download the source code or see the htmlized version.

Last update: 2007.05.14.

Head-Tail

This is a solver algorithm for the four-letter game, where you have to find a route of sensible words between two four-letter words by changing one letter at a time. It is played in Hungarian with three phonemes.

Download the Hungarian dictionary, the English dictionary and the source code, or see the htmlized version.

Last update: 2007.04.16.

PostScript Images

Some recursive images generated in Common Lisp: Cantor dust, Koch curve and the Hilbert curve.

Download the source code, or see the htmlized version.

Last update: 2007.04.13.

Dictionary HTMLizer

This Emacs routine converts a CEDICT-style Chinese dictionary file to HTML, using real pinyin.

Download the source code, or see the htmlized version.

Last update: 2007.04.13.

Go Music

If Go was music, how would it sound?

This Emacs Lisp snippet is trying to answer this question. The pitch and length of each note is based on the move's position and its distance from the neighboring moves. Requires LilyPond 2.8.1 or greater.

Download the source code, see the htmlized version or listen to a sample.

Last update: 2007.03.31.

Sudoku

A simple Sudoku solver in Common Lisp.

Download the source code or see the htmlized version.

Last update: 2007.03.31.

Horse Animation

Common Lisp routines to generate the "moving greeting card effect", i.e. creating a picture by taking every Nth column in a series of N pictures, then moving a grid where only every Nth column is transparent, thus creating the illusion of a moving image.

Download the source code and the pictures, or see the htmlized version with the result pictures.

Last update: 2007.03.31.

GETTO

Bittorrent file harvester for TV series. Given a configuration file, containing a list of filename patterns and websites, checks if there is a new episode, and downloads the torrent files if there is. Written in Tcl/Tk.

Download the source code, see the htmlized version or see a screenshot.

Last update: 2007.03.31.

Rename

A Tcl/Tk GUI for regexp renaming files in the current directory.

Download the source code or see the htmlized version.

Last update: 2007.03.31.

Copyright (C) 2007-2017 Peter Salvi