Skip to main content
added 4 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101
        % Implicit: input on stack as charcodes
N       % Set trailing newlines to False
@       % Reverse stack (so the charcodes are pulled off in order)
$       % While there are items left to print:
L       %    Push stack length
1TU     %    Push a random number 1-10
&W      %    Wait that amount of time
m:      %    min(time waited, chars left) times do:
'.      %    Print & Pop and print last char
        % Implicit: input on stack as charcodes
N       % Set trailing newlines to False
@       % Reverse stack (so the charcodes are pulled off in order)
$       % While there are items left to print:
L       %    Push stack length
1TU     %    Push a random number 1-10
&W      %    Wait that amount of time
m:      %    min(time waited, chars left) times do:
'.      %    Print & Pop last char
        % Implicit: input on stack as charcodes
N       % Set trailing newlines to False
@       % Reverse stack (so the charcodes are pulled off in order)
$       % While there are items left to print:
L       %    Push stack length
1TU     %    Push a random number 1-10
&W      %    Wait that amount of time
m:      %    min(time waited, chars left) times do:
'.      %      Pop and print last char
added 1359 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101

Pushy, 20 17 16 or 13 bytes

Not a very elegant solution..Depending on what's allowed, there are two solutions.

16 bytes:

                      % Implicit: input on stack as charcodes
@                     % Reverse input, so chars are pulled from start
 $             I      % While there are items on stack:
   T1U                %   Push a random number, 1-10
      &W              %   Wait that many seconds
  L     m:            %   min(time waited, chars left) times do:
          v;          %     Pull a char from the input.
            O"c       %   Print & delete pulled chars

13 bytes:

While coding the above answer I came up with this significantly shorter solution:

N@$L1TU&Wm:'.

Although it does a similar thing, it prints directly off the string rather than constructing a new string, for fewer bytes. This requires the N at the beginning of the program to prevent trailing newlines, or else each character would be on a newline.

However, whilst testing this I noticed a bug - stdout is line-buffered, so the program would wait the full length, and then display the hiccuped string.

I've fixed this in the latest commit by adding a simple .flush() - this is technically not adding a new feature to the language, just fixing a bug, but I understand if you don't take this answer into account :)

The breakdown looks like this:

        % Implicit: input on stack as charcodes
N       % Set trailing newlines to False
@       % Reverse stack (so the charcodes are pulled off in order)
$       % While there are items left to print:
L       %    Push stack length
1TU     %    Push a random number 1-10
&W      %    Wait that amount of time
m:      %    min(time waited, chars left) times do:
'.      %    Print & Pop last char

Pushy, 20 17 16 bytes

Not a very elegant solution...

                      % Implicit: input on stack as charcodes
@                     % Reverse input, so chars are pulled from start
 $             I      % While there are items on stack:
   T1U                %   Push a random number, 1-10
      &W              %   Wait that many seconds
  L     m:            %   min(time waited, chars left) times do:
          v;          %     Pull a char from the input.
            O"c       %   Print & delete pulled chars

Pushy, 20 17 16 or 13 bytes

Depending on what's allowed, there are two solutions.

16 bytes:

                      % Implicit: input on stack as charcodes
@                     % Reverse input, so chars are pulled from start
 $             I      % While there are items on stack:
   T1U                %   Push a random number, 1-10
      &W              %   Wait that many seconds
  L     m:            %   min(time waited, chars left) times do:
          v;          %     Pull a char from the input.
            O"c       %   Print & delete pulled chars

13 bytes:

While coding the above answer I came up with this significantly shorter solution:

N@$L1TU&Wm:'.

Although it does a similar thing, it prints directly off the string rather than constructing a new string, for fewer bytes. This requires the N at the beginning of the program to prevent trailing newlines, or else each character would be on a newline.

However, whilst testing this I noticed a bug - stdout is line-buffered, so the program would wait the full length, and then display the hiccuped string.

I've fixed this in the latest commit by adding a simple .flush() - this is technically not adding a new feature to the language, just fixing a bug, but I understand if you don't take this answer into account :)

The breakdown looks like this:

        % Implicit: input on stack as charcodes
N       % Set trailing newlines to False
@       % Reverse stack (so the charcodes are pulled off in order)
$       % While there are items left to print:
L       %    Push stack length
1TU     %    Push a random number 1-10
&W      %    Wait that amount of time
m:      %    min(time waited, chars left) times do:
'.      %    Print & Pop last char
added 7 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101

Pushy, 20 1717 16 bytes

Not a very elegant solution...

@$T1U&WLtm@$LT1U&Wm:v;O"cI

Give arguments on the command line: $ pushy hiccup.pshy 'hiccupinator'. This prints with trailing newlines after each 'hiccup'. Here's the breakdown:

                      % Implicit: input on stack as charcodes
@                     % Reverse input, (so chars are pulled from the start)
 $             I      % While stackthere isare notitems emptyon stack:
   T1U       %    Pick a uniform   %   Push a random number, 1-10
      &W        %      %   Wait that many seconds...
Ltm  L     m:      %      %   min(time waited, chars left) times do:
v;        %  v;          %     Pull a char from the input.
O"cI      %    Output and deleteO"c the      %   Print & delete pulled chars.

A 16-byte solution is available if OP allows picking a number between 1 - min(chars left, 10):

@$LTm1U&W:v;O"cI

Pushy, 20 17 bytes

Not a very elegant solution...

@$T1U&WLtm:v;O"cI

Give arguments on the command line: $ pushy hiccup.pshy 'hiccupinator'. This prints with trailing newlines after each 'hiccup'. Here's the breakdown:

@         % Reverse input (so chars are pulled from the start)
$         % While stack is not empty:
T1U       %    Pick a uniform random number, 1-10
&W        %    Wait that many seconds...
Ltm:      %    min(time waited, chars left) times do:
v;        %        Pull a char from the input.
O"cI      %    Output and delete the pulled chars.

A 16-byte solution is available if OP allows picking a number between 1 - min(chars left, 10):

@$LTm1U&W:v;O"cI

Pushy, 20 17 16 bytes

Not a very elegant solution...

@$LT1U&Wm:v;O"cI

Give arguments on the command line: $ pushy hiccup.pshy 'hiccupinator'. This prints with trailing newlines after each 'hiccup'. Here's the breakdown:

                      % Implicit: input on stack as charcodes
@                     % Reverse input, so chars are pulled from start
 $             I      % While there are items on stack:
   T1U                %   Push a random number, 1-10
      &W              %   Wait that many seconds
  L     m:            %   min(time waited, chars left) times do:
          v;          %     Pull a char from the input.
            O"c       %   Print & delete pulled chars
deleted 59 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101
Loading
added 2 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101
Loading
Source Link
FlipTack
  • 14.7k
  • 3
  • 54
  • 101
Loading