多个程序Quinecatenate!


22

您的任务是提供三种不同的语言A,B,C,并编写两种不同的程序P和Q,以便:

P是语言A的奎因,但不是语言B或C的奎因;

Q是语言B中的奎因,而不是语言A和C中的奎因;和

在P后面串联的Q(中间没有添加任何新字符)是C语言中的奎因,但B和A语言中没有。

这是代码高尔夫球,您的分数是最终级联quine的长度。同样,请遵守适当的规则 –不要阅读源代码,不要使用空程序等。


2
评论规则?
艾迪生·克伦普

那是我以前没有想到的。我倾向于让它们滑动,因为那样您就不必担心将其打印出来,并且必须确保语言C具有相同的注释语法或其他内容,但是我很灵活。
Faraz Masroor,2015年

“不是奎因”是指“做什么”还是“至少是奔跑”?
LegionMammal978

1
当放入编译器时,它不会输出其源代码。它可以运行或引发错误,也可以不编译或输出其他内容或不输出任何内容,但是只要不输出其源代码即可。
Faraz Masroor,2015年

Answers:


11

Fission + CJam + GolfScript,38 36字节

裂变,6个字节

'!+OR"

这是马丁·布特纳(MartinBüttner)的裂变奎因之一在线尝试!

CJam,30个字节

' {"''"@*" "+YX#<
\"0$~"N}0$~

最后一个字节是换行符。在线尝试!

GolfScript,36个字节

'!+OR"' {"''"@*" "+YX#<
\"0$~"N}0$~

最后一个字节是换行符。在线尝试!

验证

$ wc -c P Q
 6 P
30 Q
36 total
$ cat P Q > P+Q
$ 
$ Fission P 2>&- | diff -qs - P
Files - and P are identical
$ cjam P 2>&- | diff -qs - P
Files - and P differ
$ golfscript P 2>&- | diff -qs - P
Files - and P differ
$ 
$ cjam Q 2>&- | diff -qs - Q
Files - and Q are identical
$ golfscript Q 2>&- | diff -qs - Q
Files - and Q differ
$ Fission Q 2>&- | diff -qs - Q
Files - and Q differ
$ 
$ golfscript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q are identical
$ Fission P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ
$ cjam P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ

怎么运行的

裂变

  • R 产生一个向右移动的原子,并在边缘缠绕。

  • "切换打印模式。直到下一个的所有内容都会"被打印。

  • '! 将原子设置为代码点“!”。

  • +增加原子的质量,将其设置为的代码点"

  • O 打印其代码点为原子质量的字符并破坏原子。

贾姆

'       e# Push a space character.
{       e# Push the following code block:
  "''"  e# Push that string.
  @*    e# Separate its characters by spaces.
  " "+  e# Append one more space.
  YX#   e# Raise 2 to the first power. Pushes 2.
  <     e# Discard all but the first two characters of the string, i.e., "' ".
  \     e# Swap the string "' " with the code block in execution.
  "0$~" e# Push that string.
  N     e# Push a linefeed.
}       e#
0$~     e# Push a copy of the code block and execute it.

高尔夫脚本

'!+OR"' # Push that string.
{       # Push the following code block:
  "''"  # Push that string.
  @*    # Join its characters, separating them by the first string.
  " "+  # Append a space.
  YX    # Undefined token. Does nothing.
  #<    # Comment.
  \     # Swap the string with the code block in execution.
  "0$~" # Push that string.
  N     # Undefined token. Does nothing.
}       #
0$~     # Push a copy of the code block and execute it.

找到了另一个丹尼斯!
Faraz Masroor,2015年

8

自我修改Brainfuck + GolfScript + CJam,29岁 27字节

自修改Brainfuck,12字节

 {<[<]>[.>]}

注意前导空间。在线尝试!

GolfScript,15个字节

{So"0$~"N]}0$~

最后一个字节是换行符。在线尝试!

CJam,27个字节

 {<[<]>[.>]}{So"0$~"N]}0$~

注意前导空间。最后一个字节是换行符。在线尝试!

验证

$ wc -c P Q
12 P
15 Q
27 total
$ cat P Q > P+Q
$ 
$ timeout 10 smbf P | diff -sq - P
Files - and P are identical
$ golfscript P | diff -sq - P
Files - and P differ
$ cjam P | diff -sq - P
Files - and P differ
$ 
$ golfscript Q | diff -sq - Q
Files - and Q are identical
$ cjam Q | diff -sq - Q
Files - and Q differ
$ timeout 10 smbf Q | diff -sq - Q
Terminated
$ 
$ cjam P+Q | diff -sq - P+Q
Files - and P+Q are identical
$ golfscript P+Q | diff -sq - P+Q
Files - and P+Q differ
$ timeout 10 smbf P+Q | diff -sq - P+Q
Terminated

怎么运行的

自我修改的Brainfuck

SMBF从数据指针左侧的源代码开始。

<space>        (ignored)
{              (ignored)
<              Move the data pointer left.
[<]            Move the data pointer left to the next null byte.
>              Move the data pointer right.
[.>]           Print and move the data pointer right until null byte.
}              (ignored)

高尔夫脚本

{            # Push the following code block:
  So         # Undefined token. Does nothing.
  "0$~"      # Push that string.
  N          # Undefined token. Does nothing.
  ]          # Wrap the stack in a array. Does not affect output.
}            #
0$~          # Push a copy of the code block and execute it.


### CJam

{<[<]>[.>]} e# Push that code block.
{           e# Push the following code block:
  So        e# Print a space. Since it is printed explicitly,
            e# it will appear at the beginning of the output.
  "0$~"     e# Push that string.
  N         e# Push a linefeed.
  ]         e# Wrap the stack in a array. Does not affect output.
            e# This makes the program an infinite, empty  loop
            e# in SMBF; it would be a quine otherwise.
}           e#
0$~         e# Push a copy of the code block and execute it.

5

Tcl,CJam,GolfScript,60 + 26 = 86 112字节

打高尔夫球不好。

Tcl,60个字节

{puts} [{join} {{} \{ \}\]} {{puts} [{join} {{} \{ \}\]} }]

根据本页上的藜。它具有结尾的换行符。

CJam,26个字节

{"' '@`+n@0"L~;"0$~"N}0$~

它具有结尾的换行符。

GolfScript,86个字节

{puts} [{join} {{} \{ \}\]} {{puts} [{join} {{} \{ \}\]} }]
{"' '@`+n@0"L~;"0$~"N}0$~

这是如何运作的?我从未听说过tcl
Faraz Masroor,2015年

@FarazMasroor Tcl中的字符串可以用大括号括起来,命令名称也是字符串。大括号中的内容被视为GolfScript中的块,可以按原样打印。CJam与GolfScript类似,但差异很大,以至于无法用一种语言制作成奎因,而用另一种语言则无法奏效。有了这些语言选择,它们只是普通的木盒,带有一些额外的代码,可以以正确的格式输出,而目前还没有普及。
jimmy23013 2015年

3

ShapeScript + CJam + GolfScript,96 95 62字节

ShapeScript,16个字节

'"%r"@%"0?!"'0?!

这是标准的ShapeScript quine在线尝试!

CJam,46个字节

];{"'\"%r\"@%\"0?!\"'0?!];"SS#~(>
\"0$~"N}0$~

最后一个字节是换行符。在线尝试!

GolfScript,62个字节

'"%r"@%"0?!"'0?!];{"'\"%r\"@%\"0?!\"'0?!];"SS#~(>
\"0$~"N}0$~

最后一个字节是换行符。在Web GolfScript上在线尝试

验证

$ wc -c P Q
16 P
46 Q
62 total
$ cat P Q > P+Q
$ 
$ shapescript P 2>&- | diff -qs - P
Files - and P are identical
$ cjam P 2>&- | diff -qs - P
Files - and P differ
$ golfscript P 2>&- | diff -qs - P
Files - and P differ
$ 
$ cjam Q 2>&- | diff -qs - Q
Files - and Q are identical
$ golfscript Q 2>&- | diff -qs - Q
Files - and Q differ
$ shapescript Q 2>&- | diff -qs - Q
Files - and Q differ
$ 
$ golfscript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q are identical
$ shapescript P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ
$ cjam P+Q 2>&- | diff -qs - P+Q
Files - and P+Q differ

怎么运行的

ShapeScript

'       Push a string that, when evaluated, does the following.
  "%r"  Push this formatting string. %r gets replaced by a string
        representation of the corresponding argument.
  @     Swap the string that is being evaluated on top of the stack.
  %     Apply formatting to the string on top of the stack.
  "0?!" Push that string.
'
0?!     Push a copy of the previous string and evaluate it.

贾姆

];      e# Clear the stack. Stack is already clear. Does nothing.
{       e# Push the following code block:

  "'\"%r\"@%\"0?!\"'0?!];"

  SS#   e# Find the index of " " in " ". Pushes 0.
  ~(    e# Apply logical NOT and decrement. Pushes -2.
  >     e# Discard all but the two rightmost characters from the string,
        e# i.e., reduce it to "];".
  \     e# Swap the string "];" with the code block in execution.
  "0$~" e# Push that string.
  N     e# Push a linefeed.
}       e#
0$~     e# Push a copy of the code block and execute it.

高尔夫脚本

'"%r"@%"0?!"'

0?!     # Find the index of the number 0 in the string and apply logical NOT.
];      # Clear the stack.
{       # Push the following code block:

  "'\"%r\"@%\"0?!\"'0?!];"

  SS    # Undefined token. Does nothing.
  #~(>  # Comment.
  \     # Swap the string with the code block in execution.
  "0$~" # Push that string.
  N     # Undefined token. Does nothing.
}       #
0$~     # Push a copy of the code block and execute it.

2
我发现自己是野生丹尼斯!
Faraz Masroor,2015年
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.