2010-06-28

Molehill Empire

Am găsit un joc pe internet din întâmplare. Se numeşte Molehill Empire şi trebuie să dezvolţi o grădină. Un screenshot este mai jos.

2010-06-09

The Ten Sausages

The wife of a programmer told him: Please go to the market and if you find ten eggs, buy them, otherwise buy some sausage. The programmer returned home with ten sausages.

What went wrong... You never know how a condition sounds in a programmer's head.

For the geek:
Because the quantity of the sausages is not well defined in the request, the following two algorithms solve the problem correctly, although the result is unexpected for the first one.

for i=1 to 10 do
if exist 10 eggs then buy egg
else buy sausage

if exist 10 eggs then
for i=1 to 10 do buy egg
else buy sausage

2010-06-07

Exercise

Write a program that generates a random permutation of the numbers between 1 and n, where n is given by the user.