Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. class BoundsException(Exception):
  2. pass
  3.  
  4. class PiecewiseRange:
  5. """ Provides for (integer) values within defined ranges to provide
  6. equal or similar output.
  7.  
  8. For example:
  9.  
  10. Suppose one is running a tournament and has a $5000 prize for first
  11. place, $1000 prizes for second through fourth place, and $500 prizes
  12. for fifth through eigth place.
  13. Instead of creating an array/hash table to associate /each/ place
  14. with a cash prize, or using an if block to painstakingly hardcode the
  15. values, what one really wants is for a certain *range* of numbers to
  16. be associated with a certain value.
  17. Which is what this class is for.
  18.  
  19. 5000 1000 500
  20. |----| |------------| |----------------|
  21. 1 2 4 5 8
  22. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement