Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. def howManyGames(p, d, m, s)
  2.  
  3. price = p
  4. discount = d
  5. money = s
  6. games = 0
  7. while money >= price
  8. money = money - price # paid one game
  9. games = games + 1 # got one game
  10. price = price - discount # price is reduced by promotion
  11. price = price > m ? price : m # until it reaches a bottom limit
  12. end
  13.  
  14. return games
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement