Number distribution algorithm

Hi there,

I've been challenged to find an algorithm that evenly (or as evenly as possible) spreads **varying difficulty** between **varying number of rounds** for a hypothetical Quiz game. So you could have:

Maximum difficulty = 4 (always between 1 and x)

Number of rounds = 8

I can then evenly distribute the difficulty across the number of rounds like so:

round 1: 1

round 2: 1

round 3: 2

round 4: 2

round 5: 3

round 6: 3

round 7: 4

round 8: 4

This is fine when the number of rounds is a multiple of the maximum difficulty, but I can't get my head around how to do this when it's not:

Maximum difficulty = 5

Number of rounds = 8

round 1: 1

round 2: 1

round 3: 2

round 4: 3

round 5: 3

round 6: 4

round 7: 5

round 8: 5

This is the result I am looking for when the maximum difficulty is not a multiple of the number of rounds. I can't work out how to process the numbers so there is an even difficulty at each end of the scale where possible (in this example it works out by having only one 2 and one 4 - they are in the same position at each end).

If anyone could help me out I would greatly appreciate it.

Thanks for your time,

-Ben