Skip to main content
added 469 characters in body
Source Link
Laikoni
  • 26.4k
  • 7
  • 54
  • 116

Haskell, 84 bytes

f s@(x:r)|(n:m,x:r)<-span(`elem`['0'..'9'])s=(x<$[1..read$n:m])++f r|1<3=x:f r f e=e 

Try it online!

Explanation:

span(`elem`['0'..'9'])s splits the given string s into a prefix of digits and the remainder. Matching on the result on the pattern (n:m,x:r) ensures that the digit prefix is non-empty and binds the character after the digits to x and the remainder to r. x<$[1..read$n:m] reads the string of digits n:m as number and repeats x that many times. The result is concatenated to the recursive treatment of the remaining string r.

Haskell, 84 bytes

f s@(x:r)|(n:m,x:r)<-span(`elem`['0'..'9'])s=(x<$[1..read$n:m])++f r|1<3=x:f r f e=e 

Try it online!

Haskell, 84 bytes

f s@(x:r)|(n:m,x:r)<-span(`elem`['0'..'9'])s=(x<$[1..read$n:m])++f r|1<3=x:f r f e=e 

Try it online!

Explanation:

span(`elem`['0'..'9'])s splits the given string s into a prefix of digits and the remainder. Matching on the result on the pattern (n:m,x:r) ensures that the digit prefix is non-empty and binds the character after the digits to x and the remainder to r. x<$[1..read$n:m] reads the string of digits n:m as number and repeats x that many times. The result is concatenated to the recursive treatment of the remaining string r.

Source Link
Laikoni
  • 26.4k
  • 7
  • 54
  • 116

Haskell, 84 bytes

f s@(x:r)|(n:m,x:r)<-span(`elem`['0'..'9'])s=(x<$[1..read$n:m])++f r|1<3=x:f r f e=e 

Try it online!