I thought bad coding was what Marketing wanted. Bad code creates bugs which sets the customer up to buy the next version which promises to fix the bugs of the previous versions while adding hundreds of other bugs to be fixed in the next version. Has worked for Microsoft.
I offer that your students code is more efficient in that there are fewer steps for the computer to execute, it is equally as easy to type using ctrl v, and more intuitively obvious so they did not waste time looking for the elegant solution. If you wanted them to do it your way you should have made it 1 - 1000.
Friend of mine told me about his Dad who had to create a random number generator in college back in the days of punch cards. He sequence punched all the numbers in the desired range, threw the box out of a 4 story window, and then collected the cards.
I have lost to code once, but I stayed alive. Every coder has made crappy code in their lifetime, but the real problem are the people who deliberately make code difficult to read to make themselves "invaluable". Fortunately this is a lot less common now than it was before, but it still happens.