The Coins of Ter | Round to the Next N
Description:
The Coins of Ter
Ter is a small country, located between Brelnam and the Orange juice ocean. It uses many different coins and bills for payment. However, one day, the leaders of Ter decide that there are too many small coins. Therefore, they ban the small coins. But no one knows which coins they'll ban, so they ask you to provide a tool that can recalculate a price. After all, if one does not have a 1 Terrek bill and can only give a 2 Terrek bill, one needs to adjust the oddly priced items.
Task
Write a function adjust
, that takes a two integers: the lowest currency unit that's still allowed, and the price/debt that needs to get adjusted. All prices are going up, and debts are remitted. The lowest currency will always be positive.
In other words:adjust
takes two integers, b
and n
, and returns the smallest number k
, such that n <= k
and k % b == 0
.
Examples
adjust( 3, 0 ) == 0
adjust( 3, 1 ) == 3
adjust( 3, -2) == 0
adjust( 3, -4) == -3
adjust( 3, 3 ) == 3
adjust( 3, 6 ) == 6
adjust( 3, 7 ) == 9
Similar Kata:
Stats:
Created | Aug 18, 2015 |
Published | Aug 18, 2015 |
Warriors Trained | 2516 |
Total Skips | 255 |
Total Code Submissions | 2247 |
Total Times Completed | 1011 |
Haskell Completions | 98 |
JavaScript Completions | 413 |
CoffeeScript Completions | 20 |
Python Completions | 454 |
Ruby Completions | 107 |
Total Stars | 26 |
% of votes with a positive feedback rating | 82% of 163 |
Total "Very Satisfied" Votes | 119 |
Total "Somewhat Satisfied" Votes | 30 |
Total "Not Satisfied" Votes | 14 |