设定时间


27

想象以下可以通过箭头键控制的24小时制时钟:

╔══╗ ┌──┐
║00║:│00│
╚══╝ └──┘
 HH   mm

两次按向上箭头(↑↑)将增加当前关注的小时输入:

╔══╗ ┌──┐
║02║:│00│
╚══╝ └──┘
 HH   mm

按向右箭头()将聚焦其他输入。

┌──┐ ╔══╗
│02│:║00║
└──┘ ╚══╝
 HH   mm

现在,按三次向下箭头(↓↓↓)将减少此输入。

┌──┐ ╔══╗
│02│:║57║
└──┘ ╚══╝
 HH   mm

简而言之:

  • 向上箭头()将增加当前活动的输入。
  • 向下箭头()将减少有效输入。
  • 右箭头()将焦点移至右输入。
  • 左箭头()将焦点移到左输入。
  • 上下运动将按预期的时间循环输入。
  • 左右运动不会循环。

挑战

时钟从00:00小时输入激活开始(请参见第一个原理图)。给定输入命令列表,以HH:mm格式输出结果时间。
输入可以是字符串或列表(或等效语言),其中不同的输入方向可以是以下选项之一:

  • ↑↓←→
  • udlr
  • ^v<>
  • 如果您的程序具有GUI,则按实际的箭头键

有标准漏洞。

测试用例

↑↑→↓↓↓ = 02:57
↓→↑←↑→↓ = 00:00
↓→→↓ = 23:59
←←←←→↑ = 00:01
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓→↓ = 23:59

1
@JonathanFrech在给定的选项之一中,选择任意四个唯一值(例如0123)会使某些语言的挑战变得容易得多,而对其他语言则没有好处。
Nit

1
@LuisfelipeDejesusMunoz是的,实际上是根据输入规则写出的。
Nit

3
我认为如果包括几秒钟,这将更具挑战性。这将有更多逻辑被关注,这是当前关注的焦点
Jo King

3
缺少处理Konami代码的特殊规则。
coredump

1
@coredump考虑了一下,但是在大多数语言中,它可能比答案的核心占用更多的空间。
Nit

Answers:


39

Google Chrome 67上的HTML(中文)(简体),39字节

<input type=time value=00:00 autofocus>

屏幕截图

Chrome以不同的语言显示不同的UI组件。即使是简单的时间输入:如果您使用英语(美国),也会显示AM / PM。如果您想通过更改Chrome的语言进行测试。不要集中精力将其改回来。


2
老兄!哈哈,我认为这是无效的
路易斯·费利佩·德·耶稣·穆诺兹

2
两次正确命中AM/PM对我
有利

1
@JoKing我认为这取决于语言环境/设置吗?
Nit

1
@JoKing取决于语言环境。可以尝试将Chrome的语言更改为简体中文吗?(不要
集中精力

1
它适用于Firefox 61.0.1
Francisco Hahn,


6

Stax36 35 33 32 字节

áXò↑─↨√▓|êóÇiU&≡Q#┤Æ⌡⌠╟C▐╜√⌡∟▄╩╠

运行并调试

用途lrud

说明:

'l/{'r/Bs$2lmM{${:14-m|+i36*24+%2|zm':* Full program,
'l/                                     Split the string on "l"
   {        m                           Map over the resulting array
    'r/                                   Split at "r"
       B                                  Uncons left, first on TOS (top of stack)
        s                                 Swap to get tail to top
         $                                Flatten; this removes multiple 'r's
          2l                              Listify two items, BOS (bottom of stack) is first element
             M                          Transpose: get [hour commands, minute commands]
              {                    m    Map:
               $                          Flatten
                {    m                    Map over single commands:
                 :1                         Number of set bits: 5 for 'u', 3 for 'd'
                   4-                       Subtract 4: u -> 1, d -> -1
                      |+                  Sum
                        i                 Iteration index: hours -> 0, minutes -> 1
                         36*24+           Multiply by 36, add 24: 0 -> 24, 1 -> 60
                               %          Modulo, this does -5 % 60 = 55
                                2|z       Stringify, left-padding with "0" to length 2
                                    ':* Join on ":"
                                        Implicit output

6

Python 2,105个字节

h=m=p=0
for c in map(' ^<>'.find,input()):w=1/c;m+=w*p;h+=w-w*p;p=[c-2,p][w]
print'%02d:%02d'%(h%24,m%60)

在线尝试!



5

C#(.NET Core)149132字节

s=>{var p=0;int[]h={0,0};foreach(var c in s)h[p=c<63?c/2%2:p]+=c>62?c>95?-1:1:0;return$"{(h[0]%24+24)%24:D2}:{(h[1]%60+60)%60:D2}";}

在线尝试!

使用^v<>

这使我意识到C#中的模运算符不能按预期方式工作,因为在C#中-1 % 60 = -1,因此我需要在最后进行该奇怪的操作。


(h [1]%60 + 60)%60无法替换为(h [1] +60)%60吗?
IanF1

2
@ IanF1不,你不能。如果用户按下向下按钮100次该怎么办?还是1000次?
查理

感谢您的澄清:)令我惊讶的是,这种方法比即时应用模数(用59代替-1)更短。
IanF1

5

LUA(love2d框架),311个 308字节

l,b,d,t,f,a=love,{24,60},{1,-1},{0,0},1,{"left","right","up","down"}function c(n,i)t[f]=(n+d[i])%b[f]end function l.draw()h,m=t[1],t[2]l.graphics.print((h<10 and 0 ..h or h)..":"..(m<10 and 0 ..m or m),0,0)end function l.keypressed(k)for i,n in pairs(a)do f=k==n and(i>2 and(c(t[f],i-2)or f)or i)or f end end

未加密版本:

--initialize all needed values
l,b,d,t,f,a=love,{24,60},{1,-1},{0,0},1,{"left","right","up","down"}

--increase the numbers depending on the focus and up or down
function c(n,i)
  t[f]=(n+d[i])%b[f]
end 

--draw the time to the screen
function l.draw()
  h,m=t[1],t[2]
  l.graphics.print((h<10 and 0 ..h or h)..":"..(m<10 and 0 ..m or m),0,0)
end

--get the keys and check if it is an arrow key
function l.keypressed(k)
  for i,n in pairs(a)do
    f=k==n and(i>2 and(c(t[f],i-2)or f)or i)or f 
  end 
end

可能仍然不是100%易于阅读,因为所有if都与三元语句(..and ..or)互换:

如果从充满爱的main.lua开始,它将弹出一个窗口,您可以按箭头键更改数字


可能你还发布扩展版的可读性
AAAAA说起用莫妮卡

当然,我添加了扩展版本没问题:)
Lycea '18

4

MATL57 56 55字节

1Oi9\"@5<?y@3-ZS*+}wx7@-X^w]]wx&Zjh24 60h\'%02d:%02d'YD

在线尝试!

用复数表示小时和分钟,实际部分是小时,而虚数部分是分钟。

有评论:

1     % Push 1 on the stack
      % represents which timer box we're in, starts at hour box
      % imaginary number j would represent minutes box
O     % Push initial hour and minutes 0+0j
i9\   % Fetch input, mod each character's ASCII value by 9.
      % Gives 4 1 8 6 for ^ v > < respectively
"     % iterate through (modded) input
  @5<?     % Push current input, see if it's < 5 
           % if so, it's an up or down time change
    y        % so copy out the box indicator (1 or j)
    @3-      % Subtract 3 from the current input
    ZS       % Take the result's sign (-1 for v, 1 for ^)
    *        % Multiply indicator with that
    +        % Add the result to the time value
  }        % else, it's a right or left arrow
    wx       % so bring out the box indicator and delete it
    7@-      % Subtract current input from 7. 1 for < and -1 for >
    X^       % Take the square root of that. 1 for < and j for >
    w        % switch stack to bring time value on top again
  ]       % end if
]     % end loop
wx    % bring box indicator out, delete it
&Zj   % split the complex time value to real and imaginary
h     % then concatenate them into an array
24 60h\ % mod hour and minute values by 24 and 60 respectively
'%02d:%02d'YD % sprintf the time array with 0-padding

4

PHP145个 134 133字节

(-11个字节,更多打高尔夫球)

(使用Davіd的loop方法为-1字节)

<?for($h=$m=0,$a=h;$c=$argv[++$i];)$c<l?$$a--:($c>r?$$a++:$a=$c<r?h:m);$h%=24;$m%=60;printf('%02d:%02d',$h<0?$h+24:$h,$m<0?$m+60:$m);

要运行它:

php -n -d error_reporting=0 <filename> <command_1> <command_2> ... <command_n>

例:

php -n -d error_reporting=0 time_setter.php u u r d d d l d

在线尝试!

笔记:

  • 为了节省一些字节,我使用了没有单引号或双引号的字符串作为字符串包装器。因此,该error_reporting=0选项用于不输出警告。
  • 输入命令: u d l r

128字节,-6:在线尝试!(很好的解决方案,顺便说一句:)
Davіd

@Davіd:谢谢,但是您的更新有两个问题。首先是没有设置$ h,因此在启动时减小它失败:在线尝试!
2

@David:第二个问题发生在我们将小时/分钟向上或向下切换超过24/60次时:在线尝试!
2

@Davіd:但是由于您使用了循环方法,我可以再减少1个字节:在线尝试!
2

啊,好吧,抱歉,它没有完全工作:)
Davіd

4

JavaScript中,104个 103字节

使用将输入作为字符数组<>^v

a=>(a.map(z=>z<"^"?a=z<">":a?x+=z<"v"||23:y+=z<"v"||59,x=y=0),g=n=>`0${n}`.slice(-2))(x%24)+`:`+g(y%60)

在线尝试


3

Haskell,236个字节

f=u 0 0
k _ _ _ _ _ h m[]=z h++':':z m
k a b c d e h m(q:s)=case q of{'^'->e(a h)(b m)s;'v'->e(c h)(d m)s;'>'->v h m s;'<'->u h m s}
u=k(o(+)24)id(o(-)24)id u
v=k id(o(+)60)id(o(-)60)v
o f m x=mod(f x 1)m
z n|n<10='0':show n
z n=show n

f是主要功能,其类型为String -> String

*Main> f "^^>vvv"
"02:57"
*Main> f "v>^<^>v"
"00:00"
*Main> f "v>>v"
"23:59"
*Main> f "<<<<>^"
"00:01"
*Main> f "vvvvvvvvvvvvvvvvvvvvvvvvv>v"
"23:59"

本质上uv是类型的相互递归函数Integer -> Integer -> String -> String。他们花费小时,分钟和set上的字符列表{v,^,<,>},然后返回时间字符串。u作为如果小时表盘被突出显示,递归调用u如果列表的头在{v,^},并且v如果列表的头在{<,>}v是类似的,但分钟拨号。

其他一切只是保存字符。


3

Lua 132字节

loadstring's,t,m=1,{0,0},{24,60}for c in(...):gmatch"."do t[s]=(t[s]+(("d u"):find(c)or 2)-2)%m[s]s=("lr"):find(c)or s end return t'

在线尝试!


说明

这是一个匿名函数(链接上显示了使用它的方法)。

s=1 -- s will control the selection (1 is hour and 2 min)
t={0,0} -- is the time itself
m={24,60} -- is the maximum for each 'box' (hour or min)
-- I've actually used Lua's multiple variable assignment: s,t,m=1,{0,0},{24,60}

for c in (...):gmatch(".") do -- go through each character of the input
  t[s] = (t[s] + (("d u"):find(c) or 2)-2) % m[s] -- set the current 'box' as
          t[s] +   -- itself plus ...
                  ("d u"):find(c) or 2   -- it's index on the string "d u" (that means it's going to be 1 or 3)
                                         -- or 2 if it wasn't found (if the current character doesn't sum or subtract from the box)
                                       -2   -- this adjusts the result 1, 2 or 3 to being -1, 0 or 1
                                            -- making the inputs 'd' and 'u' as -1 and +1 respectively, and an input different from both as 0
         (                               ) % m[s]   -- modulo of the maximum of the selected 'box'

  s=("lr"):find(c) or s
    ("lr"):find(c)   -- if the current input character is l or r, then set 's' (the 'box' selection) to being 1 or 2.
                   or s   -- else let it as is
end
return t -- returns 't', a table with hour and minutes respectively

输出应该是在HH:mm格式,而不是表
乔金

2

Java 8,121字节

c->{int i=0,m[]={0,0,0};for(int t:c)if(t<63)i=t%4;else m[i]+=(t&8)>0?1:119;return"".format("%02d:%02d",m[0]%24,m[2]%60);}

Jonathan Frech的C 答案端口。接受^v<>在这里在线尝试。


2

果冻,36 字节

我相信O%5;4ṣ3œṡ€4Z%3’§§%"“ð<‘DŻ€ṫ€-j”:应该可以在32位上使用,但是œṡ 目前似乎有一个错误

O%5;4ṣ3i€4$œṖ"$Z%3’§§%"“ð<‘DŻ€ṫ€-j”:

一个完整的程序将结果打印到STDOUT(作为Monadic链接,它实际上返回整数(尽管是一位数字)和字符( :)。

使用 udlr选项进行输入。

在线尝试!还是看一个测试套件

怎么样?

O%5;4ṣ3i€4$œṖ"$Z%3’§§%"“ð<‘DŻ€ṫ€-j”: - Link: list of characters (in 'udlr')
O                                    - to ordinals
 %5                                  - modulo five  ...maps u:2, d:0, l:3, r:4
   ;4                                - concatenate a 4 (to always end up with both hrs & mins - even when no r is ever pressed)
     ṣ3                              - split at threes (the l presses)
       i€4$œṖ"$                      - a replacement for œṡ€4 (split each at first occurrence of)...
              $                      - | last two links as a monad:
          $                          - |   last two links as a monad:
         4                           - |     literal four
       i€                            - |     for €ach get first index of (4) else yield 0
             "                       - |   zip with:
           œṖ                        - |     partition at indices
               Z                     - transpose (to get a list of two lists of lists)
                %3                   - modulo by three. To replace any 4(r) with 1
                                     -  ...while keeping any 0(d) as 0, or 2(u) as 2
                  ’                  - decrement. All r are now 0, d are -1 and u are 1
                   §                 - sum each
                    §                - sum each. Now we have the total increase value as
                                     -    ...integers for each of hrs and mins
                       “ð<‘          - code-page indices list = [24,60]
                      "              - zip with:
                     %               -   modulo
                           D         - to decimal lists
                            Ż€       - prepend each with a zero (to cater for values less than ten)
                              ṫ€-    - tail each from index -1. Keeps rightmost two digits of each only)
                                  ”: - literal character ':'
                                 j   - join
                                     - as full program implicit print (smashes the digits and characters together)


2

QBasic,229字节

一个将输入作为按键并输出到控制台的脚本。

注意:"包含终端仅用于语法突出显示,并且不影响字节数

z$=CHR$(0)
DO
x=0
y=0
SELECT CASE INKEY$
CASE z$+"K"
r=0
CASE z$+"M"
r=1
CASE z$+"H"
x=1
y=1
CASE z$+"P"
x=23
y=59
END SELECT
IF r THEN m=(m+y)MOD 60ELSE h=(h+x)MOD 24
CLS
?RIGHT$("00000"+LTRIM$(STR$(h*1000+m)),5)
LOCATE 1,3
?":"
LOOP

已评论

z$=CHR$(0)                                      ''  Set var to null char
DO                                              ''
    x=0                                         ''  Set Hours Shift to 0 
    y=0                                         ''  Set Minutes Shift to 0 
    SELECT CASE INKEY$                          ''  Take keystroke input
        CASE z$+"K"                             ''  If is Left Arrow
            r=0                                 ''    Bool to modify right (minutes) 
        CASE z$+"M"                             ''  If is Right Arrow
            r=1                                 ''    Bool to modify left (hours)
        CASE z$+"H"                             ''  If is Up Arrow
            x=1                                 ''    Set Hours Shift to 1 
            y=1                                 ''    Set Minutes Shift to 1
        CASE z$+"P"                             ''  If is Down Arrow
            x=23                                ''    Set Hours Shift to 23 
            y=59                                ''    Set Minutes Shift to 23 
    END SELECT                                  ''
    IF r THEN m=(m+y)MOD 60ELSE h=(h+x)MOD 24   ''  Shift Minutes If `r=1` Else Shift Hours
    CLS                                         ''  Clear Screen
    ?RIGHT$("00000"+LTRIM$(STR$(h*1000+m)),5)   ''  Use math to concat Hours and Minutes 
                                                ''  then Convert to String and prepend 0s 
                                                ''  to a length of 5
    LOCATE 1,3                                  ''  Cursor to the the third digit
    ?":"                                        ''  Overwrite that digit with a `:`
LOOP                                            ''  Loop

1
那不是(m+y)吗?
尼尔

在注释中,应该这样做吗?
乔纳森·弗雷希

@JonathanFrech-是的。感谢您对我的语法进行检查
Taylor Scott

抱歉,m出于某种原因,我认为这是几分钟的时间...我认为您的评论版本更具可读性。
尼尔

2

Powershell,109103字节

-6字节感谢AdmBorkBork

$t=0,0
$args|%{$t[+$i]+=. @{l={$i=0};r={$i=1};u={1};d={119}}.$_}
"{0:00}:{1:00}"-f($t[0]%24),($t[1]%60)

测试脚本:

$f = {

$t=0,0
$args|%{$t[+$i]+=. @{l={$i=0};r={$i=1};u={1};d={119}}.$_}
"{0:00}:{1:00}"-f($t[0]%24),($t[1]%60)

}

@(
    ,('02:57',('u','u','r','d','d','d'))
    ,('00:00',('d','r','u','l','u','r','d'))
    ,('23:59',('d','r','r','d'))
    ,('00:01',('l','l','l','l','r','u'))
    ,('23:59',('d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','d','r','d'))
) | % {
    $e, $c = $_
    $r = &$f @c
    "$($r-eq$e): $r"
}

输出:

True: 02:57
True: 00:00
True: 23:59
True: 00:01
True: 23:59

说明

基本思想是使用[hashtable],这keys是控制命令并且values是脚本块。代码为参数中的每个命令执行脚本块。


1
您可以$i=0通过强制转换数组索引$t[+$i]来节省一些字节来摆脱这种情况。在线尝试!
AdmBorkBork

2

Perl 6的101个91 89 86字节

{$/=[];$!=0;$_>2>($!=$_-3)||($/[$!]+=$_-1)for .ords X%5;($0%24,$1%60).fmt("%02d",":")}

在线尝试!

匿名代码块,它接受字符串uldr并以给定格式返回


1

perl -F // -E,72个字节

$x=H;/u/?$$x++:/d/?$$x--:($x=/l/?H:M)for@F;printf"%02d:%02d",$H%24,$M%60

1

Python,120个字节

o,i=[0,0],0
for s in list(input()):i=(i+(s=='r')-(s=='l')>=1);o[i]+=(s=='u')-(s=='d')
print'%02d:%02d'%(o[0]%24,o[1]%60)

这看起来像一个片段,将变量输入。作为一般规则,我们需要给出完整程序(从程序参数或标准输入中获取输入)或函数(从功能参数中获取输入)的答案。
OOBalance '18

1
此外,当输入(例如)ldrru导致i其离开范围(0,1)并o[i]随后被访问时,这是否会碰壁?
OOBalance

@OOBalance哦,谢谢您提醒我您需要功能或unput()。根据需求,我认为L和R动作永远不会循环(即否LL
aaaaa说,请恢复莫妮卡(Monica)

@aaaaaa没有循环的方法lll与相同r。具有llrr有效的输入,它也在测试用例中,例如,参见第三个。
Nit

此答案当前在第三个测试用例上具有IndexError,而不是输出23:59在线尝试!
0'

1

186字节的Haskell

f(0,0)'<'
f t i('^':r)=f(i#t$1)i r
f t i('v':r)=f(i#t$ -1)i r
f t i(x:r)=f t x r
f(h,m)_ _=s h++':':s m
('<'#(h,m))n=(mod(24+n+h)24,m)
(_#(h,m))n=(h,mod(60+n+m)60)
s n=['0'|n<10]++show n

在线尝试!


1

R,368355字节

f=function(){C=as.character
i=ifelse
p=paste0
r=1:10
h=C(0:23);m=C(0:59)
h[r]=p(0,h[r])
m[r]=p(0,m[r])
x=y=z=1
while(T){print(p(h[x],":",m[y]))
v=1
n="[UDLRS]"
while(!grepl(n,v))v=toupper(readline(n))
if(v=="L")z=1 else if(v=="R")z=0
if(v=="S")T=F
if(v=="U")if(z)x=i(x==24,1,x+1)else y=i(y==60,1,y+1)
if(v=="D")if(z)x=i(x==1,24,x-1)else y=i(y==1,60,y-1)}}

绝对不是最好的方法,但是有效。

功能:运行功能,键入每个字母以增加(增加/减少)或向左/向右移动,键入“ s”结束“游戏”。问题是它一次只能接受一个字母。

-13个字节将一些值合并为一行,将T改写为F而不是使用break,发现要消除的几个空格,并将字符串存储在变量中

f=function(){C=as.character                             # Abbreviate functions
i=ifelse
p=paste0
r=1:10                                                  # Initialize and format values
h=C(0:23);m=C(0:59)
h[r]=p(0,h[r])
m[r]=p(0,m[r])
x=y=z=1
while(T){print(p(h[x],":",m[y]))                        # Begin while loop and print time
v=1                                                     # Initial value reset each iteration to retrieve a new direction
n="[UDLRS]"                                             # Used for verification and request
while(!grepl(n,v))v=toupper(readline(n))                # Will only accept proper directions or stopping rule
if(v=="L")z=1 else if(v=="R")z=0                        # Evaluate for hour or minute
if(v=="S")T=F                                           # Stopping rule, overwrite True to False
if(v=="U")if(z)x=i(x==24,1,x+1)else y=i(y==60,1,y+1)    # Rules for Up
if(v=="D")if(z)x=i(x==1,24,x-1)else y=i(y==1,60,y-1)}}  # Rules for Down

我还在编辑另一种格式,以接受R字符串和/或矢量,这些格式将在下周发布。


1

SmileBASIC,123字节

@L
B=BUTTON(2)D=(B==1)-(B==2)S=S+!S*(B>7)-S*(B==4)H=(H+D*!S+24)MOD 24WAIT
M=(M+D*S+60)MOD 60?FORMAT$("%02D:%02D",H,M)GOTO@L

BUTTON() 返回一个整数,其中每个位代表一个按钮

1 = up
2 = down
4 = left
8 = right
...

BUTTON(2) 仅返回刚刚按下(不按住)的按钮

WAIT 是必需的,因为 BUTTON每帧更新一次(1/60秒)。否则,将多次检测到相同的按钮按下。

这绝对可以缩短


0

05AB1E38 37 字节

'l¡ε'r¡}0ζćs˜‚€S„udS1®‚:OŽ9¦2ä%T‰J':ý

用途udlr为方向,但也可以使用^v<>了相同的字节数(字符↑↓←→不是05AB1E的代码页的一部分,所以使用这些会被大量增加的字节数,因为编码应改为ASCII)。

在线尝试验证所有测试用例

说明:

'l¡            '# Split the (implicit) input on "l"
                #  i.e. "lllrurulddd" → ["","","","ruru","ddd"]
   ε   }        # Map each item to:
    'r¡        '#  Split the item on "r"
                #   i.e. ["","","","ruru","ddd"] → [[""],[""],[""],["","u","u"],["ddd"]]
        0ζ      # Zip/transpose; swapping rows/columns, with "0" as filler
                #  i.e. [[""],[""],[""],["","u","u"],["ddd"]]
                #   → [["","","","","ddd"],["0","0","0","u","0"],["0","0","0","u","0"]]
ć               # Head extracted: pop and push the remainder and head-item to the stack
                #  i.e. [["","","","","ddd"],["0","0","0","u","0"],["0","0","0","u","0"]]
                #   → [["0","0","0","u","0"],["0","0","0","u","0"]] and ["","","","","ddd"]
 s              # Swap to get the remainder
  ˜             # Flatten it
                #  i.e. [["0","0","0","u","0"],["0","0","0","u","0"]]
                #   → ["0","0","0","u","0","0","0","0","u","0"]
               # Pair the head and remainder back together
                #  i.e. ["","","","","ddd"] and ["0","0","0","u","0","0","0","0","u","0"]
                #   → [["","","","","ddd"],["0","0","0","u","0","0","0","0","u","0"]]
    S          # Convert each item to a list of characters
                # (implicitly flattens and removes empty strings)
                #  i.e. [["","","","","ddd"],["0","0","0","u","0","0","0","0","u","0"]]
                #   → [["d","d","d"],["0","0","0","u","0","0","0","0","u","0"]]
      udS1®‚:  # Replace all "u" with "1" and all "d" with "-1"
                #  i.e. [["d","d","d"],["0","0","0","u","0","0","0","0","u","0"]]
                #   → [["-1","-1","-1"],["0","0","0","1","0","0","0","0","1","0"]]
              O # Then take the sum of each inner list
                #  i.e. [["-1","-1","-1"],["0","0","0","1","0","0","0","0","1","0"]]
                #   → [-3,2]
Ž9¦             # Push compressed integer 2460
   2ä           # Split into two parts: [24,60]
     %          # Modulo the two lists
                #  i.e. [-3,2] and [24,60] → [21,2]
      T        # Divmod each with 10
                #  i.e. [21,2] → [[2,1],[0,2]]
        J       # Join each inner list together
                #  i.e. [[2,1],[0,2]] → ["21","02"]
         ':ý   '# Join the list with ":" delimiter
                #  i.e. ["21","02"] → "21:02"
                # (and output the result implicitly)

看到这个05AB1E尖矿(部分如何压缩大整数?理解为什么Ž9¦2460

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.