Wednesday, May 16, 2012

Indices cycling

I have a array of 7 sets of data which are accessed through their indices 0-6. I need to use 6 for training and 1 for testing which need to be cycled until 7 combinations have been achieved like so.



Training - 0, 1, 2, 3, 4, 5
Testing - 6



Training - 1, 2, 3, 4, 5, 6
Testing - 0



Training - 2, 3, 4, 5, 6, 0
Testing - 1



....



Training 6, 0, 1, 2, 3, 4,
Testing - 5



The training data will be a queue of queues of ints and the testing is a queue of ints. My brain is fried I need to help desperately. I have resorted to simply hard coding them but it looks dreadful and if I want to change the amount of sets I have then it will require a rewrite.



A lot of answer using modulo!, I only used that for finding even numbers :) i'm testing now if it works your all gettin upvotes





No comments:

Post a Comment