Statistics

Problem Statement for "BritishCoins"

Problem Statement

Prior to 1971, Britain used a system of coins that can be traced back to the time of Charlemagne. The three main units of coinage were the penny, the shilling, and the pound. There were 12 pennies in a shilling and 20 shillings in a pound. Given a number pence of pennies, convert this amount into pounds, shillings, and pennies by first converting as many pennies as possible into pounds, and then converting as many of the remaining pennies as possible into shillings. Return a int[] of size three containing the number of pounds, the number of shillings, and the number of pennies, in that order.

Definition

Class:
BritishCoins
Method:
coins
Parameters:
int
Returns:
int[]
Method signature:
int[] coins(int pence)
(be sure your method is public)

Constraints

  • pence is between 0 and 10000, inclusive.

Examples

  1. 533

    Returns: { 2, 4, 5 }

    First, we make 2 pounds, leaving 53 pence. Then, we make 4 shillings, leaving 5 pence.

  2. 0

    Returns: { 0, 0, 0 }

  3. 6

    Returns: { 0, 0, 6 }

  4. 4091

    Returns: { 17, 0, 11 }

  5. 10000

    Returns: { 41, 13, 4 }

  6. 72

    Returns: { 0, 6, 0 }

  7. 2400

    Returns: { 10, 0, 0 }

  8. 504

    Returns: { 2, 2, 0 }

  9. 61

    Returns: { 0, 5, 1 }

  10. 76

    Returns: { 0, 6, 4 }

  11. 669

    Returns: { 2, 15, 9 }

  12. 889

    Returns: { 3, 14, 1 }

  13. 1201

    Returns: { 5, 0, 1 }

  14. 1303

    Returns: { 5, 8, 7 }

  15. 1363

    Returns: { 5, 13, 7 }

  16. 1499

    Returns: { 6, 4, 11 }

  17. 1584

    Returns: { 6, 12, 0 }

  18. 1845

    Returns: { 7, 13, 9 }

  19. 1849

    Returns: { 7, 14, 1 }

  20. 2580

    Returns: { 10, 15, 0 }

  21. 2682

    Returns: { 11, 3, 6 }

  22. 2808

    Returns: { 11, 14, 0 }

  23. 3505

    Returns: { 14, 12, 1 }

  24. 3937

    Returns: { 16, 8, 1 }

  25. 4022

    Returns: { 16, 15, 2 }

  26. 4179

    Returns: { 17, 8, 3 }

  27. 4319

    Returns: { 17, 19, 11 }

  28. 4382

    Returns: { 18, 5, 2 }

  29. 5261

    Returns: { 21, 18, 5 }

  30. 5819

    Returns: { 24, 4, 11 }

  31. 6524

    Returns: { 27, 3, 8 }

  32. 6601

    Returns: { 27, 10, 1 }

  33. 7148

    Returns: { 29, 15, 8 }

  34. 7170

    Returns: { 29, 17, 6 }

  35. 7192

    Returns: { 29, 19, 4 }

  36. 7310

    Returns: { 30, 9, 2 }

  37. 7344

    Returns: { 30, 12, 0 }

  38. 7494

    Returns: { 31, 4, 6 }

  39. 7533

    Returns: { 31, 7, 9 }

  40. 7659

    Returns: { 31, 18, 3 }

  41. 7946

    Returns: { 33, 2, 2 }

  42. 8241

    Returns: { 34, 6, 9 }

  43. 8685

    Returns: { 36, 3, 9 }

  44. 9143

    Returns: { 38, 1, 11 }

  45. 9258

    Returns: { 38, 11, 6 }

  46. 9507

    Returns: { 39, 12, 3 }

  47. 9600

    Returns: { 40, 0, 0 }

  48. 9966

    Returns: { 41, 10, 6 }

  49. 9874

    Returns: { 41, 2, 10 }

  50. 240

    Returns: { 1, 0, 0 }

  51. 533

    Returns: { 2, 4, 5 }

  52. 239

    Returns: { 0, 19, 11 }

  53. 4091

    Returns: { 17, 0, 11 }

  54. 12

    Returns: { 0, 1, 0 }

  55. 240

    Returns: { 1, 0, 0 }

  56. 4091

    Returns: { 17, 0, 11 }

  57. 10000

    Returns: { 41, 13, 4 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: