Form the question, if you pattern the s,d, and J , it becomes
Have you find any pattern on the sequence? I dont think so...(one label condition)
Though you can do that by mutiple loops and condition statements, but direct implementation is much easier and faster here.
"What would be a generic way of doing this instead of hard coding?"
In addition, all vectors having 3 lengths only, you can do it by direct implementation, why do you think you have to go for "for loop" here.