州和首都


23

给定一个字符串作为输入,如果它是州资本,则输出其资本为美国的州,如果它为州,则输出其国家的资本,或者Arstotzka都不是。

例子:

Austin -> Texas
Alaska -> Juneau
The Nineteenth Byte -> Arstotzka

所有首都及其各自的州:

Baton Rouge, Louisiana
Indianapolis, Indiana
Columbus, Ohio
Montgomery, Alabama
Helena, Montana
Denver, Colorado
Boise, Idaho
Austin, Texas
Boston, Massachusetts
Albany, New York
Tallahassee, Florida
Santa Fe, New Mexico
Nashville, Tennessee
Trenton, New Jersey
Jefferson, Missouri
Richmond, Virginia
Pierre, South Dakota
Harrisburg, Pennsylvania
Augusta, Maine
Providence, Rhode Island
Dover, Delaware
Concord, New Hampshire
Montpelier, Vermont
Hartford, Connecticut
Topeka, Kansas
Saint Paul, Minnesota
Juneau, Alaska
Lincoln, Nebraska
Raleigh, North Carolina
Madison, Wisconsin
Olympia, Washington
Phoenix, Arizona
Lansing, Michigan
Honolulu, Hawaii
Jackson, Mississippi
Springfield, Illinois
Columbia, South Carolina
Annapolis, Maryland
Cheyenne, Wyoming
Salt Lake City, Utah
Atlanta, Georgia
Bismarck, North Dakota
Frankfort, Kentucky
Salem, Oregon
Little Rock, Arkansas
Des Moines, Iowa
Sacramento, California
Oklahoma City, Oklahoma
Charleston, West Virginia
Carson City, Nevada

规则

  • 没有提供状态到首都或首都到州的映射或首都和/或州列表的内置程序或库/模块(例如,Mathematica的CityData内置程序)
  • 适用标准漏洞
  • 这是,因此最短答案以字节为单位!

排行榜

这篇文章底部的堆栈摘录从答案a)生成排行榜,答案是每种语言的最短解决方案列表,b)则是总体排行榜。

为确保您的答案显示出来,请使用以下Markdown模板以标题开头。

## Language Name, N bytes

N您提交的文件大小在哪里。如果您提高了分数,则可以通过打败旧分数保持标题。例如:

## Ruby, <s>104</s> <s>101</s> 96 bytes

如果要在标头中包含多个数字(例如,因为您的分数是两个文件的总和,或者您想单独列出解释器标志罚分),请确保实际分数是标头中的最后一个数字:

## Perl, 43 + 2 (-p flag) = 45 bytes

您还可以将语言名称设置为链接,然后该链接将显示在代码段中:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes



4
请以明文形式正确拼写州及其首都的完整列表。
orlp 2015年

2
@sysreq拼写和大小写必须与提供的列表完全匹配。由于“美国”既不是美国州也不是美国州首府,因此应返回“ Arstotzka”。
Mego 2015年

6
@sysreq对我来说,这听起来不是一个好主意。
SuperJedi224

4
@FarazMasroor Builtins被禁止
意大利面条

Answers:


10

Pyth,597 596 590

00000000: 40 4a 63 72 58 73 40 4c 2b 62 47 6a 43 22 05 77 c6  @JcrXs@L+bGjC".w.
00000011: fa 94 29 be 77 9b 88 35 9b e0 86 05 86 8a d3 cd 53  ..).w..5........S
00000022: e6 97 c1 20 f4 bd b5 76 f3 f7 14 ab 4b fa 8e 4d 2c  ... ...v....K..M,
00000033: be 71 4d 13 ca 9c 67 3e 35 21 76 6b 74 f8 88 8b c1  .qM...g>5!vkt....
00000044: bc 2a ab da 6b ba 1f 2b a3 2c 12 bc d1 b8 c3 b6 7c  .*..k..+.,......|
00000055: b0 4d 0f 11 a2 dc 15 a2 94 45 39 1c 20 12 08 03 a3  .M.......E9. ....
00000066: 5c 71 d9 11 1c 56 f5 c2 2d cb 63 64 b3 c0 d8 e7 e3  \q...V..-.cd.....
00000077: 9b 82 28 85 57 2b e4 28 ea 8f 17 02 1d a8 8f f3 0e  ..(.W+.(.........
00000088: 31 5f 8e c4 2b b3 8f 7e b2 64 fc d2 99 dc 9d 98 e5  1_..+..~.d.......
00000099: 3a b3 8b 59 52 5f 63 5a ae c9 3d 8a 7a b6 a2 0a 8a  :..YR_cZ..=.z....
000000aa: 2f 4c 43 78 fa 56 9b 07 ce 21 3a 2f 50 5e d3 f3 a9  /LCx.V...!:/P^...
000000bb: 90 ad 21 85 75 cd 9e 07 29 a3 3d b7 c2 cd f4 b8 5f  ..!.u...).=....._
000000cc: 60 b4 72 cd 47 93 17 14 28 3e da b1 65 90 ec 5f 35  `.r.G...(>..e.._5
000000dd: 4d c6 0e b1 66 40 af 8a 67 95 47 f8 8f fd 38 66 c8  M...f@..g.G...8f.
000000ee: df fd 51 6c 5f 06 06 35 a1 77 ae 93 84 73 33 63 be  ..Ql_..5.w...s3c.
000000ff: 98 3e 1c f3 43 de ca 0a 13 6d e9 64 52 96 b8 41 e8  .>..C....m.dR..A.
00000110: db 23 a6 01 c5 60 38 db 63 9c 2a d9 5d 03 fc 38 c8  .#...`8.c.*.]..8.
00000121: 94 1e 2f 70 8e 4d 0f 93 44 4a 6c 57 e8 af cc e7 e2  ../p.M..DJlW.....
00000132: 70 82 84 a3 06 d3 2a 4f cd 8b b6 68 a5 80 98 9e 49  p.....*O...h....I
00000143: 4f bc fd 91 20 55 a6 66 12 1d c0 49 f2 3e 9e ef 5d  O... U.f...I.>..]
00000154: 89 bc b3 30 ef dd cc ca 93 70 27 2c 14 03 6a 53 32  ...0.....p',..jS2
00000165: ef af e1 b5 d3 5a cc 3e fd 1d 78 a5 b3 06 ae 67 58  .....Z.>..x....gX
00000176: ec e4 7a 99 16 f5 da a7 1e 51 0a 94 fc cd e9 e8 fe  ..z......Q.......
00000187: 5a d1 bc 0f bb 24 9d 45 9a ac 97 58 a7 9b ea f0 77  Z....$.E...X....w
00000198: 89 e8 a1 fa e7 83 2c b9 ea 5c a7 f1 b3 76 ba 97 fb  ......,..\...v...
000001a9: 41 b7 74 9a 09 2d 96 97 73 80 13 17 7a fe 15 5f c6  A.t..-..s...z.._.
000001ba: cf 89 3d 7f df 54 cd 16 fe 8a ea d7 0a 91 84 54 61  ..=..T.........Ta
000001cb: 4f 03 87 a6 d2 1c c8 a9 b8 0f 52 2e 39 13 2e 48 8b  O.........R.9..H.
000001dc: 04 ce 2d 35 5e 02 96 63 11 a7 f8 75 6d 8a e2 13 e2  ..-5^..c...um....
000001ed: d6 1b f9 43 07 3e 99 29 a9 69 7f f5 6a 72 15 7b 92  ...C.>.).i..jr.{.
000001fe: 5b 26 cb 74 48 1b c0 fc fb 64 45 05 2d 37 d6 21 6a  [&.tH....dE.-7.!j
0000020f: d9 83 88 13 fb e7 e8 f2 17 c7 54 de 48 f6 23 1e bf  ..........T.H.#..
00000220: b0 34 f5 4f 63 ce 46 40 a9 16 e7 4a 60 71 ce a3 d3  .4.Oc.F@...J`q...
00000231: 6a 15 4c 8b 52 d6 3f cb 53 dd 96 97 10 f6 e5 22 32  j.L.R.?.S......"2
00000242: 37 5c 71 64 33 62 5f 68 68 78 4a 7a                 7\qd3b_hhxJz

上面的hexdump可以用反转xxd -r -c 17。在Pyth编译器中在线尝试。

理念

我们将所需信息编码如下:

columbia
columbus
frankfort
⋮
kentucky
ohio
southqcarolina
arstotzka

所有名称都已强制转换为小写字母,空格已替换为q,并且名称之间用换行符分隔。

所有大写字母都首先列出(以设法使字节数最小的顺序)。然后以相反的顺序列出相应的状态。最后,附加了Arstotzka

这样,索引i处的资本/州对应于索引-(x + 2)的州/资本。同样,无效的输入将具有索引100Arstotzka)或-1(未找到),以及-(100 + 2)-1 -1-(-1 + 2)mod 101。此布局可防止Arstotzka成为特殊情况,而无需在列表前添加或添加任何内容。

为了压缩信息,我们在其中找到每个字符的索引"\nabc...xyz",并将结果从27转换为256。

解码非常简单:我们从256的基数返回到27的基数,从中检索相应的元素"\nabc…xyz",用空格替换q,然后将每个结果单词的首字母大写。

@JcrXs@L+bGjC"…"27\qd3b_hhxJz

            C"…"               Convert the 562-character from base 256 to integer.
           j    27             Convert the result from integer to base 27.
        +bG                    Compute "\n" + "abc…xyz".
      @L                       Retrieve the corresponding characters.
     s                         Flatten the resulting array of strings.
    X             \qd          Replace each q with a space.
   r                 3         Apply title casing.
 Jc                   b        Split at linefeeds and save in J.
                          xJz  Compute the index of the input (z) in J.
                       _hh     Increment twice and negate.
@                              Retrieve the element at that index from J.

24

Python3,997个字节

i=input()
s="Baton Rouge,Louisiana,Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Albany,New York,Tallahassee,Florida,Santa Fe,New Mexico,Nashville,Tennessee,Trenton,New Jersey,Jefferson,Missouri,Richmond,Virginia,Pierre,South Dakota,Harrisburg,Pennsylvania,Augusta,Maine,Providence,Rhode Island,Dover,Delaware,Concord,New Hampshire,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Saint Paul,Minnesota,Juneau,Alaska,Lincoln,Nebraska,Raleigh,North Carolina,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Columbia,South Carolina,Annapolis,Maryland,Cheyenne,Wyoming,Salt Lake City,Utah,Atlanta,Georgia,Bismarck,North Dakota,Frankfort,Kentucky,Salem,Oregon,Little Rock,Arkansas,Des Moines,Iowa,Sacramento,California,Oklahoma City,Oklahoma,Charleston,West Virginia,Carson City,Nevada,Arstotzka".split(",")+[i]
print(s[1^s.index(i)])

我不必费心去做胜出版本无疑会做的基数转换或二进制打包,但是我确实想发布它以显示一个很酷的技巧。

将数字与1进行XOR运算等效于如果数字为偶数则加1,或者如果数字为奇数则减1。使用此技巧,您可以制作出非常简单且容易打高尔夫球的双向地图。


2
与我的技巧相同,但语言不同。你打我一分钟!
级圣河

啊,这就是我想做的,但我不知道怎么做。高尔夫不错!
2015年

如果您切换到2.7,则可以消除原音,print()其他所有内容都仍然可以正常使用
2015年

1
您可能只需要输入带有引号(使用时raw_input)。@orlp
Zach Gates

1
@ΚριτικσιΛίθος这是一个TypeError。
orlp 2015年

13

CJam,625个 609 603 599字节

00000000: 22 05 77 c6 fa 94 29 be 77 9b 88 35 9b e0 86 05 86  ".w...).w..5.....
00000011: 8a d3 cd 53 e6 97 c1 20 f4 bd b5 76 f3 f7 14 ab 4b  ...S... ...v....K
00000022: fa 8e 4d 2c be 71 4d 13 ca 9c 67 3e 35 21 76 6b 74  ..M,.qM...g>5!vkt
00000033: f8 88 8b c1 bc 2a ab da 6b ba 1f 2b a3 2c 12 bc d1  .....*..k..+.,...
00000044: b8 c3 b6 7c b0 4d 0f 11 a2 dc 15 a2 94 45 39 1c 20  ...|.M.......E9. 
00000055: 12 08 03 a3 5c 71 d9 11 1c 56 f5 c2 2d cb 63 64 b3  ....\q...V..-.cd.
00000066: c0 d8 e7 e3 9b 82 28 85 57 2b e4 28 ea 8f 17 02 1d  ......(.W+.(.....
00000077: a8 8f f3 0e 31 5f 8e c4 2b b3 8f 7e b2 64 fc d2 99  ....1_..+..~.d...
00000088: dc 9d 98 e5 3a b3 8b 59 52 5f 63 5a ae c9 3d 8a 7a  ....:..YR_cZ..=.z
00000099: b6 a2 0a 8a 2f 4c 43 78 fa 56 9b 07 ce 21 3a 2f 50  ..../LCx.V...!:/P
000000aa: 5e d3 f3 a9 90 ad 21 85 75 cd 9e 07 29 a3 3d b7 c2  ^.....!.u...).=..
000000bb: cd f4 b8 5f 60 b4 72 cd 47 93 17 14 28 3e da b1 65  ..._`.r.G...(>..e
000000cc: 90 ec 5f 35 4d c6 0e b1 66 40 af 8a 67 95 47 f8 8f  .._5M...f@..g.G..
000000dd: fd 38 66 c8 df fd 51 6c 5f 06 06 35 a1 77 ae 93 84  .8f...Ql_..5.w...
000000ee: 73 33 63 be 98 3e 1c f3 43 de ca 0a 13 6d e9 64 52  s3c..>..C....m.dR
000000ff: 96 b8 41 e8 db 23 a6 01 c5 60 38 db 63 9c 2a d9 5d  ..A..#...`8.c.*.]
00000110: 03 fc 38 c8 94 1e 2f 70 8e 4d 0f 93 44 4a 6c 57 e8  ..8.../p.M..DJlW.
00000121: af cc e7 e2 70 82 84 a3 06 d3 2a 4f cd 8b b6 68 a5  ....p.....*O...h.
00000132: 80 98 9e 49 4f bc fd 91 20 55 a6 66 12 1d c0 49 f2  ...IO... U.f...I.
00000143: 3e 9e ef 5d 89 bc b3 30 ef dd cc ca 93 70 27 2c 14  >..]...0.....p',.
00000154: 03 6a 53 32 ef af e1 b5 d3 5a cc 3e fd 1d 78 a5 b3  .jS2.....Z.>..x..
00000165: 06 ae 67 58 ec e4 7a 99 16 f5 da a7 1e 51 0a 94 fc  ..gX..z......Q...
00000176: cd e9 e8 fe 5a d1 bc 0f bb 24 9d 45 9a ac 97 58 a7  ....Z....$.E...X.
00000187: 9b ea f0 77 89 e8 a1 fa e7 83 2c b9 ea 5c a7 f1 b3  ...w......,..\...
00000198: 76 ba 97 fb 41 b7 74 9a 09 2d 96 97 73 80 13 17 7a  v...A.t..-..s...z
000001a9: fe 15 5f c6 cf 89 3d 7f df 54 cd 16 fe 8a ea d7 0a  .._...=..T.......
000001ba: 91 84 54 61 4f 03 87 a6 d2 1c c8 a9 b8 0f 52 2e 39  ..TaO.........R.9
000001cb: 13 2e 48 8b 04 ce 2d 35 5e 02 96 63 11 a7 f8 75 6d  ..H...-5^..c...um
000001dc: 8a e2 13 e2 d6 1b f9 43 07 3e 99 29 a9 69 7f f5 6a  .......C.>.).i..j
000001ed: 72 15 7b 92 5b 26 cb 74 48 1b c0 fc fb 64 45 05 2d  r.{.[&.tH....dE.-
000001fe: 37 d6 21 6a d9 83 88 13 fb e7 e8 f2 17 c7 54 de 48  7.!j..........T.H
0000020f: f6 23 1e bf b0 34 f5 4f 63 ce 46 40 a9 16 e7 4a 60  .#...4.Oc.F@...J`
00000220: 71 ce a3 d3 6a 15 4c 8b 52 d6 3f cb 53 dd 96 97 10  q...j.L.R.?.S....
00000231: f6 e5 22 32 35 36 62 32 37 62 27 60 66 2b 27 60 2f  .."256b27b'`f+'`/
00000242: 7b 27 71 2f 33 32 61 66 2e 5e 53 2a 7d 25 5f 71 61  {'q/32af.^S*}%_qa
00000253: 23 7e 28 3d                                         #~(=

上面的hexdump可以用反转xxd -r -c 17。在CJam解释器中在线尝试。

理念

我们将所需信息编码如下:

columbia`columbus`frankfort`olympia`desqmoines`jefferson`springfield`carsonqcity`topeka`sacramento`littleqrock`saltqlakeqcity`boston`trenton`batonqrouge`indianapolis`madison`charleston`austin`denver`hartford`santaqfe`atlanta`augusta`boise`oklahomaqcity`dover`helena`tallahassee`richmond`lansing`honolulu`saintqpaul`salem`providence`raleigh`cheyenne`nashville`concord`albany`bismarck`phoenix`jackson`montpelier`montgomery`harrisburg`juneau`pierre`annapolis`lincoln`nebraska`maryland`southqdakota`alaska`pennsylvania`alabama`vermont`mississippi`arizona`northqdakota`newqyork`newqhampshire`tennessee`wyoming`northqcarolina`rhodeqisland`oregon`minnesota`hawaii`michigan`virginia`florida`montana`delaware`oklahoma`idaho`maine`georgia`newqmexico`connecticut`colorado`texas`westqvirginia`wisconsin`indiana`louisiana`newqjersey`massachusetts`utah`arkansas`california`kansas`nevada`illinois`missouri`iowa`washington`kentucky`ohio`southqcarolina`arstotzka

所有名称都已强制转换为小写字母,空格已替换为q,并且名称之间用反引号分隔。

所有大写字母都首先列出(以设法使字节数最小的顺序)。然后以相反的顺序列出相应的状态。最后,附加了Arstotzka

这样,索引i处的资本/州对应于索引-(x + 2)的州/资本。同样,无效的输入将具有索引100Arstotzka)或-1(未找到),以及-(100 + 2)-1 -1-(-1 + 2)mod 101。此布局可防止Arstotzka成为特殊情况,而无需在列表前添加或添加任何内容。

为了压缩信息,我们`从字符串中的每个字符中减去97(的代码点),并将结果从27转换为256。

解码非常简单:我们从256的基数返回到27的基数,将产生的27底的数字加到反引号字符,用空格替换q,然后将每个产生的单词的首字母大写。

"…"          e# Push a string of 562 characters.
256b27b      e# Convert it from base 256 to base 27.
'`f+         e# Add each base-27 digit to the character '`'.
'`/          e# Split at occurrences of '`'.
{            e#   For each resulting chunk:
  'q/        e#   Split at occurrences of 'q'.
  32a        e#   Push [32].
  f.^        e#   For each chunk, perform vectorized XOR with 32.
             e#   This capitalizes the first character of the chunk.
  S*         e#   Join the chunks, separating by spaces.
}%           e#
_            e# Push a copy of the resulting array.
qa           e# Read all user input and wrap it in an array.
#            e# Find its index (i) in the copy.
~(           e# Apply bitwise NOT and decrements to calculate
             e# ~i - 1 = -(i + 1) - 1 = -(i + 2).
=            e# Retrieve element at the corresponding index.

这是哪种编码?
lirtosiast 2015年

ISO 8559-1,因此每个字符为一个字节。
丹尼斯

您可以使用CJam做的事真是令人惊讶...
GamrCorps 2015年

我认为这是我所见过的最大的CJam程序。
Mego 2015年

9

JavaScript(ES6),821806字节

使用Base64解码来压缩字符串。现场演示

s=>(S=(r=x=>btoa(x).replace(/\+/g," ").split`/`)`.¢²&§kò'v&§kó¡À¦Ú¯Ì¢{Z¯Â¢Z+iÚ?!Ö¡£ôÞÅ«?1«,iÈn±ëm³ó^Ãæ(®OÅâu¯Í{{£ôÞw¬±ç¿5ì>%êì{/ÌË(º¸¿V*àxý*.¶jJ-kóÞ{2ö§¯Ìj)Þýhuï²V§wðÞ¬­ïÍ{jjl*ÞýW«íü*'ç-Ë­ü¦§±«?2)çzÊ-kð%jÉü×­«$kóh®Ø~    ªè)Úýh¬rìÖjÈbhð+:'kó"r jÇk¢ó"²È¬²*iò%)èÏÒ¢ëaø&«¢X§kó¯)ZßÖÊ¢Ôµ¨ê+&¿6íàÚZü§§¶ç$Ëó«z
'ü
äj{³ò(Á¯ÂjX¢¹âkó¤¨h¯ÖzË~V*àxüׯiÖ¿`,C=r`«hähº¿"wbjv©¢X¬ü*%ºfî³ó(Ø(êòüw¥zv¿
éïz¿Á¢+ü¬¶)ÿ-¢À¶§ËôÚV¡jË{ôÖ¾ïÍjÈoY^ý:ÞÚ'ü}êì¢ÑÈf¢w>'«­ïÇjºâ±»«ð.ë-kóë¢øzwü:/z¿Â¢w(­ßÌ¢{izX¯ñÚ®×è­ßÓ¢¤kô{~=«¥ü§y«¿.)Ü¢YÿE©^1§b²ÿ:\\¦¦&¿>,-©ìx?èénüÊ'ý*kxé]ü*%ºfâkð'ªh+?
²zyÞý&¥·âÚïÜ¿ÙZÖ¿+&j·$üZÚGè®ßÒjW¦ü¸­¶W¾F$ü7¬øÊ"ë?I§+jg§¶ÎV¡¢f¾
+rü(Z®W¬¶ÿ  ªì¢Ü¿`,S[C.indexOf(s)]||C[S.indexOf(s)]||"Arstotzka")

这是一个十六进制转储;用于xxd -r filename反转。

00000000: 733d 3e28 533d 2872 3d78 3d3e 6274 6f61  s=>(S=(r=x=>btoa
00000010: 2878 292e 7265 706c 6163 6528 2f5c 2b2f  (x).replace(/\+/
00000020: 672c 2220 2229 2e73 706c 6974 602f 6029  g," ").split`/`)
00000030: 602e 3fa2 b226 a76b f227 7626 a76b f3a1  `.?..&.k.'v&.k..
00000040: 3f8f c03f a6da 3faf cca2 7b5a 9daf c2a2  ?..?..?...{Z....
00000050: 5a2b 69da 3f21 d6a1 a3f4 dec5 ab3f 31ab  Z+i.?!.......?1.
00000060: 2c69 c86e b1eb 6db3 f35e c3e6 28ae 4fc5  ,i.n..m..^..(.O.
00000070: 3f3f e275 afcd 7b0f 3f7b 183f a3f4 de3f  ??.u..{.?{.?...?
00000080: 77ac b1e7 bf35 ec3e 25ea ec7b 2fcc 3fcb  w....5.>%..{/.?.
00000090: 28ba b8bf 562a e03f 783f fd2a 2eb6 1f3f  (...V*.?x?.*...?
000000a0: 6a4a 2d6b f3de 3f7b 323f f6a7 3faf cc6a  jJ-k..?{2?..?..j
000000b0: 29de fd18 6875 ef3f b256 a777 f0de 3fac  )...hu.?.V.w..?.
000000c0: 1aad efcd 7b0f 3f6a 6a6c 3f2a defd 57ab  ....{.?jjl?*..W.
000000d0: 3f3f edfc 2a27 9de7 2d3f cbad fca6 a7b1  ??..*'..-?......
000000e0: ab3f 3229 e77a ca2d 6bf0 256a c91a fcd7  .?2).z.-k.%j....
000000f0: 3fad ab24 6bf3 68ae d87e 09aa e83f 29da  ?..$k.h..~...?).
00000100: fd68 ac72 3fec 3f7f d66a c862 3f0b 683f  .h.r?.?..j.b?.h?
00000110: f02b 3f3a 276b f322 7218 206a 7fc7 6b06  .+?:'k."r. j..k.
00000120: a23f f322 b2c8 acb2 2a69 3ff2 253f 29e8  .?."....*i?.%?).
00000130: 3fcf d2a2 eb61 f826 aba2 58a7 6bf3 1aaf  ?....a.&..X.k...
00000140: 295a 9ddf d6ca 3fa2 3f0f d4b5 a87f 19ea  )Z....?.?.......
00000150: 2b3f 26bf 363f ed3f e0da 3f3f 5afc a7a7  +?&.6?.?..??Z...
00000160: b6e7 24cb f3ab 7a0a 27fc 0ae4 6a7b 1ab3  ..$...z.'...j{..
00000170: f228 c1af c26a 583f a2b9 e26b f3a4 3fa8  .(...jX?...k..?.
00000180: 683f afd6 7acb 7e56 2ae0 3f78 3ffc d7af  h?..z.~V*.?x?...
00000190: 69d6 bf60 2c43 3d72 6005 ab68 3fe4 68ba  i..`,C=r`..h?.h.
000001a0: 07bf 2277 626a 76a9 a258 acfc 2a25 ba66  .."wbjv..X..*%.f
000001b0: eeb3 f328 3fd8 283f eaf2 fc77 a57a 76bf  ...(?.(?...w.zv.
000001c0: 0ae9 ef7a bfc1 a22b 1efc 0bac b629 ff06  ...z...+.....)..
000001d0: 3f2d a27f c03f b6a7 cbf4 da3f 56a1 6acb  ?-...?.....?V.j.
000001e0: 1e7b f43f 3fd6 be15 efcd 6ac8 6f3f 595e  .{.??.....j.o?Y^
000001f0: fd3a de3f da27 fc3f 3f7d eaec a27f d13f  .:.?.'.??}.....?
00000200: c866 a277 7f3e 27ab adef c76a bae2 b1bb  .f.w.>'....j....
00000210: ab3f f02e 3feb 2d6b f3eb a2f8 9d7a 771e  .?..?.-k.....zw.
00000220: fc3a 2f7a bfc2 a277 28ad dfcc a27b 697a  .:/z...w(....{iz
00000230: 583f aff1 daae d7e8 addf d3a2 3fa4 6bf4  X?..........?.k.
00000240: 3f3f 7b7e 3dab a5fc 3fa7 79ab bf2e 29dc  ??{~=...?.y...).
00000250: a259 ff45 a95e 3f08 7f31 a762 b23f ff3a  .Y.E.^?..1.b.?.:
00000260: 5c5c a6a6 26bf 3e1a 1e3f 2c7f 2da9 ec3f  \\..&.>..?,.-..?
00000270: 783f 1e3f e83f e96e fc3f 3f3f ca27 fd2a  x?.?.?.n.???.'.*
00000280: 6b3f 781f 3fe9 5dfc 2a25 ba66 e26b f027  k?x.?.].*%.f.k.'
00000290: 9daa 683f 2b3f 0a17 b27a 79de fd26 a5b7  ..h?+?...zy..&..
000002a0: e2da 3fef 3f3f dcbf 02d9 5a3f d6bf 062b  ..?.??....Z?...+
000002b0: 266a b724 fc5a da3f 47e8 aedf d26a 57a6  &j.$.Z.?G....jW.
000002c0: fcb8 adb6 57be 463f 24fc 37ac f8ca 229d  ....W.F?$.7...".
000002d0: eb3f 49a7 2b6a 67a7 b68f ce3f 56a1 a266  .?I.+jg....?V..f
000002e0: be0a 2b72 fc28 5aae 57ac b63f ff09 aaec  ..+r.(Z.W..?....
000002f0: a27f 3f3f dcbf 602c 535b 432e 696e 6465  ..??..`,S[C.inde
00000300: 784f 6628 7329 5d7c 7c43 5b53 2e69 6e64  xOf(s)]||C[S.ind
00000310: 6578 4f66 2873 295d 7c7c 2241 7273 746f  exOf(s)]||"Arsto
00000320: 747a 6b61 2229                           tzka")

r=必要吗?
Conor O'Brien 2015年

@CᴏɴᴏʀO'Bʀɪᴇɴ是的,它已被重新用于解码状态字符串和大写字符串。
intrepidcoder

7

PHP,1272 1239字节

确保您已在php.ini中启用short_open_tag:

此代码使用argv [1]作为输入。

<?$c=json_decode('{"Baton Rouge":"Louisiana","Indianapolis":"Indiana","Columbus":"Ohio","Montgomery":"Alabama","Helena":"Montana","Denver":"Colorado","Boise":"Idaho","Austin":"Texas","Boston":"Massachusetts","Albany":"New York","Tallahassee":"Florida","Santa Fe":"New Mexico","Nashville":"Tennessee","Trenton":"New Jersey","Jefferson":"Missouri","Richmond":"Virginia","Pierre":"South Dakota","Harrisburg":"Pennsylvania","Augusta":"Maine","Providence":"Rhode Island","Dover":"Delaware","Concord":"New Hampshire","Montpelier":"Vermont","Hartford":"Connecticut","Topeka":"Kansas","Saint Paul":"Minnesota","Juneau":"Alaska","Lincoln":"Nebraska","Raleigh":"North Carolina","Madison":"Wisconsin","Olympia":"Washington","Phoenix":"Arizona","Lansing":"Michigan","Honolulu":"Hawaii","Jackson":"Mississippi","Springfield":"Illinois","Columbia":"South Carolina","Annapolis":"Maryland","Cheyenne":"Wyoming","Salt Lake City":"Utah","Atlanta":"Georgia","Bismarck":"North Dakota","Frankfort":"Kentucky","Salem":"Oregon","Little Rock":"Arkansas","Des Moines":"Iowa","Sacramento":"California","Oklahoma City":"Oklahoma","Charleston":"West Virginia","Carson City":"Nevada"}',1);$s=array_flip($c);$z=$argv[1];echo @$c[$z]?$c[$z]:(@$s[$z]?$s[$z]:'Arstotzka');

1
整个代码将是WAY短,如果你这样做:<?$c=['Baton Rouge'=>Louisiana,$I=Indiana=>$I.polis, ... ];echo$c[$z=$argv[1]]?:(array_flip($c)[$z]?:Arstotzka);。您只需要填充数组。忽略所有警告
Ismael Miguel

6

Java,1062 964字节

s->{String t="Arstotzka",a[]="AlabamaMontgomeryAlaskaJuneauArizonaPhoenixArkansasLittle RockCaliforniaSacrementoColoradoDenverConecticutHartfordDelawareDoverFloridaTallahasseeGeorgiaAtlantaHawaiiHonoluluIdahoBoiseIllinoisSpringfieldIndianaIndianapolisIowaDes MoinesKansasTopekaKentuckyFrankfortLouisianaBaton RougeMaineAugustaMarylandAnnapolisMassachusettsBostonMichiganLansingMinnesotaSaint PaulMississippiJacksonMissouriJefferson CityMontanaHelenaNebraskaLincolnNevadaCarson CityNew HampshireConcordNew JerseyTrentonNew MexicoSanta FeNew YorkAlbanyNorth CarolinaRaleighNorth DakotaBismarckOhioColumbusOklahomaOklahoma CityOregonSalemPennsylvaniaHarrisburgRhode IslandProvidenceSouth CarolinaColumbiaSouth DakotaPierreTennesseeNashvilleTexasAustinUtahSalt Lake CityVermontMontpelierVirginiaRichmondWashingtonOlympiaWest VirginiaCharlestonWisconsinMadisonWyomingCheyenne".split("(?<=[a-z])(?=[A-Z])");for(int k=-1;k++<99;t=s.equals(a[k])?a[k%2*-2-~k]:t);return t;}

-17个字节,感谢@KevinCruijssen。

在线尝试!

非常简单;如果找到匹配项,则根据数组的当前索引是偶数还是奇数来增加或减少。否则,打印“ Arstotzka”。

保存的大多数字节是由于删除了99 :s并基于regex拆分了字符串,该regex (?<=[a-z])(?=[A-Z])使用正向和反向查找来检查大小写是否不同。


1
谢谢你的建议。有趣的是,我昨晚正在考虑可以对这个答案进行改进。我将尽快实施它们。:)
TNT

5

R1023 985字节

function(s){g=strsplit
y="Bat9 Rouge,Indi2apol3,Columbus,M9tgomery,Hel6a,D6ver,Bo3e,Aust1,Bost9,Alb2y,Tallah5s4,S2ta Fe,N5hville,Tr6t9,Jeffers9,Richm9d,Pierre,H7r3burg,Augusta,Provid6ce,Dover,C9c0d,M9tpelier,H7tf0d,Topeka,Sa1t Paul,Juneau,L1coln,Raleigh,Mad39,Olympia,Pho6ix,L2s1g,H9olulu,Jacks9,Spr1gfield,Columbia,Annapol3,Chey6ne,Salt Lake8,Atl2ta,B3m7ck,Fr2kf0t,Salem,Little Rock,Des Mo1es,Sacram6to,Oklahoma8,Ch7lest9,C7s98,Nevada,West Virg1ia,Oklahoma,Calif0nia,Iowa,Ark2s5,Oreg9,K6tucky,N0th Dakota,Ge0gia,Utah,Wyom1g,M7yl2d,South C7ol1a,Ill1o3,M3s3sippi,Hawaii,Michig2,Ariz9a,W5h1gt9,W3c9s1,N0th C7ol1a,Nebr5ka,Al5ka,M1nesota,K2s5,C9necticut,Verm9t,New Hampshire,Delaw7e,Rhode Isl2d,Ma1e,P6nsylv2ia,South Dakota,Virg1ia,M3souri,New Jersey,T6ness4,New Mexico,Fl0ida,New Y0k,M5sachusetts,Tex5,Idaho,Col0ado,M9t2a,Alabama,Ohio,Indi2a,Lou3i2a"
for(i in 0:9)y=gsub(i,g("or,in,an,is,ee,as,en,ar, City,on",",")[[1]][i+1],y)
x=g(y,",")[[1]]
'if'({y=match(s,x,0)},x[101-y],'Arstotzka')}

在线尝试!

与其他R提交不同。

该代码将大写字母和州放在同一个向量中。这些州的顺序相反,因此,给定州或首都的索引length(data)-index+1,匹配条目的索引为,其中length(data)=100,50(州)+ 50(大写)

同样,输入数据打包为单个字符串,然后分割。线可以压缩以进一步打高尔夫球。

编辑:添加了一些未优化的字符对替换。


4

Javascript,1057 1042字节

答案1:1042

(()=>{for(i=0,b=prompt(),c='Baton Rouge,Louisiana,Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Albany,New York,Tallahassee,Florida,Santa Fe,New Mexico,Nashville,Tennessee,Trenton,New Jersey,Jefferson,Missouri,Richmond,Virginia,Pierre,South Dakota,Harrisburg,Pennsylvania,Augusta,Maine,Providence,Rhode Island,Dover,Delaware,Concord,New Hampshire,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Saint Paul,Minnesota,Juneau,Alaska,Lincoln,Nebraska,Raleigh,North Carolina,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Columbia,South Carolina,Annapolis,Maryland,Cheyenne,Wyoming,Salt Lake City,Utah,Atlanta,Georgia,Bismarck,North Dakota,Frankfort,Kentucky,Salem,Oregon,Little Rock,Arkansas,Des Moines,Iowa,Sacramento,California,Oklahoma City,Oklahoma,Charleston,West Virginia,Carson City,Nevada'.split(","),q="Arstotzka";i<100;i++){if(c[i]==b)q=c[i%2?i-1:i+1];}return q})()

更新的答案1缺少零:S,还修复了一般性的不正确性。更新了答案1 + 2有点重新排列了结构。

建议答案1在Java控制台(例如,您的浏览器的控制台)中运行,该未命名函数会返回到控制台。您也可以在这里进行测试。

回答2 1049

alert((()=>{for(i=0,b=prompt(),c='Baton Rouge,Louisiana,Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Albany,New York,Tallahassee,Florida,Santa Fe,New Mexico,Nashville,Tennessee,Trenton,New Jersey,Jefferson,Missouri,Richmond,Virginia,Pierre,South Dakota,Harrisburg,Pennsylvania,Augusta,Maine,Providence,Rhode Island,Dover,Delaware,Concord,New Hampshire,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Saint Paul,Minnesota,Juneau,Alaska,Lincoln,Nebraska,Raleigh,North Carolina,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Columbia,South Carolina,Annapolis,Maryland,Cheyenne,Wyoming,Salt Lake City,Utah,Atlanta,Georgia,Bismarck,North Dakota,Frankfort,Kentucky,Salem,Oregon,Little Rock,Arkansas,Des Moines,Iowa,Sacramento,California,Oklahoma City,Oklahoma,Charleston,West Virginia,Carson City,Nevada'.split(","),q="Arstotzka";i<100;i++){if(c[i]==b)q=c[i%2?i-1:i+1];}return q})())

答案2将与代码段按钮一起使用


我完全放错了一段代码... zzz修复
Spaceman 2015年

@GamrCorps全部修复:)对此感到抱歉
太空人

答案是可以接受的答案,因为它必须在控制台中工作吗?
太空人2015年

我会说是的。然而。meta可能会不同意,尽管我怀疑人们会这么做。
GamrCorps 2015年

我刚刚指定了您的控制台行,并添加了一个测试链接。
GamrCorps,2015年

3

红宝石989

->s{a="Baton Rouge|Louisiana|Indianapolis|Indiana|Columbus|Ohio|Montgomery|Alabama|Helena|Montana|Denver|Colorado|Boise|Idaho|Austin|Texas|Boston|Massachusetts|Albany|New York|Tallahassee|Florida|Santa Fe|New Mexico|Nashville|Tennessee|Trenton|New Jersey|Jefferson|Missouri|Richmond|Virginia|Pierre|South Dakota|Harrisburg|Pennsylvania|Augusta|Maine|Providence|Rhode Island|Dover|Delaware|Concord|New Hampshire|Montpelier|Vermont|Hartford|Connecticut|Topeka|Kansas|Saint Paul|Minnesota|Juneau|Alaska|Lincoln|Nebraska|Raleigh|North Carolina|Madison|Wisconsin|Olympia|Washington|Phoenix|Arizona|Lansing|Michigan|Honolulu|Hawaii|Jackson|Mississippi|Springfield|Illinois|Columbia|South Carolina|Annapolis|Maryland|Cheyenne|Wyoming|Salt Lake City|Utah|Atlanta|Georgia|Bismarck|North Dakota|Frankfort|Kentucky|Salem|Oregon|Little Rock|Arkansas|Des Moines|Iowa|Sacramento|California|Oklahoma City|Oklahoma|Charleston|West Virginia|Carson City|Nevada".split(?|)
i=a.index(s)
i ?a[i^1]:"Arstotzka"}

将数据拆分为单个数组。在数组中找到输入的索引(如果输入不存在indexnil则返回假值)

如果错误,则返回“ Arstotzka”,否则将索引与1异或以找到该对中的另一个成员

在测试程序中:

f=->s{a="Baton Rouge|Louisiana|Indianapolis|Indiana|Columbus|Ohio|Montgomery|Alabama|Helena|Montana|Denver|Colorado|Boise|Idaho|Austin|Texas|Boston|Massachusetts|Albany|New York|Tallahassee|Florida|Santa Fe|New Mexico|Nashville|Tennessee|Trenton|New Jersey|Jefferson|Missouri|Richmond|Virginia|Pierre|South Dakota|Harrisburg|Pennsylvania|Augusta|Maine|Providence|Rhode Island|Dover|Delaware|Concord|New Hampshire|Montpelier|Vermont|Hartford|Connecticut|Topeka|Kansas|Saint Paul|Minnesota|Juneau|Alaska|Lincoln|Nebraska|Raleigh|North Carolina|Madison|Wisconsin|Olympia|Washington|Phoenix|Arizona|Lansing|Michigan|Honolulu|Hawaii|Jackson|Mississippi|Springfield|Illinois|Columbia|South Carolina|Annapolis|Maryland|Cheyenne|Wyoming|Salt Lake City|Utah|Atlanta|Georgia|Bismarck|North Dakota|Frankfort|Kentucky|Salem|Oregon|Little Rock|Arkansas|Des Moines|Iowa|Sacramento|California|Oklahoma City|Oklahoma|Charleston|West Virginia|Carson City|Nevada".split(?|)
i=a.index(s)
i ?a[i^1]:"Arstotzka"}

puts f[gets.chop]

我想知道您是否可以通过使用~a.index(s)州和州并使州和州之间的联系来节省空间(例如["New York", "New Jersey", "California",..., "Sacramento", "Trenton", "Albany"]
并不是查尔斯(Charles

3

PHP,674字节

<?php $a=explode("\n",gzinflate('=SÛŽê0.|÷WôWº =Àr.p..GÓšÆj.WN.ÛýúãÀ²R¥ÞÆžñxRkL’¾{„7L.ªƒäŽ`-™#c@X†¶ÜGñ._/0.Ÿ‡KŽ°s,°‘.:.H\'¨=^p@X.\'Õ?.?§p#-e¢Ø.¼.G‚e‹N Î1q€.}a´.¦&À.cÄÆåH)EkzÁ0Á–îÕ?Ñ.Nè=:ƒ.Á»uä.áˆÆT½Ó.µ¡/n.¶.Ý.½\'k..=ð\'¥P..lE.i‚.]¯öTh9FÉÊpàÆ..Zødí80žI•à(9¹jŽ½$..U9^²v°7‚8ù..l.;›É¦G..{•.·..‚ƒ“–ªeôh.çR,™“Ç;Z癄F´}.[à0FÇöµ.8’7rø$5I©°¦kAZE &q“.œd$[á.†h...8U{ÌÞF*“.µ«..sÙP4äš.Î...úøp@OÜ9ØŠÚ„3T[xÙ ¶\¬9sl$D[ÔÎOÃhSžÍ].]1sï„..A.ü-V´Æ‚쌼qÜa€….KŒÏ&þŽÌ°Â¦..^®qd8Žj5W&ßÂÒ.¹eä\'hÆö4þWV.^‘Ü N.?gŽ¦²f8O2.ö#úT.±§jÆi‚¿..ÔÉ— À..[¬ežã€Úô?cÿ,ö]1ôæq‚.KKnú©4£.vJ.É^sJžì¨Xa.ýÓô9Åj#¶q;&r/‰l.‡’6˜¡gkW²±ë-º2àSÓëÍÄ£zzdÿl·ê7w6±.õDoé†-þ.'));$b=array_search($argv[1],$a);echo $a[$b?$b%2?$b+1:$b-1:0];

十六进制:

00000000: 3C 3F 70 68 70 20 24 61 - 3D 65 78 70 6C 6F 64 65 |<?php $a=explode|
00000010: 28 22 5C 6E 22 2C 67 7A - 69 6E 66 6C 61 74 65 28 |("\n",gzinflate(|
00000020: 27 3D 53 DB 8E EA 30 0C - 7C F7 57 F4 57 BA A0 3D |'=S   0 | W W  =|
00000030: C0 72 13 70 16 9D 47 D3 - 9A C6 6A 1A 57 4E 02 DB | r p  G   j WN  |
00000040: FD FA E3 C0 B2 52 A5 DE - C6 9E F1 78 52 6B 4C 92 |     R     xRkL |
00000050: BE 7B 84 37 4C 12 AA 83 - E4 8E 60 2D 99 23 63 40 | { 7L     `- #c@|
00000060: 58 86 B6 DC 47 F1 1C 5F - 2F 30 13 9F 87 4B 8E B0 |X   G  _/0   K  |
00000070: 73 2C B0 91 90 3A 19 48 - 5C 27 A8 3D 5E 70 40 58 |s,   : H\' =^p@X|
00000080: 90 5C 27 C3 95 3F 05 3F - A7 70 23 2D 65 A2 D8 0A | \'  ? ? p#-e   |
00000090: BC 09 47 82 65 8B 4E A0 - CE 31 71 80 13 7D 61 B4 |  G e N  1q  }a |
000000a0: 1F A6 26 C0 06 63 C4 C6 - E5 48 29 45 6B 7A C1 30 |  &  c   H)Ekz 0|
000000b0: C1 96 EE D5 3F D1 1E 4E - E8 3D 3A 83 10 C1 BB 75 |    ?  N =:    u|
000000c0: E4 16 E1 88 C6 54 BD D3 - 03 B5 A1 2F 6E 04 B6 18 |     T     /n   |
000000d0: DD 8D BD 5C 27 6B 1E 02 - 3D F0 5C 27 A5 50 18 0A |   \'k  = \' P  |
000000e0: 6C 45 1A 69 82 15 5D AF - F6 54 68 39 46 C9 CA 70 |lE i  ]  Th9F  p|
000000f0: E0 C6 0D 12 5A F8 64 ED - 38 30 C2 9E 49 95 E0 28 |    Z d 80  I  (|
00000100: 39 B9 6A 8E BD 24 1B 12 - 55 39 5E B2 76 B0 37 82 |9 j  $  U9^ v 7 |
00000110: 38 F9 1B 16 6C 9D 3B 9B - C9 A6 47 0E 04 7B 95 1B |8   l ;   G  {  |
00000120: B7 14 1A 82 83 93 96 AA - 65 F4 68 AD E7 52 2C 99 |        e h  R, |
00000130: 93 C7 3B 5A E7 99 84 46 - B4 7D 08 5B E0 30 46 C7 |  ;Z   F } [ 0F |
00000140: F6 B5 18 38 92 37 72 F8 - 24 35 49 A9 B0 A6 6B 41 |   8 7r $5I   kA|
00000150: 5A 45 A0 26 71 93 13 9C - 64 24 5B E1 07 86 68 2E |ZE &q   d$[   h.|
00000160: 1E 8D 38 55 7B CC DE 46 - 2A 93 17 B5 AB 1C 08 73 |  8U{  F*      s|
00000170: D9 50 34 E4 9A 8D CE 17 - 1F 2E FA F8 70 40 4F DC | P4      .  p@O |
00000180: 39 D8 8A DA 84 33 54 5B - 78 D9 20 B6 5C AC 39 73 |9    3T[x   \ 9s|
00000190: 6C 24 44 5B D4 CE 4F C3 - 68 53 9E CD 5D 0E 5D 31 |l$D[  O hS  ] ]1|
000001a0: 73 EF 84 02 7F 41 AD FC - 2D 56 B4 C6 82 EC 8C BC |s    A  -V      |
000001b0: 71 DC 61 80 85 04 4B 8C - CF 26 FE 8E CC B0 C2 A6 |q a   K  &      |
000001c0: 7F 19 5E AE 71 64 38 8E - 6A 35 57 26 DF C2 D2 1B |  ^ qd8 j5W&    |
000001d0: B9 65 E4 5C 27 68 C6 F6 - 34 FE 57 56 1D 5E 91 DC | e \'h  4 WV ^  |
000001e0: A0 4E 0F 3F 67 8E A6 B2 - 66 38 4F 32 14 F6 23 FA | N ?g   f8O2  # |
000001f0: 54 AD B1 A7 6A C6 69 82 - BF 09 1D D4 C9 97 A0 C0 |T   j i         |
00000200: 1F 12 5B AC 65 9E E3 80 - DA F4 3F 63 FF 2C F6 5D |  [ e     ?c , ]|
00000210: 31 F4 E6 71 82 0F 4B 4B - 6E FA A9 34 A3 01 76 4A |1  q  KKn  4  vJ|
00000220: 9D C9 5E 73 4A 9E EC A8 - 58 61 AD FD D3 F4 39 C5 |  ^sJ   Xa    9 |
00000230: 6A 23 B6 71 3B 26 72 2F - 89 6C 14 87 92 36 98 A1 |j# q;&r/ l   6  |
00000240: 67 6B 57 B2 B1 EB 2D BA - 32 E0 53 D3 EB CD C4 A3 |gkW   - 2 S     |
00000250: 7A 7A 64 FF 6C B7 EA 37 - 77 36 B1 19 F5 44 6F E9 |zzd l  7w6   Do |
00000260: 86 2D FE 07 27 29 29 3B - 24 62 3D 61 72 72 61 79 | -  '));$b=array|
00000270: 5F 73 65 61 72 63 68 28 - 24 61 72 67 76 5B 31 5D |_search($argv[1]|
00000280: 2C 24 61 29 3B 65 63 68 - 6F 20 24 61 5B 24 62 3F |,$a);echo $a[$b?|
00000290: 24 62 25 32 3F 24 62 2B - 31 3A 24 62 2D 31 3A 30 |$b%2?$b+1:$b-1:0|
000002a0: 5D 3B                   -                         |];|
000002a2;

说明

<?php
// create array of capitals and states
$a = explode("\n", gzinflate(/* Arstotzka
                                Baton Rouge
                                Louisiana
                                Indianapolis
                                Indiana
                                ...
                             */));
$b = array_search($argv[1], $a); // find user input in list
echo $a[
  $b          // if $b is nonzero, the match succeded
    ?$b % 2   // checks if $b is odd, indicating a capital
      ?$b + 1 // $b points to capital; return the next item, the state
      :$b - 1 // $b points to state; return the previous item, the capital
    :0        // select "Arstotzka" otherwise
];

2

Prolog,1221字节

p(X):-L=['Baton Rouge','Louisiana','Indianapolis','Indiana','Columbus','Ohio','Montgomery','Alabama','Helena','Montana','Denver','Colorado','Boise','Idaho','Austin','Texas','Boston','Massachusetts','Albany','New York','Tallahassee','Florida','Santa Fe','New Mexico','Nashville','Tennessee','Trenton','New Jersey','Jefferson','Missouri','Richmond','Virginia','Pierre','South Dakota','Harrisburg','Pennsylvania','Augusta','Maine','Providence','Rhode Island','Dover','Delaware','Concord','New Hampshire','Montpelier','Vermont','Hartford','Connecticut','Topeka','Kansas','Saint Paul','Minnesota','Juneau','Alaska','Lincoln','Nebraska','Raleigh','North Carolina','Madison','Wisconsin','Olympia','Washington','Phoenix','Arizona','Lansing','Michigan','Honolulu','Hawaii','Jackson','Mississippi','Springfield','Illinois','Columbia','South Carolina','Annapolis','Maryland','Cheyenne','Wyoming','Salt Lake City','Utah','Atlanta','Georgia','Bismarck','North Dakota','Frankfort','Kentucky','Salem','Oregon','Little Rock','Arkansas','Des Moines','Iowa','Sacramento','California','Oklahoma City','Oklahoma','Charleston','West Virginia','Carson City','Nevada'],nth0(I,L,X),J is I xor 1,nth0(J,L,E),write(E),!.
p(X):-write('Arstotzka').

大多数字节计数来自状态和大写字母列表。
所有州名和大写名称都必须用原子引用,因为它们以大写字母开头,仅花费,我们就花了202个字节。

怎么运行的

 nth0(I,L,X)

获取指数元素的X列表大号

J is I xor 1

将索引与1异或以获取返回值的索引。

nth0(J,L,E)

获取元件È在索引Ĵ列表的大号

如果任何规则失败,请打印Arstotzka


>p('Austin').
Texas

>p('Texas').
Austin

2

Python 2.7、1271 1232 1054字节

y='Little Rock,Boise,Richmond,Denver,Olympia,Sacramento,Springfield,Baton Rouge,Tallahassee,Austin,Trenton,Lansing,Annapolis,Dover,Phoenix,Pierre,Charleston,Salt Lake City,Montpelier,Indianapolis,Concord,Providence,Madison,Oklahoma City,Santa Fe,Frankfort,Columbia,Atlanta,Boston,Salem,Juneau,Bismarck,Helena,Montgomery,Des Moines,Saint Paul,Jefferson,Lincoln,Hartford,Augusta,Carson City,Albany,Cheyenne,Columbus,Harrisburg,Honolulu,Raleigh,Nashville,Jackson,Topeka'.split(',')
z='Arkansas,Idaho,Virginia,Colorado,Washington,California,Illinois,Louisiana,Florida,Texas,New Jersey,Michigan,Maryland,Delaware,Arizona,South Dakota,West Virginia,Utah,Vermont,Indiana,New Hampshire,Rhode Island,Wisconsin,Oklahoma,New Mexico,Kentucky,South Carolina,Georgia,Massachusetts,Oregon,Alaska,North Dakota,Montana,Alabama,Iowa,Minnesota,Missouri,Nebraska,Connecticut,Maine,Nevada,New York,Wyoming,Ohio,Pennsylvania,Hawaii,North Carolina,Tennessee,Mississippi,Kansas'.split(',')
def a(b):
 m='Arstotzka'
 if b in y:m=z[y.index(b)]
 if b in z:m=y[z.index(b)]
 print m

I / O示例:

>>> a('Baton Rouge')
Louisiana
>>> a('Montana')
Helena
>>> a('asdfghjkl;')
Arstotzka

编辑:方法改进


我希望能有一些办法可以压缩字典...

@ Sp3000哦,不,不是zip(),仅此而已!(我也觉得尝试使用字符串插值/级联对这个只会使代码程较长而稍微缩短了字典,但我不知道如何去尝试)

实际上,Python2的长度是完全相同的,因为即使您可以消除印刷品中的括号,也无法将印刷品绑定到字母上。

2

Perl 5,999字节

我在codegolf中的第一篇文章。

%m;@r=qw/la ol ia nt en or is an in on/;map{$x=$_;$x=~s/$_/$r[$_]/eg for(0..9);$x=~s/\b(\w)/\U$1/g;($c,$s)=split'\|',$x;$m{$c}=$s;$m{$s}=$c}qw(bat9_rouge|lou62na 8d2nap16|8d2na c1umbus|ohio mo3gomery|a0bama hel4a|mo37a d4ver|c15ado bo6e|idaho aust8|texas bost9|massachusetts alb7y|new_y5k tal0hassee|fl5ida sa3a_fe|new_mexico nashville|t4nessee tre39|new_jersey jeffers9|m6souri richm9d|virg82 pierre|south_dakota harr6burg|p4nsylv72 augusta|ma8e provid4ce|rhode_60nd dover|de0ware c9c5d|new_hampshire mo3pelier|vermo3 hartf5d|c9necticut topeka|k7sas sai3_paul|m8nesota juneau|a0ska l8c1n|nebraska raleigh|n5th_car18a mad69|w6c9s8 1ymp2|wash8gt9 pho4ix|ariz9a 0ns8g|michig7 h91ulu|hawaii jacks9|m6s6sippi spr8gfield|ill8o6 c1umb2|south_car18a 7nap16|mary0nd chey4ne|wyom8g salt_0ke_city|utah at03a|ge5g2 b6marck|n5th_dakota fr7kf5t|ke3ucky salem|5eg9 little_rock|ark7sas des_mo8es|iowa sacrame3o|calif5n2 ok0homa_city|ok0homa charlest9|west_virg82 cars9_city|nevada);print $m{$ARGV[0]}||"Arstotzka"

取消高尔夫:

%m;
@r=qw/la ol ia nt en or is an in on/; # Top 10 bigrams
map{
    $x=$_;
    $x=~s/$_/$r[$_]/eg for(0..9); # Resolve bigram placeholders
    $x=~s/\b(\w)/\U$1/g;          # ucfirst each word
    ($c,$s)=split'\|',$x;         # split city and state
    $m{$c}=$s;                    # key on both city and state
    $m{$s}=$c
} qw(
    bat9_rouge|lou62na
    8d2nap16|8d2na
    c1umbus|ohio
    mo3gomery|a0bama
    hel4a|mo37a
    d4ver|c15ado
    bo6e|idaho
    aust8|texas
    bost9|massachusetts
    alb7y|new_y5k
    tal0hassee|fl5ida
    sa3a_fe|new_mexico
    nashville|t4nessee
    tre39|new_jersey
    jeffers9|m6souri
    richm9d|virg82
    pierre|south_dakota
    harr6burg|p4nsylv72
    augusta|ma8e
    provid4ce|rhode_60nd
    dover|de0ware
    c9c5d|new_hampshire
    mo3pelier|vermo3
    hartf5d|c9necticut
    topeka|k7sas
    sai3_paul|m8nesota
    juneau|a0ska
    l8c1n|nebraska
    raleigh|n5th_car18a
    mad69|w6c9s8
    1ymp2|wash8gt9
    pho4ix|ariz9a
    0ns8g|michig7
    h91ulu|hawaii
    jacks9|m6s6sippi
    spr8gfield|ill8o6
    c1umb2|south_car18a
    7nap16|mary0nd
    chey4ne|wyom8g
    salt_0ke_city|utah
    at03a|ge5g2
    b6marck|n5th_dakota
    fr7kf5t|ke3ucky
    salem|5eg9
    little_rock|ark7sas
    des_mo8es|iowa
    sacrame3o|calif5n2
    ok0homa_city|ok0homa
    charlest9|west_virg82
    cars9_city|nevada
);
print $m{$ARGV[0]}||"Arstotzka"

1

Perl 5,1029字节

$h{$h{$_}}=$_ for keys{%h=(Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Tallahassee,Florida,Nashville,Tennessee,Jefferson,Missouri,Richmond,Virginia,Harrisburg,Pennsylvania,Augusta,Maine,Dover,Delaware,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Juneau,Alaska,Lincoln,Nebraska,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Annapolis,Maryland,Cheyenne,Wyoming,Atlanta,Georgia,Frankfort,Kentucky,Salem,Oregon,Sacramento,California,Charleston,'West Virginia','Carson City',Nevada,'Baton Rouge',Louisiana,Albany,'New York','Santa Fe','New Mexico','Trenton','New Jersey',Pierre,'South Dakota',Providence,'Rhode Island',Concord,'New Hampshire','Saint Paul',Minnesota,Raleigh,'North Carolina',Columbia,'South Carolina','Salt Lake City',Utah,Bismarck,'North Dakota','Little Rock',Arkansas,'Des Moines',Iowa,'Oklahoma City',Oklahoma)};say$h{$ARGV[0]}//Arstotzka

这就是为什么我爱Perl。做得好。
tale852150

1

Haskell1077 1069 1068 1063字节

z s=last$"Arstotzka":[last$l:[r|s==l]|(l,_:r)<-span(<'~')<$>lines"Baton Rouge~Louisiana\nIndianapolis~Indiana\nColumbus~Ohio\nMontgomery~Alabama\nHelena~Montana\nDenver~Colorado\nBoise~Idaho\nAustin~Texas\nBoston~Massachusetts\nAlbany~New York\nTallahassee~Florida\nSanta Fe~New Mexico\nNashville~Tennessee\nTrenton~New Jersey\nJefferson~Missouri\nRichmond~Virginia\nPierre~South Dakota\nHarrisburg~Pennsylvania\nAugusta~Maine\nProvidence~Rhode Island\nDover~Delaware\nConcord~New Hampshire\nMontpelier~Vermont\nHartford~Connecticut\nTopeka~Kansas\nSaint Paul~Minnesota\nJuneau~Alaska\nLincoln~Nebraska\nRaleigh~North Carolina\nMadison~Wisconsin\nOlympia~Washington\nPhoenix~Arizona\nLansing~Michigan\nHonolulu~Hawaii\nJackson~Mississippi\nSpringfield~Illinois\nColumbia~South Carolina\nAnnapolis~Maryland\nCheyenne~Wyoming\nSalt Lake City~Utah\nAtlanta~Georgia\nBismarck~North Dakota\nFrankfort~Kentucky\nSalem~Oregon\nLittle Rock~Arkansas\nDes Moines~Iowa\nSacramento~California\nOklahoma City~Oklahoma\nCharleston~West Virginia\nCarson City~Nevada",s==l||s==r]

在线尝试!

在浪费大量时间尝试霍夫曼编码的实现之后,我意识到直接的方法可能会更短。呃,好吧。

编辑:感谢@Laikoni脱掉8个字节!

编辑:再次感谢莱科尼的那个额外的字节。使用'〜'的好主意

编辑:感谢Laikoni脱掉了这5个字节!


1
您可以使用模式匹配代替fmap tail(l,_:r)<-span(/=',')
Laikoni '17

最后span(>',')应该也可以。
Laikoni '17

@Laikoni span(>',')如果首都的名称(例如Baton Rouge)中有空格,则不会生效,因为' '<','
user1472751

1
我知道了,但是您可以使用~代替,,它比所有其他使用的字符大。
Laikoni '17

1
last$l:[r|s==l]比短filter(/=s)[l,r]!!0s==l||s==r跳动elem s[l,r]一个字节。
Laikoni

1

T-SQL,1402字节(.sql文件的大小)

create table t(s varchar(99),c varchar(99))insert into t values('Baton Rouge','Louisiana'),('Indianapolis','Indiana'),('Columbus','Ohio'),('Montgomery','Alabama'),('Helena','Montana'),('Denver','Colorado'),('Boise','Idaho'),('Austin','Texas'),('Boston','Massachusetts'),('Albany','New York'),('Tallahassee','Florida'),('Santa Fe','New Mexico'),('Nashville','Tennessee'),('Trenton','New Jersey'),('Jefferson','Missouri'),('Richmond','Virginia'),('Pierre','South Dakota'),('Harrisburg','Pennsylvania'),('Augusta','Maine'),('Providence','Rhode Island'),('Dover','Delaware'),('Concord','New Hampshire'),('Montpelier','Vermont'),('Hartford','Connecticut'),('Topeka','Kansas'),('Saint Paul','Minnesota'),('Juneau','Alaska'),('Lincoln','Nebraska'),('Raleigh','North Carolina'),('Madison','Wisconsin'),('Olympia','Washington'),('Phoenix','Arizona'),('Lansing','Michigan'),('Honolulu','Hawaii'),('Jackson','Mississippi'),('Springfield','Illinois'),('Columbia','South Carolina'),('Annapolis','Maryland'),('Cheyenne','Wyoming'),('Salt Lake City','Utah'),('Atlanta','Georgia'),('Bismarck','North Dakota'),('Frankfort','Kentucky'),('Salem','Oregon'),('Little Rock','Arkansas'),('Des Moines','Iowa'),('Sacramento','California'),('Oklahoma City','Oklahoma'),('Charleston','West Virginia'),('Carson City','Nevada') declare @i varchar(99) = 'Austin' select coalesce((select s from t where c = @i union select c from t where s = @i),(select 'Arstotzka'))

Fort这种任务集逻辑胜过过程逻辑,从而可以轻松,快速地在关系数据库上解决它。

在未处理的代码下面。注意,我们可以在单独的批处理中运行一次创建/填充部分

create table t
(
     s varchar(99)
    ,c varchar(99)
)

insert into t
 values
 ('Baton Rouge','Louisiana')
,('Indianapolis','Indiana')
,('Columbus','Ohio')
,('Montgomery','Alabama')
,('Helena','Montana')
,('Denver','Colorado')
,('Boise','Idaho')
,('Austin','Texas')
,('Boston','Massachusetts')
,('Albany','New York')
,('Tallahassee','Florida')
,('Santa Fe','New Mexico')
,('Nashville','Tennessee')
,('Trenton','New Jersey')
,('Jefferson','Missouri')
,('Richmond','Virginia')
,('Pierre','South Dakota')
,('Harrisburg','Pennsylvania')
,('Augusta','Maine')
,('Providence','Rhode Island')
,('Dover','Delaware')
,('Concord','New Hampshire')
,('Montpelier','Vermont')
,('Hartford','Connecticut')
,('Topeka','Kansas')
,('Saint Paul','Minnesota')
,('Juneau','Alaska')
,('Lincoln','Nebraska')
,('Raleigh','North Carolina')
,('Madison','Wisconsin')
,('Olympia','Washington')
,('Phoenix','Arizona')
,('Lansing','Michigan')
,('Honolulu','Hawaii')
,('Jackson','Mississippi')
,('Springfield','Illinois')
,('Columbia','South Carolina')
,('Annapolis','Maryland')
,('Cheyenne','Wyoming')
,('Salt Lake City','Utah')
,('Atlanta','Georgia')
,('Bismarck','North Dakota')
,('Frankfort','Kentucky')
,('Salem','Oregon')
,('Little Rock','Arkansas')
,('Des Moines','Iowa')
,('Sacramento','California')
,('Oklahoma City','Oklahoma')
,('Charleston','West Virginia')
,('Carson City','Nevada')

并保留该数据,仅使用此查询

declare @i varchar(99) = 'Austin'

select coalesce(
    (
       select s from t
       where c = @i

       union

       select c from t where s = @i
    ),
    (select 'Arstotzka')
)

变量声明不是强制性的,当然您可以将输入直接放入查询中并保留10个字节,但是我希望将查询参数化。


387个字节?你算什么 答案的第一部分中的长线是1437字节。
matz 2015年

抱歉,@ matz发布了错误的文件大小
jean

这是Oracle PL * SQL吗?您可能想要在标题中指定。也可能能够使用sqlldr格式而不是直接插入来保存字节- sqlldr不需要到处都加引号,例如
roblogic

1

Zsh993928924字节

-4字节感谢@spuck的Bash答案,替换th Dakotath Carolina

a=(_ Bat4\ Rouge Lou7i5a Indi5apol7 Indi5a Columbus Ohio M4tgomery Alabama Hel8a M4t5a D8ver Col9ado Bo7e Idaho Aust6 Texas Bost4 Massachusetts Alb5y New\ Y9k Tallahassee Fl9ida S5ta\ Fe New\ Mexico Nashville T8nessee Tr8t4 New\ Jersey Jeffers4 M7souri Richm4d Virg6ia Pierre Sou3 Harr7burg P8nsylv5ia Augusta Ma6e Provid8ce Rhode\ 7l5d Dover Delaware C4c9d New\ Hampshire M4tpelier Verm4t Hartf9d C4necticut Topeka K5sas Sa6t\ Paul M6nesota Juneau Alaska L6coln Nebraska Raleigh N92 Mad74 W7c4s6 Olympia Wash6gt4 Pho8ix Ariz4a L5s6g Michig5 H4olulu Hawaii Jacks4 M7s7sippi Spr6gfield Ill6o7 Columbia Sou2 5napol7 Maryl5d Chey8ne Wyom6g Salt\ Lake1 Utah Atl5ta Ge9gia B7marck N93 Fr5kf9t K8tucky Salem 9eg4 Little\ Rock Ark5sas Des\ Mo6es Iowa Sacram8to Calif9nia 01 0 Charlest4 West\ Virg6ia Cars41 Nevada)
for w (Oklahoma \ City th\ Carol6a th\ Dakota on an in is en or)a=(${a//$[i++]/$w})
<<<${a[$a[(ie)$1]^1]:-Arstotzka}

在线尝试! 在线尝试! 在线尝试!

通过替换数组中的数字0..9进行手动压缩。

由于Zsh使用1索引数组,因此我们必须在开头添加一个虚拟元素。

$a[(i)$1]获取匹配数组元素的索引。添加(e)标志将禁用模式匹配,并使用纯字符串匹配。如果我们不这样做,将Ut*匹配Utah并打印Carson City。如果未找到该元素,则返回数组末尾以外的索引。

然后,我们与1进行异或运算,得到相应的配对元素。如果我们在索引1处的虚拟元素匹配,则为,它将$a[0]替换空字符串。无论如何,如果为空,${ :-Arstotzka}则将替换为Arstotzka。


我喜欢您的通行证扩展为0..9。试图借用它。
9:30播出

1

巴什(Bash),927 978 1003 1051 976字节

再进行一次编辑,减少$ T中空格和换行符占用的字节。

还重新排列了0..9的替换顺序,修复了处理“ Carol1a”的问题,因为在此之前已经完成了1->“ in”的替换。

在下面的@GammaFuntion评论后编辑我的答案;我没有满足处理所有输入的原始规则;与州或首都部分匹配的字符串将产生错误的输出。

他/她的Zsh答案激发了我也使用XOR而不是100模的索引,并使用数字0..9进行了一些手动压缩。我编写了一个脚本,对输入列表进行了一些快速而肮脏的计算,以确定哪十个字符串将提供最佳的字节减少效果。然后迭代使用该脚本来减少字符串。在此处查看: 在线尝试!

T="Bat8.RougeLou3i2aIndi2apol3Indi2aColumbusOhioM8tgom9yAlabamaHel6aM8t2aD6v9Col5adoBo3eIdahoAust4Tex7Bost8M7sachusettsAlb2yNew.Y5kTallah7seeFl5idaS2ta.FeNew.MexicoN7hvilleT6nesseeTr6t8New.J9seyJeff9s8M3souriRichm8dVirg4iaPi9reSou0Harr3burgP6nsylv2iaAugustaMa4eProvid6ceRhode.Isl2dDov9DelawareC8c5dNew.HampshireM8tpeli9V9m8tHartf5dC8necticutTopekaK2s7Sa4t.PaulM4nesotaJuneauAl7kaL4colnNebr7kaRaleighN51Mad38W3c8s4OlympiaW7h4gt8Pho6ixAriz8aL2s4gMichig2H8oluluHawaiiJacks8M3s3sippiSpr4gfieldIll4o3ColumbiaSou1Annapol3Maryl2dChey6neWyom4gSalt.Lake.CityUtahAtl2taGe5giaB3marckN50Fr2kf5tK6tuckySalemOreg8Little.RockArk2s7Des.Mo4esIowaSacram6toCalif5niaOklahoma.CityOklahomaCharlest8West.Virg4iaCars8.CityNevada"
for t in th.Dakota th.Carol4a an is in or en as on er;{ T=${T//$[j++]/$t};}
for t in {A..Z};{ T=${T//$t/ $t};}
S=${T//. /.}
U=($S)
for s in $S;{ [ "${s//./ }" = "$1" ]&&echo ${U[i^1]//./ }&&exit;i=$[i+1];}
echo Arstotzka

在线尝试!

在线尝试!

在线尝试!

在线尝试!

在线尝试!


1
聪明的想法想用替换的方式,但是如果我Rock作为输入给出,则输出Little Arkansas代替Arstotzka
GammaFunction

@GammaFunction,您是对的。我正在编辑我的答案来处理这个问题。
9:30播出

随意剥夺我的Zsh答案。数组扩展不会那么紧凑,但是您可以利用零索引。
GammaFunction

进入986 :for t in on in an is th.Carol1a or en as th.Dakota er;{ S=${S//$[j++]/$t};}。另外,很好地使用th.,我将其添加到我的zsh答案中。
GammaFunction

哦,并且unset / empty变量在算术上下文中隐式为0,您不需要事先设置i(或j)。
GammaFunction

0

R,1294字节

d=data.frame(a=c("Baton Rouge","Indianapolis","Columbus","Montgomery","Helena","Denver","Boise","Austin","Boston","Albany","Tallahassee","Santa Fe","Nashville","Trenton","Jefferson","Richmond","Pierre","Harrisburg","Augusta","Providence","Dover","Concord","Montpelier","Hartford","Topeka","Saint Paul","Juneau","Lincoln","Raleigh","Madison","Olympia","Phoenix","Lansing","Honolulu","Jackson","Springfield","Columbia","Annapolis","Cheyenne","Salt Lake City","Atlanta","Bismarck","Frankfort","Salem","Little Rock","Des Moines","Sacramento","Oklahoma City","Charleston","Carson City"),b=c("Louisiana","Indiana","Ohio","Alabama","Montana","Colorado","Idaho","Texas","Massachusetts","New York","Florida","New Mexico","Tennessee","New Jersey","Missouri","Virginia","South Dakota","Pennsylvania","Maine","Rhode Island","Delaware","New Hampshire","Vermont","Connecticut","Kansas","Minnesota","Alaska","Nebraska","North Carolina","Wisconsin","Washington","Arizona","Michigan","Hawaii","Mississippi","Illinois","South Carolina","Maryland","Wyoming","Utah","Georgia","North Dakota","Kentucky","Oregon","Arkansas","Iowa","California","Oklahoma","West Virginia","Nevada"),stringsAsFactors=F)
print(ifelse(any(e<-d[,1]%in%(n<-scan("","raw",sep='$'))),d[e,2],ifelse(any(f<-d[,2]%in%n),d[f,1],'Arstotzka')))

根据示例显示的输入,这是区分大小写的。

非高尔夫代码(扫描位置略有不同):

n<-scan("","raw",sep='$')
print(
  ifelse(
    any(e<-d[,1]%in%n), # test city
    d[e,2], # if yes return the state
    ifelse(
      any(f<-d[,2]%in%n), # test state
      d[f,1], # return city
      'Arstotzka'
    )
  )
)

0

爪哇,1312

public class a{public static void main(String[]x){List<String>a=Arrays.asList("Baton Rouge","Louisiana","Indianapolis", "Indiana","Columbus","Ohio", "Montgomery","Alabama","Helena","Montana","Denver","Colorado","Boise","Idaho","Austin","Texas","Boston","Massachusetts","Albany","New York","Tallahassee","Florida","Santa Fe","New Mexico","Nashville","Tennessee","Trenton","New Jersey","Jefferson","Missouri","Richmond","Virginia","Pierre","South Dakota","Harrisburg","Pennsylvania","Augusta","Maine","Providence","Rhode Island","Dover","Delaware","Concord","New Hampshire","Montpelier","Vermont","Hartford","Connecticut","Topeka","Kansas","Saint Paul","Minnesota","Juneau","Alaska","Lincoln","Nebraska","Raleigh","North Carolina","Madison","Wisconsin","Olympia","Washington","Phoenix","Arizona","Lansing","Michigan","Honolulu","Hawaii","Jackson","Mississippi","Springfield","Illinois","Columbia","South Carolina","Annapolis","Maryland","Cheyenne","Wyoming","Salt Lake City","Utah","Atlanta","Georgia","Bismarck","North Dakota","Frankfort","Kentucky","Salem","Oregon","Little Rock","Arkansas","Des Moines","Iowa","Sacramento","California","Oklahoma City","Oklahoma","Charleston","West Virginia","Carson City","Nevada");int b=a.indexOf(x[0]);String s=b<0?s="Arstotzka":a.get(b/2*2+((b+1)%2));System.out.print(s);}}

0

JavaScript,1042年

var x=prompt(),a="Baton Rouge,Louisiana,Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Albany,New York,Tallahassee,Florida,Santa Fe,New Mexico,Nashville,Tennessee,Trenton,New Jersey,Jefferson,Missouri,Richmond,Virginia,Pierre,South Dakota,Harrisburg,Pennsylvania,Augusta,Maine,Providence,Rhode Island,Dover,Delaware,Concord,New Hampshire,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Saint Paul,Minnesota,Juneau,Alaska,Lincoln,Nebraska,Raleigh,North Carolina,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Columbia,South Carolina,Annapolis,Maryland,Cheyenne,Wyoming,Salt Lake City,Utah,Atlanta,Georgia,Bismarck,North Dakota,Frankfort,Kentucky,Salem,Oregon,Little Rock,Arkansas,Des Moines,Iowa,Sacramento,California,Oklahoma City,Oklahoma,Charleston,West Virginia,Carson City,Nevada".split(","),b=a.indexOf(x),s=b<0?s="Arstotzka":a[Math.floor(b/2)*2+((b+1)%2)];alert(s);

0

AWK,1009字节

{split("Baton Rouge,Louisiana,Indianapolis,Indiana,Columbus,Ohio,Montgomery,Alabama,Helena,Montana,Denver,Colorado,Boise,Idaho,Austin,Texas,Boston,Massachusetts,Albany,New York,Tallahassee,Florida,Santa Fe,New Mexico,Nashville,Tennessee,Trenton,New Jersey,Jefferson,Missouri,Richmond,Virginia,Pierre,South Dakota,Harrisburg,Pennsylvania,Augusta,Maine,Providence,Rhode Island,Dover,Delaware,Concord,New Hampshire,Montpelier,Vermont,Hartford,Connecticut,Topeka,Kansas,Saint Paul,Minnesota,Juneau,Alaska,Lincoln,Nebraska,Raleigh,North Carolina,Madison,Wisconsin,Olympia,Washington,Phoenix,Arizona,Lansing,Michigan,Honolulu,Hawaii,Jackson,Mississippi,Springfield,Illinois,Columbia,South Carolina,Annapolis,Maryland,Cheyenne,Wyoming,Salt Lake City,Utah,Atlanta,Georgia,Bismarck,North Dakota,Frankfort,Kentucky,Salem,Oregon,Little Rock,Arkansas,Des Moines,Iowa,Sacramento,California,Oklahoma City,Oklahoma,Charleston,West Virginia,Carson City,Nevada,Arstotzka,",S,",")
for(x in S)if(S[x]==$0)break
$0=S[x-1+x%2*2]}1

在线尝试!

如果有办法缩小这种范围,我很乐意得知。:)


0

Ĵ843个 829字节

-&.((<;._1'-rstotzk7Bat> Roug/Ind6?p@;5@umbus.o8gom4y,Hel97D9v4,Bo;e-ust=,Bost>-lb<y,Tal1h2se/Sa8a F/N2hvill/Tre8>,Jeff4s>,Richm>d,Pi4r/H3r;burg-ugust7Provid9c/Dov45>c:d.o8peli4,H3tf:d,Topek7Sai8 Paul,Juneau,L=c@n,Raleigh.ad;>,Olymp6,Pho9ix,L<s=g,H>@ulu,Jacks>Apr=gfield5@umb6-n?p@;5hey9n/Salt Lake City-t187B;m3ck,Fr<kf:tAalem,Little Rock,Des Mo=esAacrame8o,Ok1homa City5h3lest>53s> City0evad7West Virg=6,Ok1homa5alif:n6,Iowa-rk<s2,Oreg>,Ke8ucky0:th Dakot7Ge:g6,Utah,Wyom=g.3y1ndAouth C3@=7Ill=o;.;s;sippi,Hawaii.ichig<-riz>7W2h=gt>,W;c>s=0:th C3@=a0ebr2ka-1ska.=nesot7K<s25>necticut,V4mo80ew Hampshir/De1w3/Rhode Is1nd.a=/P9nsylv<6Aouth Dakot7Virg=6.;souri0ew J4sey,T9nesse/New Mexico,Fl:ida0ew Y:k.2sachusetts,Tex2,Idaho5@:ado.o8<a-1bam7Ohio,Ind6n7Lou;6?'rplc(45{21;/\a.),._2<\',A,Me,,Nlaasarer,Ciaa,ntenorisaninonnaol,S')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.