给定ASCII加上换行符中的95个可打印字符,将其分成两个相等的48个字符组(以下称为A组和B组)。创建一个一对一的映射,你的选择(你有完全的自由裁量权)之间的两组。换句话说,A可能映射到a,反之亦然,但是A也可能映射到>,反之亦然,如果这是您的程序所需要的。
将ASCII分成两组后,编写两个程序和/或函数,分别使用每个组中的字符。换句话说,编写一个程序/函数,它只使用组A中的字符,另一个程序/函数只使用组B中的字符。
这些程序必须能够接收一个字符作为输入。如果输入是A组字符,则用A组中的字符编写的程序应该输出/返回相同的字符;如果A组字符接收到组B字符,则映射组A字符应输出/返回相同的字符;A组程序应始终输出A组字符。类似地,如果是组B字符,组B程序应该输出相同的字符,如果输入是组A字符,则输出映射组B字符。
这可能不是很清楚,下面是一个例子。如果您假设所有大写字母都在组A中,所有小写字母都在组B中,并且您已经选择这些字母的一对一映射是从一个到另一个,那么:下面是一些示例输入/输出:
Input Output
A A
D D
a A
q QInput Output
A a
D d
a a
q q其他规则:
正常情况下,标准漏洞是被禁止的。所有程序必须是自包含的,没有包含您选择的映射的文件。
评分标准:密码-高尔夫。具体来说,两个程序的文本的字节之和。
请这样贴出你的答案:
语言-#字节+语言-#字节=#字节
对您的映射的明确描述。如果情况很复杂,请使用这样的图表:
ABCDEFGHIJKLMNOPQRSTUVWXYZ (等)zyxwvutsrpqonmlkjihgfedcba (等)
或者,你可以解释它(前48张地图到最后48张顺序),然后是你的答案。
发布于 2015-09-08 18:14:37
在16个交替组中选择字符:
!"#$%&'()*+,-./@ABCDEFGHIJKLMNO`abcdefghijklmno
0123456789:;<=>?PQRSTUVWXYZ[\]^_pqrstuvwxyz{|}~\n很酷的是,可以使用shift键获得一些映射:)
lL,H-f&'o+c在网上试试
q_S<\_0=16|_127<\S0=42^??在网上试试
方案A:
l read a line from the input, this is a 1-character string
or the empty string if the input was a newline
L, get the length of an empty string/array (0)
H- subtract 17, obtaining -17 (~16)
f& bitwise-"and" each character (based on the ASCII code) with -17
'o+ append the 'o' character
c convert to (first) character
the result is the "and"-ed character, or 'o' for newline方案B:
q_ read the whole input and duplicate it
S<\ compare with " " and move the result before the input
_0= duplicate the input again, and get the first (only) character
16| bitwise-"or" with 16 (based on the ASCII code)
_127< duplicate and compare (its ASCII code) with 127
\ move the result before the "or"-ed character
S0= get the space character (first character of the space string)
42^ xor with 42, obtaining a newline character
stack: (input<" ") (input) ("or"-ed char<127) ("or"-ed char) (newline)
? if the "or"-ed character is less than 127, use the "or"-ed character
else use the newline character
? if the input was smaller than space (i.e. it was a newline),
use the input, else use the character from the previous step发布于 2015-09-06 01:11:59
感谢@durron597 597帮助第一个程序使用1090字节的高尔夫球。
证明用一种语言是可能的(在这一点上是非语言的)。
使用unicode技巧将第一个字符转换为所有unicode字符。第二种是使用反射来访问System.out,以便打印到std。出去吧。它不能使用u,因为这是在第一个程序中使用的。我知道这可以得到更多,但我想先发一个有效的解决方案。
组是相当任意的映射,但基本上,第一个组只需要u、\和十六进制数字(无论如何)。
这些小组:
!#7A289'0123456>fB@UXZ\^AKCDEGH_JL`NOkQRxzVWYu~\n
"%()*+,-./:;<=?FIMPST[]abcdeghijlmnopqrstvwy{|}第一个节目:
\u0076\u006F\u0069\u0064
k\u0028\u0069\u006E\u0074
x\u0029\u007B\u0069\u006E\u0074\u005B\u005Du\u003D\u007B33\u002C33\u002C35\u002C35\u002C36\u002C55\u002C38\u002C39\u002C36\u002C38\u002C56\u002C57\u002C39\u002C48\u002C49\u002C50\u002C48\u002C49\u002C50\u002C51\u002C52\u002C53\u002C54\u002C55\u002C56\u002C57\u002C51\u002C52\u002C53\u002C54\u002C62\u002C62\u002C64\u002C65\u002C66\u002C67\u002C68\u002C69\u002C102\u002C71\u002C72\u002C66\u002C74\u002C75\u002C76\u002C64\u002C78\u002C79\u002C85\u002C81\u002C82\u002C88\u002C90\u002C85\u002C86\u002C87\u002C88\u002C89\u002C90\u002C92\u002C92\u002C94\u002C94\u002C95\u002C96\u002C65\u002C75\u002C67\u002C68\u002C69\u002C102\u002C71\u002C72\u002C95\u002C74\u002C107\u002C76\u002C96\u002C78\u002C79\u002C107\u002C81\u002C82\u002C120\u002C122\u002C117\u002C86\u002C87\u002C120\u002C89\u002C122\u002C117\u002C126\u002C10\u002C126\u007D\u003B\u0053\u0079\u0073\u0074\u0065\u006D\u002E\u006Fu\u0074\u002E\u0070\u0072\u0069\u006E\u0074\u0028x>10\u003F\u0028\u0063\u0068\u0061\u0072\u0029u\u005Bx\u002D32\u005D\u003A'\u005C\u006E'\u0029\u003B\u007D相当于
void
k(int
x){int[]u={33,33,35,35,36,55,38,39,36,38,56,57,39,48,49,50,48,49,50,51,52,53,54,55,56,57,51,52,53,54,62,62,64,65,66,67,68,69,102,71,72,66,74,75,76,64,78,79,85,81,82,88,90,85,86,87,88,89,90,92,92,94,94,95,96,65,75,67,68,69,102,71,72,95,74,107,76,96,78,79,107,81,82,120,122,117,86,87,120,89,122,117,126,10,126};System.out.print(x>10?(char)u[x-32]:'\n');}第二个节目:
void n(int r)throws Throwable{int p=(int)Math.PI;int q=p/p;int t=p*p+q;int w=q+q;int[]g={t*p+w,t*p+w,t*p+q+p,t*p+q+p,t*(q+p),t*p+t-p,t*(q+p)+q,t*(q+p)+q+p,t*(q+p),t*(q+p)+q,t*(q+p)+w,t*(q+p)+p,t*(q+p)+q+p,t*(q+p)+p+w,t*(q+p)+p+p,t*(q+p)+t-p,t*(q+p)+p+w,t*(q+p)+p+p,t*(q+p)+t-p,t*(p+w)+t-w,t*(p+w)+t-q,t*(p+p),t*(p+p)+q,t*p+t-p,t*(q+p)+w,t*(q+p)+p,t*(p+w)+t-w,t*(p+w)+t-q,t*(p+p),t*(p+p)+q,t*(p+p)+p,t*(p+p)+p,t*(t-p)+t-p,t*(t-q)+t-p,t*(t-p)+p,t*(t-q)+t-q,t*t,t*t+q,t*(t-p),t*t+p,t*t+q+p,t*(t-p)+p,t*t+p+p,t*(t-q)+t-w,t*t+t-w,t*(t-p)+t-p,t*(t+q),t*(t+q)+q,t*(t-w),t*(t+q)+p,t*(t+q)+q+p,t*(t-w)+p,t*(t-w)+q+p,t*(t-w),t*(t+q)+t-w,t*(t+q)+t-q,t*(t-w)+p,t*(t+w)+q,t*(t-w)+q+p,t*(t-q)+q,t*(t-q)+q,t*(t-q)+p,t*(t-q)+p,t*t+p+w,t*t+t-q,t*(t-q)+t-p,t*(t-q)+t-w,t*(t-q)+t-q,t*t,t*t+q,t*(t-p),t*t+p,t*t+q+p,t*t+p+w,t*t+p+p,t*(t+q)+w,t*t+t-w,t*t+t-q,t*(t+q),t*(t+q)+q,t*(t+q)+w,t*(t+q)+p,t*(t+q)+q+p,t*(t+q)+p+w,t*(t+q)+p+p,t*(t+w)+p,t*(t+q)+t-w,t*(t+q)+t-q,t*(t+q)+p+w,t*(t+w)+q,t*(t+q)+p+p,t*(t+w)+p,t*(t+w)+q+p,t*(t+w)+p+w,t*(t+w)+q+p};java.io.PrintStream o=(java.io.PrintStream)System.class.getFields()[p/p].get(p);o.print((r<=t)?"}":(char)g[r-t*p-w]);}https://codegolf.stackexchange.com/questions/57075
复制相似问题