oh god...
Seems like rules pattern is applicable here
look, I don’t know C#, I’m a Go’pher so please excuse me for sharing Go code but that is the fastest I can help: https://play.golang.org/p/R4H55fbkVcb 1. the code you wrote is terrible because you hardcoded all rules, which is really really bad. You want rules to be dynamically configurable. 2. you just iterate over a sorted (by max student count) list of rules until you pick one that suits the number at hand.
few notes here..... 1. groups is an unsorted list. Who knows what order they'll be in when you get them. Also, List().ToList()... what? 2. if you simply need to group 3 students at a time, use math var groupNumber = (studentNumber / 3) + 1 example: student 10, divide by 3 = 3, plus 1 = 4, this student is in group 4. 3. Group size should be a configurable variable, as @Romshark was saying, hardcoding = bad. 4. what the heck is going on in that for loop? Barring all of that, could you instead tell us what the expected end result is?
Another thought, you are assuming there are enough groups to handle the number of students it seems. If I only have 3 groups and send 20 students in, that's going to be an issue. You need to handle that.
OT, i love the fact that go as has its own "playground"
we also have a more advanced playground for analyzer and nuget developers https://sharplab.io/
Nothing official tho
There's also https://try.dot.net/
That looks official, never seen it before
Yep. It was released maybe 9 or 10 months ago.
Обсуждают сегодня