// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)
Loading...

Solutions 301 - 400

Project Euler 371 Solution

Project Euler 371 Solution

Project Euler 371: License plates


Problem Description

Oregon licence plates consist of three letters followed by a three digit number (each digit can be from [0..9]).
While driving to work Seth plays the following game:
Whenever the numbers of two licence plates seen on his trip add to 1000 that’s a win.

E.g. MIC-012 and HAN-988 is a win and RYU-500 and SET-500 too. (as long as he sees them in the same trip).

Find the expected number of plates he needs to see for a win.
Give your answer rounded to 8 decimal places behind the decimal point.

Note: We assume that each licence plate seen is equally likely to have any three digit number on it.

Project Euler 371 Solution

Runs < 0.001 seconds in Python 2.7.
download arrowUse this link to get the Project Euler 371 Solution Python 2.7 source.

Afterthoughts

  • As these problems originate in the UK, the spelling of licence follows the convention in British English, Canadian English, Irish English, Australian English, and New Zealand English where the noun is spelled licence and the verb is license.
  • Try this with 365 and think about what the significance the answer has.
  • Other license plates with more digits:
  • 4 digits: 126.340880766
  • 5 digits: 397.335708939
  • 6 digits: 1254.31507797
  • 7 digits: 3964.32759492
  • 8 digits: 12534.1414672
  • 9 digits: 39634.2730058
  • 10 digits: 125332.413741 (1.19 s)
  • 11 digits: 396333.729764
  • 12 digits: 1253315.13732
  • 13 digits: 3963328.2966
  • Approxmation:
    \sqrt{\frac{t\pi}{2}}+1

Discussion

No comments yet.

Post a comment