Skip to main content
added 58 characters in body
Source Link
Bubbler
  • 77.5k
  • 5
  • 149
  • 465

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing at least \$n\$ copies of the original string, using only select-all, copy, and paste operations.

In the Mathematics answer, \$S(n)\$ is defined asfound to satisfy the formula

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (0,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 0
2 => 3
4 => 5
8 => 8
16 => 10
32 => 13
64 => 15
128 => 18
256 => 20
512 => 23
1024 => 25
2048 => 28
4096 => 30
8192 => 33
16384 => 35
32768 => 38
65536 => 40
131072 => 43
262144 => 45
524288 => 48
1048576 => 50
2097152 => 53
100000 => 42

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing \$n\$ copies of the original string, using only select-all, copy, and paste operations.

\$S(n)\$ is defined as

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (0,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 0
2 => 3
4 => 5
8 => 8
16 => 10
32 => 13
64 => 15
128 => 18
256 => 20
512 => 23
1024 => 25
2048 => 28
4096 => 30
8192 => 33
16384 => 35
32768 => 38
65536 => 40
131072 => 43
262144 => 45
524288 => 48
1048576 => 50
2097152 => 53
100000 => 42

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing at least \$n\$ copies of the original string, using only select-all, copy, and paste operations.

In the Mathematics answer, \$S(n)\$ is found to satisfy the formula

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (0,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 0
2 => 3
4 => 5
8 => 8
16 => 10
32 => 13
64 => 15
128 => 18
256 => 20
512 => 23
1024 => 25
2048 => 28
4096 => 30
8192 => 33
16384 => 35
32768 => 38
65536 => 40
131072 => 43
262144 => 45
524288 => 48
1048576 => 50
2097152 => 53
100000 => 42
edited body
Source Link
Bubbler
  • 77.5k
  • 5
  • 149
  • 465

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing \$n\$ copies of the original string, using only select-all, copy, and paste operations.

\$S(n)\$ is defined as

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (1,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$\$ I = \{ (0,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 10
2 => 3
4 => 65
8 => 8
16 => 1110
32 => 13
64 => 1615
128 => 18
256 => 2120
512 => 23
1024 => 2625
2048 => 28
4096 => 3130
8192 => 33
16384 => 3635
32768 => 38
65536 => 4140
131072 => 43
262144 => 4645
524288 => 48
1048576 => 5150
2097152 => 53
100000 => 42

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing \$n\$ copies of the original string, using only select-all, copy, and paste operations.

\$S(n)\$ is defined as

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (1,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 1
2 => 3
4 => 6
8 => 8
16 => 11
32 => 13
64 => 16
128 => 18
256 => 21
512 => 23
1024 => 26
2048 => 28
4096 => 31
8192 => 33
16384 => 36
32768 => 38
65536 => 41
131072 => 43
262144 => 46
524288 => 48
1048576 => 51
2097152 => 53
100000 => 42

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing \$n\$ copies of the original string, using only select-all, copy, and paste operations.

\$S(n)\$ is defined as

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (0,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 0
2 => 3
4 => 5
8 => 8
16 => 10
32 => 13
64 => 15
128 => 18
256 => 20
512 => 23
1024 => 25
2048 => 28
4096 => 30
8192 => 33
16384 => 35
32768 => 38
65536 => 40
131072 => 43
262144 => 45
524288 => 48
1048576 => 50
2097152 => 53
100000 => 42
Became Hot Network Question
Source Link
bigyihsuan
  • 10.2k
  • 1
  • 22
  • 63

Minimum number of select-all/copy/paste steps for a string containing n copies of the original

This challenge is based on this Mathematics answer.

Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for generating a string containing \$n\$ copies of the original string, using only select-all, copy, and paste operations.

\$S(n)\$ is defined as

$$ S(n) = \min_{i=1, \ldots, 8} 5 \lceil \log_4(n/u_i) \rceil+c_i $$ where \$(c_i, u_i)\$ is a tuple from the set of tuples \$ I = \{ (1,1), (3,2), (7,6), (4,3), (8,9), (12,27), (16,81), (6,5) \}\$.

Test Cases

1 => 1
2 => 3
4 => 6
8 => 8
16 => 11
32 => 13
64 => 16
128 => 18
256 => 21
512 => 23
1024 => 26
2048 => 28
4096 => 31
8192 => 33
16384 => 36
32768 => 38
65536 => 41
131072 => 43
262144 => 46
524288 => 48
1048576 => 51
2097152 => 53
100000 => 42