Define the Fouriest Transform of a number to be the base- representation of whose digits contain the most 's of all representations such that is minimized. If you wrote out the Fouriest Transform of all positive integers up to and including , let be the total number of 's you would count in all of their digits. What are the last three digits of ?
Details and Assumptions
As an explicit example, the Fouriest Transform of is (base- ) which contains fours. Although its base- representation, , also contains fours, is the smaller base.
If there does not exists a base that can be represented in that has any fours, define the Fouriest Transform of that number to be its base- representation.
This problem was inspired by the following Saturday Morning Breakfast Cereal Cartoon .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
My solution in python:
I added comments to explain parts of the code that may have been unclear or little pieces that make the algorithm run more efficiently.
Result = 1 8 4 4 4 . This gave me about an 11 second runtime. And yes, I did choose 9 9 5 2 so the answer would come out to 4 4 4