여러 프로그램 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

"Quine이 아님"이 "무엇인가"또는 "적어도 실행"을 의미합니까?
— LegionMammal978

1
컴파일러에 넣으면 소스 코드가 출력되지 않습니다. 소스 코드를 출력하지 않는 한 실행하거나 오류를 발생 시키거나 다른 것을 컴파일하거나 출력하지 않을 수 있습니다.
— Faraz Masroor

Quine은 다음과 같은 관심을 가진 사람들에게 영감을 불어 넣습니다. "모든 언어의 프로그램을 <언어>로 인쇄하십시오.
— ETHproductions

답변:


11

핵분열 + CJam + GolfScript, 38 36 바이트

핵분열 , 6 바이트

'!+OR"

이것은 Martin Bü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 코드 포인트가 원자의 질량 인 문자를 인쇄하고 원자를 파괴합니다.

CJam

'       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.

GolfScript

'!+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

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

작동 원리

자기 수정 브레인

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)

GolfScript

{            # 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

Tcl의 @FarazMasroor 문자열은 중괄호로 묶을 수 있으며 명령 이름도 문자열입니다. 그리고 중괄호 안의 것은 그대로 인쇄 할 수있는 GolfScript의 블록으로 간주됩니다. CJam은 GolfScript와 비슷하지만 한 언어에서는 퀴네를 만들어 다른 언어에서는 작동하지 않을 정도로 다릅니다. 이러한 언어 선택을 통해 올바른 형식으로 출력하기위한 추가 코드가 포함 된 일반 퀴인이며 아직 골프를 타지 않았습니다.
— jimmy23013

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$~

마지막 바이트는 줄 바꿈입니다. 웹 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.

CJam

];      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.

GolfScript

'"%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 2018
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.