TopcoderArchiveVisit Topcoder
SRM23 Feb 2005
SRM 232

BritishCoins

Problem statement, definition, constraints, and public examples.

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 }
Back to all problems