| To reach the exact number, I would think that: - if the number n is prime, it would be an SC + (n-1)*P, making the total number of actions n + 1 (as SC counts as 2 actions) - if the number n is composite, you'd need to factor it, find the smallest and largest prime factors (pf1 and pf2), which would necessarily multiply into n again, and the total number of actions is (pf1 + 1) + (pf2 + 1) If my reasoning is correct, reaching 100007, which is prime, would require 100008 actions. And reaching 100001, which factors to 11x9091, would require 9104 actions. To reach at least n, I reason: - 1 or 2 action sequences do nothing, as an SC is necessary followed by at least 1 P to have any effect on the output - 3 actions (SCP) allow you to at most double the size - 4 actions (SCPP) is more efficient, allowing you to triple the size - 5 actions (SCPPP) is yet more efficient, allowing you to quadruple the size - 6 actions of (SCPPPP) would allow you to quintuple the size (still more efficient than SCPSCP) - 7 actions gets interesting as SCPSCPP, SCPPSCP and SCPPPPP would all sextuple the size - 8 actions is the tipping point, where SCPPPPPP would hextuple the size, but you can achieve a better result by combining the previous steps - only SCP+SCPPP [identical to SCPPP+SCP, as multiplication is commutative] would make 8 actions, leading to octuple, or SCPP+SCPP leading to nonuple That means that SCPPPPPP is no longer a viable choice and that more than 7 actions always means it's more effective to combine shorter sequences to muliply things out. The order of them does not matter. As x^y gets bigger faster with increases in y than with increases in x, and we can see from the list above that, whenever we starting combining sequences, multiplying the size by 9 is the most efficient we can do, for any significant large number n, we'd just wants as many repetitions of SCPP as possible in there, only switching to something else down the list when reaching the end goal can be done in fewer steps than multiplying by 3 repeatedly (and there's only a finite number of combinations there, when the number of actions is not evenly divisible by 4, not allowing you to use the SCPP sequence). Disregarding any further occurrences of SCPP, you can do a combination of 1 sequence: SCP (x2), SCPPP (x4), SCPPPP (x5), SCPPPPP (x6) or a combination of 2 sequences, once again disregarding SCPP and more efficient shorter combinations:
SCPPPSCPPP (x16), SCPPPSCPPPP (x20) Even SCPPPPSCPPPP (x25) is already less efficient than the SCPPSCPPSCPP (x27) sequence of the same length. So I figure that to reach at least n, you would always end up with as many repetitions of SCPP as possible, followed by one of the 6 above combinations (of one or two sequences, at most 11 actions). Any sequence of 12 actions or more could be more efficiently reduced to ones containing SCPP again. |