Skip to content

Instantly share code, notes, and snippets.

@Rooarii
Last active August 14, 2020 15:11
Show Gist options
  • Save Rooarii/ec0f2a2acac0b7f2eee95cce3e792dbc to your computer and use it in GitHub Desktop.
Save Rooarii/ec0f2a2acac0b7f2eee95cce3e792dbc to your computer and use it in GitHub Desktop.
pseudo-code algorithm returning the number of candy you can buy
start buyCandies (real money, real price)
integer boughtCandies = 0
while ((money and price > 0) and money >= price)
|
| money <- money - price
| boughtCandies <- boughtCandies + 1
|
end while
return boughtCandies
End buyCandies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment