Re: problem with printing Vigenere table



SARA <dev.sara87@xxxxxxxxx> wrote:

hi all

please i wan to print a Vigenere table like this

http://mathdemos.gcsu.edu/mathdemos/vigenere/ventableau.gif

I write this code but did not give me the desired results

what is the wrong with it???

[code snipped]

Your idea is quite correct, but with my limited Java knowledge (it is
Java, isn't it?) you are exceeding array bounds. If i is your
horizontal index and k is your vertical index in the Vigenere table,
then i+k `mod` n is the character's index in an alphabet of length 'n'.
The modulo operation ensures that i+k wraps at the alphabet's border,
while the absolute value doesn't make it wrap, but rather reflects it
from zero, like in these graphs:

4 | -4 4 -1 4 9
3 | -3 3 -2 3 8
2 | -2 2 -3 2 7
1 | -1 1 -4 1 6
0 | 0 -5 0 5
---------------------------------------------------------
abs(x) x `mod` 5


Greets,
Ertugrul.


--
nightmare = unsafePerformIO (getWrongWife >>= sex)

.