Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
shared void run() {
|
||||
|
||||
function lookAndSay(Integer|String input) {
|
||||
|
||||
variable value digits = if (is Integer input) then input.string else input;
|
||||
value builder = StringBuilder();
|
||||
|
||||
while (exists currentChar = digits.first) {
|
||||
if (exists index = digits.firstIndexWhere((char) => char != currentChar)) {
|
||||
digits = digits[index...];
|
||||
builder.append("``index````currentChar``");
|
||||
}
|
||||
else {
|
||||
builder.append("``digits.size````currentChar``");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return builder.string;
|
||||
}
|
||||
|
||||
variable String|Integer result = 1;
|
||||
print(result);
|
||||
for (i in 1..14) {
|
||||
result = lookAndSay(result);
|
||||
print(result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue