g | x | w | all
Bytes Lang Time Link
068AWK250521T164941Zxrs
046Arturo230730T060838Zchunes
033Factor230730T054729Zchunes
003Thunno 2230729T175613ZThe Thon
110Racket230717T204610ZEd The &
020V vim230717T202840Znmjcman1
094Setanta230717T185420Zbb94
020Juby230717T162000ZJordan
005Vyxal220105T220202Zemanresu
009K oK191023T063920ZGalen Iv
054Wren191028T055801Zuser8505
063Bracmat191024T102547ZBart Jon
075Ceylon191026T010123ZPaŭlo Eb
009Husk191025T071508ZUnrelate
064dc191025T012057Zbrhfl
055Zsh191024T152019ZGammaFun
088C gcc191023T215729Zforevers
057Python 2191023T003827ZChas Bro
049PowerShell191023T122359ZVeskah
057Gema191023T162912Zmanatwor
067Lua191023T152723Zanderium
008QuadR191023T130510ZAdá
021Retina191023T122932ZNeil
055Lua191023T111929Zval - di
009Charcoal191023T093713ZNeil
063Icon191023T065835ZGalen Iv
040JavaScript ES6191023T010913ZArnauld
057Red191023T070919ZGalen Iv
030Haskell191023T080112Zxnor
013J191023T074555ZBubbler
055Python 2191023T073325Zxnor
060Python 3191023T060131ZPaul-B98
018J191023T062521ZJonah
00305AB1E191023T064159ZKevin Cr
022Perl 5191023T061453ZNahuel F
005Japt h191023T052256ZGymhgy
055C# Visual C# Interactive Compiler191023T051448ZGymhgy
007Brachylog191023T002715ZUnrelate
030Haskell191023T012529ZUnrelate
058PHP191023T025828ZNight2
005Jelly191023T003445ZUnrelate
147C# .NET Core191023T020320ZHiddenBa
016APL Dyalog Unicode191023T015544ZBubbler
041Wolfram Language Mathematica191023T005048Zatt
030Ruby191023T004736ZValue In
028Perl 6191023T002440ZJo King

AWK, 68 bytes

{for(s=$1;$2--;){k=split(s,a,X);for(s=j=X;j++<k;)s=s a[j]+48}}1,$0=s

Attempt This Online!

Arturo, 46 bytes

$=>[&do.times:&->join to[:integer]to[:char]<=]

Try it!

Factor, 33 bytes

[ [ [ >dec ] map-concat ] times ]

Attempt This Online!

Thunno 2, 3 bytes

{CJ

Try it online!

Explanation

{CJ  # Implicit input
{    # Repeat N times:
 C   #  Get ASCII codes
  J  #  Join into a string
     # Implicit output

Racket, 110 bytes

(define(a x n)(if(< n 1)x(a(string->number(string-join(for/list([c(~a x)])(~a(char->integer c)))""))(- n 1))))

Try it online!

Also, as a bonus, it works with bigger numbers as well! For example: (a 11 3) and (a 123456789 10) (this gives a number with 9216 digits) are both valid inputs.


Explanation

  1. We receive two inputs x (the number to expand) and n the number of expansions.

  2. If n is less than 1, we return x as is.

  3. We iterate through all the digits of x by converting x to a string. During each iteration, we obtain the string representation of each digit's ASCII value and append it to the list.

    1. for/list handle all list appending for us, so all we need to do is return the string at the end of the iteration.
  4. Once the list is obtained, we join it to a string without any spaces between all the values.

  5. We convert the final string back into a number, pass it to step 1 as the new x and pass n - 1 as the n argument.

    1. Repeat steps 1-5 until step 2 is executed.
(define (expand-to-ascii x n)
  (if (< n 1)
      x
      (a (string->number
           (string-join
             (for/list ([c (~a x)])
               (~a (char->integer c)))
             ""))
         (- n 1))))

Have an awesome week ahead!

V (vim), 20 bytes

ÀñÓ./½submatch(0)+48

Try it online!

Input is given as buffer input and an argument. It runs :s/./\=submatch(0)+47/g the arg number of times

Setanta, 106 94 bytes

gniomh(d,n){le i idir(0,n){i=""le j idir(0,fad(d)){i+=go_teacs(48+go_uimh(d[j]))}d=i}toradh d}

Requires d to be passed in as a string.

Try it here!

J-uby, 20 bytes

Takes curried arguments with \$n\$ first and \$digit\$ second, i.e. F[n][digit].

:**&(S|:bytes|:join)

Attempt This Online!

Explanation

The function S|:bytes|:join converts to a string, gets the character codes, then joins them. The :** operator applies that function \$n\$ times.

Vyxal, 5 bytes

(SCfṅ

Try it Online!

(     # Input times...
 S    # Stringify
  C   # Charcodes 
   fṅ # Join together (Should just be ṅ, but bugs)

K (oK), 13 9 bytes

-4 bytes thanks to ngn

(,/$`i$)/

Try it online!

Wren, 54 bytes

One iteration is simply x.bytes.join()....

Fn.new{|x,y|
for(i in 1..y)x=x.bytes.join()
return x
}

Try it online!

Bracmat, 63 bytes

get':%?a %?n&whl'(!n+-1:~<0:?n&str$vap$((=.asc$!arg).!a):?a)&!a

Try it online!

Ceylon, 75

String?x(String d,Integer n)=>loop(d)((s)=>"".join(s*.hash)).skip(n).first;

Try it online!

Here is the long version, which might be more understandable:

"""convert a string of digits (or other characters) into a string of the digits'
   ASCII values, represented themselves as decimal ASCII digits (without any
   separator).
"""
String asciify(String input) {
    // maps each character of the string into its ASCII value (actually unicode, 
    // but that's the same for the relevant range), and this to decimal digits.
    {String*} asciiDecimals = input.map((Character c) => c.integer.string);
    // concatenate all those strings
    return String.sum(asciiDecimals);
}

"""expand a digit (or a string) into its ASCII representation several times."""
String asciiExpand(String digit, Integer times) {
    // infinite (lazy) list of all the expansions
    {String*} allExpansions = loop(digit)(asciify);
    // take the entry `times` steps from the first.
    return allExpansions.getFromFirst(times)
          // If that is null (which can't happen, as we have an infinite list),
          // throw an exception instead.
          else nothing;
}

Tricks used to make it shorter:

I also thought I found a shorter way of writing this (which works for finite iterables), but it actually doesn't work here, because loop returns an infinite iterable, and trying to convert it into a sequence (with [* ... ])will run forever until it runs out of memory:

String?y(String d, Integer n)=>[*loop(d)((s)=>"".join(s*.hash))][n];

Husk, 9 bytes

~!ȯ¡ṁosc→

Try it online!

Mostly a translation of the Haskell answer, with some combinator stuff thrown in to deal with 1-indexing.

 !           Index into
  ȯ¡         the infinite list of iterations of
    ṁ        concat-mapping
      s      show
     o       .
       c     ord
~            starting with the first argument, and with the index being the second argument
        →    incremented.

dc, 64 bytes

dsi[A~48+lrZAr^*lr+srdZ1<P]sP[0srA*lPxlPxlrI3^/li1-dsi0<M]sM0<Mp

Try it online!

I wouldn't be surprised if I could golf this down a bit. It's more verbose than anticipated due to handling a lot of edge cases, etc. Put the 'digits' to transform on the stack first, then the number of iterations.

dsi stores the number of iterations in i. Macro P does one iteration of the transformation. A~ to divide w/ remainder by 10, 48+ to give us ASCII. Variable r holds our result. lrZAr^* loads this variable for the sake of finding how many digits it currently has. It shifts our ASCII value left (decimal) this many places (48 becomes 4800), then lr+sr adds our old value r and stores the result back into r. Here's tricky situation number one: dZ1<P says to keep running P as long as our source material is at least one digit. But, we need to do a final run when we hit 1 digit as well.

Macro M is our main. 0sr initializes r to 0, and then... the rest of this I'm going to explain a bit out of order. For each iteration, we need to run P twice, because of the aforementioned single-digit thing. So, lPxlPx. However, this screws us up when our original value is only a single digit. Plus, we often get left with an extra 0 at the right side. A* multiplies the original by ten, and I3^/ at the end divides by a thousand. This is pretty goofy, but it ensures all values work ok. li1-dsi0<M keeps running M until i, our number of iterations, is complete. We can't do dsMx as per usual to save & run a macro, because this won't work if our number of iterations is 0. So we test for that, leaving us with the longer sM0<M. Finally, we print.

Zsh, 55 bytes

(($2*#1))&&<<<`$0 $[#1] $[$2-1]``$0 "${1:1}" $2`||<<<$1

Try it online!

A port of @xnor's Python 2 solution, it came in just two bytes below my first solution. We require quotes around ${1:1}, otherwise it is removed when empty, turning $2 into $1 on the recursive call.


If the repeated expansion never grows past 2^63, 53 bytes with a recursive math function:

(){s=
for c (${(s::)1})s+=$[#c]
(($2?$0(s,$2-1):$1))}

Try it online!

C (gcc), 88 bytes

Thanks ceilingcat and peter cordez for their contributions.

z(v,n){for(sprintf(o,"%d",v);n--;)for(strcpy(t,o),v=0;t[v];)sprintf(o+v++*2,"%d",t[v]);}

Try it online!

Python 2, 63 57 bytes

f=lambda i,n:n and f(''.join(`ord(c)`for c in i),n-1)or i

Try it online!

-6 bytes due to Jonathan Allan noting that the input can be a string.

Takes input as single digit string and an integer number of repetitions.

PowerShell, 51 49 bytes

-2 bytes thanks to mazzy

param($s,$n),1*$n|%{$s=-join($s|% t*y|%{+$_})};$s

Try it online!

Gema, 57 characters

* *=@set{d;*}@repeat{*;@set{d;@x{$d}}}$d
x:?=@char-int{?}'

Sample run:

bash-5.0$ echo -n '0 3' | gema '* *=@set{d;*}@repeat{*;@set{d;@x{$d}}}$d;x:?=@char-int{?}'
53505354

Try it online!

Lua, 67 bytes

i=io.read d=i(1)for _=1,i()do
d=d:gsub(".",string.byte)end
print(d)

Try it online!

Let d be the digit we will transform (always of length 1, so we ask to read 1 character with io.read(1)). If N > 0, replace each character by its byte value. Return the digit.

QuadR, 8 bytes

Translation of Nahuel Fouilleul's solution. Thanks to Veskah for pointing it out.

.
⎕UCS⍵M

Try it online!

. replace any character

⎕UCS with the Universal Character Set ordinal of the
⍵M Match

This is equivalent to the Dyalog APL expression '.'⎕R{⍕⎕UCS⍵.Match}⍣⎕⊢⍞. Try it online!

Retina, 21 bytes

.+¶

"$+"+`.
$.(*_48*

Try it online! Takes N as the first input and the digit as the second input. Explanation:

.+¶

Delete N from the output.

"$+"+`

Repeat N times.

.
$.(*_48*

Replace each digit with its ASCII code.

Lua, 55 bytes

a,N=...for i=1,N do a=a:gsub('.',('').byte)end
print(a)

Try it online!

Take input as arguments. Explanation is fairly obvious.

Alternative solution: Lua, 60 bytes

a,N=...for i=1,N do a=table.concat{a:byte(1,-1)}end
print(a)

Try it online!

Charcoal, 9 bytes

FN≔⭆η℅κηη

Try it online! Link is to verbose version of code. Takes N as the first input and the digit as the second input. Explanation:

FN

Repeat N times...

≔⭆η℅κη

Map each character to its ordinal and concatenate.

η

Output the final result.

Sadly FN≦℅ηη doesn't work...

Icon, 72 63 bytes

Inspired by @xnor's Python 2 solution

procedure f(d,n)
return(*d*n<1&d)|f(48+!d,n-1)||f(d[2:0],n)
end

Try it online!

JavaScript (ES6),  43  40 bytes

Thanks to @tsh for reminding me that I didn't use currying this time :p (-3 bytes)

Takes input as (N)(digit).

n=>g=k=>n--?g(k.replace(/./g,c=>c^48)):k

Try it online!

How?

This is a simple recursive function. The only trick in there is c^48. Because c is a string, we need to coerce it to an integer. We could do +c+48, but that would be 1 byte longer. Using a bitwise XOR is safe here, as \$48\$ is \$110000_2\$ and c is less than \$10000_2\$.

Red, 62 57 bytes

func[d n][loop n[parse d[any[change p: skip(0 + p/1)]]]d]

Try it online!

Explanation:

f: func [ d n ] [                  ; a function with 2 parameters
    loop n [                       ; repeat n times
        parse d [                  ; parse the string with the following rules        
            any [                  ; one ore more 
                change p: skip     ; change any string with length 1 (a single digit)
                (0 + p/1)          ; with its representation as a number 48..57 
            ]                       
        ]
    ]
    d                              ; return the altered string
]

Haskell, 30 bytes

(!!).iterate(show.fromEnum=<<)

Try it online!

J, 14 13 bytes

[:,":@u:~"+&3

Try it online!

How it works

The "bind" operator & is commonly used to bind a constant to a dyad, so that it can be used as a monad. However, the same form can be used as a dyad: x n&v y (where n is a noun and v is a dyadic verb) or x v&n y applies monadic n&v or v&n to y repeatedly x times. Using this feature, we can design the target function like this:

x some_constant&some_dyad y
run `some_constant some_dyad y` x times
... or ...
x some_dyad&some_constant y
run `y some_dyad some_constant` x times

In this case, there is an obvious choice for the some_constant, which is 3 for 3 u: y.

And here goes the full explanation:

[:,":@u:~"+&3
           &   Apply this function x times...
      u:~   3  Convert chars of y to ASCII values (3 u:)
   ":@   "+    Convert each number back to string
[:,            Flatten the array to get a single string

Python 2, 55 bytes

f=lambda s,n:f(`ord(s[0])`,n-1)+f(s[1:],n)if n*s else s

Try it online!


56 bytes

lambda s,n:eval("''.join(`ord(c)`for c in"*n+" s"+")"*n)

Try it online!

Generates and evaluates monstrosities like:

''.join(`ord(c)`for c in''.join(`ord(c)`for c in''.join(`ord(c)`for c in s)))

56 bytes

f=lambda s,n:s*0**n or''.join(`ord(c)`for c in f(s,n-1))

Try it online!

Python 3, 69 60 bytes

f=lambda n,i:i and f(''.join(str(ord(c))for c in n),i-1)or n

Try it online!

J, 18 bytes

([:,3":@u:"0])@[&0

Try it online!

From the J dictionary:

The phrase x f@[&0 y is equivalent to f^:x y , apply the monad f x times to y.

That is, it's a shortcut for power of ^: applied as many times as the left arg. Which explains the

(  )@[&0

part of the code. Now for what's in the parentheses:

3 u:] converts to a unicode code point, but unfortunately has infinite rank, and we want to apply it with 0 rank, hence the added "0. The code point is a number, and we convert it back to a string with format ":. Finally, we flatten , this list of strings.

05AB1E, 3 bytes

FÇJ

Takes N as first input and the digit as second.

Try it online or verify all test cases.

Explanation:

F    # Loop the (implicit) first input (N) amount of times
 Ç   #  Convert the characters in the string at the top of the stack to its unicode values
     #  (which will take the second input implicitly in the first iteration)
  J  #  Join these unicode integers together to a single string
     # (after the loop, the result is output implicitly)

Perl 5, 22 bytes

eval's/./ord$&/ge;'x<>

Try it online!

Japt -h, 5 bytes

VÆ=mc

Try it

VÆ=mc   V = number of times, U = digit
VÆ      V times do: (Collects each result into an array)
  =mc     Map every digit of U to it's ASCII value, and make that the new U
-h      Take last element

C# (Visual C# Interactive Compiler), 55 bytes

a=>b=>{for(;b-->0;a=a.SelectMany(l=>l-0+""));return a;}

Try it online!

Brachylog, 7 bytes

{ṫạc}ⁱ⁾

Try it online!

{   }ⁱ     Repeat
 ṫ         stringifying,
  ạ        converting to a list of codepoints,
   c       and concatenating
      ⁾    a number of times equal to the last element of the input.

Haskell, 30 35 30 bytes

(!!).iterate(>>=show.fromEnum)

Try it online!

+5 then -5 bytes from Jo King clarifying the rules and then working it into pointfree.

My first Haskell golf so I've probably done something horribly wrong. In addition to having misspelled golf, I tried to import ord without putting it in my byte count!

    .                             The composition of
     iterate                      infinitely iterating, starting with the argument,
            (>>=             )    concatenating the results of mapping
                show              finding the string representation of
                    .fromEnum     the codepoint of the argument,
(!!)                              with indexing into the resulting infinite list.

PHP, 58 bytes

for([,$a,$b]=$argv;$b--;)$a=strtr($a,range(48,57));echo$a;

Try it online!

Input digit and number are two command arguments ($argv) in same order.

Comented

for(
  [,$a,$b]=$argv;  // $a is input digit and $b is number
  $b--;            // loop $b times
)
  $a=              // set $a to
    strtr(         // strtr in array mode, replaces keys with values
      $a,          // replace in $a itself
      range(48,57) // an array with keys 0...9 and values 48...57
    );
echo$a;            // at the end, output $a

Jelly, 7 5 bytes

ṾOVƊ¡

Try it online!

-2 bytes after a friend helped me figure out what's wrong with O

For some reason, to run all test cases with a footer, an extra byte is required for the explicit nilad: Try it online!

Ṿ        Stringify the input
 O       and convert each character to a codepoint,
  V      then concatenate them and eval the result,
   Ɗ¡    repeated a number of times equal to the right argument.

C# (.NET Core), 174 147 bytes

class Z{static void Main(string[] a){for(int n=int.Parse(a[1]);n-->0;){var x="";foreach(char c in a[0])x+=c-0;a[0]=x;}System.Console.Write(a[0]);}}  

Big help from Jo King.

Try it online!

Ungolfed

class Z
{
   static void Main(string[] a)
    {
        int n = int.Parse(a[1]);
        for (; n-- > 0;)
        {
            var x = "";
            foreach (char c in a[0])
                x += c - 0; //c-0 gets converted to int, and then the int is 
                                   //automatically converted to a string
            a[0]=x;
        }
        System.Console.Write(a[0]);
    }
}

APL (Dyalog Unicode), 16 bytes

{(∊⍕¨∘⎕UCS)⍣⍵⊢⍺}

Try it online!

Left input is a one-digit string, right input is the number of iteration. Returns the string representation of the result.

How it works

{(∊⍕¨∘⎕UCS)⍣⍵⊢⍺}
{              }  Dyadic dfn, ⍺=digit string, ⍵=iteration
             ⊢⍺   Start with ⍺
 (        )⍣⍵     Repeat ⍵ times...
      ⎕UCS        Convert each char to Unicode codepoint
   ⍕¨∘            Convert each number back to string
  ∊               Enlist (flatten) all chars into one string

Wolfram Language (Mathematica), 41 bytes

""<>ToString/@ToCharacterCode@#&~Nest~##&

Try it online!

Ruby, 30 bytes

->s,n{n.times{s=s.bytes*''};s}

Try it online!

Perl 6, 28 bytes

{($^a,*.ords.join...*)[$^b]}

Try it online!

Explanation:

{                          }  # Anonymous codeblock
 (               ...*)[$^b]   # Index into an infinite list
  $^a,                        # Starting from the given number
      *                       # Where each element is
       .ords.join             # The ordinal values joined