# Code point sum quine

All the challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point sum identical to the source's code point sum.

To produce a code point sum:

1. Find the values of the characters in the program's character set.
For example - FOO in ASCII: F = 70, O = 79, O = 79
2. Add them all together.
Code point sum of FOO in ASCII: F+O+O = 70+79+79 = 228.

An example of an ASCII sum quine would be if the source code was ABC and the output was !!!!!!. This is because the sum of the the ASCII values of the source (A = 65, B = 66, C = 67, sum = 198) is the same as the sum of the ASCII values in the output (! = 33, 33*6 = 198). BBB would also be valid output, as would cc.

# Rules

• Your program must not be a reverse, shuffled, error, or any other type of "true" quine. To elaborate: If the output contains all the same characters as the source, it is invalid.
• Your program cannot use any errors/warnings from the compiler/interpreter as the output.
• Your program's source must use the same codepage as the output.
• Your program may use any codepage that was created before this challenge was.
• Your program's output must not contain any unprintable characters (e.g. ASCII 0 through 31, or above 127) aside from linefeeds and tabs.
• Standard loopholes apply.
• If the source and/or output has a trailing linefeed, it must be included in the code point sum.
• Compiler flags need to be included in the final byte count (score), but not the source's code point sum.
• The output/source may not be empty.

# Scoring

Shortest answer in byte count (not code point sum) wins. Please use this header format answers:

# Jelly, 12 bytes, sum 56 (SBCS)


You can use this tool to calculate ASCII sums.

# Reference

Here are some useful codepage references.

/* Configuration */

var QUESTION_ID = 135571; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(a) {
var id = +a.share_link.match(/\d+/);
});
if (!data.has_more) more_answers = false;
comment_page = 1;
}
});
}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(c) {
if (c.owner.user_id === OVERRIDE_USER)
});
else process();
}
});
}

var SCORE_REG = (function(){
var headerTag     = String.raw h\d
var score         = String.raw \-?\d+\.?\d* // with negative/floating-point support
var normalText    = String.raw [^\n<>]* // no HTML tag, no newline
var strikethrough = String.raw <s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del> var noDigitText = String.raw [^\n\d<>]* var htmlTag = String.raw <[^\n<>]+> return new RegExp( String.raw <${headerTag}>+
String.raw    \s*([^\n,]*[^\s,]),.*?+
String.raw    (${score})+ String.raw (?=+ String.raw ${noDigitText}+
String.raw      (?:(?:${strikethrough}|${htmlTag})${noDigitText})*+ String.raw </${headerTag}>+
String.raw    )
);
})();

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
return a.owner.display_name;
}

function process() {
var valid = [];

var body = a.body;
if(OVERRIDE_REG.test(c.body))
body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
});

var match = body.match(SCORE_REG);
if (match)
valid.push({
user: getAuthorName(a),
size: +match[2],
language: match[1],
});

});

valid.sort(function (a, b) {
var aB = a.size,
bB = b.size;
return aB - bB
});

var languages = {};
var place = 1;
var lastSize = null;
var lastPlace = 1;
valid.forEach(function (a) {
if (a.size != lastSize)
lastPlace = place;
lastSize = a.size;
++place;

.replace("{{NAME}}", a.user)
.replace("{{LANGUAGE}}", a.language)
.replace("{{SIZE}}", a.size)

var lang = a.language;
lang = jQuery('<i>' + a.language + '</i>').text().toLowerCase();

languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};
});

var langs = [];
for (var lang in languages)
if (languages.hasOwnProperty(lang))
langs.push(languages[lang]);

langs.sort(function (a, b) {
if (a.uniq > b.uniq) return 1;
if (a.uniq < b.uniq) return -1;
return 0;
});

for (var i = 0; i < langs.length; ++i)
{
var language = jQuery("#language-template").html();
var lang = langs[i];
language = language.replace("{{LANGUAGE}}", lang.lang)
.replace("{{NAME}}", lang.user)
.replace("{{SIZE}}", lang.size)
language = jQuery(language);
jQuery("#languages").append(language);
}

}
body { text-align: left !important}

float: left;
}

#language-list {
float: left;
}

font-weight: bold;
}

table td {
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654">
<div id="language-list">
<h2>Winners by Language</h2>
<table class="language-list">
<tr><td>Language</td><td>User</td><td>Score</td></tr>
<tbody id="languages">

</tbody>
</table>
</div>
<tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>

</tbody>
</table>
</div>

<table style="display: none">
</tbody>
</table>
<table style="display: none">
<tbody id="language-template">
</tbody>
</table>

• Are comments allowed? Jul 25, 2017 at 5:02
• @musicman523 yes, I guess so. Jul 25, 2017 at 5:04
• Why disallow warnings? I feel that's unnecessary. Jul 25, 2017 at 16:55
• @ConorO'Brien Warnings are not allowed to be the output of the program, e.g. no error quines. I guess that's unclear, one minute. Jul 25, 2017 at 16:56
• What's the policy on flags?
– Okx
Jul 25, 2017 at 19:17

# Retina, 1 byte, sum = 58 (ASCII)

:


This counts the matches of : in the input (0), so it prints

0



The code points of :, 0, and LF (linefeed) are 58, 48, and 10 (respectively), and 58 = 48 + 10.

Try it online!

# ArnoldC, 316 bytes, sum 20992 (ASCII)

Fun enough.

IT'S SHOWTIME
HEY CHRISTMAS TREE s
YOU SET US UP 1
HEY CHRISTMAS TREE iaV
YOU SET US UP 0
STICK AROUND s
GET TO THE CHOPPER iaV
HERE IS MY INVITATION iaV
GET UP 8
ENOUGH TALK
TALK TO THE HAND "H"
GET TO THE CHOPPER s
HERE IS MY INVITATION 2048
LET OFF SOME STEAM BENNET iaV
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED


I used this and this to do my calculations. Took me an hour and a half. But fun.

Try It Online!

How it works

STICK AROUND is a loop, that loops 2048 times on the index iaV, but this index steps by 8. So there is 256 loops, printing H and a linefeed (72+10 = 82, 82*256 = 20992).

This is still HIGHLY golfable (by finding other calcs) but it is long and boring to measure your byte sum every time you do a modification.

Please tell me if I'm mistaken anywhere.

• The best ArnoldC answer I've seen. Jul 25, 2017 at 17:25
• @MagicOctopusUrn thanks xD it's my first try on this language (¿¿??!?!? still not sure it is one) Jul 25, 2017 at 17:54
• github.com/samshadwell/TrumpScript is another pointless "language" if you want to emulate the president of the USA. Jul 25, 2017 at 17:55
• @MagicOctopusUrn well ima doing this challenge in trumpscript then. Jul 25, 2017 at 17:59
• So I found out ArnoldC supports unicode output and shaved an additional 2 bytes off. I've posted it separately (with acknowledgement) Jul 26, 2017 at 22:23

# Charcoal, 1 byte, sum = 180 (Charcoal SBCS)

⁴


Try it online! In Charcoal's code page, ⁴ has a code of 0xB4 = 180, while the output is 4 -s which is 4 * 45 = 180.

# Python 2, 11 bytes, sum 838 (ASCII)

print 76**8


prints

1113034787454976


Not very clever but it works

Try it online!

• Great first answer; welcome to the site! I can verify that the ASCII sum is correct. Jul 25, 2017 at 19:44
• This is a polygot, it also works in Groovy, very impressive. Jul 25, 2017 at 19:45
• Great answer, but doesn't the output have a trailing linefeed which has to be added? Jul 25, 2017 at 22:38
• This also works in ruby Jul 26, 2017 at 12:20

# Jelly, 12 bytes, sum 948 (SBCS)

You said:

Jelly, 12 bytes

then it's Jelly, 12 bytes.

\
³³³,:D+++



Was fun, since I don't know Jelly at all.

How it works

I don't have any idea. But ³ does put 100 in the stack, , puts the stack in an array or something, : might concatenate the thing while D lists every letter of the last numeral (which does not exist), and +++ are for fun. The first and last line does not affect the output :)

Try it Online!

Used this to count.

• "I know what ³ and D does, but don't ask me WTF anything else does." - This would also be my write-up if I did a Jelly answer. Jul 25, 2017 at 19:02

# CJam/Japt/bc, 2 bytes, sum 97 (ASCII)

A

Try it Online (CJam), Try it Online (Japt) (thanks @shaggy),

The bc version works on command line, but not TIO.

Outputs 10

Source: A + Space = 65 + 32 = 97

Output: 1 + 0 = 49 + 48 = 97

• This also works in Japt. Jul 25, 2017 at 6:19
• I don't think this works in bc. All versions I know insist on a trailing newline. Sep 27, 2017 at 11:33
• @Dennis I just ran the bc program and then typed in A . Should I call it bc REPL? Oct 4, 2017 at 18:28

# Haskell, 9 bytes, byte sum 743 (ASCII)

Code:

show$29^9  Output: 14507145975869  Try it online! # Cubically, 4 bytes, sum 141 (ASCII) %44E  Outputs 3636. Try it online! And here's the ASCII sum checker I used. Explanation: • % means 'print face sum as integer'. • 4 prints the sum of all values on the BACK face (36) twice. • E is a no-op, just used to get the required sum. • hahaha, take my upvote Jul 25, 2017 at 16:50 Some of these answers contain characters that will likely be invisible to you (particularly ASCII 17), click the TIO links to see their placement. # Klein 100/110, 4 bytes, sum 147 1 @  Try it online! Output: 1 1  # Klein 201, 4 bytes, sum 147 1 @  Try it online! Output: 1 1  # Klein (any topology), 5 bytes, sum 221 (ASCII) 111@  Try it online! This prints 1 1 1  • A thanks to whoever just upvoted this out of the blue. You got me to take a second look at this and now I've improved it a bit. Oct 11, 2019 at 4:23 • @JoKing I'd say post that as your own answer. Its quite smart and is more than just an improvement on what I've done. Oct 11, 2019 at 5:35 # Java 7, 88 85 bytes, sum 78087617 7507 (ASCII) class w{public static void main(String[]H){for(int B=0;B<77;)System.out.print(B++);}}  Almost certainly golfable. It's pretty easy to tweak since we have some spare variables like the name of the class and the name of the program arguments parameter that we can change freely. Test it online! Try it online! # Java 8, 84 bytes, sum 7434 Credit goes to Kevin Cruijssen. interface A{static void main(String[]G){for(int A=59;A-->0;)System.out.print("~");}}  Test it online! Try it online! • Good job, I can verify it works here. Would +1 but I'm out of votes. Jul 25, 2017 at 20:06 • Converting it to Java 8 you can use this: interface A{static void main(String[]G){for(int A=59;A-->0;)System.out.print("~");}} to golf it by 4 bytes and lower it to 7434 as sum. Try it here. and Verify the resulting sum. Sep 27, 2017 at 11:10 • @KevinCruijssen I would like to keep my answer in Java 7 but I have added your Java 8 solution to my answer and credited you. If you'd rather post yourself I can remove your answer from mine. – Poke Sep 27, 2017 at 17:26 # Python 2, 11 bytes, byte sum 854 (ASCII) Code (with trailing newline): print'z'*7  Output (with trailing newline): zzzzzzz  Try it online! • why doesn't the <code> section work? I mean, I can see trailing newline on preview when I edit your post, but we can't see it on the post. Jul 26, 2017 at 7:07 • @V.Courtois Browser differences (e.g. works in Firefox, doesn’t work in Chrome). That’s why I explicitly pointed out the newline. Jul 26, 2017 at 7:10 • ok, seems like it's something I'll have to do next. But why does the second section react well then? :o Jul 26, 2017 at 7:18 # brainfuck, 3 bytes - byte sum 255 (ISO-8859-1) -.¤  Try it online! Requires 8-bit cells. Prints the character ÿ, which is value 255. ¤ is a no-op to fill the sum. # V, 2 bytes, Sum 255 (Latin1)  á  Try it online! Hexdump: 00000000: 1ee1 ..  The first character is ctrl-^, or LATIN1/ASCII code-point 0x1E. The second character is alt-a, or the LATIN1 character 0xE1. This program outputs ÿ, which is 0xFF in LATIN1. How does it work? The first character is a no-op. It has no effect on the program at all. The second character is the append single character command. But we don't specify what character to append. So, due to implicit endings, it appends the character that V uses to signal the program is over, which just so happens to be 0xFF. • Sum and codepage? Jul 25, 2017 at 16:52 • @MDXF That's all in my explanation... Jul 25, 2017 at 16:56 # 05AB1E, 5 bytes, sum 256 (05AB1E Base-255 Translation) ΔTnon  Try it online! This outputs: 1606938044258990275541962092341162602522202993782792835301376 Which, using 05AB1E's code-page results in: [1, 6, 0, 6, 9, 3, 8, 0, 4, 4, 2, 5, 8, 9, 9, 0, 2, 7, 5, 5, 4, 1, 9, 6, 2, 0, 9, 2, 3, 4, 1, 1, 6, 2, 6, 0, 2, 5, 2, 2, 2, 0, 2, 9, 9, 3, 7, 8, 2, 7, 9, 2, 8, 3, 5, 3, 0, 1, 3, 7, 6] Which is: 256 Where the code is: ΔTnon With code-points: [79, 29, 49, 50, 49] Which is: 256 • Which code page is this? This one lists 1 as 49, not 1. Jul 25, 2017 at 18:50 • @Dennis I went with whatever 05AB1E returned for the function base(char, 255), I had assumed (seemingly incorrectly) that they'd be one and the same. Jul 25, 2017 at 18:57 # Taxi, 543 bytes, sum 47124 (ASCII) 374 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 r 1 l 1 l 2 l.Pickup a passenger going to The Underground.'~' is waiting at Writer's Depot.Go to Writer's Depot:w 1 r 1 l 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n.[a]Pickup a passenger going to Cyclone.Pickup a passenger going to Post Office.Go to Zoom Zoom:n.Go to Post Office:w 3 l 2 r 1 l.Go to The Underground:n 1 r 1 l.Switch to plan "R" if no one is waiting.Pickup a passenger going to The Underground.Go to Cyclone:n 3 l 2 l.Switch to plan "a".[R]  The output is 374 tildes ~. # Mathematica, 2 bytes, sum=101 (ASCII) E + Space returns e E  # Mathematica, 2 bytes, sum=105 (ASCII) it works for I, too I + Space returns i I  # Factor, 7 bytes, sum 250 7/2 .  Try it online! Outputs 3+1/2 and a newline. Factor has a rational number type. When an improper fraction (numerator > denominator) is printed, it is converted to a mixed fraction form (integer part + proper fraction part). Since the easiest way to adjust the byte value sum is to add spaces or newlines (which are the only token separators in Factor), I tried various fractions until the code's sum is higher than the output's sum by a multiple of 10, and added a couple newlines at the end. # Jelly, 3 bytes, sum = 152 (ASCII) 58+  Try it online! # Brain-Flak (Rain-Flak), 79 bytes (((((((((((((((((((((((((((((((((()()()()){}){})))))))))))))))))))))))))))))))  Try it online! This prints 16 and a newline 31 times. # Brain-Flak (BrainHack), 55 bytes (((((((((((((((((((((()()()()){}){})))))))))))))))))))#  Try it online! This prints 16 and a space 18 times. # Also 55 bytes ((((((((((((((((((((((()()()){}){}))))))))))))))))))))  Try it online! This prints 12 followed by a space 19 times. • Sum and codepage? Jul 25, 2017 at 16:52 • @MDXF I don't recall the sums but they are all ascii. Jul 25, 2017 at 16:52 • The second and third don't seem right (they print 19 and 20 times the mentioned string), though you can fix them both, see here. Jul 25, 2017 at 21:35 # Vim, 3 bytes, sum 234 (ASCII) 3iN  Output: NNN  Try it online! # Cubix, 20 bytes, code point sum 1505 OuOOQ++OOOOU@>!OOO<  Contains the unprintable character DEL (ascii 127). Q pushes " (the largest constant available in cubix), then repeatedly prints out (O) 68 or 102 enough times to get it to 68686868686868102102102102102 which is 1505; through some trial and error I realized that I needed 81 more points than . (a Cubix no-op and ASCII 46) which resulted in needing DEL, which is still a no-op in Cubix. Try it online! On a cube:  O u O O Q + + O O O O U @ > ! O O O < . . . .  • I saw "Cubix" and read "Cubically", had to catch myself before I gave you a bounty... sigh +1 Jul 25, 2017 at 16:37 • @MDXF challenge accepted Jul 25, 2017 at 16:39 • Beat you :P Jul 25, 2017 at 16:46 # dc, 7 bytes, sum 720 (ASCII) [my]fff  (91+109+121+93+(102*3)=720) Outputs: my my my  ((109+121+10)*3=720) # Carrot, 4 bytes, sum = 279 (ASCII) ]^*2  Try it online! Prints ]]]. • Way ahead of me in this one. I was no where close to getting a correct sum. Jul 25, 2017 at 10:12 • @TheLethalCoder The ASCII sum of ^*3 was 187, so I tried solving x+187=4x, but that resulted in no integer solutions. So I went on to ^*2, which have me 186+x=3x which gave me x as 93, the code point of ]. That was all I did :) Jul 25, 2017 at 10:17 • Ah smart way of doing it :) Jul 25, 2017 at 10:18 • I assume then that ¹^*1 also works. If I did my maths correctly that is. Although that is the unicode value not utf8. Jul 25, 2017 at 10:22 • @TheLethalCoder I'd suppose it depends on the encoding, because Carrot uses ASCII by default. Jul 25, 2017 at 10:25 # Cubically, 3 bytes, sum = 105 (ASCII) %4  The third byte is DLE, which has code point 16, so the code point sum of the source code is 37 + 52 + 16 = 105. The program prints 36  whose code point sum is 51 + 54 = 105. Try it online! • *implements DLE* sorry, invalid. :P +1 Jul 26, 2017 at 2:52 • Oh, I didn't see another Cubically solution here. Whoops! Jul 26, 2017 at 15:42 # Cubix, 11 bytes, byte sum 954 (ASCII) Code: vOw~N(!@O^|  Output: 998877665544332211  Verified here! Try it online! Cubified:  v O w ~ N ( ! @ O ^ | . . . . . . . . . . . . .  • N initializes the stack with 10 • (! decrement and test for truthy • @ on zero halt • O^O output current number redirect to top face and output again • vw redirect back to the ( decrement to begin the loop again Watch it run # INTERCAL, 4746 45 bytes, sum = 2945 (ASCII...?) PLEASE,8<-#38DO,8SUB#8<-#6DOREADOUT,8DOGIVEUP  Try it online! Prints seven null bytes followed by thirty-one underscores. One of six possibilities generated by a somewhat revised awful hacky Python script. # Husk, 4 bytes, sum 334 (Husk SBCS) up63  Output: [3,7]  The value of a digit is given by 0x3? (where ? stands for that digit) and u,p,[,],, have values 0x75,0x70,0x5b,0x5d,0x2c - thus the sums are: 0x75 + 0x70 + 0x36 + 0x33 = 0x14e 0x5b + 0x33 + 0x2c + 0x37 + 0x5d = 0x14e  Try it online! ## JavaScript (ES6), 6 bytes, sum = 385 (ASCII) Y=>1E7  Outputs 10000000. There are other 6 byte answers such as h=>1e8. Try this code point counter: <input oninput=o.textContent=[...this.value].reduce(function(s,c){return(s+c.charCodeAt())},0)><pre id=o>0 # cQuents, 5 bytes, sum 238 (ASCII) #3::$


Outputs 1,2,3, or in cQuents terms, prints the first three terms of the sequence 1,2,3,4,5,6....

Now listen. This was, literally, the first program I tried. The reason I tried it was because this was the program I used for Output with the same length as code. And it freaking worked.

Try it online!

# Gaia, 4 bytes, sum 176 (SBCS)

6 5%


## Explanation

In Gaia's codepage, linefeed has a code point of x7F (127 in decimal). Printable ASCII characters have the same code point as in ASCII.

This computes 6 modulo 5, which is 1, and prints 1 with a trailing linefeed.

Byte values of the characters in the codepage (in decimal):

6 5%: 54 + 32 + 53 + 37 = 176

1: 49 + 127 (linefeed) = 176