Skip to main content
added 157 characters in body
Source Link
Bubbler
  • 78.1k
  • 5
  • 149
  • 466

Picat, 41 bytes

f(1)=0.
f(N)=[f(N/>I)+I+1:I in 2..5].min.

Attempt This Online!

Same approach as xnor's Python answer: recurses through the cases of ctrl+A C V{1,4} to get at least N characters as a result.

With the help of table in the header section, it computes all test cases almost instantly. Thanks to the /> operator which does ceil-ed integer division, all intermediate arguments are integers without any complications, and we can simply pattern-match the 1 as the base case.

Bitwise not operator ~ exists in Picat, but it doesn't like putting the two symbols -~ side-by-side, so the usual -~ trick does not save any bytes.

Picat, 41 bytes

f(1)=0.
f(N)=[f(N/>I)+I+1:I in 2..5].min.

Attempt This Online!

Same approach as xnor's Python answer: recurses through the cases of ctrl+A C V{1,4} to get at least N characters as a result.

With the help of table in the header section, it computes all test cases almost instantly. Thanks to the /> operator which does ceil-ed integer division, all intermediate arguments are integers without any complications, and we can simply pattern-match the 1 as the base case.

Picat, 41 bytes

f(1)=0.
f(N)=[f(N/>I)+I+1:I in 2..5].min.

Attempt This Online!

Same approach as xnor's Python answer: recurses through the cases of ctrl+A C V{1,4} to get at least N characters as a result.

With the help of table in the header section, it computes all test cases almost instantly. Thanks to the /> operator which does ceil-ed integer division, all intermediate arguments are integers without any complications, and we can simply pattern-match the 1 as the base case.

Bitwise not operator ~ exists in Picat, but it doesn't like putting the two symbols -~ side-by-side, so the usual -~ trick does not save any bytes.

Source Link
Bubbler
  • 78.1k
  • 5
  • 149
  • 466

Picat, 41 bytes

f(1)=0.
f(N)=[f(N/>I)+I+1:I in 2..5].min.

Attempt This Online!

Same approach as xnor's Python answer: recurses through the cases of ctrl+A C V{1,4} to get at least N characters as a result.

With the help of table in the header section, it computes all test cases almost instantly. Thanks to the /> operator which does ceil-ed integer division, all intermediate arguments are integers without any complications, and we can simply pattern-match the 1 as the base case.

-