code golf 您所在的位置:网站首页 工作日历表格怎么做 code golf

code golf

#code golf| 来源: 网络整理| 查看: 265

Back-story

After typing up your essay on your new Macbook, you look up at the screen and realize that you typed in ten pages of gibberish! Or is it? On further inspection, you come to find that your Option key was stuck this whole time and these special Option-key characters correspond to the ASCII keys on your keyboard!

Challenge

Your challenge is to write the shortest possible program or function that converts an encoded Option-key input into ASCII output.

Here's the Option-key special characters to ASCII characters dictionary:

+---------+-------+-------+-------+ | OPT-KEY | CODE | ASCII | CODE | +---------+-------+-------+-------+ | ¡ | 161 | 1 | 49 | | ™ | 8482 | 2 | 50 | | £ | 163 | 3 | 51 | | ¢ | 162 | 4 | 52 | | ∞ | 8734 | 5 | 53 | | § | 167 | 6 | 54 | | ¶ | 182 | 7 | 55 | | • | 8226 | 8 | 56 | | ª | 170 | 9 | 57 | | º | 186 | 0 | 48 | | – | 8211 | - | 45 | | ≠ | 8800 | = | 61 | | œ | 339 | q | 113 | | ∑ | 8721 | w | 119 | | ® | 174 | r | 114 | | † | 8224 | t | 116 | | ¥ | 165 | y | 121 | | ø | 248 | o | 111 | | π | 960 | p | 112 | | “ | 8220 | [ | 91 | | ‘ | 8216 | ] | 93 | | « | 171 | \ | 92 | | å | 229 | a | 97 | | ß | 223 | s | 115 | | ∂ | 8706 | d | 100 | | ƒ | 402 | f | 102 | | © | 169 | g | 103 | | ˙ | 729 | h | 104 | | ∆ | 8710 | j | 106 | | ˚ | 730 | k | 107 | | ¬ | 172 | l | 108 | | … | 8230 | ; | 59 | | æ | 230 | ' | 39 | | Ω | 937 | z | 122 | | ≈ | 8776 | x | 120 | | ç | 231 | c | 99 | | √ | 8730 | v | 118 | | ∫ | 8747 | b | 98 | | µ | 181 | m | 109 | | ≤ | 8804 | , | 44 | | ≥ | 8805 | . | 46 | | ÷ | 247 | / | 47 | |   | 160 | | 32 | | ⁄ | 8260 | ! | 33 | | € | 8364 | @ | 64 | | ‹ | 8249 | # | 35 | | › | 8250 | $ | 36 | | fi | 64257 | % | 37 | | fl | 64258 | ^ | 94 | | ‡ | 8225 | & | 38 | | ° | 176 | * | 42 | | · | 183 | ( | 40 | | ‚ | 8218 | ) | 41 | | — | 8212 | _ | 95 | | ± | 177 | + | 43 | | Œ | 338 | Q | 81 | | „ | 8222 | W | 87 | | ‰ | 8240 | R | 82 | | ˇ | 711 | T | 84 | | Á | 193 | Y | 89 | | Ø | 216 | O | 79 | | ∏ | 8719 | P | 80 | | ” | 8221 | { | 123 | | ’ | 8217 | } | 125 | | » | 187 | | | 124 | | Å | 197 | A | 65 | | Í | 205 | S | 83 | | Î | 206 | D | 68 | | Ï | 207 | F | 70 | | ˝ | 733 | G | 71 | | Ó | 211 | H | 72 | | Ô | 212 | J | 74 | |  | 63743 | K | 75 | | Ò | 210 | L | 76 | | Ú | 218 | : | 58 | | Æ | 198 | " | 34 | | ¸ | 184 | Z | 90 | | ˛ | 731 | X | 88 | | Ç | 199 | C | 67 | | ◊ | 9674 | V | 86 | | ı | 305 | B | 66 | |  | 194 | M | 77 | | ¯ | 175 | < | 60 | | ˘ | 728 | > | 62 | | ¿ | 191 | ? | 63 | +---------+-------+-------+-------+

It's not that simple though... There are a five Option-key special characters that do not follow this trend, specifically (Option-key special characters and their corresponding lowercase ASCII characters):

Beginning of input or after special space (" ", code 160): +---------+-------+-------+-------+ | OPT-KEY | CODE | ASCII | CODE | +---------+-------+-------+-------+ | ` | 96 | ~ | 126 | | ´ | 180 | E | 69 | | ¨ | 168 | U | 85 | | ˆ | 710 | I | 73 | | ˜ | 732 | N | 78 | +---------+-------+-------+-------+ Otherwise: +---------+-------+-------+-------+ | OPT-KEY | CODE | ASCII | CODE | +---------+-------+-------+-------+ | ` | 96 | ` | 96 | | ´ | 180 | e | 101 | | ¨ | 168 | u | 117 | | ˆ | 710 | i | 105 | | ˜ | 732 | n | 110 | +---------+-------+-------+-------+

When any of these characters are found after the Option-key special space character ( ) or at the beginning of the input, output the capitalized version of their ASCII equivalents. (Note that the capitalized version of "`" is "~".) Otherwise, output the lowercase version of their ASCII equivalents.

Finally, do not attempt to decode any other characters, just output them.

Rules & Grading All Code-Golf rules barring standard loopholes apply. Scores will be based on the number of bytes your program uses. The program with the smallest score (or the smallest number of bytes) will win! Examples

Input, output:

`´¨ˆ˜` ~euin` ´´ ´⁄ Ee E! `` ´ ¨ ˆ ˜ ~` E U I N Ó´¬¬ø ∑ø®¬∂⁄ Hello world! „˙冠ˆß ¥ø¨® ˜åµ´¿ Í´®©´å˜† ıˆ¬¬ˆå®∂ß⁄ What Is your Name? Sergeant Billiards! „˙´®´ ∂ø ¥ø¨ çøµ´ ƒ®øµ¿ Where do you come from? „˙´˜ ˆ µø√´∂ †ø Áø®˚ß˙ˆ®´≤ †˙´®´ ∑åߠ堵嘠∑分ˆ˜© ƒø® µ´≥ When I moved to Yorkshire, there was a man waiting for me. ӈߠ˜åµ´ ∑åß ∏嬴߆ˆ˜´≥ Ó´ çåµ´ ƒ®øµ Òå˜∂ø≥ His Name was Palestine. He came from Lando. Åç®øßß †˙´ ®´´ƒ ¬å¥ ˜ø†˙ˆ˜©≥ Across the reef lay Nothing. Â¥ ˜åµ´ ˆß ´å†ø˜≥ My Name Is Eaton. ˆ˜† µåˆ˜·√øˆ∂‚ ” ß†∂ÚÚçø¨† ¯¯ ÆÓ´¬¬ø ∑ø®¬∂⁄Æ… ’ Int main(void) { std::cout


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有