posted 1 year ago
This is what I had as solution to Pr. Euler:
First a class called Field:
and I had this algo (use Google Translate if necessary):
/*
we gaan het volgende doen; we beginnen met bord[0][0] in de queu
te mikken. Dan zolang de queu niet leeg is, doen we:
- haal het eerste element van queu, noem het Q
- voor elke buurman B van Q, doe:
- als B.currentValue = -1, dan sla B op in de Queu, met als
currentValue: Q.curentValue + B.originalValue, en met
x_voor = Q.x, en y_voor = Q.y
- anders: als Q.currentValue + B.originalValue < B.currentValue
sla B op in de queu, met als currentValue = Q.currentValue + B.originalValue
en x_voor = Q.x, en y_voor = Q.y
- als de queu leeg is, druk dan bord[80][80] (eigenlijk: bord[79][79]) af.
De currentValue is dan wat we hebben moeten
*/
did the 80x80 matrix in less than half a second.
There are three kinds of actuaries: those who can count, and those who can't.