Кілька програм Quinecatenate!


22

Ваше завдання - дати три різні мови A, B, C і написати дві різні програми P і Q таким чином:

Р - це квітка мовою A, але не квінка в B, C;

Q є лайкою мовою B, але не квінкою в A і C; і

Q, з'єднаний після P (без будь-яких нових символів, що додаються між ними), є лайкою мовою C, але не B і A.

Це кодогольф, де ваш рахунок - це довжина заключної, з'єднаної квітки. Знову ж таки, дотримуйтесь правил належних quines - не читайте свій вихідний код, не пусті програми тощо.


2
Правила щодо коментарів?
— Аддісон Кримп

Це те, про що я не думав раніше. Я схильний дозволити їм ковзати, тому що тоді ви повинні турбуватися про друк цього тексту та переконатися, що мова C має той самий синтаксис коментарів чи щось таке, але я гнучка.
— Фараз Массур

Чи означає «не королева» означає «робити щось» або «принаймні бігати»?
— LegionMammal978

1
Коли його поміщають у компілятор, він не виводить свій вихідний код. Він може запускати або видаляти помилку, або не компілювати чи виводити щось інше чи нічого, але поки не виводить свій вихідний код.
— Фараз Масрур

Відповіді:


11

Fission + CJam + GolfScript, 38 36 байт

Ділення , 6 байт

'!+OR"

Це одна з лайків Мартіна Бюттнера . Спробуйте в Інтернеті!

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.

Знайшов іншого Денніса!
— Фараз Масрур

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)

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

@FarazMasroor рядки в Tcl можуть бути оточені дужками, а назви команд - також рядки. А речі в дужках вважаються блоками в GolfScript, які можна надрукувати як є. CJam схожий на GolfScript, але досить інший, щоб звести лайки на одній мові, а не на іншій. За допомогою цих варіантів вибору мов це просто звичайні королеви з додатковим кодом для виведення у потрібному форматі, який ще не є гольфом.
— jimmy23013

3

ShapeScript + CJam + GolfScript, 96 95 62 байт

ShapeScript , 16 байт

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

Це стандартна квітка ShapeScript . Спробуйте в Інтернеті!

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
Використовуючи наш веб-сайт, ви визнаєте, що прочитали та зрозуміли наші Політику щодо файлів cookie та Політику конфіденційності.
Licensed under cc by-sa 3.0 with attribution required.