← Back to challenges

The Million Dollar Fence

PythonHardstringsnumbers

Instructions

Your task is to create a fence worth $1 million. You are given the price of the material (per character), meaning the length of the fence will change depending on the cost of the material.

Create a function which constructs this pricey pricey fence, using the letter "H" to build.

construct_fence("$50,000") ➞ "HHHHHHHHHHHHHHHHHHHHHHHHHHHH"
# 20 fence posts were set up ($1,000,000 / $50,000 = 20)

Examples

construct_fence("$50,000") ➞ "HHHHHHHHHHHHHHHHHHHHHHHHHHHH"

construct_fence("$100,000") ➞ "HHHHHHHHHH"

construct_fence("$1,000,000") ➞ "H"

Notes

You are ordered to spend all of your $1,000,000 budget...

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Two Lists inside a List to One