Thank you. I probably understand my fault. My algorithm assumes that every numbers for input are in separate data streams (interactive). But for testing it is enough that all input data be in one stream (the arrays for storing results are redundant). That is simplifying the algorithm. I have to fix my all algorithms at the Polish site.
Thank you. Adalbert Hermann
the simplest solution is:
while let n = Int(readLine()!), n != 42 { print(n) }