Build a half cardinal cyclic quine

18

2

A half cardinal cyclic quine is a cyclic quine with two states, one perpendicular to the other.

Rules

You can decide which rotation you want to implement, clockwise or counter-clockwise.

Once rotated, any gaps in your code should be replaced with spaces to preserve the positioning.

Your program must satisfy the community definition of a quine.

This is so the shortest program in each language wins. Your first program is used for your byte count.

Standard loopholes are forbidden.

Examples

If your program is:

$_='print';eval

Then the next iteration must be either:

$
_
=
'
p
r
i
n
t
'
;
e
v
a
l

or

l
a
v
e
;
'
t
n
i
r
p
'
=
_
$

which must output the original program:

$_='print';eval

If your program is:

;$_=';
;$_=';
print

Then the next iteration must be either:

;;
''t
==n
__i
$$r
;;p

or:

p;;
r$$
i__
n==
t''
 ;;

which must output the original program:

;$_=';
;$_=';
print

Dom Hastings

Posted 2018-02-28T20:14:30.967

Reputation: 16 415

Related. – Dom Hastings – 2018-02-28T20:14:52.323

1Somewhat related. – Martin Ender – 2018-02-28T20:17:34.170

So, we pad the code with spaces to keep its shape after turning? – Erik the Outgolfer – 2018-02-28T20:23:12.333

@EriktheOutgolfer Yes, I'll confirm that in the body, thanks! I've also clarified that the first program is the byte-count used. – Dom Hastings – 2018-02-28T20:30:31.090

Is the only difference between this and the post @MartinEnder linked that that is a transpose and this is a rotation? – dylnan – 2018-02-28T20:56:13.530

1@dylnan No, the other one doesn't ask for a mutual quine. – Martin Ender – 2018-02-28T20:57:34.143

1Having seen the answers so far I think the real challenge would be the anticlockwise one or a quine with more than one lines (so that rotation is different from transposition or simply inserting newlines). – Weijun Zhou – 2018-02-28T21:30:02.600

@WeijunZhou Indeed, I'm not sure how feasible it is, but I have a more complex version of this in the sandbox.

– Dom Hastings – 2018-02-28T21:32:35.830

Are the quine and its rotation allowed to be the same? – mbomb007 – 2018-02-28T21:40:58.227

1You might want to require the two programs to be different. Otherwise, quines which happen to have rotational symmetry would be valid answers. – Martin Ender – 2018-02-28T21:41:04.750

And the same applies to the one in the sandbox – mbomb007 – 2018-02-28T21:41:58.283

I really want to see an answer in Python, even if it has symmetry. I'm getting stuck – mbomb007 – 2018-02-28T22:55:38.110

@mbomb007 I'm not sure I feel the programs have to be different, I think a quine that can be rotated would be valid as I feel that might be a challenge on its own. Does that help you compete (not really I'm guessing, by the last comment!), I would love to see a Python solution! – Dom Hastings – 2018-03-01T08:53:02.753

I sure hope no lovely red birds are going to be harmed in the course of this contest... – GNiklasch – 2018-03-01T11:32:52.217

I think another interesting scoring method would be max(width, height) ** 2, so getting your program to be more square would be incentivized. – mbomb007 – 2018-03-01T14:13:28.327

@mbomb007 I quite like that... Perhaps a challenge to create a quine that is the same when rotated 90° using that scoring mechanism? – Dom Hastings – 2018-03-01T14:26:20.133

Answers

14

CJam, 19 17 15 bytes

{s"_~"+N*""-}_~

Try it online! Try the rotation.

Explanation

{s"_~"+  e# Standard quine framework. Puts a string representation of the entire
         e# program on the stack.
  N*     e# Riffle linefeeds into the string, which is effectively a clockwise
         e# rotation by 90°.
  ""-    e# Does nothing.
}_~

In the rotated code, we've got linefeeds everywhere:

{
s
"
_
~
"
+
N
*
"
"
-
}
_
~

As Lynn noticed on Dom's earlier quine challenge inserting linefeeds actually still forms valid quine, because the linefeeds inside the block will just be retained verbatim anyway, and there will also be linefeeds in the "_~" string to make those two characters at the end show up on their own line. So {s"_~"+...}_~ (with linefeeds) is still a valid quine framework (although there'll be an additional linefeed at the end of the string). N* now inserts even more linefeeds into that string, but we don't really care: because now ""- has a linefeed inside that string so it actually removes all linefeeds from the program representation. So we end up with the horizontal form of the code again, undoing the rotation.

Martin Ender

Posted 2018-02-28T20:14:30.967

Reputation: 184 808

5

Stax, 28 bytes

"8H^Hs+2*A]/Mm"8H^Hs+2*A]/Mm

Run and debug the first form

Run and debug the second form

recursive

Posted 2018-02-28T20:14:30.967

Reputation: 8 616

5

><>, 22 bytes

 "2+}>oao#ov*48}}*d3'v

Try it online!

Rotated anti-clockwise:

v
'
3
d
*
}
}
8
4
*
v
o
#
o
a
o
>
}
+
2
"

Try it online!

The first one prints the line in reverse with newlines interspersed, and the second prints it in reverse without the newlines.

Jo King

Posted 2018-02-28T20:14:30.967

Reputation: 38 234

This is very clever! – Esolanging Fruit – 2018-03-01T01:35:19.317

Good going on approaching it on hard mode! – Dom Hastings – 2018-03-01T02:56:20.200

4

05AB1E, 36 34 bytes

4"D6Ø·çýD¶åi¶KëS»"D6Ø·çýD¶åi¶KëS»

Try first iteration or Try next iteration

Emigna

Posted 2018-02-28T20:14:30.967

Reputation: 50 798