9

# 输入

``````1:00 EDT (1 PM Eastern Daylight Time)
4:05 MDT (4:05 PM Mountain Daylight Time)
12:23 PDT (12:23 PM Pacific Daylight Time)
1:10 CDT (1:10 PM Central Daylight Time)
``````

# 输出

1. 将给定时间转换为PDT并输出`It is XX:XX PM PDT.`，其中`XX:XX`是转换后的时间。请注意，你不会需要处理，其中转换的时间将跨越AM / PM边界的任何情况。

2. 打印以下内容之一：

1. 如果转换后的时间是下午六时PDT，打印`X minutes until the pre-show!`，替换`X`与到下午6点的PDT的分钟数。

2. 如果转换后的时间在PDT下午6:00之前和PDT 7:00之前之后，请打印`Pre-show started X minutes ago; UNCOVERED is starting in Y minutes!`，其中PDT`X`是自6:00 PM PDT经过`Y`的分钟数，是7:00之前的分钟数。太平洋夏令时间。

3. 如果转换的时间在PDT 7:00 PM之后或等于7:00 PM PDT，则打印`UNCOVERED started X minutes ago!`，这里`X`PDT 7:00 PM之后经过的分钟数。

# 计分

Leaky Nun

1
`HH:MM XDT`错字吗？可以`CST`
Leaky Nun

1

Leaky Nun

@KennyLau这`CST`是一个错字，不会出现任何时间可以跨越AM / PM边界的情况。编辑帖子。
kirbyfan64sos '16

1

## JavaScript（ES6），257个字节

``````s=>(t=` minutes`,a=s.match(/(\d+):(\d+) (.)/),h=+a[1]+"PMCE".search(a[3]),m=420-h*60-a[2],`It is \${h}:\${a[2]} PM PDT
\${h<6?m-60+t+` until the pre-show`:h<7?`Pre-show started \${60-m+t} ago; UNCOVERED is starting in \${m+t}`:`UNCOVERED started \${-m+t} ago`}!`)
``````

@Matt对于仅在开销为13个字节后才重复的字符串，因此，它必须为14个字节长才值得。“分钟”由于紧挨时间并且需要四次而获得奖励。
Neil

4

# Python（335字节）

``````t=raw_input().replace(*': ').split();x='PMCE'.index(t[2][0]);t[0]=int(t[0])+x;print '%s:%s PM PDT' % tuple(t[:1]);x=t[0]*60+int(t[1]);print ['%s minutes until the pre-show!'%(360-x),'Pre-show started %s minutes ago; UNCOVERED is starting in %s minutes!'%((x-360),(420-x)), 'UNCOVERED started %s minutes ago!'%(x-420)][(x>360)+(x>420)]
``````

``````1:00 MDT
2:00 PM PDT
240 minutes until the pre-show!

6:00 CDT
8:00 PM PDT
UNCOVERED started 60 minutes ago!

6:50 PDT
6:50 PM PDT
Pre-show started 50 minutes ago; UNCOVERED is starting in 10 minutes!
``````

Leaky Nun

Leaky Nun

Katenkyo

Blue

2

# Lua中，357个335 332字节

``h,m,t=(...):match("(%d+):(%d+) (.)")f=tonumber h=(f(h)-("PMCE"):find(t))%12+1m=f(m)print("It is "..h..":"..m.." PM PDT.")a=" minutes"b="UNCOVERED"n=(6-h)*60-m r=h<6 and n..a.." until the pre-show!"or h<7 and"Pre-show started "..m..a.." ago; "..b.." is starting in "..(n+60)..a.."!"or b.." started "..(m+(h-7)*60)..a.." ago!"print(r)``

``````n = "7:10 CST"

h,m,t = n:match("(%d+):(%d+) (.)")
h = (tonumber(h) - ("PMCE"):find(t))%12 + 1
m = tonumber(m)
print("It is "..h..":"..m.." PM PDT.")

n = (6-h)*60-m

if h<6 then
r=n.." minutes until the pre-show!"
elseif h<7 then
r="Pre-show started "..m.." minutes ago; UNCOVERED is starting in "..(n+60).." minutes!"
else
r="UNCOVERED started "..(m+(h-7)*60).." minutes ago!"
end

print(r)``````

Katenkyo

Katenkyo

（仍然没有足够的空间来完成我想说的话）不要忘了检查lua技巧，它们还不是很详尽，但是还有一些有用的东西：）
Katenkyo

Katenkyo

Leaky Nun

1

# C，333字节

``````#define p printf
char s[9];main(t){gets(s);s[5]=0;s[1]-=2+s[6]%2-s[6]%3;s[1]<48&&(s[1]+=10,--*s);
t=*s*600+s[1]*60+s[3]*10+s[4]-32568;p("It is %s PM PDT.",s);
t<0?p("%d minutes until the pre-show!",-t):t<60?p(
"Pre-show started %d minutes ago; UNCOVERED is starting in %d minutes!",t,60-t):
p("UNCOVERED started %d minutes ago!",t-60);}
``````

Matt

1

# PHP，347个328 327 322字节

``````<?=\$u="UNCOVERED";\$m=" minutes";\$s=" started ";\$p="re-show";\$z=['P'=>0,'M'=>1,'C'=>2,'E'=>3];\$i=explode(":",\$argv[1]);\$h=\$i[0]%12-\$z[\$argv[2][0]];\$o=\$i[1];\$t=60-\$o;\$a="\$s\$o\$m ago";echo"It is ".((\$h+11)%12+1).":\$o".(\$h<0?" A":" P")."M PDT.\n".(\$h<6?\$t."\$m until the p\$p!":(\$h<7?"P\$p\$a; \$u is starting in \$t\$m!":"\$u\$a!"));?>
``````

### 分解图

``````<?=
\$u = "UNCOVERED";
\$m = " minutes";
\$s = " started ";
\$p = "re-show";
\$z = [ 'P' => 0,
'M' => 1,
'C' => 2,
'E' => 3 ];

\$i = explode(":", \$argv[1]);
\$h = \$i[0]%12 - \$z[\$argv[2][0]];
\$o = \$i[1];
\$t = 60 - \$o;
\$a = "\$s\$o\$m ago";

echo "It is " . ((\$h+11)%12+1) . ":\$o" . (\$h < 0 ? " A" : " P") . "M PDT.\n" .
(\$h < 6 ? \$t . "\$m until the p\$p!"
: (\$h < 7 ? "P\$p\$a; \$u is starting in \$t\$m!"
: "\$u\$a!"));
?>
``````

0

# PowerShell 292字节

``\$r,\$i,\$s,\$u="re-show"," minutes"," start","UNCOVERED";\$h,\$m,\$z=\$args[0]-split":| ";\$h=+\$h-"PMCE".IndexOf(\$z[0]);"It is \$h`:\$m PM PDT.";if((\$t=\$h*60+\$m-360)-lt0){"\$(\$t*-1)\$i until the p\$r!"}else{if(\$t-gt59){"\$u\$s`ed \$(\$t-60)\$i ago!"}else{"P\$r\$s`ed \$t\$i ago; \$u is\$s`ing in \$((\$t-60)*-1)\$i!"}}``

``````# Some string literals.
\$r,\$i,\$s,\$u,\$g="re-show"," minutes"," start","UNCOVERED"," ago"
# Get the hours, minutes and zone into variables.
\$h,\$m,\$z=\$args[0]-split":| "
# Offset the time based on the passed timezone.
\$h=+\$h - "PMCE".IndexOf(\$z[0])
# Display current PDT time.
"It is \$h`:\$m PM PDT."

# Based on adjusted time value for PDT determine what string to show.
# Several string literals were used to save space.
if((\$t=\$h*60+\$m-360)-lt0){
# Show has not started yet
"\$(\$t*-1)\$i until the p\$r!"
}else{
if(\$t-gt59){
# Between 6 and 7
"\$u\$s`ed \$(\$t-60)\$i\$g!"
}else{
# It's after 7. Should have check more often.
"P\$r\$s`ed \$t\$i\$g; \$u is\$s`ing in \$((\$t-60)*-1)\$i!"
}
}``````

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.