A loose collection of short programs in AWK.
Exploring the possibilities of a classical tool in the Unix world.
An implementation of the Chinese remainder theorem.
Given a positive integer k
, positive integers a_1, ..., a_k
which are pairwise coprime and arbitrary integers n_1, ..., n_k
, we find the unique x
such that
x = a_1 (mod n_1), ..., x = a_k (mod n_k)
There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there? (Sunzi Suanjing)
In other words, we must find the solution of the congruential system of equations:
x ≡ 2 (mod 3) ≡ 3 (mod 5) ≡ 2 (mod 7)
Let's use chinese.awk
:
$ chinese.awk
2 3 2
3 5 7
^D
And the answer is:
23
An AWK implementation of a very basic web server.
Calculates an approximation of PI by means of Viète's formula
An implementation of the classical Tic-Tac-Toe game, based on von Neumann's Minimax algorithm.
Just do
awk -f ttt.awk
Enjoy!