22
\$\begingroup\$

Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript:

(x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x)
  • Standard quine rules apply.

  • The score is given by number of bytes in the source code - number of case inversions. For example, the quine above has a score of 29.

  • The program with the lowest score wins. If two programs have the same score then the shorter one wins.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ So non-letters count as 1 byte each no matter what, because they cannot be case-inverted? (Also, please use the sandbox next time.) \$\endgroup\$
    – Bubbler
    Commented Aug 19, 2020 at 3:06
  • 4
    \$\begingroup\$ Yes they do. The challenge is to try to make as much of the program change as possible. Sorry for not using the sandbox. It wasn't letting me post in there for some reason (maybe not enough rep?) \$\endgroup\$
    – user82867
    Commented Aug 19, 2020 at 3:09
  • 5
    \$\begingroup\$ invert the case of as many ascii characters Does that mean that if a unicode character has its case inverted complement, we aren't expected to count that unicode character if we invert it in our output? \$\endgroup\$
    – user96495
    Commented Aug 19, 2020 at 9:40
  • 4
    \$\begingroup\$ Hmm, so theoretically you could get a negative score if you found a language that encoded letters in less than a byte? \$\endgroup\$
    – Jo King
    Commented Aug 19, 2020 at 11:53
  • 7
    \$\begingroup\$ @user253751 Code golf is secondary winning criterion (so currently Gol><> wins over ><>). OP didn't have access to the sandbox when they wrote the challenge (see OP's first comment). \$\endgroup\$
    – Bubbler
    Commented Aug 20, 2020 at 2:24

24 Answers 24

30
\$\begingroup\$

><>, score 479 - 479 = 0

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllbfppllfepeeppppgglcepppbeppppppppppplfdppedpddpgglcdppbdpfcpecpggldcppllccpbcpplfbpebppldbppcbpggcbglefgpgbeglefgpgcbglefgpgggggedglefgpgccglefgpgfdglefgpgebglefgpgecglefgpggdcglefgpgceglefgpgeeglefgpgbcglefgpgfbglefgpgcdgfefgpbdgeefgpfegdefgpccgcefgpfdgbefgpdbgaefgpppddglefgpgbcglefgpgfcglefgpgdbglefgpgdcglefgpgecglefgpgddglefgpgdbglefgplffpbfgffgefgpcbgefgefgp

Try it online!

How it works

Very few useful instructions in ><> are letters. However, we still have the l, pushing the length of the stack to the stack. As such, it's possible to (very verbosely) push arbitrary values to the stack. Thus, strings can be encoded in a similar fashion to brainfuck, using a to increase the length of the stack, and g or p to reduce it.

As per usual quine rules, g is not used to read the source code itself, instead maintaining registers at locations such asbb and bc and so on.

The string encoded is the prefix:

"r&:20&3-:&?.p48*-od0l2)?.;lllll"]"

Which after over 7,000 instructions outputs the original string in upper case.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ @JoKing Made a better encoding, where your version performs better. \$\endgroup\$ Commented Aug 19, 2020 at 12:58
11
\$\begingroup\$

Gol><>, 77 75 - 75 = 0

urassssissezplzelssmzmzpssazmkqjmkrmbrrrrrtsuotlballsssssassmzpsssssbssmzpu

Try it online!

Based on Bubbler's answer, this goes even further by also putting the " at the start of the code to get a score of 0!

Explanation

ur       Move over one on the stack tape and reverse the stack
  assssissez      Push 10+16*4=74,-1+16*2=31,!(15)=0
            p     And put the 74 (J) at position 0,31

lz            Push 0 if there is anything on the stack
  e           Push 14 for later
   lssmzmz    Push 2+16*2=34, !(-1)=0, !(-1)=0
          p   Put the 34 (") at position 0,0

sss           Add 3*16 to the -1 from earlier
   az         Push !(10)=0
     mkq      Some no-ops
        J     And jump to 0,47 if the stack was initially empty

lballsssssassmzp  Put T at position 0,43
sssssbssmzpu      Put S at position 0,44
u                 Move one over on the stack again (effectively resetting the stack)

"                 Wrap, pushing everything to the stack
 r                Reverse
  .........       Put everything again
           J      But this time don't jump, since the stack is not empty

mk           Copy the bottom of the stack (u)
  rm         Push a -1 to the bottom of the stack
    brrrrr   No-ops

T   t      Finally, loop over the stack, 
 Suo       Capitalising then outputting everything until we get to the -1
\$\endgroup\$
3
  • 6
    \$\begingroup\$ The arithmetic reads almost like "ur ass plz"... \$\endgroup\$ Commented Aug 19, 2020 at 13:31
  • 1
    \$\begingroup\$ @SE-stopfiringthegoodguys You may like my most recent golf \$\endgroup\$
    – Jo King
    Commented Aug 20, 2020 at 5:01
  • \$\begingroup\$ @user253751 Similar \$\endgroup\$
    – Jo King
    Commented Aug 20, 2020 at 9:30
11
\$\begingroup\$

80186+ machine code (MS-DOS .COM format), 115-115=0

It was a bit tricky to do this, as I only had access to INC, DEC, PUSH, certain POP variations, POPA, IMUL, and certain conditional jumps. Fortunately, IMUL could do the heavy lifting for this challenge!

I encoded the actual code that does the printing in a series of values that get multiplied together. I compute those values (which get truncated to 16-bit values), store them on the stack which I moved to be just above the code, and then jump to the generated code to print the program's code in the opposite case.

Machine code:

hrXhCNhGUhnPhPwhYkhvLhKwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaPQRjZTUVjfaiQVGARiQSCARiQPQARiQMJARiQJZARiQGuARiQDkARiQAWARpI

Assembler source:

IDEAL
P186

MODEL   TINY
CODESEG
ORG 100H

MAIN:
        ; Encoded code:
        ;   MOV SI,100H
        ;   MOV CX,73H
        ; PRINT:
        ;   LODSB
        ;   XOR AL,20H
        ;   INT 29H
        ;   NOP
        ;   LOOP PRINT
        ;   INT 20H
               ; Offset Bytes Multiplier
    PUSH 5872H ; +41    BE 00 4157H
    PUSH 4E43H ; +44    01 B9 416BH
    PUSH 5547H ; +47    73 00 4175H
    PUSH 506EH ; +4A    AC 34 415AH
    PUSH 7750H ; +4D    20 CD 414AH
    PUSH 6B59H ; +50    29 90 4151H
    PUSH 4C76H ; +53    E2 F8 4143H
    PUSH 774BH ; +56    CD 20 4147H

REPT 30
    POPA ; Adjust stack to point to end of generated code
ENDM

    PUSH AX
    PUSH CX
    PUSH DX
    PUSH 5AH
    PUSH SP
    PUSH BP
    PUSH SI
    PUSH 66H
    POPA ; Use POPA as POP DX and POP DI are not in [A-Za-z]
    IMUL DX,[BX+DI+56H],4147H
    PUSH DX
    IMUL DX,[BX+DI+53H],4143H
    PUSH DX
    IMUL DX,[BX+DI+50H],4151H
    PUSH DX
    IMUL DX,[BX+DI+4DH],414AH
    PUSH DX
    IMUL DX,[BX+DI+4AH],415AH
    PUSH DX
    IMUL DX,[BX+DI+47H],4175H
    PUSH DX
    IMUL DX,[BX+DI+44H],416BH
    PUSH DX
    IMUL DX,[BX+DI+41H],4157H
    PUSH DX
    JO $+4BH ; Jump to start of generated code

END MAIN
ENDS
\$\endgroup\$
4
  • \$\begingroup\$ Would it be too restrictive to use only one case (upper or lower)? \$\endgroup\$
    – Bubbler
    Commented Aug 20, 2020 at 23:26
  • \$\begingroup\$ @Bubbler: Probably uppercase-only would work, but it would be quite lengthy, as only INC, DEC, PUSH, POP and POPA would be available. I'll try that approach, though, and see if I can get it to work! \$\endgroup\$
    – ErikF
    Commented Aug 21, 2020 at 0:09
  • \$\begingroup\$ Sounds impossible if you don't have jumps (unless you can somehow force the memory layout to work without jumps...) \$\endgroup\$
    – Bubbler
    Commented Aug 21, 2020 at 0:16
  • 1
    \$\begingroup\$ @Bubbler: You can either write a long enough program that enters the stack normally, or adjust the stack with POPA by underflowing the stack! \$\endgroup\$
    – ErikF
    Commented Aug 21, 2020 at 0:17
8
\$\begingroup\$

Gol><>, score 34 - 33 = 1

"mrllssslssscsmzpdsmzprrrrrrtsuota

Try it online!

Outputs the following and exits by error, which is every char uppercased except the leading ".

"MRLLSSSLSSSCSMZPDSMZPRRRRRRTSUOTA

How it works

The lines marked with * are the differences from the previous version.

"..."    Push every char except `"`
mrl      Push -1, reverse stack, push stack length (34 = `"`)
* lsss   Push stack length (35) and add 16 three times (83 = S)
* lsss   Push stack length (36) and add 16 three times (84 = T)
* csmzp  Push 13, add 16 (29), push -1, boolean negate (0), and
         replace the command at (29,0) by T
* dsmzp  Push 14, add 16 (30), push -1, boolean negate (0), and
         replace the command at (30,0) by S
* rrrrrr  Reverse the stack 6 times;
          no-op to move the positions to overwrite
TSuot    Infinite uppercase-print loop; halt by error at -1
a        Not executed

Gol><>, score 34 - 31 = 3

"mrlTSuotaaaaaaaaaaaaaaaaaaaaaaaaa

Try it online!

Outputs the following and exits by error.

"MRLTSUOTAAAAAAAAAAAAAAAAAAAAAAAAA

Every lowercase letters are uppercased, so the only chars that are not modified are "TS.

How it works

"..."  Start string literal, push every char in the source code (except `"`),
       wrap around and end string literal
mr     Push -1 and reverse the stack
       (setup the chars for printing from top, and bury the trap at the bottom)
l      Push length of stack, which gives 34 == `"`
T...t  Infinite loop until it errors in the middle:
 Su     Uppercase the char at the top (errors when trying to uppercase -1)
 o      Pop and print as char
a...   Not reached

I suspect 2 or lower might be possible.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You can probably get 0 through some careful putting and Jumping? \$\endgroup\$
    – Jo King
    Commented Aug 19, 2020 at 8:11
  • 1
    \$\begingroup\$ Like this! \$\endgroup\$
    – Jo King
    Commented Aug 19, 2020 at 10:12
  • \$\begingroup\$ @JoKing Wow, awesome. You definitely should post it as your own answer. \$\endgroup\$
    – Bubbler
    Commented Aug 19, 2020 at 12:41
7
\$\begingroup\$

V (vim), score 3

2i2I

Try it online!

4 bytes with 1 case inversion. Twice inserts (2i) the string 2I.

\$\endgroup\$
5
  • \$\begingroup\$ You need an escape character at the end for this to work. What you have now just writes 2I. <esc> completes the i insert so the initial 2 can be used to double the insertion to 2I2I. \$\endgroup\$
    – Noodle9
    Commented Aug 19, 2020 at 9:40
  • 2
    \$\begingroup\$ @Noodle9 In vim, yes, but this is V. V escapes implicitly at the end. \$\endgroup\$
    – Dingus
    Commented Aug 19, 2020 at 9:42
  • \$\begingroup\$ Oh, didn't realise there's a language V, will check it out - thanks! :-) \$\endgroup\$
    – Noodle9
    Commented Aug 19, 2020 at 9:45
  • 1
    \$\begingroup\$ You could get a slightly better score if unicode characters were allowed to be lowercased: ñéÑ"qpxVUllvulllllvlu would have a score of 1 Try it online! \$\endgroup\$
    – DJMcMayhem
    Commented Aug 19, 2020 at 20:45
  • \$\begingroup\$ @James Cool! If Unicode characters end up being allowed then you should definitely post your own answer. \$\endgroup\$
    – Dingus
    Commented Aug 20, 2020 at 0:04
6
\$\begingroup\$

Husk, Score = 3 2

foccmawSeohs"foccmawseohs

Try it online!

So many letters!

Thanks Dominic van Essen for -1 to the score.

Explanation

The standard quine in Husk is S+s"S+s": it takes the string S+s, and concatenates it with its version surrounded by quotes. The swapcase command \ would be easy to add here, but being an escape character as well it needs to be doubled inside the quoted string, resulting in too many unswappable character for my tastes.

What we do instead is convert each character to uppercase (with the conveniently lowercase builtin a), and then we just need to make sure to use only lowercase letters as much as possible. We can get rid of a final " by using h (init) on the quoted string, then the rest of the code is devoted to getting rid of that + symbol to concatenate strings.

foccmawSeohs"foccmawseohs
            "foccmawseohs    A string
       Se                    put it in a 2-elements list
         ohs                 with the quoted version of itself, minus the last quote
      w                      Join the two strings with a space
    ma                       Convert each character to uppercase
f                            And keep only those characters that are truthy when...
 occ                          converted to charcode and back

The last part is just an identity function (but I would be uppercase), and spaces are falsy in Husk, so we are just keeping all non-space characters in the string.

I'd love to get rid of the S but I don't see how, and I don't think it is possible to have a quine without quotes, barring convoluted conversions from numbers that would score terribly in this challenge... (Prove me wrong and you get a bounty!)

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Easy score of 2 by lowercasing the second capital "S"... \$\endgroup\$ Commented Mar 16, 2021 at 7:32
  • \$\begingroup\$ Yeah, one would have to be pretty dumb to miss that :D \$\endgroup\$
    – Leo
    Commented Mar 16, 2021 at 7:33
5
\$\begingroup\$

05AB1E, 16 - 6 = 10

0"D34çýu"D34çýu

(trailing newline)

Explanation

0"D34çýu"D34çýu # full code
0"D34çý "D34çý  # standard 05AB1E quine
       u      u # uppercase string in stack
                # implicit print

Not the best golf, but it is my first golf so have mercy please.

Try It Online!


05AB1E (legacy), 16 - 8 = 8

0"D34çýš"D34çýš

(trailing newline)

Explanation

0"D34çýu"D34çýu # full code
0"D34çý "D34çý  # standard 05AB1E quine
       š      š # switch case builtin
                # implicit print

Thanks to Kevin Cruijssen for -2 score. Doesnt work with current 05AB1E becuase the switch case function is which makes the byte count larger

Try It Online!

\$\endgroup\$
3
  • \$\begingroup\$ Too bad (switch case builtin) only works on ASCII letters a-zA-Z in the new version of 05AB1E. You can however improve your score by switching to the older legacy version of 05AB1E, and use š instead of u: 0"D34çýš"D34çýš, which also switches the unicode letters çýš. Btw, I think your current score is actually 16-2=14, since only the two u are U in your output, and everything else is the same. The new score would become 16-8=8. Nice first answer regardless, and welcome to CGCC! :) \$\endgroup\$ Commented Aug 20, 2020 at 15:06
  • 1
    \$\begingroup\$ The output on TIO for me is 0"D34ÇÝU"D34ÇÝU... Does the ÇÝ case inversion not count? Also, thanks for the suggestion! \$\endgroup\$
    – the-cobalt
    Commented Aug 20, 2020 at 16:35
  • \$\begingroup\$ Ah sorry, I saw it incorrectly. It does indeed count. I thought u only worked with ASCII letters, but apparently I was mistaken. You can still lower your score by 2 by changing the language to 05AB1E (legacy) and changing both u to š, which is the switch-case builtin. :) In the new 05AB1E version this would be instead, which make the byte-count larger. \$\endgroup\$ Commented Aug 20, 2020 at 16:39
5
\$\begingroup\$

Ruby, score 24 20 16 12 11

Saved a byte thanks to a comment by @Sisyphus on another answer.

eval S="print'EVAL s=%p'%S.swapcase"

Try it online!

36 bytes with 25 case inversions. The case of every letter is changed in the output.

\$\endgroup\$
5
\$\begingroup\$

JavaScript (browser), score 4, 224 bytes

eval(atob`IGMgPWAnYCwgZXZhbChTPSdrPSAgIkVWQUwoQVRPQmAiOyAgIGZvcihkICBvZiAgYnRvYSgiIGMgPWAiICtjKyAiYCwgZXZhbChTPSIrYytTICtjKyIpIikpayArPWRbYHRvJHtkPHsgfSAgPyJMbyIrInciOiJVcHAifWVyYCArIGBDYXNlYCBdKCkgOyBhbGVydChrKyJgKSIgKScp`)

Try it online!

atob and btoa are functions that convert a string of bytes from/to base64 respectively. They only exist in browser JS, so in the above TIO link which uses node.js I've polyfilled them, and I've also taken the liberty of using alert for output. This evaluates some base64'd code which is carefully manipulated to only use letters when encoded with the base64 table ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/.

Base64 maps groups of three bytes to four base64 chars, and if we consider some triplet of printable ASCII bytes with binary digits abcdefgh ijklmnop qrstuvwx, they get mapped to the base64 values abcdef ghijkl mnopqr stuvwx:

  • Since the 0 in the base64 table is at index 52, we want all four parts to have a binary value less than 52.
  • As abcdefgh is in the printable ASCII range, it's at most 126, so abcdef is at most 31 and will always be a letter.
  • ghijkl will be >= 52 if gh is 11, i.e. abcdefgh mod 4 is 3 and abcdefgh is among #'+/37;?CGKOSW[_cgkosw{, as long as ijkl is at least 4 i.e. ijklmnop is at least 64.
  • mnopqr will be >= 52 if mnop is >= 13, i.e. ijklmnop is among -./=>?MNO]^_mno}~.
  • stuvwx will be >= 52 if qrstuvwx is among 456789:;<=>?tuvwxyz{|}~

So, for a triplet b1 b2 b3 to have only letters in its base64:

  • b1 can be anything, but if it is one of #'+/37;?CGKOSW[_cgkosw{, b2 must be among !"#$%&'()*+,0123456789:;<
  • b2 can't be among -./=>?MNO]^_mno}~
  • b3 can't be among 456789:;<=>?tuvwxyz{|}~

It turns out to be feasible (albeit annoying) to write meaningful JavaScript under this source restriction. The eval'd code is (linebreaks added for clarity):

 c =`'`, eval(S='k=  "EVAL(ATOB`";   for(d  of  btoa(" c =`" +c+ "`, eval(S="+c+S +c+")"))
k +=d[`to${d<{ }  ?"Lo"+"w":"Upp"}er` + `Case` ]() ; alert(k+"`)" )')

This assigns a single quote to c and then assigns the following string to S and evaluates it:

k=  "EVAL(ATOB`";   for(d  of  btoa(" c =`" +c+ "`, eval(S="+c+S +c+")"))
k +=d[`to${d<{ }  ?"Lo"+"w":"Upp"}er` + `Case` ]() ; alert(k+"`)" )

This takes S and inserts it into the above c = "'", eval(S='[S]'). It then base64s and swapcases the entire thing, inserts it into EVAL(ATOB`string`), and alerts it.

The source restriction makes things quite tricky - in particular, the characters = and > can only appear as the first character of a triplet, so I can't use => to write arrow functions. As such, instead of using replace or map, I've used a for loop to iterate over every char of the base64'd string. ='s restrictions have been a particular thorn in my side, as it's used six times in the compressed code and the segments between each one can only be shortened by multiples of three bytes.

All the funky whitespace is to accomodate for this source restriction, but aside from that this has been surprisingly usable. for, eval, alert and btoa are all usable at at least one shift, and I can just chuck "EVAL(ATOB`" straight into the source code. I wouldn't be surprised if there's a few bytes to shave here, but certain constraints make this very annoying to golf further.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ So glad I lost steam trying to hack this together myself--that's some really impressive golf underneath the b64! \$\endgroup\$ Commented 1 hour ago
4
\$\begingroup\$

JavaScript (Node.js), 70 - 38 = 32

f=x=>`f=${f}`.replace(/(.)/g,y=>y<'`'?y.toLowerCase():y.toUpperCase())

Try it online!

BTW: This is my first contribution and I'm a bit confused. I made sure to swap every possible character. The example only uppercases. If you don't need to actually swap cases, then one can get 11-0=11 with a simplified variant of an answer given above:

f=x=>"f="+f
\$\endgroup\$
2
  • 3
    \$\begingroup\$ Welcome to CGCC and congratulations on a great first answer! You're right that there's no requirement to change all (or any) of the cases, so your second 'simple quine' indeed beats the first one according to the scoring system. However, you can improve your score by at least swapping one character: ```f=x=>"F="+f```` scores 10 (since the first 'f' changes case)... \$\endgroup\$ Commented Aug 22, 2020 at 13:33
  • \$\begingroup\$ Woah, good point. Thanks! \$\endgroup\$ Commented Aug 28, 2020 at 19:55
4
\$\begingroup\$

05AB1E, Score = very big number - very big number 4508 - 4508 = 0

XaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXODTnBsbRvTTTTngmngmnngmngDUTnBsTTnnngmgTnBsTTTngmnnnngmgDVTnBsTTTnnngmngmngTnBsYTnBsTXmRykTnBXaKsYTnBsJ

Try it online!

EDIT: Can now finish in the lifetime of the universe!

Explaination:

XaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOOXaODOOXaODOOXaODOOXaODOXOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOOXaODOXOXaODOOXaODOXOXaODOXOXaODOOXaODOXO
            pushes 395523372811533155555555231622231622232316222316395655233728555523232316221655233728555555231622232323231622163957552337285555552323231622231622231655233728605523372855592253342055233759104628605523372845
D           duplicate it
TnB         and convert one of the duplicated to base 10^2 = 100, which is this code case inverted
s           swap, moving to front the number
b           convert it to binary
R           and reverse the binary
v           for each digit
 TTTT       push 10,10,10,10^1
 n          square, 10,10,10,10^2
 g          length, 10, 10, 10, 3
 m          exponent, 10,10,10^3
 n          square, 10,10,10^6
 gm         10^length, 10,10^7
 n          square, 10, 10^14
 n          square, 10, 10^28
 gm         10^length, 10^29
 n          square, 10^58
 g          59
 DU         duplicate and save in variable X
 TnB        convert to base 100, "x"
 s          and swap, so the stack is "x", "<string>"
 TTnnngmg   push 10, in the same way as 59
 TnBs       convert from base 100 and swap, so the stack is "x", "A", "<string>"
 TTTngmnnnngmg  push 50, in the same way as 59 and 10
 DV          save in variable Y
 TnBs       convert from base 100 and swap, so the stack is "x", "A", "o", "<string>"
 TTTnnngmngmng  push 39
 TnBs      convert from base 100 and swap, so the stack is "x", "A", "o", "d", "<string>"
 Y         push variable Y, 50
 TnBs      convert from base 100 and swap, "x", "A", "o", "d", "o", "<string>"
 TXmRyk    X if the current bit is 0, else 0
 TnBXaK    convert from base 100 and remove zeros, "X" if the value is 0 else ""
 sYTnBs    add "o" again
 J         join everything
\$\endgroup\$
3
\$\begingroup\$

Python 2, Score 52 - 33 = 19

s='S=%r;PRINT S%%S.SWAPCASE()';print s%s.swapcase()

Try it online!

Case inverts every letter in the quine.

\$\endgroup\$
3
\$\begingroup\$

Perl 5, 37 bytes, 20 swapped case, Score 17

Thanks to @Dominic van Essen for -1!

eval($a=q{print uc"eval(\$a=q{$a})"})

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Rearranged a bit to get 37 with 20 swapped = score 17. \$\endgroup\$ Commented Aug 19, 2020 at 9:39
  • \$\begingroup\$ @DominicvanEssen Nice one, thank you! I was hoping to get something working with: the printf+qw()x2 approach, but %S doesn't work... Also looked as using letters as delimeters (q z...z) but the nesting is problematic, didn't think to rearrange though... :) \$\endgroup\$ Commented Aug 19, 2020 at 12:00
  • 1
    \$\begingroup\$ Are you sure? I still count 17 non-letter characters... \$\endgroup\$ Commented Aug 19, 2020 at 13:50
  • \$\begingroup\$ @DominicvanEssen that'll teach me to count the chars in a browser window, \$ doesn't count :P \$\endgroup\$ Commented Aug 19, 2020 at 14:07
3
\$\begingroup\$

Vyxal, 732 bytes, score 0

uTuJuJnJnJnJnJuTuJuJnJuJuTuJnJuJnJnJuTuJnJnJuJuJuJuTuJnJuJnJuJuTuJnJuJuJuJuJuTuJnJuJuJnJuTuJuJuJnJuJuTuJuJuJuTuJnJuJnJnJuTuJnJuJnJuJuTuJnJuJnJuJuTuJnJuTuJnJuJnJuJuTuJuJnJuJuJuTuJnJuJnJuTuJuJnJuJuJuTuJnJnJnJuTuJuJuJuJuTuJuJnJnJnJuTuJnJuJuTuJnJuJnJuTuJuJnJuJnJuTuJnJuJuTuJnJnJnJuJnJuTuJnJnJuJuJuTuJnJnJnJuJnJuTuJnJuJnJuJuTuJuJuJuTuJuJnJuJuTuJnJuJuTuJnJnJnJuJnJuTuJuJuJuTuJnJnJnJuJnJuTuJnJnJuJuJuTuJnJnJnJuJnJuTuJuJuJuTuJnJnJuJuJuTuJnJuJnJuJuTuJnJnJnJuJuJuTuJuJuJnJuJuTuJuJuJuJuTuJnJnJuJuJuTuJuJuJuTuJuJnJuJuTuJnJuJuTuJnJnJnJuJnJuTuJnJnJuJuJuTuJnJnJnJuJnJuTuJuJuJuTuJnJnJuJuJuTuJnJnJnJuJuJuTuJuJuJuJuTuJnJuJnJuJuTuJnJnJnJuTuJuJuJuJuTuJnJuJuTuJnJuJnJnJuTuJnJnJnJuJnJuTuJnJnJuJWnuNvVwDhuvvcvBkBipyfkAfItIvhnfIhItIhtvJDpthnfItIhtJpvipfuIj

Try it Online!

This hurt my brain.

The standard way to do this sort of restricted quine, using only the ASCII letters, is to:

  • Push a list of numbers to the stack, encoding the rest of the code
  • Have the rest of the code reconstruct the code pushing those numbers, and itself

However, it's a bit more complicated than that. Vyxal's set of built-in constants includes kL, the concatenation of the lowercase and uppercase alphabets, so we can just index each number into that to recover the rest of the source code, but actually generating those numbers with this builtin set is the problem. The numbers need to be encoded in a way that:

  • Ideally, is as compact as possible
  • Can be easily decoded using the limited set of builtins available, which is not particularly powerful.

We have no access to string, number or list literals, or pretty much any form of arithmetic, but we can still construct lists with the J and p builtins, which respectively append/prepend two values. We also have the single-char constants u and n, which push -1 and the lowercase alphabet respectively (don't ask).

One way to encode numbers would be to map each number to that many copies of -1 - e.g. 5 -> [-1, -1, -1, -1, -1], which can be generated with u uJ uJ uJ uJ - push -1, and append another four -1s. However, part of the program needs to be able to take this array and reconstruct the code that generated it, and this is somewhat annoying to do with this method as the first u is different: we'd need to to remove the first -1, replace all the rest with uJ, then prepend a u. A smarter way to do this would be to use e.g. [0, -1, -1, -1, -1], and map 0 to [some code generating a 0] and -1 to uJ (append -1).

However, that approach still requires amounts of code proportional to each number included. Instead, we can encode each number in binary, and decode it with the B builtin. The approach I ended up going with was mapping 0 to the lowercase alphabet and 1 to -1, then prepending -3, which can be created with uT (T is triple). This results in a list like [-3, -1, alphabet, alphabet, -1] encoding 0b1001 == 9, and to reconstruct it we map -3 to uT, -1 to uJ and alphabet to nJ. This can be accomplished by replacing (V) alphabet with 1 and indexing into the list ["uT", "nJ", "uJ"].

Constructing this list is somewhat annoying. We have access to the builtins kA (uppercase alphabet) and n (lowercase alphabet); I, which cuts a list of characters into two pieces, and h and t which get the first and last items of a list respectively (along with J and p from before to concatenate). With this, it's not too hard to construct

kAfI                             # Split uppercase alphabet in half - ["ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"]
    tI                           # Get the second half and halve it - ["NOPQRST","UVWXYZ"]
      vh                         # Get the first item of each - ["N","U"]
        nfIhI                    # first half of lowercase alphabet in half - ["abcdefg","hijklm"]
             tIht                # last of first half of second item - "j"
                 vJ              # append to each - ["Nj","Uj"]
                   Dpth          # Grab the "U" from the previous
                       nfItIht   # Last char of first half of second half of lowercase alphabet - "t"
                              Jp # Append to the U and prepend - ["Ut","Nj","Uj"]

The final piece of the puzzle is the case swapping. While Vyxal's case swap builtin N is available, it's shorter to just construct the data code flipped and also flip the decoding. Then, it's just a matter of decoding everything:

WnuNvVwDhuvvcvBkBipyfk...pvipfuIj
W                                 # Wrap all pushed data into an array
    vV                            # Over each, replace
 nuN                              # alphabet with -1

         uvvc                     # Check if each is -1 - -1 -> 1, alphabet/-3 -> 0
             vB                   # Convert each from binary
               kBi                # Index each into uppercase+lowercase alphabet
      wDh         py              # Swap to another copy of the data (no stack manip = pain)
                     k...p        # Construct ["Ut","Nj","Uj"] (from befor)
                    f     vi      # and index each value into that   
                            pf    # Prepend to the original data and flatten
                              uIj # And concatenate
\$\endgroup\$
2
\$\begingroup\$

Keg, score 4

`④`④

Try it online!

4 bytes with 0 case conversions.

The standard quine without case conversion easily beats any Keg approaches that would have case conversion: by the time you've thrown case conversion techniques into the mix, you might as well have just written a standard quine with no fancy details.

\$\endgroup\$
2
\$\begingroup\$

Javascript, 27 - 13 = 14

f=x=>`f=${f}`.toUpperCase()

Try It Online!

\$\endgroup\$
2
\$\begingroup\$

R, score = 78 - 53 = 25

a='a=%s;cat(toupper(sprintf(a,squote(a))))';cat(toupper(sprintf(a,sQuote(a))))

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ I think there is an issue with the quotes: the source code uses quotation marks (U+0022) but sQuote gives "fancy" single quotation marks (U+2018 and U+2019). Using dQuote(a,F) instead works on my computer (at a cost of +3 points), but not on TIO for some reason. \$\endgroup\$ Commented Mar 15, 2021 at 8:46
  • \$\begingroup\$ @RobinRyder - I think this is an effect of the default locale configured on TIO: I've added a header to reset to the less-'fancy' 'C' locale for everything, and it now seems to work (as it does on my own local R instance). Thanks for spotting this. \$\endgroup\$ Commented Mar 15, 2021 at 9:22
  • \$\begingroup\$ Looks good now. BTW, congrats on 10k rep! \$\endgroup\$ Commented Mar 15, 2021 at 9:27
2
\$\begingroup\$

Japt, score 16 - 6 = 10

Sadly, a standard quine with no toggling scores the same (10 bytes), but this is way more fun. Every letter is toggled.

"i34d¹²u"i34d¹²u 
"i34d¹²u"        // Take this string, shortly just the program string after the quote
         i       // Prepend
          34d    // a quote char,
             ¹   // and then (closing parens)
              ²u // repeat the result twice and uppercase it.

Try it here.

\$\endgroup\$
2
\$\begingroup\$

Vyxal, 10 bytes − 8 inversions = score 2

`NDqp`NDqp

Try it Online!

\$\endgroup\$
1
\$\begingroup\$

Python 3.8 (pre-release), 44 - 25 = 19 bytes

SwapCase all the char of the quine leaving only the non-alpha chars unchanged

exec(a:="input('EXEC(A:=%r)'%a.swapcase())")

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Haskell, score 29

import Data.Char;main=putStr x>>print x;x=map toUpper"import data.char;main=putstr x>>print x;x=map toupper"

Try it online!

The non-flipped bytes are:

 D.C;=S >> ;= U" .;= >> ;= "

\$\endgroup\$
1
\$\begingroup\$

Uiua, score 32 - 28 = 4

&pfabsjoibyrepr"&pfabsjoibyrepr"

Try it: Uiua pad

There are shorter quines but this way I'm able to avoid non-alphabet characters by using repr to surround the string in quotes, rather than using a $ raw string which ends up with a score of 6.

I think score 1 may be possible. You can get arbitrary strings by indexing into the Lorem ipsum constant and adding to the characters, e.g. addfloetafirLorem gives M, so in theory the only character which should be necessary is the & in &pf.

\$\endgroup\$
0
\$\begingroup\$

Python 2, 43 - 27 = 16 bytes

a="print'A=%r;EXEC A'%a.swapcase()";exec a

Try it online!

Same answer than my Python 3 solution ... but ths time I can remove the parenthesis of the exec function and the print function (costing one char for the trailing newline)

\$\endgroup\$
0
\$\begingroup\$

JavaScript (Node.js), 11 bytes, 10 score

f=x=>'F='+f

Try it online!

Trivial and silly.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.