시간에 민감한 에코


38

배경

이 echo프로그램은 매우 깔끔합니다. 당신은 그것에 대해 아무 말이나 할 수 있으며 매번 당신의 말을 완벽하게 반복합니다! 얼마나 멋진가요? 실망스럽게도 타이핑 속도에 관계없이 입력을 한 번에 반복하므로 매우 현실적이지 않습니다. 우리는 그것을 고쳐야 할 것입니다.

작업

귀하의 프로그램은 STDIN 또는 그와 가장 유사한 프로그램에서 입력을 받아야합니다. 사용자가 빈 줄을 입력 할 때까지 한 줄씩 읽어야하며, 프롬프트가 표시 될 수 있습니다. 그 후, 주어진 순서대로 행을 STDOUT 또는 가장 가까운 해당 행에 인쇄해야합니다. 마지막 (빈) 줄은 인쇄되지 않으며 마지막 인쇄 줄에는 줄 바꿈 문자가 없어도됩니다.

또한 프로그램은 각 줄 사이의 시간 간격을 유지해야합니다. 사용자 x가 줄을 입력하는 데 x몇 초가 걸리면 프로그램이 인쇄하는 데 몇 초가 걸립니다. 이것은 첫 줄과 마지막 줄에도 적용됩니다. 빈 줄은 인쇄되지 않지만 프로그램은 종료 전에 종료됩니다.

예

다음은 프로그램과의 세션 예입니다. 텍스트를 생성하지 않는 모든 작업은 괄호 안에 표시되며 (선택 사항) 프롬프트는로 표시됩니다 >.

[begin program]
> fhtagn[enter; 1.48s passed since starting program]
> yum yum[enter; 3.33s passed since previous enter]
> so cool![enter; 2.24s passed since previous enter]
> [enter; 0.23s passed since previous enter]
[wait 1.48s]fhtagn
[wait 3.33s]yum yum
[wait 2.24s]so cool!
[wait 0.23s, then end program]

조치가 없으면 세션은 다음과 같습니다.

> fhtagn
> yum yum
> so cool!
> 
fhtagn
yum yum
so cool!

규칙과 채점

대기 시간은 0.01 초 이내에 정확해야합니다 (실제로 평균적인 사람이 차이를 알 수 없다면 괜찮습니다). 가장 낮은 바이트 수가 이기고 표준 허점 은 허용되지 않습니다. 언어에이 작업을위한 기능이 내장되어 있으면 사용하지 못할 수 있습니다.


9
다음 단계 : 기본 리듬 게임을하는 프로그램 골프 : P
— Sp3000

프로그램이 문자를 출력하는 데 걸리는 시간을 무시할 수 있습니까? 내 언어가 문자를 출력하는 데 0.1 초가 걸린다는 것을 측정 할 수 있다면 그것을 고려해야합니까? 전체 공개, 나는 지연을 구현하기 위해> <> 통역사의 틱 시간을 사용할 계획이다; 이 경우 입력 시간을 줄인 루프를 표시 한 다음 디스플레이 루프가 경과 한 시간을 무시할 수 있습니까?
— Aaron

1
@AaronGOUZIT 나는 당신이 일관된 한, 프로그램이 줄을 인쇄하기 시작하는 순간 사이의 시간 간격이 모두 사용자로부터 취해 지거나 줄 인쇄가 끝나고 인쇄가 시작되기까지의 대기 시간 중 하나 인 것을 허용합니다. 다음은 모두 사용자가 가져옵니다.
— Zgarb

1
@TessellatingHeckler 후자; 예제 세션을 참조하십시오.
— Zgarb

1
@KritixiLithos 나는 단지 오른손을 사용했지만 yum yum다소 번거로 웠다 .
— Zgarb

답변:


15

CJam, 45 41 39 36 34 바이트

{eslN1$}g;es](es-fm3/{){_es>}g;o}/

이것은 물론 온라인 인터프리터에서는 의미가 없지만 Java 인터프리터에서는 작동합니다.

프롬프트가 표시되지 않습니다.

설명

{        e# Do while... (popping the condition from the stack)
  es     e#   Get the current timestamp.
  l      e#   Wait for a line to be entered and read it.
  N      e#   Push a linefeed.
  1$     e#   Copy the line we read - this terminates if the line is empty, because
         e#   empty strings/arrays are falsy.
}g
;        e# Discard the last linefeed (the one after the empty input).
es       e# Push the current timestamp (corresponding to the last, empty, input).
]        e# Wrap everything in an array. This is now a flat array containing:
         e#   - The initial timestamp.
         e#   - Three elements for each line: the line, a linefeed, the timestamp.
         e#   - Two elements for the last line: the empty string and the timestamp.
(        e# Pull off the initial time.
es-      e# Subtract the current time, which gives (minus) the difference between
         e# when a line was entered and when it should be printed back.
fm       e# This maps "minus that value" onto each element in the array. Now the lines
         e# and linefeeds are strings (arrays) - so minus is set difference, but they
         e# only contain characters, not any integers (like the difference value), so
         e# none of the strings will be affected.
         e# The timestamps on the other hand will be incremented by the time difference
         e# between reading and printing, giving the time at which each line should be
         e# printed back.
3/       e# Split the array into chunks of 3 (where the remaining two elements are
         e# just grouped as a pair).
{        e# For each of those chunks...
  )      e#   Pull off the timestamp.
  {      e#   Do while... (popping the condition from the stack)
    _    e#     Duplicate the target time.
    es>  e#     Check if it's still greater than the current time.
  }g
  ;o     e# Discard the target time and print the rest of the current chunk, which will
         e# automatically be flattened/concatenated into a single string.
}/

9

자바 스크립트, 119112 바이트

k=(d=Date.now)(i=j=[]);do{i[++j]=[prompt(),d()-k]}while(i[j][0]);i.map(a=>setTimeout(b=>console.log(a[0]),a[1]))

잘라 내기 위해 몇 바이트 더 찾기를 바라고 있습니다.


1
당신은 j=i=[]( ++여전히 작동 할 것입니다!)을 사용하여 몇 바이트를 절약 할 수 있으며, 허위이므로 while필요하지 않습니다 !=''! 너무 실망해서 미쳤다 map! +1
— Dom Hastings

1
온 좋은 참고 !=''. 입력이 0인 경우 걱정 했지만 잘 처리하는 것 같습니다. 나는 []이전에 증가 가능성을 알았지 만 어리 석었고 관련이있었습니다 j++. ++j작동 하는 []++것은 분명히 0 XD입니다!
— Mwr247

1
do...whileJS 에 루프 가 있다는 것을 알게 된 날을 표시하십시오.
— Conor O'Brien

6

자바 스크립트, 120 바이트

이 방법으로 CJam에 접근 할 수는 없지만 간단한 스크립트입니다.

a=[];t=+new Date;while(s=prompt()){a.push({s:s,t:+new Date})}while(v=a.pop()){setTimeout(`console.log('${v.s}')`,v.t-t)}

1
우리 둘 다 동시에 JS에 갔던 것 같습니다. 여전히 다른 접근법.
— Mwr247

@ Mwr247 사실, 당신은 더 우아합니다!
— Dom Hastings

6

Pyth, 68 바이트

M&p+Gb$__import__('time').sleep(H)$J].dZWeaYwaJ.dZ)aJ.dZp&gVPY-VtJJk

Pyth에는 기능 이 없으므로 에 대한 호출 에서 많은 바이트를 낭비했습니다 .sleepsleep


3
아마도 Pyth에 추가로 제안해야 할 것입니다.
— mbomb007

대기 중 오류가 있다고 생각합니다. 프로그램을 시작하고 기다린 다음 무언가를 입력하고 Enter 키를 빠르게 두 번 누르십시오. 첫 번째 줄을 즉시 인쇄 한 다음 잠시 기다렸다가 종료하십시오.
— FryAmTheEggman

6

루비, 74

t,*a=Time.now
a<<[$_,t-t=Time.now]while$/<gets
a.map{|l,i|sleep -i;puts l}

트릭 : *a첫 번째 줄에서 빈 배열을 초기화합니다. $*대신 사용할 수는 있지만 약간의 호출로 채워져 바이트를 절약하기 때문에 약간 스케치입니다. $/개행 문자이며로 $_검색된 마지막 행 gets입니다.

편집 : 마지막에 자면 20 바이트가 더 필요합니다.

t,*a=Time.now
a<<[$_,t-t=Time.now]while$/<gets
t-=Time.now
a.map{|l,i|sleep -i;puts l}
sleep -t

사용자가 빈 줄을 제공하는 데 걸린 시간에 따라 마지막 줄에서 잠을 자야한다고 생각합니다.
— Konrad Borowski 2016

마지막에 잠을 자려면 (솔루션 2) Time.now를 사용하여 충분한 시간을 호출 def n;Time.now;end하여 전체 2 바이트를 절약하십시오.
— Value Ink

6

파이썬 3, 124

Windows 플랫폼에서만 작동

from time import*
s=[(1,clock())]
while s[-1][0]:s+=[(input(),clock()-s[-1][1])]
[sleep(y)or x and print(x)for x,y in s[1:]]

입력과 시간을 별도의 목록으로 유지하려면 3 바이트가 더 필요합니다 . 아마도 최선의 방법은 아닙니다.

Mego에 대한 129 바이트 Unix 친화적 인 버전 :

from time import*
t=time
s=[(1,t())]
while s[-1][0]:s+=[(input(),t(),t()-s[-1][1])]
[sleep(y)or x and print(x)for x,z,y in s[1:]]

2 바이트를 저장 하는 time()대신 사용할 수 없습니까 clock()?
— kirbyfan64sos

4

SWI- 프롤로그, 185 바이트

a:-b([],S),reverse(S,T),c(T),!.
b(R,S):-get_time(X),read_string(user_input,"\n","",_,A),get_time(Y),Z is Y-X,(A="",S=[A:Z|R];b([A:Z|R],S)).
c([A:Z|T]):-sleep(Z),T=[];(write(A),nl,c(T)).

아마 여기 골프를 많이 할 수 있지만 이것은 지금 할 것입니다 ...


4

PowerShell을 261 190 121 95 바이트

$(do{Measure-Command{$l=read-host};$l}while($l))|%{($_,(sleep -m($_.Ticks/1e4)))[($b=!$b+!$_)]}

골프 지원 및 영감을 위해 TessellatngHeckler 및 tomkandy 에 소품

이것은 아래의 121 바이트 버전과 개념 상 매우 유사합니다 $a. 명시적인 배열에 객체를 저장하기 위해 while 루프를 거치지 않고 객체 목록을 동적으로 생성하고 작성하는 것 입니다. 두 경우 모두 해당 객체 목록이 동일한 foreach 루프로 파이프 라인됩니다 |%{...}. 결과 배열 선택기에 대한 색인 작성 ($b=!$b+!$_)은 이번에 if($_){$_}아래 반복 을 제거하도록 작성되어 몇 바이트를 더 절약합니다.


이전, 121 바이트

$l,$a=1,@();while($l){$t=Measure-Command{$l=read-host};$a+=$t,$l}$a|%{($(if($_){$_}),(sleep -m($_.Ticks/1e4)))[($b=!$b)]}

확장 및 설명 :

$l,$a=1,@()                        # Set variable $l and create array $a
while($l){                         # So long as we don't have a blank line
  $t=Measure-Command{$l=read-host} # Read the input and measure time to input
  $a+=$t,$l                        # Add those values into the array
}
$a|%{                              # For each item in $a, do
  ($(if($_){$_}),(sleep -m($_.Ticks/1e4)))[($b=!$b)]
  # Magic happens here ... first, we set $b to the NOT of it's uninitialized
  # value, so $b is initially set to truthy
  # This value in [...] selects which of the two elements ( , ) get selected
  # Truthy to start means the second command, sleep, gets chosen first, and
  # then it alternates every next item, so it sleeps, then prints, then
  # sleeps, then prints, etc., until we run out of $a
}

이전, 190 바이트

function f {param($m)sleep -m $a[$m].totalmilliseconds}$a=1,1;while($a[-1]-ne""){$a+=Measure-Command{$b=read-host};$a+=$b}if(!($a[3])){f 2;exit}$i=2;while($i-lt$a.length){f($i++);$a[($i++)]}

function f {                        # Define a new function
  param($m)                         # with $m as input
  sleep -m $a[$m].totalmilliseconds # sleep for $a[$m] milliseconds
}
$a=1,1                              # Create new array with two elements
while($a[-1]-ne""){                 # While the last element isn't empty
  $a+=Measure-Command{$b=read-host} # Read into $b and measure how long that took,
                                    # and add the time into $a
  $a+=$b                            # Then add the input into $a
}
if(!($a[3])){                       # If the third element is empty, the user entered
                                    # a blank as the only input, so...
  f 2                               # sleep for $a[2] ms (how long it took them to hit enter)...
  exit                              # and exit the script
}                                   # Else ...
$i=2                                # Set a counter variable
while($i-lt$a.length){              # While we haven't reached the end of $a
  f($i++)                           # Sleep
  $a[($i++)]                        # Write the output
}

이전, 261 바이트

$a=$d=@();$d+=,@(date);$x=Read-Host
while($x){$a+=,@($x);$d+=,@(date);$x=Read-Host}
if($x){0..($a.Length-1)|%{sleep -m((($d[$_+1]).ticks-($d[$_]).ticks)/1e4);$a[$_]};sleep -m((($d[-1]).ticks-($d[-2]).ticks)/1e4)}
else{sleep -m(((date).Ticks-($d[0]).Ticks)/1e4)}

배트맨! 그것을 분해하자 :

$a=$d=@()                  # Create two empty arrays
$d+=,@(date)               # Add the current time into $d
$x=Read-Host               # Read the first line
while($x){                 # So long as it's not empty
  $a+=,@($x)               # Add it into our output array
  $d+=,@(date)             # Add the current time into $d
  $x=Read-Host             # Get the next line
}
if($a){                    # So long as $a exists (i.e., the first input wasn't blank)
  0..($a.Length-1)|%{      # For-loop over the length
                           # Sleep for how long it took to do input
    sleep -m((($d[$_+1]).ticks-($d[$_]).ticks)/1e4)
    $a[$_]                 # Print out the input
  }
                           # Sleep the length it took for the final blank
  sleep -m((($d[-1]).ticks-($d[-2]).ticks)/1e4)
}
else{
                           # If we're here, the initial input was blank, so just sleep
  sleep -m(((date).Ticks-($d[0]).Ticks)/1e4)
}

144$a=1,1;while($a[-1]-ne""){$a+=Measure-Command{$b=read-host};$a+=$b};$i=2;while($i-lt$a.length){sleep -m $a[($i++)].totalmilliseconds;$a[($i++)]}
— tomkandy

@tomkandy 감사합니다! 개선으로 업데이트되었습니다.
— AdmBorkBork

@TessellatingHeckler 우수! 나는 교류를 효과적으로 제어하는 ​​방법으로 고심하고 있었고, 배열로 인덱싱하는 것은 지금 내가 볼 수있는 확실한 선택입니다. 또한, I는를 제거하여 다른 바이트 golfed @이 때문에 아래에,이 문맥에서 필요하지 않을 것 같은 그 배열 (121) .
— AdmBorkBork

@TimmyD 내가 어제 시도한 것은 중첩 배열을 만드는 $ a에 ($ t, $ l) 쌍을 넣는 것이 었습니다. 나는 그것을 작동시킬 수 없었지만, 오늘은 할 수 있고 토글 할 필요가 없기 때문에 조금 도움이됩니다. 모든 쌍을 읽고 사용하십시오. 그런 다음 깨달았습니다. 우리는 완벽하게 좋은 파이프 라인을 가지고 있습니다. $($l=1;while($l){Measure-Command{$l=read-host};$l})|%{($_,(sleep -m($_.Ticks/1e4)))[($b=!$b+!$_)]}-토글을 변경하면 문자열이 비어있을 때 토글되지 않고 대신 절전 모드로 전환됩니다.- 98
— TessellatingHeckler

( do{...}while($l)루프를 만들어 95$l=1; 를 얻기 위해 떨어 뜨림 )
— TessellatingHeckler

3

펄 6, 70 자

repeat {$/=now;.push($!=get,now -$/)}while $!;.map:{sleep $^b;say $^a}

Perl 6 인터프리터는 (Perl 5의 크랙과 달리) 세 가지 상징적 변수 만 정의합니다. 정확한 될하려면 $/, $!및 $_. 이 프로그램은를 사용하여 변수를 선언하는 비용을 피하기 위해 모두 사용 my합니다.

getSTDIN에서 행을 읽습니다. Perl 5와 달리 줄 바꿈이 포함되어 있지 않습니다.

now내장은 현재 시간을 반환합니다. 빼면 문자열에 전달 될 수있는 간격을 제공합니다.

그것의 (같은 왼쪽에 아무것도하는 방법 .push과 .map,이 코드는)에 작동합니다 $_.

repeat while루프 ( do while다른 프로그래밍 언어에서 알려진)를 사용하여 Perl 6은 현재 타임 스탬프를에 기록 $/하고 수신 된 라인 (또한 저장 됨 $!)을 푸시하고 현재 시간과 타임 스탬프의 차이를에 입력 $/합니다. 매개 변수 순서로 인해 now라인이 수신 될 때까지 계산되지 않습니다.

while라인이 비어 있지 않은 경우 조건 검사 (펄 6, "0"펄 5는 달리 실제 값이다).

모든 타임 스탬프와 라인을 얻은 후에는 map콜백에 콜백을 제공하여 잠들고 말한 것을 말합니다.


2

그루비, 202 바이트

def b={System.currentTimeMillis()};def h=[];for(;;){def t=b();def s=System.console().readLine();h.add(s+" "+(b()-t));if(s=="")break};for(def s:h){Thread.sleep((s=s.split(" "))[1].toLong());println s[0]}

근본적인.

언 골프 버전 :

def b = {System.currentTimeMillis()}; // Creates a closure (short function) b that returns the current time since the epoch in milliseconds.
def h = []; // Makes an empty list
for(;;) { // Infinite loop
  def t = b(); // Get the time
  def s = System.console().readLine(); // Read a line
  h.add(s + " " + b()-t); // Add the string plus the amount of time elapsed to the list
  if(s=="") // If the string is blank
    break; // Exit loop
}
for(def s : h) { // Iterate through array
  Thread.sleep((s=s.split(" "))[1].toLong()); // Splits s into an array and puts the value in s, then takes the second element (the time), converts into a long and sleeps for that time.
  println s[0] // Print the first element (text)
}

2

자바 스크립트 (ES6) 102

Mwr247과 Dom Hastings (CW)의 노력을 모아

/* for TEST */ console.log=x=>O.innerHTML+=x+'\n'

for(k=new Date,i=[];p=prompt();i.push([p,new Date]));i.map(a=>setTimeout(b=>console.log(a[0]),a[1]-k))
<pre id=O></pre>


2

MATLAB, 107 99

tic;a={};i=1;while nnz(i);i=input('','s');a=[a;{i,toc}];tic;end;for b=a';pause(b{2});disp(b{1});end

그리고 골퍼되지 않은 :

tic; %Start timer
a={};
i=1; %Make us enter the while loop
while nnz(i); %While i has some non-zero elements (this is used to detect a zero length input where we end)
    i=input('','s'); %Get an input string
    a=[a;{i,toc}]; %Append the string and current time as a new cell in a
    tic; %Restart timer
end
for b=a' %For each input
    pause(b{2}); %Wait for the required time
    disp(b{1}); %Then print the string
end

각 문자열을 표시하는 데 걸리는 시간을 고려하지 않기 때문에 타이밍이 100 % 정확하지는 않지만 타이밍이 빠르므로 시간이 가까워 야합니다.


빠른 재 방문 후, 더블 레이어 딥 셀 어레이를 제거하여 몇 바이트를 절약했습니다. 내가 ;포장 할 때 올바르게 쪼개는 데 필요한 모든 것이 나왔습니다 .


1
MATL에서 골프 용 버전을 만들 수도 있습니다.
— ckjbgames 2016 년

1

Java, 이 라이브러리 버전 1.04 사용 , 385 바이트

import sj224.lib.util.*;import java.util.*;class E{static long t(){return System.currentTimeMillis();}public static void main(String[]a) throws Exception{List<Pair<?,Long>>l=new ArrayList();Scanner i=new Scanner(System.in);while(true){long t=t();String s=i.nextLine();if(s.isEmpty())break;l.add(new Pair(s,t()-t));}for(Pair<?,Long>p:l){Thread.sleep(p.two);System.out.println(p.one);}}}

1

Caché ObjectScript, 123 바이트

w() q $P($ZTS,",",2)
r f  s i=i+1,t=$$w() r x,! q:x=""  s g(i,x)=$$w()-t
    f i=1:1 s s=$O(g(i,"")) q:s=""  w s,! h g(i,s)
    q

평소와 같이, 이것은 실행하기 전에 깨끗한 기호 테이블을 가정합니다 d r.

ANSI 표준은 시간 고유의 두 번째 수준 해상도 만 필요하므로이 문제는 ANSI MUMPS에서 해결할 수 없습니다 $H[OROLOG]. 운 좋게도 현재 MUMPS를위한 업계 최고의 플랫폼 인 Intersystems Caché 는 구현 정의 내장 함수를 제공 합니다.$ZT[IME]S[TAMP] 는 마이크로 초 수준의 해상도를 를 제공합니다.

(점수는 이전에 105 바이트 였지만 버그가있었습니다.)


1

C ++ 11, 343 338 바이트

C ++에서 코드에 필요한 바이트 수를 확인하고 싶었습니다. 내가 기대했던 것보다 훨씬 더. 어쩌면 나는 해결책을 복잡하게 만들었습니다.

#include<iostream>
#include<vector>
#include<chrono>
int i;using namespace std;int main(){auto n=chrono::system_clock::now;auto t=n();string s{1};vector<string>r;vector<decltype(t-t)>w;while(s.size())getline(cin,s),r.push_back(s),w.push_back(n()-t),t=n();while(i<r.size()){while((n()-t)<w[i]);t=n();cout<<r[i++]<<(i<r.size()-1?"\n":0);}}  

어떻게 든 이것을 줄일 수 있는지 봅시다.


의 공백 #include과에 대한 유형 선언을 제거 할 수 있습니다 main. 그것은 7 바이트입니다.별로 많지는 않지만 시작입니다. 당신은 또한 사용할 수 있습니다 auto보다는 string위한 s.
— Alex A.

피드백 주셔서 감사합니다. 메인의 리턴 타입을 유지하겠습니다. 내가 정확하게 기억한다면, c우리는 그것을 지정할 필요가 없습니다. 내가 사용에 처음 시도 auto s...하지만 같은 외모로 변환됩니다 const char *하지 std::string. 에 대한 별칭을 만들 수 있는지 궁금합니다 while.
— wendelbsilva

반환 유형을 제거하면 표준에 따라 "하지 않아야"하더라도 C ++에서 작동합니다. 어쩌면 while사용할 별칭을 만들 #define수 있습니다.
— Alex A.

1

배쉬, 91 90 바이트

while r=`\time -fsleep\ %e head -1`
[[ $r ]]
do printf{,\ %%b\ %q\;} "$r
"
done>t 2>&1
. t

이것은 임시 파일을 만듭니다 t. 동일한 이름으로 기존 파일을 덮어 씁니다.

아이디어 자체는 매우 짧지 만 입력의 특수 문자를 처리하면 약 15 바이트가 추가됩니다 ...


1

VBA, 233 228bytes

나는 이것이 골프를 많이 치는 것이 확실하다. 그들은 얼마나 많은 입력을 지정하지 않았기 때문에 배열 길이가 더 짧기 때문에 배열 길이를 하드 코딩했습니다 Redim preserve.

팝업을 통한 입력, 출력은 MODAL을 생성하고 코드를 중지 debug.print하기 때문 msgbox입니다.

이것이 0.01에 정확한지 테스트하는 방법을 모르겠습니다. 어쩌면 누군가 테스트 할 수는 있지만 대기 명령에 밀리 초를 사용해야하는 방식으로 숫자를 제공하지만 VBA는해야 할 일을하는 것으로 알려져 있지 않습니다.

는 If goto잘 golfed에 의해 대체 될 수 있습니다 Do Loop While.

Sub a()
Dim k(99) As String
Dim h(99) As Date
b:
t=Now()
i=i+1
k(i)=InputBox("")
h(i)=Now()-t
If k(i)<>"" Then GoTo b
For u=1 To i
Application.Wait (Now()+(Format(h(u),"s")&Format(h(u),"ms"))/10^8)
Debug.Print k(u)
Next
End Sub

Microsoft가 일관성을 싫어하기 때문에 액세스에 대기 명령이 없기 때문에 Access VBA에서 작동하지 않습니다.


0

SmileBASIC, 122 바이트

DIM A$[0],T[0]@L
C=MAINCNT
LINPUT S$PUSH A$,S$PUSH T,MAINCNT-C
IF""<S$GOTO@L@P
WAIT SHIFT(T)IF""<A$[0]THEN?SHIFT(A$)GOTO@P

나는 이것이 약간 짧아 질 수 있다고 생각한다.


0

C UNIX, 272 바이트

#include <stdio.h>
#include <unistd.h>
#define P printf
i;r;c;main(){char*L[99]={0};size_t s;long T[99]={0};while(1){P(">  ");T[c]=time(0);r=getline(&L[c],&s,stdin);T[c]=time(0)-T[c];if(r==-1|!(*L[c]-10))break;c++;}while(i<c){P("> ");usleep(T[i]*1000);P("%s", L[i]);i++;}}

상세한

#include <stdio.h>
#include <unistd.h>

int main(void)
{
    int i = 0, c = 0, r;
    char * L[99] = {0};
    size_t size;
    long T[99] = {0L};

    while(1)
    {
        printf("> ");
        T[c] = time(0);
        r = getline(&L[c], &size, stdin);
        T[c] = time(0) - T[c];
        if(r == (-1)) break;
        if(*L[c]=='\0' || *L[c]=='\n') break;
        c = c + 1;
    }

    while(i < c)
    {
        printf(" %ld > ",T[i]);
        usleep(T[i]*1000);
        printf("%s", L[i]);
        i = i + 1;
    }

    return 0;
}
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.