Week2 - random_mini_batches() - deviate from suggested solution

Hi,

my solution for random_mini_batches, deviates from the suggested path.
I’ve submitted my assignment, and it passes all tests.
I’m wondering though if I’m missing something, and it will fail under different conditions. If this is a possibility, I’d appreciate it if one of the mentors could check it at some point. If the tests are super robust and I shouldn’t be concerned, then yay, I found a shorter solution! :smiley:

Thank you!

There can be more than one correct way to implement pretty much any solution. The test cases here are good, but I would not assume that they are bulletproof. The other thing to realize is that everyone’s notebooks are private, so neither the mentors nor anyone else can magically reach in and review your code. If you want to discuss in more detail, we’re not supposed to publish solution code but maybe you can describe in words how you designed your code to be different than the suggested solution. And we can try to go from there …

Thank you for your reply. I am aware of policies on publishing code, hence my original post didn’t include any. I also did not expect for anyone to magically reach in a notebook, but it is unclear to me if a private message with a mentor where I could share my code, would be a possibility.
In any case, in my version, there was no need for the two if statements, so one for loop (with a different range ofc) is enough, and the last mini-batch has the expected smaller size. My main concern for asking in the first place is, if it would be possible to end up with the wrong size for the last mini-batch under some circumstances (and maybe identifying some of them).
But I understand that without code it’s hard to move forward, so it’s ok. I can live without a clarification and keep my eyes out for this, next time I need to implement it.