Skip to main content
added 72 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 19 bytes

`10YrtY.ynhX<:&)wDt

###How it works

Try it online! The online compiler does gradually produce the outputs with the pauses.

`         % Do...while loop
  10Yr    %   Random integer from 1 to 10
  tY.     %   Duplicate. Pause that many seconds
  y       %   Duplicate the second-top element. This is the remaining string; or it
          %   takes the input implicitly in the first iteration
  n       %   Number of elements
  hX<     %   Minimum of the number of elements and the random number
  :       %   Range from 1 to that
  &)      %   Apply as index. Push the substring as given by the index and the
          %   remaining substring
  w       %   Swap
  D       %   Display
  t       %   Duplicate the remaining substring. This is used as loop condition:
          %   if non-empty execute next iteration
          % End loop implicitly

MATL, 19 bytes

`10YrtY.ynhX<:&)wDt

###How it works

Try it online!

`         % Do...while loop
  10Yr    %   Random integer from 1 to 10
  tY.     %   Duplicate. Pause that many seconds
  y       %   Duplicate the second-top element. This is the remaining string; or it
          %   takes the input implicitly in the first iteration
  n       %   Number of elements
  hX<     %   Minimum of the number of elements and the random number
  :       %   Range from 1 to that
  &)      %   Apply as index. Push the substring as given by the index and the
          %   remaining substring
  w       %   Swap
  D       %   Display
  t       %   Duplicate the remaining substring. This is used as loop condition:
          %   if non-empty execute next iteration
          % End loop implicitly

MATL, 19 bytes

`10YrtY.ynhX<:&)wDt

###How it works

Try it online! The online compiler does gradually produce the outputs with the pauses.

`         % Do...while loop
  10Yr    %   Random integer from 1 to 10
  tY.     %   Duplicate. Pause that many seconds
  y       %   Duplicate the second-top element. This is the remaining string; or it
          %   takes the input implicitly in the first iteration
  n       %   Number of elements
  hX<     %   Minimum of the number of elements and the random number
  :       %   Range from 1 to that
  &)      %   Apply as index. Push the substring as given by the index and the
          %   remaining substring
  w       %   Swap
  D       %   Display
  t       %   Duplicate the remaining substring. This is used as loop condition:
          %   if non-empty execute next iteration
          % End loop implicitly
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 19 bytes

`10YrtY.ynhX<:&)wDt

###How it works

Try it online!

`         % Do...while loop
  10Yr    %   Random integer from 1 to 10
  tY.     %   Duplicate. Pause that many seconds
  y       %   Duplicate the second-top element. This is the remaining string; or it
          %   takes the input implicitly in the first iteration
  n       %   Number of elements
  hX<     %   Minimum of the number of elements and the random number
  :       %   Range from 1 to that
  &)      %   Apply as index. Push the substring as given by the index and the
          %   remaining substring
  w       %   Swap
  D       %   Display
  t       %   Duplicate the remaining substring. This is used as loop condition:
          %   if non-empty execute next iteration
          % End loop implicitly