Skip to main content
added 82 characters in body
Source Link
H.PWiz
  • 11.6k
  • 2
  • 22
  • 56

Husk, 1313 12 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫṁit§+SRL§+ḣṫ

Try it online!Try it online!

Explanation

              -- implicit input, say "123"
  §+ §+         -- concatenate the results of the following two functions
    SR SR       --  ¹repeat the input n times, where n is the result of the next function
        L      --   length                                                  ["123","123"]
       §+  §+   --  ²concatenate the results of the following two functions
             --     prefixes                                              ["","1","12","123"]
          otṫ --     allsuffixes but the first suffix                              ["23"            ["123","23","3",""]
              -- inner concatenation                                       ["","1","13","123","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","123","23","3",""]
  t           -- all but the first element                                ["123","","1","13","123","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer (where "" converts to 0)
  

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
             --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer (where "" converts to 0)

Husk, 13 12 bytes

ṁit§+SRL§+ḣṫ

Try it online!

Explanation

              -- implicit input, say "123"
   §+         -- concatenate the results of the following two functions
     SR       --  ¹repeat the input n times, where n is the result of the next function
       L      --   length                                                  ["123","123"]
        §+   --  ²concatenate the results of the following two functions
            --     prefixes                                              ["","1","12","123"]
           --     suffixes                                              ["123","23","3",""]
              -- inner concatenation                                      ["","1","13","123","123","23","3",""]
              -- outer concatenation                                      ["123","123","","1","13","123","123","23","3",""]
  t           -- all but the first element                                ["123","","1","13","123","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer (where "" converts to 0)
  
added 25 characters in body
Source Link
H.PWiz
  • 11.6k
  • 2
  • 22
  • 56

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
         ḣ    --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer (where "" converts to 0)

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
         ḣ    --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
         ḣ    --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer (where "" converts to 0)
added 901 characters in body
Source Link
H.PWiz
  • 11.6k
  • 2
  • 22
  • 56

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
         ḣ    --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Husk, 13 bytes

I have a feeling this has golfing potential

ṁi§+SRL§+ḣotṫ

Try it online!

Explanation

              -- implicit input, say "123"
  §+          -- concatenate the results of the following two functions
    SR        --  ¹repeat the input n times, where n is the result of the next function
              --   length                                                  ["123","123"]
       §+     --  ²concatenate the results of the following two functions
         ḣ    --     prefixes                                              ["","1","12","123"]
          otṫ --     all but the first suffix                              ["23","3",""]
              -- inner concatenation                                       ["","1","13","123","23","3",""]
              -- outer concatenation                                       ["123","123","","1","13","123","23","3",""]
ṁ             -- map then sum
 i            --   convert to integer
Source Link
H.PWiz
  • 11.6k
  • 2
  • 22
  • 56
Loading