卢卡斯诉 车库门遥控器


15

免责声明

虽然我知道有一个特定的相关问题,但我的问题使用了两个车库门和一个随机组成部分,我也基于现实生活中的事件,看到儿子在我走出车库时不小心放下了其中一个车库门。上周的车库...没什么可让头脑震撼的!;)

的背景

卢卡斯(我15个月大的儿子)喜欢和车库遥控器一起玩。此遥控器上有两个按钮,一个用于左侧车库门,一个用于右侧车库门。两个按钮的工作方式相同。按一次使门开始打开,再按一次停止,再按一次开始关闭,再按一次再次停止,依此类推。

卢卡斯(Lucas)喜欢这个遥控器,他会随机按下其中一个按钮,或者同时按下两个按钮,或者完全不按下。如果两者都按下,则不会发送信号,但是按下一个按钮将发出信号。

因此,代码高尔夫球挑战分为两个部分:

第一部分

生成一个60字符长的字符串,表示卢卡斯在一分钟内随机按下按钮。在这种情况下,“随机”表示“在每个刻度上每个输入的机会均等”。字符如下:

  • 0:卢卡斯未按下任何按钮,或者同时按下了两个按钮。无论哪种方式,都没有发送信号。
  • 1:卢卡斯按下了左车库门的按钮
  • 2:右车库门的按钮已被Lucas按下

第二部分

使用在第一部分中生成的字符串,使用数字作为打开,停止和关闭这些门的触发器来模拟两车车库的打开和关闭。

我的车库门非常快(有关原因,请参见上面的免责声明)。按下按钮后,需要四秒钟才能完全打开或关闭。

因此,如果关闭:

  • 0秒:0%打开(关闭);当按下按钮时,门开始打开
  • 1秒:打开25%
  • 2秒:50%开启
  • 3秒:75%开启
  • 4秒:100%打开,门停

因此,如果打开:

  • 0秒:100%打开;当按下按钮时,门开始关闭
  • 1秒:打开75%
  • 2秒:50%开启
  • 3秒:25%开启
  • 4秒:0%打开(关闭),门停止

如果特定的门在运动,则向该门的信号将使其停止。下一个发送到同一扇门的信号将使它朝相反的方向移动。如果门在先前运动时已停止,而在收到“停止”信号时现已完全打开或完全关闭,则该门将在完全打开或完全关闭状态下注册为“已停止”,准备进行接收到新信号时,向相反方向移动。

通过此模拟,两个车库门将最初处于关闭位置。因此,让我们看一下10秒的命令列表,看看如果Lucas在远程执行命令会发生什么:

2120221120
2: (L:0% stopped, R:0% opening)
1: (L:0% opening, R:25% opening)
2: (L:25% opening, R:50% stopped)
0: (L:50% opening, R:50% stopped)
2: (L:75% opening, R:50% closing)
2: (L:100% stopped, R:25% stopped)
1: (L:100% closing, R:25% stopped)
1: (L:75% stopped, R:25% stopped)
2: (L:75% stopped, R:25% opening)
0: (L:75% stopped, R:50% opening)

输出量

输出的第一部分要求显示从第一部分生成的60个字符长的字符串,其中包含随机的“ 0”,“ 1”和“ 2”字符。例如。 212022112021202211202120221120212022112021202211202120221120

在此字符串的下面,是根据上述规则(对车库门的每个相应角色如何行为)(以秒为单位)处理这些“信号”。结果,您应该在初始显示字符串下方得到60行。

这些处理的行中的每行将采用以下形式: N: (L:X% XXXXXXX, R:Y% YYYYYYY)其中:

  • N是相应随机字符串中的第n个字符,其形式为0、1或2。
  • X%是左门的打开百分比(没有零填充)
  • XXXXXXX是左门的状态。如果门未处于运动状态(即未打开或关闭),则将强制执行“已停止”状态,这意味着门已处于运动状态(仅在25%,50%或75%时可能停止)或在完全打开时已停止(100%) )或完全关闭(0%)。否则,门将“打开”或“关闭”。
  • Y%是右门的打开百分比(没有零填充)
  • YYYYYYY是右门的状态。如果门未处于运动状态(即未打开或关闭),则将强制执行“已停止”状态,这意味着门已处于运动状态(仅在25%,50%或75%时可能停止)或在完全打开时已停止(100%) )或完全关闭(0%)。否则,门将“打开”或“关闭”。

下面显示的示例使用10个“信号”和10条处理过的行

2120221120
2: (L:0% stopped, R:0% opening)
1: (L:0% opening, R:25% opening)
2: (L:25% opening, R:50% stopped)
0: (L:50% opening, R:50% stopped)
2: (L:75% opening, R:50% closing)
2: (L:100% stopped, R:25% stopped)
1: (L:100% closing, R:25% stopped)
1: (L:75% stopped, R:25% stopped)
2: (L:75% stopped, R:25% opening)
0: (L:75% stopped, R:50% opening)

这是代码高尔夫球,因此最短的代码将是明显的赢家。我通过使用诸如“ opening”,“ stopped”和“ closes”之类的七个字母使这变得容易一些,因此您可能希望将其应用于您的策略中。

祝你好运!


您应该定义一个更清晰的输出格式为2部分
LegionMammal978

@ LegionMammal978您觉得输出中缺少什么?
WallyWest

1
我暂时不知道,但我确实认为这是一个整洁的问题,我可以解决。
DLosc '16

1
1在您的示例中,为什么最后一个命令没有将左门停在75%的位置?
Arnauld

1
0,1和2应该在第一部分中均等出现,还是不按,双击,左按和右键均均出现?(意味着,0更有可能是因为它代表两个导致相同结果的场景...)
Socratic Phoenix

Answers:


2

Pyth,156个 149 145字节

jkJmO3U60K=G*]Z3=b*3]_1VJFHS2I&=T@KHq*2hT@XHGTH XbHT XKH0)) XKN*_@XbN|@KN@bNN!@KN%+N": (L:%s, R:%s)"m++*@Gd25"% "%3>"csoltpooespnipinengdg"h@KdS2

我的Python答案的直接翻译。

在线尝试!

说明:

jk                              " print ''.join(map(str,                   "
JmO3U60                         "  J = [randint(0,2) for _ in range(60)])) "
K=G*]Z3                         " K = copy(G = [0] * 3)                    "
=b*3]_1                         " b = [-1] * 3                             "
VJ                              " for N in J:                              "
FHS2                            "  for H in range(1, 3):                   "
I&=T@KH                         "   if ((T = K[H]) and                     "
q*2hT@XHGTH                     "       (2 * (T + 1) == (G[H] += T)[H]):   "
 XbHT                           "    b[H] = T                              "
 XKH0))                         "    K[H] = 0                              "
 XKN*_@XbN|@KN@bNN              "  K[N] = (-(b[N] = K[N] or B[N])[N] *     "
!@KN                            "   (not K[N]))                            "
%+N": (L:%s, R:%s)"             "  print(str(N) + ': (L:%s, R:%s)' %       "
m++                             "   map(lambda d:                          "
*@Gd25                          "    G[d] * 25 +                           "
"% "                            "    '% ' +                                "
%3>"csoltpooespnipinengdg"h@Kd  "    'csoltpooespnipinengdg'[K[d]+1::3]]   "
S2                              "   ), range(1, 3))                        "

哇!感谢您的回答以及代码的说明...到达代码结尾时,我实际上已经意识到了...
WallyWest 2016年

5

使用Javascript(ES6),277 275 263 253个 250 247 234字节

_=>(d=[0,0],l=s='',[...Array(60)].map(_=>(s+=`
${c=Math.random()*3|0}:(`,l+=c,d=d.map((v,i)=>(v=v&8?v&16?v-27?v+1:20:v-9?v-1:0:v,v^=c+~i?0:v&8||24,s+='LR'[i]+`:${(v&7)*25}% `+(v&8?v&16?'opening':'closing':'stopped')+',)'[i],v)))),l+s)

取消评论

_ => (
  // Initialize array:
  //   - d = door states as integers
  //     - bits 0 to 2: door opening state (from 0b000 = 0% to 0b100 = 100%)
  //     - bit #3: door in motion (0: no, 1: yes)
  //     - bit #4: door direction (0: closing, 1: opening)
  d = [0, 0],

  // Initialize strings:
  //   - l = list of commands
  //   - s = door states in plain text
  l = s = '',

  // Iterate on an array of 60 entries.
  [...Array(60)].map(_ => (
    // c = new random command (0, 1 or 2)
    // Append new line and new command to s.
    s += `\n${c = Math.random() * 3 | 0}:(`,

    // Append new command to l.
    l += c,

    // For each door ...
    d = d.map((v, i) => (
      // If the door is in motion, update its opening state.
      // Clear the 'in motion' bit if a bound is reached (either closed or fully open).
      v = v & 8 ? v & 16 ? v - 27 ? v + 1 : 20 : v - 9 ? v - 1 : 0 : v,

      // If the current command is intended for this door, update its direction and
      // 'in motion' bit. Direction is changed on the 'stopped => moving' transition.
      v ^= c + ~i ? 0 : v & 8 || 24,

      // Translate the door state in plain text and append it to s
      s +=
        'LR'[i] +
        `:${(v & 7) * 25}% ` +
        (v & 8 ? v & 16 ? 'opening' : 'closing' : 'stopped') +
        ',)'[i],

      // Value to be taken into account by map()
      v
    ))
  )),

  // Final result to be returned
  l + s
)

演示版

let f = 
_=>(d=[0,0],l=s='',[...Array(60)].map(_=>(s+=`
${c=Math.random()*3|0}:(`,l+=c,d=d.map((v,i)=>(v=v&8?v&16?v-27?v+1:20:v-9?v-1:0:v,v^=c+~i?0:v&8||24,s+='LR'[i]+`:${(v&7)*25}% `+(v&8?v&16?'opening':'closing':'stopped')+',)'[i],v)))),l+s)

console.log(f())


哇,那条衬垫让我印象深刻,然后把它扔到console.log了!做得好!
WallyWest

1
奇怪的是,在Firefox中无法正常工作,仅输出4行,就像这样112200001100122021010101012100000010011200201022122021012211 [ "L:25% stopped", "R:25% stopped" ](逗号和括号后的换行符)
edc65 '16

@ edc65-实际上,我不好。我误读了有关输出格式的说明。这是固定的。
Arnauld

@Arnauld也可以删除括号v^=(c-i-1?0:v&8||24)以节省两个字节。
WallyWest '16

PS @Arnauld,感谢您的参与!
WallyWest '16

4

Python 2中,377 370 361 357 345 335 326 316 312 306 304字节

第二个缩进级别是原始制表符(\t),真正的厉害与降价,因此它被两个空格。

from random import*
p=[randint(0,2)for d in[[0]*3]*60]
print`p`[1::3]
v=[-1]*3
c=[0]*3
f=lambda y:str(c[y]*25)+'% '+'csoltpooespnipinengdg'[d[y]+1::3]
for x in p:
 for i in 1,2:
  q=d[i];c[i]+=q
  if(2*-~q==c[i])*q:v[i]=q;d[i]=0
 z=d[x]
 if z:v[x]=z
 d[x]=-v[x]*(z==0);print'%d: (L:%s, R:%s)'%(x,f(1),f(2))

我几乎可以肯定,这可以进一步进行。

取消评论,并附上评论:

import random

# Generate the random string - represented as a list of ints
presses = [random.randint(0, 2) for _ in range(60)]
print ''.join(map(str, presses))

# Constants for door states used for easier reading
CLOSING = -1
STOPPED = 0
OPENING = 1

# Variables representing the state of the garage doors
# There's a third element in these so that x[0] resolves to a dummy slot
# (this way, we can avoid a conditional down the road)
prev_states = [CLOSING, CLOSING, 0]
door_states = [STOPPED, STOPPED, 0]
door_pcts = [0, 0, 0]  # delta 1 = 25%

for press in presses:
  # Close/open the door 1 more
  for i in 1, 2:
    if door_states[i] != STOPPED:
      delta_pct, stop_pct = (-1, 0) if door_states[i] == CLOSING else (1, 4)
      door_pcts[i] += delta_pct
      if door_pcts[i] == stop_pct:
        prev_states[i] = door_states[i]
        door_states[i] = STOPPED

  # Handle pressing a button
  # If the press is 0 (no press), the 0th element resolves to a dummy
  # door, thus saving us an expensive conditional

  if door_states[press] == STOPPED:
    door_states[press] = -prev_states[press]
  else:
    prev_states[press] = door_states[press]
    door_states[press] = STOPPED

  # Print the status update
  print '%d: (L:%d%% %s, R:%d%% %s)' % (
    press,
    door_pcts[0]*25,
    ['closing', 'stopped', 'opening'][door_states[0]+1],
    door_pcts[1]*25,
    ['closing', 'stopped', 'opening'][door_states[1]+1],
  )

已保存4 14 感谢@TheBikingViking, 15个字节!

@ValueInk节省了6个字节!


1
您可以更改range(60)[0]*60
TheBikingViking

1
@TheBikingViking谢谢!我现在正在编辑。

2
您可以'p'[1::3]使用代替(用反引号代替撇号)''.join(map(str,p))
TheBikingViking

2
(4,0)[q<0]==c[i]and q->((4,0)[q<0]==c[i])*q
TheBikingViking

2
@ValueInk该行滥用Python 2的列表推导中的一个错误来设置n该字符串。n被用在最终行以提取closingstoppedopening从该字符串。

2

红宝石,263个 261 260 254字节

JavaScript的答案怎么这么短???当我不在时,它超越了我,但目前仍在赢...

s=(1..60).map{rand 3}
puts s*''
D=1,2
d=[25]*3;a=[0]*3;m=[p]*3
s.map{|i|D.map{|j|m[j]&&a[j]+=d[j];(0..100)===a[j]+d[j]||i!=j&&(d[j]*=-1;m[j]=p)}
(m[i]^=1)||d[i]*=-1
puts"#{i}: (L%s, R%s)"%D.map{|j|":#{a[j]}% #{%w"stopped opening closing"[m[j]?d[j]:0]}"}}

2

C,420个 433 424 374字节

#define F(X,x) X=x==1?X+1:x==2?X-1:X;X=X<0?0:X>4?4:X;x=X==0?0:X==4?3:x
#define G(x) x=x==1?3:x==2?0:x==3?2:x+1
#define H(X,x) X*25,x==0||x==3?"stopped":x==1?"opening":"closing"
c,i,l,r,L,R,x[60];main(){while(i<60)printf("%d",x[i++]=random()%3);while(c<60){if(x[c]==1)G(l);else if(x[c]==2)G(r);printf("\n%d: (L:%d%% %s, R:%d%% %s)",x[c++],H(L,l),H(R,r));F(L,l);F(R,r);}}

不播种随机生成器,但使用随机数以获得更好的分布。当然,必须有更好的方法来打高尔夫球这种逻辑...

110121100121212100112200222111200020111100022122202112202211002
1: (L:0% opening, R:0% stopped)
1: (L:25% stopped, R:0% stopped)
0: (L:25% stopped, R:0% stopped)
1: (L:25% closing, R:0% stopped)
2: (L:0% stopped, R:0% opening)
1: (L:0% opening, R:25% opening)
1: (L:25% stopped, R:50% opening)
0: (L:25% stopped, R:75% opening)
0: (L:25% stopped, R:100% stopped)
1: (L:25% closing, R:100% stopped)
2: (L:0% stopped, R:100% closing)
1: (L:0% opening, R:75% closing)
2: (L:25% opening, R:50% stopped)
1: (L:50% stopped, R:50% stopped)
2: (L:50% stopped, R:50% opening)
1: (L:50% closing, R:75% opening)
0: (L:25% closing, R:100% stopped)
0: (L:0% stopped, R:100% stopped)
1: (L:0% opening, R:100% stopped)
1: (L:25% stopped, R:100% stopped)
2: (L:25% stopped, R:100% closing)
2: (L:25% stopped, R:75% stopped)
0: (L:25% stopped, R:75% stopped)
0: (L:25% stopped, R:75% stopped)
2: (L:25% stopped, R:75% opening)
2: (L:25% stopped, R:100% closing)
2: (L:25% stopped, R:75% stopped)
1: (L:25% closing, R:75% stopped)
1: (L:0% opening, R:75% stopped)
1: (L:25% stopped, R:75% stopped)
2: (L:25% stopped, R:75% opening)
0: (L:25% stopped, R:100% stopped)
0: (L:25% stopped, R:100% stopped)
0: (L:25% stopped, R:100% stopped)
2: (L:25% stopped, R:100% closing)
0: (L:25% stopped, R:75% closing)
1: (L:25% closing, R:50% closing)
1: (L:0% opening, R:25% closing)
1: (L:25% stopped, R:0% stopped)
1: (L:25% closing, R:0% stopped)
0: (L:0% stopped, R:0% stopped)
0: (L:0% stopped, R:0% stopped)
0: (L:0% stopped, R:0% stopped)
2: (L:0% stopped, R:0% opening)
2: (L:0% stopped, R:25% stopped)
1: (L:0% opening, R:25% stopped)
2: (L:25% opening, R:25% closing)
2: (L:50% opening, R:0% opening)
2: (L:75% opening, R:25% stopped)
0: (L:100% stopped, R:25% stopped)
2: (L:100% stopped, R:25% closing)
1: (L:100% closing, R:0% stopped)
1: (L:75% stopped, R:0% stopped)
2: (L:75% stopped, R:0% opening)
2: (L:75% stopped, R:25% stopped)
0: (L:75% stopped, R:25% stopped)
2: (L:75% stopped, R:25% closing)
2: (L:75% stopped, R:0% opening)
1: (L:75% opening, R:25% opening)
1: (L:100% closing, R:50% opening)

旧版本1:

c,i,l,r,L,R,x[60];main(){while(i<60)printf("%d",x[i++]=random()%3);while(c<60){if(x[c]==1)l=l==1?3:l==2?0:l==3?2:l+1;else if(x[c]==2)r=r==1?3:r==2?0:r==3?2:r+1;printf("\n%d: (L:%d%% %s, R:%d%% %s)",x[c++],L*25,l==0||l==3?"stopped":l==1?"opening":"closing",R*25,r==0||r==3?"stopped":r==1?"opening":"closing");L=l==1?L+1:l==2?L-1:L;R=r==1?R+1:r==2?R-1:R;L=L<0?0:L>4?4:L;R=R<0?0:R>4?4:R;l=L==0?0:L==4?3:l;r=R==0?0:R==4?3:r;}}

旧版本2:

c,i,l,r,L,R,x[60];g(){while(i<60)printf("%d",x[i++]=random()%3);}main(){g();while(c<60){if(x[c]==1)l=l==1?3:l==2?0:l==3?2:l+1;else if(x[c]==2)r=r==1?3:r==2?0:r==3?2:r+1;printf("%d: (L:%d%% %s, R:%d%% %s)\n",x[c++],L*25,l==0||l==3?"stopped":l==1?"opening":"closing",R*25,r==0||r==3?"stopped":r==1?"opening":"closing");L=l==1?L+1:l==2?L-1:L;R=r==1?R+1:r==2?R-1:R;L=L<0?0:L>4?4:L;R=R<0?0:R>4?4:R;l=L==0?0:L==4?3:l;r=R==0?0:R==4?3:r;}}

2
您可以将其转换为代码吗?
haykam

2

PHP,254 247 246 245 235 230 226字节

再次击败ES!

for($t=60;$t--;)$s.=rand()%3;echo$s;for(;++$t<60;print"
$c: ($o[1], $o[2])")for($i=3;--$i;$o[$i]='.LR'[$i].':'.$d[$i]*25 .'% '.[opening,stopped,closing][abs($z-1)])if(((1&$z=&$r[$i])&&!(3&$d[$i]+=2-$z))|$i&$c=$s[$t])$z=++$z%4;

从这些311开始打高尔夫球(第一个完整版本,已经打了一些高尔夫球):

<?for($i=60;$i--;)$s.=rand(0,2);echo$s;$d=$r=[0,0];$n=[L,R];$p=[stopped,opening,stopped,closing];for($t=-1;++$t<60;print"
$c: (".join(', ',$x).")")for($m=$c=$s[$t],$i=-1;$i++<1;){if($r[$i]&1)if(!($d[$i]+=2-$r[$i])||4==$d[$i])$m|=$i+1;if($m&$i+1)$r[$i]=(1+$r[$i])%4;$x[$i]="$n[$i]:".($d[$i]*25)."% ".$p[$r[$i]];}

分解

for($t=60;$t--;)$s.=rand()%3;   // part 1               also initializes $t to -1
echo$s;
for(
    ;
    ++$t<60;
    print"\n$c: ($o[1], $o[2])" // print output
)
    for($i=3;--$i;  // loop $i from 2 to 1 (door number)
        // generate output
        $o[$i]='.LR'[$i].':'.$d[$i]*25 .'% '
        .[opening,stopped,closing][abs($z-1)]           // map 0123 to 1012
    )
        if(((1&$z=&$r[$i])  // if door in motion        ... and reference the array item
            &&!(3&              // 2. if end position   "&&" needed for short circuit
            $d[$i]+=2-$z        // 1. move door         2-$z maps 1,3 to 1,-1 = delta
            )
        )|$i&$c=$s[$t])     // 3. or if button $i pressed   "|" needed for no short circuit
            $z=++$z%4;          // rotate direction     ++$z%4 maps 0,1,2,3 to 1,2,3,0
        // generate output (loop post condition)
    // print output (loop post condition)

@Arnauld:抓到你了!:)
Titus

1

Java 8 lambda,500个字符

我已经尽力了,这是我想出的:

()->{String r="";int i=0,l=0,m=0,n=1,o=1,p=0,q=0;for(;i++<60;)r+=(int)(Math.random()*3);for(char s:r.toCharArray()){l+=p;m+=q;if(l>99&p>0){l=100;p=25*(((n=++n%4)-1)%2);}if(l<1&p<0){l=0;p=25*(((n=++n%4)-1)%2);}if(m>99&q>0){m=100;q=25*(((o=++o%4)-1)%2);}if(m<1&q<0){m=0;q=25*(((o=++o%4)-1)%2);}if(s<49);else if(s>49)q=25*(((o=++o%4)-1)%2);else p=25*(((n=++n%4)-1)%2);r+="\n"+s+": (L:"+l+"% "+(p<0?"closing":p>0?"opening":"stopped")+", R:"+m+"% "+(q<0?"closing":q>0?"opening":"stopped")+")";}return r;}

取消完整分类:

public class Q91479 {

    public static String movedDoorsCombined() {
        String result = "";
        int i = 0, leftDoor = 0, rightDoor = 0, stepLeft = 1, stepRight = 1, changeLeft = 0, changeRight = 0;

        for (; i++ < 60;) {
            result += (int) (Math.random() * 3);
        }

        for (char step : result.toCharArray()) {
            // update stats
            leftDoor += changeLeft;
            rightDoor += changeRight;

            if (leftDoor > 99 & changeLeft > 0) {
                leftDoor = 100;
                changeLeft = 25 * (((stepLeft = ++stepLeft % 4) - 1) % 2);
            }
            if (leftDoor < 1 & changeLeft < 0) {
                leftDoor = 0;
                changeLeft = 25 * (((stepLeft = ++stepLeft % 4) - 1) % 2);
            }
            if (rightDoor > 99 & changeRight > 0) {
                rightDoor = 100;
                changeRight = 25 * (((stepRight = ++stepRight % 4) - 1) % 2);
            }
            if (rightDoor < 1 & changeRight < 0) {
                rightDoor = 0;
                changeRight = 25 * (((stepRight = ++stepRight % 4) - 1) % 2);
            }

            if (step < 49) {
                // 0
            }
            else if (step > 49) {
                // right
                changeRight = 25 * (((stepRight = ++stepRight % 4) - 1) % 2);
            }
            else {
                // left
                changeLeft = 25 * (((stepLeft = ++stepLeft % 4) - 1) % 2);
            }
            result += "\n" + step + ": (L:" + leftDoor + "% "
                        + (changeLeft < 0 ? "closing" : changeLeft > 0 ? "opening" : "stopped")
                        + ", R:" + rightDoor + "% "
                        + (changeRight < 0 ? "closing" : changeRight > 0 ? "opening" : "stopped")
                        + ")";
        }
        return result;
    }
}

非常简单。stepLeft / stepRight变量从0-3圈出。做一些简单的数学运算changeLeft / changeRight保持每步各自的相对变化,这些变化将被添加到leftDoor / rightDoor中。许多if语句仅在门必须自行停止时才起作用。

请随意帮我缩短时间,我认为有很多事情要做。


1

Haskell(lambdabot)-409字节

p=(cycle[0,1,0,-1],0)
t(d:q,s)=(if d/=0&&(s+d<1||3<s+d)then q else d:q,s+d)
k i(a,b)=[o i,": (L:",j a,", ","R:",j b,")"]>>=id
j(d:_,s)=o(round$(fromIntegral s/4)*100)++"% "++words"closing stopped opening"!!(d+1)
s=scanl$ \(a,b)i->i(t a,t b)
main=do b<-(fmap(round.(*(2::Float))).take 60<$>randoms)<$>getStdGen;putStrLn.unlines$(o=<<b):(zipWith k b.w.s(p,p)$([id,f$f w,second$f w]!!)<$>b)
o=show;f=first;w=tail

请添加所有必需的imports,例如用于randoms的代码(和字节数)。如果有默认情况下导入的解释器,请以语言名称引用它。
nimi 2016年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.