| Bytes | Lang | Time | Link |
|---|---|---|---|
| 040 | Vyxal 3 | 240920T160211Z | Ginger |
| 019 | Japt | 240919T152932Z | Shaggy |
| nan | Vyxal | 240919T143623Z | lyxal |
| 088 | Perl 5 MListUtil=uniq F | 240918T164826Z | Xcali |
| 246 | C# | 170201T211936Z | CSharpie |
| 141 | PHP | 170523T095510Z | Jör |
| 027 | Jelly | 170523T031047Z | fireflam |
| 116 | Python 2 | 170201T131224Z | Rod |
| 117 | Mathematica | 170201T182038Z | Greg Mar |
| 021 | 05AB1E | 170201T143939Z | Emigna |
| 104 | PowerShell | 170131T234848Z | briantis |
Vyxal 3, 40 bytes
fwṆDᵛCZuVƛ\$:9>[ᵂ:9∥%Ṡ←w9pY→$W|n)f}5Θḣᵛ“
fwṆDᵛCZuVƛ\$:9>[ᵂ:9∥%Ṡ←w9pY→$W|n)f}5Θḣᵛ“
f # Convert starting number to a list of digits
wṆ }5Θḣ # Four times:
DᵛCZuV # [[digit, number of occurrences] for digit in number]
ƛ\$ ) # For each digit:
:9>[ # If there's more than nine occurrences:
ᵂ:9∥%Ṡ # Divmod by 9
←w9p # Wrap in a list and prepend 9
Y # Repeat that list (digit count // 9) times
→$W # Concatenate the repeated list with [digit, digit count % 9]
|n) # Otherwise don't do anything
f ᵛ“ # Flatten and join to strings
💎
Created with the help of Luminespire.
Japt, 22 19 bytes
Input as a string, output as an array of strings.
4Æ=ü@bXÃcò9 ËÊ+DÎì
4Æ=ü@bXÃcò9 ËÊ+DÎì :Implicit input of string U
4Æ :Map the range [0,4)
= : Reassign to U
ü : Group & sort by
@ : Passing each X through the following function
bX : First index of X in U
à : End grouping
c : Flat map
ò9 : Partitions of length 9
Ë : Map each D
Ê : Length
+ : Append
DÎ : First character of D
à : End map
¬ : Join to a string
Vyxal, 139 bitsv2, 17.375 bytes
4(Ċƛ÷9ḋ\91"*∑MRṅ∑;∑…
Bitstring:
0100101010101001110011011100001001011100011110001100011100101111100011011010111010000101111111000110011100010011000000111001010111100100001
Explained
4(Ċƛ÷9ḋ\91"*∑MRṅ∑;∑…
4( # 4 times:
Ċ # [[x, top.count(x)] for x in top]
ƛ ; # To each count pair:
÷ # Dump
9ḋ # Divmod by 9
\91" # ["9", 1]
* # Repeat the 9 (count // 9) times, leave the count % 9 as is
MR # Append x to each character in ^
ṅ∑ # Join into a single string
∑ # Join all that into a single string
… # and print without popping
💎
Created with the help of Luminespire.
Perl 5 -MList::Util=uniq -F, 88 bytes
my$a;for$t(uniq@F){$n=0;1while s/$t//&&++$n<9;$a.=$n.$t;/$t/&&redo}say$_=$a;++$c<4&&redo
C# 246 bytes
namespace System{using Linq;using f=String;class p{static void Main(f[] s){f p=s[0];for(int i=0,n;i++<4;Console.Write(p+" "))p=f.Concat(p.GroupBy(c=>c).SelectMany(g=>new int[(n=g.Count())/9].Select(_ =>"9"+g.Key).Concat(new[]{n%9+""+g.Key})));}}}
Ungolfed:
namespace System
{
using Linq;
using f = String;
class p
{
static void Main(f[] s)
{
f p = s[0];
for (int i = 0, n; i++ < 4; Console.Write(p + " "))
p = f.Concat(p.GroupBy(c => c).SelectMany(g =>
new int[(n = g.Count()) / 9].Select(_ => "9" + g.Key).Concat(new[] { n % 9 + "" + g.Key }
)));
Console.ReadKey();
}
}
}
Try it here (Type input into bottom frame once its compiled and hit ENTER)
PHP, 141 Bytes
for($a=$argn;$i++<4;$a=$o,print$a._,$o="")foreach(array_count_values(str_split($a))as$n=>$c)$o.=str_repeat("9$n",$c/9^0).($c%9?($c%9).$n:"");
Jelly, 27 bytes
L,Ḣ
D©®i$ÞŒgs9$€Ç€€FḌµ4µÐ¡Ḋ
The successive €s cannot be nested because chains cannot be nested.
Nesting with separate link: 27 bytes.
Print instead of cumulation: 27 bytes.
Explanation
L,Ḣ - helper function, does the look-and-say. Input is a list of digits
, - return 2-tuple of:
L - length of input
Ḣ - first element of input
D©®i$ÞŒgs9$€Ç€€FḌµ4µÐ¡Ḋ - main link, takes input as integer
µ4µÐ¡ - repeat 4 times, saving the results of each iteration:
D - convert integer to list of digits
© - save into register, for later use
®i$Þ - sort list's elements by first occurrence in list
Œg - group runs of equal elements
s9$€ - split each run into sets which are at most 9 elements long
Ç€€ - do the look-and-say with helper function
FḌ - flatten and convert back into integer for next iteration
Ḋ - remove the first element from the list since it includes the
initial element
Python 2, 116 bytes
x=input()
exec"x=''.join(x.count(n)/9*(`9`+n)+`x.count(n)%9`+n for i,n in enumerate(x)if n not in x[:i]);print x;"*4
Mathematica, 117 bytes
Grid@{Rest@NestList[FromDigits[Join@@(Reverse/@Tally@IntegerDigits@#//.{a_,b_}/;a>9->{9,b}~Sequence~{a-9,b})]&,#,4]}&
Seems like it shouldn't need to be this long.
05AB1E, 30 23 21 bytes
4F©Ùv9y«®y¢9‰`U×XyJ}=
Explanation
4F # 4 times do:
© # store a copy of the current number in register
Ùv # for each unique digit y in the number
9y« # concatenate 9 with y
®y¢ # count occurrences of y in current number
9‰ # divmod by 9
`U # store the result of modulus in X
× # repeat the number "9y" result_of_div times
X # push result of modulus
y # push y
J # join everything to one number
} # end inner loop
= # print the current number without popping
PowerShell, 111 104 bytes
$z=$args;1..4|%{($z=-join($z-split'\B'|group|%{for($c,$n=$_.Count,$_.Name;$c-gt9;$c-=9){"9$n"}"$c$n"}))}