yaworsw/euler-manager

View on GitHub
data/problems/277.yml

Summary

Maintainability
Test Coverage
---
:id: 277
:name: A Modified Collatz sequence
:url: https://projecteuler.net/problem=277
:content: "A modified Collatz sequence of integers is obtained from a starting value
  a<sub>1</sub> in the following way:\n\n<var>a<sub>n+1</sub></var> = <var>a<sub>n</sub></var>/3
  if <var>a<sub>n</sub></var> is divisible by 3. We shall denote this as a large downward
  step, \"D\".\n\n<var>a<sub>n+1</sub></var> = (4<var>a<sub>n</sub></var> + 2)/3 if
  <var>a<sub>n</sub></var> divided by 3 gives a remainder of 1. We shall denote this
  as an upward step, \"U\".\n\n<var>a<sub>n+1</sub></var> = (2<var>a<sub>n</sub></var>
  - 1)/3 if <var>a<sub>n</sub></var> divided by 3 gives a remainder of 2. We shall
  denote this as a small downward step, \"d\".\n\nThe sequence terminates when some
  <var>a<sub>n</sub></var> = 1.\n\nGiven any integer, we can list out the sequence
  of steps.  \nFor instance if <var>a</var><sub>1</sub>=231, then the sequence {<var>a<sub>n</sub></var>}={231,77,51,17,11,7,10,14,9,3,1}
  corresponds to the steps \"DdDddUUdDD\".\n\nOf course, there are other sequences
  that begin with that same sequence \"DdDddUUdDD....\".  \nFor instance, if <var>a</var><sub>1</sub>=1004064,
  then the sequence is DdDddUUdDDDdUDUUUdDdUUDDDUdDD.  \nIn fact, 1004064 is the smallest
  possible <var>a</var><sub>1</sub> \\> 10<sup>6</sup> that begins with the sequence
  DdDddUUdDD.\n\nWhat is the smallest <var>a</var><sub>1</sub> \\> 10<sup>15</sup>
  that begins with the sequence \"UDDDUdddDDUDDddDdDddDDUDDdUUDd\"?\n\n"