6502's cornerThe small ones
2002-12-28
Index

Welcome!
Who am I
Demo
Documents
Small ones
Problems
Chess
Images
Music
My blog
Write me

Versione italiana 


The small ones

In this section I collected a few small programs in which I tried to use the smallest number of characters in the source code. Of course this is not something that has any pratical use as the only effect is that the programs are more difficult to understand... but anyway...

All programs are presented as a C source code file. You will have to compile them yourself with a C compiler to be able to see the programs running.

Eight queens

This program solves the well known problem of the eight queens on a board. The problem is placing eight chess queens on the chessboard in a way that no queen can attack any of the other queens... in other words there must be no two queens on the same row, the same coloumn or the same diagonal.

The program generates the list of all possible solutions in which every solution is represented by an 8-digit numbers where every digit is between 1 and 8. The n-th digit tells on what columns should be placed the queen on the n-th row.

Tic-Tac-Toe

This program is a computer player of the classical tic-tac-toe. The program starts by visualizing a 9 squares board using the digits from 1 to 9 and asking to the human player what his/her move is and then replying to every move automatically. Replying '0' as the first move is assumed as the will of having the computer make the first move.

Calculator

This program accepts in input an expression with numbers, the four basic operations (with parenthesis) ending with the special character ";" and prints out what the result of the computation is. For example giving as input the expression "((1*16+9)*16+6)*16+6;" the programm will reply "6502". NOTE: The eventuality of a division by zero has not been handled in this program.