Project Euler 116: Count the number of ways a space 50 units long could be filled by tiles, homogeneously, measuring 2, 3 or 4 units long.
Problem Description
A row of five black square tiles is to have a number of its tiles replaced with coloured oblong tiles chosen from red (length two), green (length three), or blue (length four).
If red tiles are chosen there are exactly seven ways this can be done.
If green tiles are chosen there are three ways.
And if blue tiles are chosen there are two ways.
Assuming that colours cannot be mixed there are 7 + 3 + 2 = 12 ways of replacing the black tiles in a row measuring five units in length.
How many different ways can the black tiles in a row measuring fifty units in length be replaced if colours cannot be mixed and at least one coloured tile must be used?
NOTE: This is related to Problem 117.
Analysis
As a continuation from the two previous problems we remove the empty space option and one-space tile separation requirement. Now it makes sense to include a function since we are adding 3 different fixed-length tiles of sizes 2, 3 and 4.
Project Euler 116 Solution
Runs < 0.001 seconds in Python 2.7.Use this link to get the Project Euler 116 Solution Python 2.7 source.
Afterthoughts
- See also, Project Euler 117 Solution:
Discussion
No comments yet.