I have a quite interesting problem that’s making my head twist. I’m working on a small system consisting of users and awards (called badges). There is a special badge that is awarded to users depending on the following criteria: 10 bronze badges, 5 silver badges and 1 gold badge. That is pretty simple, however, if an user has 8 bronze badges, 7 silver badges and 1 gold badge, he can use his 2 additional silver badges as bronze ones.
This happens everytime the user has available “higher” badges to distribute. Again, for example, if he has 8 bronze badges, 4 silver badges and 4 gold badges, he can “transform” 2 of his gold badges into bronze and 1 to silver, in order to earn the special badge.
I have absolutely no idea of how to do this. I’ve tried with various loops, ifs, but i can never distribute properly. Maybe someone can help me out?
The user needs at least 1 gold badge, at least 6 badges that are either silver or gold, and at least 16 badges that are bronze, silver or gold.
The pseudocode is
If you also have a diamond medal that can swap for a gold, silver or bronze then include that as well, like
Or you could use a ‘medal rank’ so that you can do something simpler like