Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BoundsException(Exception):
- pass
- class PiecewiseRange:
- """ Provides for (integer) values within defined ranges to provide
- equal or similar output.
- For example:
- Suppose one is running a tournament and has a $5000 prize for first
- place, $1000 prizes for second through fourth place, and $500 prizes
- for fifth through eigth place.
- Instead of creating an array/hash table to associate /each/ place
- with a cash prize, or using an if block to painstakingly hardcode the
- values, what one really wants is for a certain *range* of numbers to
- be associated with a certain value.
- Which is what this class is for.
- 5000 1000 500
- |----| |------------| |----------------|
- 1 2 4 5 8
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement