I have an array with subarrays containing integers, and want to make
sure that the distance between any two numbers next to each other is
equal to or less than 7, also from one subarray to the next. Rigth now I
have two blocks to do this, one to check each element of a subarray
against the previous element, and one to check the last element of a
subarray against the first element in the next subarray. The problem is
that whichever block comes last mess up the work done by the first
Here is an example with an array that is similar to the one my program
If you’re not familiar with Pastie, you can click “View” on the right to
see a wrapped version (at least in Safari).
Any help is much appreciated!
PS. Using flatten is really not an option (as far as my newbie eyes can
see) because when modifying a “bad” integer I can’t just choose any
number, but need a number from the corresponding skala_rekke-subarray
(sorry about the norwegian variable-name).
Wow, thanks! That makes a lot of sense, now that I’ve spent half an hour
understanding exactly what you were doing. Your help is much
appreciated, I’m learning a lot from it. It dawns on me that learning to
program is much more about logic than memorizing methods.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.