text:
Code point sum quine
All the quine 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:

Find the values of the characters in the program's character set.
For example - FOO in ASCII: F = 70, O = 79, O = 79
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.

ASCII table
UTF-8 table
UTF-16 table
EBCDIC table
Jelly SBCS table
CP-1252 table
ISO-8859-1 table

/* 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 */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  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;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

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 = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

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

  });

  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;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery('' + a.language + '').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)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  float: left;
}

#language-list {
  padding: 10px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654">

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}

{{LANGUAGE}}	{{NAME}}	{{SIZE}}

Are comments allowed?

@musicman523 yes, I guess so.

Why disallow warnings? I feel that's unnecessary.

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

What's the policy on flags?

@Okx Compiler flags need to be included in the final byte count, but not the source's code point sum. I've updated to include this in the post.

@MDXF why is this impossible in Lenguage :c

@V.Courtois It should be technically possible, if nothing simpler works you can always do a full quine construction. Of course full quine constructions are awkward and verbose already in the base brainfuck...

@ØrjanJohansen Yeah ... quine does exist in Lenguage but I can't find a way to get a small quine.

If an empty program outputs nothing (not even a linefeed), is that valid?

@Mego No, it's not. I meant to include that in the rules, which I've updated.

Does our output need to be deterministic?  That is: Is it ok if my program randomly outputs one of several output but always outputs something with the proper sum?

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.

@MagicOctopusUrn thanks xD it's my first try on this language (¿¿??!?!? still not sure it is one)

https://github.com/samshadwell/TrumpScript is another pointless "language" if you want to emulate the president of the USA.

@MagicOctopusUrn well ima doing this challenge in trumpscript then.

@MagicOctopusUrn done

Golfed down to 187 bytes: Try it online! sum is 12300. You don't need the second variable at all... and given the var s is used 4 times, changing the character gives you a lot of leverage to merge answers.

@TemporalWolf well done! I do think (seeing how much it is different) you can post it for you :)

So I found out ArnoldC supports unicode output and shaved an additional 2 bytes off. I've posted it separately (with acknowledgement)

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.

This is a polygot, it also works in Groovy, very impressive.

Great answer, but doesn't the output have a trailing linefeed which has to be added?

This also works in ruby

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.

I don't think this works in bc. All versions I know insist on a trailing newline.

@Dennis I just ran the bc program and then typed in A . Should I call it bc REPL?

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.

Haskell, 9 bytes, byte sum 743 (ASCII)
Code:
show$29^9

Output:
14507145975869

Try it online!

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.

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

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

Java 7, 88 85 bytes, sum 7808 7617 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.

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.

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

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

@V.Courtois Browser differences (e.g. works in Firefox, doesn’t work in Chrome). That’s why I explicitly pointed out the newline.

ok, seems like it's something I'll have to do next. But why does the second section react well then? :o

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.

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

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?

@MDXF That's all in my explanation...

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.

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

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]

Try it online!   (Score verification)
The output is 374 tildes ~.

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?

@MDXF I don't recall the sums but they are all ascii.

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.

Vim, 3 bytes, sum 234 (ASCII)
3iN

Output:
NNN

Try it online!

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.

@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 :)

Ah smart way of doing it :)

I assume then that ¹^*1 also works. If I did my maths correctly that is. Although that is the unicode value not utf8.

@TheLethalCoder I'd suppose it depends on the encoding, because Carrot uses ASCII by default.

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

@MDXF challenge accepted

Beat you :P

dc, 7 bytes, sum 720 (ASCII)
[my]fff

(91+109+121+93+(102*3)=720)
Outputs:
my
my
my

((109+121+10)*3=720)

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

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

Oh, I didn't see another Cubically solution here. Whoops!

INTERCAL, 47 46 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.

Labyrinth, 6 bytes, sum 271 (ASCII)
92
9!@

Try it online!
Outputs 92299 (the number 92, then the number 299, without separators).
I experimented with small layouts that print some digits in the code twice until I got
99
9!@

whose output's ASCII sum is 7 higher than code's. Decreasing a digit on the top row by one decreases two digits in the output, which leads to the solution above.

Ly, 10 5 bytes, byte sum 679 381 (ASCII)
97^u:

Outputs:
4782969

Try it online!

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)>
0

Whitespace, 105 bytes, sum 2232 (ASCII)

Well you can't see the code but it's here ._.
I did put two <tab>s at the end (that doesn't affect the program) to match sum.
Explanation
The program counts from 1 to 24. I used the example you can find in this tutorial at the Annotated Example section.
For those who don't want to check this tutorial:
It puts your number onto the stack, then loop until <line10>'s number is reached by the number on the stack. The loop prints your number on the stack to stdout, increments it by 1, and puts a space and a linefeed.
Try it online!
Counted with this.

Cubically (6 bytes, sum 309)
I thought I'd do this in your language just for fun. Turns out the solution is pretty simple since % can print out up to two characters for every one character.
F1%441

Output:
363621

You seem to like Cubically :D +1

@MDXF It's a fun language! Plus, aside from BF, it's the only esoteric language I'm familiar with.

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!

Help, WarDoq!, 5 bytes, sum 1052 (Latin1)
l³ÿÿÿ

Prints
Hello World

Try it online!
Help, WarDoq! can add two numbers and test for primes, so it is considered as a valid programming language per this meta post.

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

Trumpscript, 131 bytes, sum 10600 (ASCII)
They wants to make war 110000000;make dark 10000000;as long as,dark less war;:make dark,dark plus 1000000;say "00"!america is great

Is this real life?
Check with this.
Thanks @MagicOctopusUrn for telling me that exists.

PHP, 12 9 bytes, sum 481
<?=10**9;

prints 1000000000
Try it online.
other solutions:
PRINT 5**19;    # 12 bytes, sum 731, output 19073486328125
Print 4/31;     # 11 bytes, sum 815, output 0.12903225806452
Print 8/7;      # 10 bytes, sum 774, output 1.1428571428571
<?=5<<29;       #  9 bytes, sum 523, output 2684354560

ArnoldC, 185 bytes, sum 14508
IT'S SHOWTIME
HEY CHRISTMAS TREE i
YOU SET US UP 6
STICK AROUND i
TALK TO THE HAND "२"
GET TO THE CHOPPER i
HERE IS MY INVITATION i
GET DOWN 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

Try it online!
Code sum
Output sum
Special thanks to V. Courtois and their answer, in particular for providing the sum count scripts.
Pseudocode:
start
var i
i = 6
while i
    print "२\n"
    i
    = i
        - 1
    (end assignment)
(end loop)
(end program)

At this point, I don't see a way to further golf it, as the rest is boilerplate for ArnoldC... ArnoldC surprisingly supports unicode output, so it was just finding a unicode character which, when repeated 5 times, summed to the same as the code.

If printable unicode is off-limits:
ArnoldC, 187 bytes, sum 12300
IT'S SHOWTIME
HEY CHRISTMAS TREE q
YOU SET US UP 150
STICK AROUND q
TALK TO THE HAND "H"
GET TO THE CHOPPER q
HERE IS MY INVITATION q
GET DOWN 1
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

Try it online!
Verification

unicode~~ good work!

@V.Courtois I think unicode is technically against the rules, and it certainly fails the ascii codepoint checker... I now want to make one that passes his ascii verifier with unicode xD

wait... pass ascii with unicode? but how? maybe in a language with implicit conversion to int (scala) but not arnold c lel, even if arnoldc is scala

@V.Courtois २ == -213 according to his ascii codesum... I think I could swing a mix of ascii/unicode that gives a codesum of near zero >:D. Not sure it's worth the effort though. Also, that unicode is 3 bytes, so TIO is wrong.

good luck with this, though I don't think having negative codes is quite legit >:D

From the spec - "Your program's output must not contain any unprintable characters (ASCII 0 through 31, or above 127)" the second one is valid though.

Perl 5, 8 bytes, sum = 688 (ASCII)
Input:
say"q"x6

Output:

qqqqqq

x is the repetition operator in perl. So "q"x6 is the same as qqqqqq. say prints the string with a following line feed.

Z80Golf, 4 bytes, sum 354 (ASCII)
00000000: 3676 7e38                                6v~8

Try it online!
The output is vvv.
Slightly modified from my 3-byte Output same length as code.
Disassembly
start:
  ld (hl), $76  ; 36 76
  ld a, (hl)    ; 7e
  db $38        ; 38 ; jr c, 0

As always, (hl) allows to use the memory address 0 similar to a register with pre-loaded value. In this case, the program overwrites its first opcode to halt, and then loads the same value to a. Usual stack underflow causes v to be printed three times and return to the start of program.
The last instruction is a no-op added to match the sum. The alternative 3-byte vvv program (in the link above) is unusable here because the difference $7a translates to ld a, d, which interferes with the preceding ld a, $76 (and it can't be moved in order to halt correctly).

Lost, 31 30 bytes, sum 1598
///x///<<<///
>!?<@]]1111<%
//

Try it online!
Output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Klein, 3 bytes, sum 138
$@&

Try it online!
This outputs 0 0 with a trailing newline (48 32 48 10). The executing parts are $, which swaps the top two values of the stack (taking implicit zeroes from the bottom) and @, which terminates the program and prints the stack. & is just there to balance out the codepoint sum, and isn't a valid instruction in Klein, nor is it actually parsed. Since the pointer doesn't wrap around any edge, this works in any topology of Klein.

Deadfish~, 5 bytes, sum = 574 (ASCII)
{ion}

Try it online!
Prints from 1 to 10, no spaces. n is a no-op (like most characters in deadfish~) which puts the code point sum where it needs to be.

Runic Enchantments, 6 bytes, sum=380
"Dz":@

Try it online!
D has a code-point-sum double that of " while z has the code-point-sum equal to : plus @. Duplicating the string (resulting in DzDz) then provides one copy to count for its own characters in the source and one copy to count for the remainder of the program. Getting a lower sum will be difficult, but I don't preclude it.
For comparison, the 6 byte quines are "'<~@> and variants of '<~@|" (any IP redirection command that turns a left-pointing IP into a right-pointing IP all work).

How about a7p@9? There's probably a 4 byte solution floating about somewhere

@JoKing Nice! I figure there was probably one of that form, but I didn't have the mental energy to hash it out (work's been a real nightmare lately; client recently OK'd an extension that would allow us to write a better framework with the understanding that we were going to miss the deadline anyway, then two days later asked for something extra).

Keg, 4 bytes, sum=272
Note: This is kept as 4 general pure ASCII one-byte encoding bytes. Keg has multiple code pages, and the user can alternate between them. The pure ASCII+EASCII code page is one of them.
\*

There are control characters in between the characters \ and *. The bytecode of 136 is counted as 2 bytes.
Try It Online!
How did I get this program?
First of all, the challenge wants us to solve an equation, and the sum of all of the numbers in the source code equals a mystery number passed through a mystery function. I chose the multiply-two function because it is powerful enough to allow the solving of the equation. This is what I get as a draft (replace 2 with its control-character form mentally):
\?2*

(I prepended an escaping instruction before the mystery character because I want the character to be pushed no matter what the character is. My previous attempt of the mystery character without escaping had failed. The character was ,, which is a Keg instruction.) Obviously the ord codes of \, 2, and * are 92, 2, and 42 respectively, so we've complete half of the equation:
x+92+2+42

The other half is simply multiplying x by 2.
2x=x+2+92+42
 x=136

Therefore I escaped the 136 character, which is unprintable. So I need to verify the solution in case the result is wrong:
2*136=136+2+92+42
  272=272

The solution is valid, therefore the program is a valid code point sum quine solution.

Isn't this 5 bytes, since the 136 character counts for 2 bytes? (As it says on TIO)

Pretend that I'm using pure ASCII.

If I'm not mistaken any code points above 128 would be extended ascii, meaning it'd be two bytes still

It is two bytes in Unicode, but it is one byte in the code page.

Yeah I guess, though since the code page doesn't really exist yet I'd say keep it as 5 bytes until it's implemented and on TIO

If I recall correctly, Keg has multiple code pages, and users choose which code page they are using based on their current program. I think ASCII + Extended ASCII is one of them. (It is 4 bytes encoded in an SBCS code page.)

Python 3, 13 bytes, sum 950 (ASCII)
print('_'*10)

Try it online!

Zsh, 11 bytes
<<< $[1e12]

Try it online!
Outputs 1000000000000. followed by a newline.

ARBLE, 4 bytes, Sum 186
''+A

Outputs
""+A

Each " is 5 codepoints smaller than their respective ', -5*2 and the output includes a newline, +10, which equals the source.
+A has to to be included as an implicit argument is needed to stringify as it does.
Try it online!

Vyxal, 1 byte, sum 58
:

Try it Online!
Outputs 0\n, which has codepoint sum 48+10=58, which is the codepoint of :.

Triangular, 6 bytes, sum 306 (ASCII)
FA%%%<

Prints 151515. Check it here and Try it online!
Formats into this triangle:
  F
 A %
% % <

The IP starts reading southwest from the topmost character. < directs it east, so the code is read like this:
F%%%

F pushes 15 to the stack, % prints it. A was the necessary character to get the byte sums even.

Bitwise, 117 bytes, sum 5796 (ASCII)
MOV 1 &46 &1
LABEL &1
MOV 2 &1 &1
LABEL &2
NOT 1 *1
AND *1 2 *2
XOR 1 2 1
SL *2 &1 2
JMP @2 2
OUT &126 &1
JMP @1 1
;$

Outputs 46 tildes (~). Try it online!
This will be alot shorter once I add functions to Bitwise...
MOV 1 &46 &1     move l46 into r1 when l1 is truthy
LABEL &1         create label 1
MOV 2 &1 &1      move l1 into r2 when l1 is truthy
LABEL &2         \
NOT 1 *1          \
AND *1 2 *2        \_ all this code performs r1 = r1 - r2
XOR 1 2 1          /
SL *2 &1 2        /
JMP @2 2         /
OUT &126 &1      print l126 (~) when l1 is true
JMP @1 1         jump to jp1 when r1 is truthy
;$               byte fill :P

l is short for literal, r is short for register, jp is short for jump point. I'll update with a better explanation later.

Bash + coreutils, 13 bytes, sum = 1090 (ASCII)
yes c|   head

Note the three spaces after the pipe.
Output:
c
c
c
c
c
c
c
c
c
c

Output is 10 c's and 10 line feeds, ascii 99 and 10 respectively, for a total of 1090. Input is 121+101+115+32+99+124+32+32+32+104+101+97+100=1090.

Actually, 6 4 bytes
Simply outputs 512. Adds 2 NOPs in order to get to that number.
9╙Ω☼

Try it online!
Explanation
9╙   512 is 2**9
  Ω  Unfortunately opcode 250 is an implemented instruction;
     opcode 234 has to be used instead.
   ☼ Opcode 16 just for the bytecount; this is also not an instruction.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
The infinite power tower
The challenge
Quite simple, given an input x, calculate it's infinite power tower!
x^x^x^x^x^x...

For you math-lovers out there, this is x's infinite tetration.
Keep in mind the following:
x^x^x^x^x^x... = x^(x^(x^(x^(x...)))) != (((((x)^x)^x)^x)^x...)

Surprised we haven't had a "simple" math challenge involving this!*
Assumptions

x will always converge.
Negative and complex numbers should be able to be handled
This is code-golf, so lowest bytes wins!
Your answers should be correct to at least 5 decimal places

Examples
Input >> Output

1.4 >> 1.8866633062463325
1.414 >> 1.9980364085457847
[Square root of 2] >> 2
-1 >> -1
i >> 0.4382829367270323 + 0.3605924718713857i
1 >> 1
0.5 >> 0.641185744504986
0.333... >> 0.5478086216540975
1 + i >> 0.6410264788204891 + 0.5236284612571633i
-i >> 0.4382829367270323 -0.3605924718713857i
[4th root of 2] >> 1.239627729522762

*(Other than a more complicated challenge here)

I don’t think this tower converges at x = −2 or x = −0.5.

@AndersKaseorg I agree, though all programs seem to have the same converging answer. Why don't they converge?

x = −2 gets attracted to a 8-cycle and x = −0.5 gets attracted to a 6-cycle. (My program still gives an answer in these cases, but it’s one of the points in the cycle and not a fixed point; this doesn’t indicate convergence.)

@AndersKaseorg Aha very interesting. You wouldn't happen to know why '8' for -2 and '6' for -0.5? Just out of curiosity of course.

You can run the iterations just as easily as I can, but here’s a picture: https://commons.wikimedia.org/wiki/File:Tetration_period.png

You say we have to calculate the infinite power tower, but do we have to display/output it?

@kamoroso94 Yes and no. A lot of answers just have a function that generates a number, but can be outputted quite easily (usually shown in the 'Try It Online'). It really depends if it's faster to print it or to return it as a function.

APL (Dyalog), 4 bytes
*⍣≡⍨

Try it online!
* power
⍣ until
≡ stable
⍨ selfie

Pyth,  4  3 bytes
crossed out 4 is still regular 4 ;(
u^Q

Try it online
How it works
u       first repeated value under repeated application of G ↦
 ^QG        input ** G
    Q   starting at input

You don't need the last G, it will get auto-filled.

@FryAmTheEggman Right, thanks!

Haskell, 100 63 bytes
For inputs that don't converge (eg. -2) this won't terminate:
import Data.Complex
f x=until(\a->magnitude(a-x**a)<1e-6)(x**)x

Thanks a lot @ØrjanJohansen for teaching me about until and saving me 37 bytes!
Try it online!

You can shorten this a lot with the until function. Try it online!

Neat! Did not know until, thanks a lot.

Python 3, 40 39 35 bytes

Thanks @Ørjan Johansen for a byte: d>99 instead of d==99: 1 more iteration for a lesser byte-count
Thanks @Uriel for 4 bytes: wise utilization of the fact that x**True evaluates to x in x**(d>99or g(x,d+1)). The expression in the term evaluates to True for depth greater than 99 and thus returns the passed value.

Recursive lambda with a max-depth 100 i.e. for a depth 100 returns the same value. Actually is convergency-agnostic, so expect the unexpected for numbers with non-converging values for the function.
g=lambda x,d=0:x**(d>99or g(x,d+1))

Try it online!

In the tio link, you can replace complex('j') with 1j

d>99 does one more iteration and is shorter.

save 4 bytes with g=lambda x,d=0:x**(d>99or g(x,d+1)), x**True evaluates to x

@Uriel, That is really smart..... Thanks!!!

Python 3, 37 30 27 bytes
-7 bytes from @FelipeNardiBatista.
-3 bytes from from @xnor
I don't remember much of Python anymore, but I managed to port my Ruby answer and beat the other Python 3 answer :D
lambda x:eval('x**'*99+'1')

Try it online!

FYI, it appears that f-strings were first introduced in Python 3.6: see https://www.python.org/dev/peps/pep-0498/ .  (This would explain why your code didn't work for me in 3.5.2.)  Just thought I'd mention this in case anyone else was confused.

You don't need to substitute in the value of x, eval('x**'*99+'1') works

@xnor doh, of course it does :) thanks

@xnor Neat -- I applied the same thing in my Ruby answer and it somehow fixed it :)

+1, I am slapping myself for forgetting the existence of eval.... :D

Mathematica, 12 bytes
#//.x_:>#^x&

Takes a floating‐point number as input.

J, 5 bytes
^^:_~

Try it online!
Explanation
First, I'll show what command is being executed after parsing the ~ at the end, and the walk-through will be for the new verb.
(^^:_~) x = ((x&^)^:_) x

((x&^)^:_) x  |  Input: x
      ^:_     |  Execute starting with y = x until the result converges
  x&^         |    Compute y = x^y

The J solution is really nice here.  To break down your first line in finer grain, is it correct to say that the following happens: (^^:_)  creates a new dyadic verb via the power conj, then self adverb ~ makes that verb monadic, so that when given an argument x it's expanded to x (^^:_) x.  the left x subsequently "sticks", giving ((x&^)^:_) x per your note, and only the right argument changes during iteration?

@Jonah Sure, when giving two arguments to a dyad with power, x u^:n y, the left argument is bonded with the dyad to form a monad that is nested n times on y. x u^:n y -> (x&u)^:n y -> (x&u) ... n times ... (x&u) y

C# (.NET Core), 79 78 bytes
x=>{var a=x;for(int i=0;i++<999;)a=System.Numerics.Complex.Pow(x,a);return a;}

Try it online!
I chose to iterate until i=999 because if I iterated until 99 some examples did not reach the required precision. Example:
Input:                      (0, 1)
Expected output:            (0.4382829367270323, 0.3605924718713857)
Output after 99 iterations: (0.438288569331222,  0.360588154553794)
Output after 999 iter.:     (0.438282936727032,  0.360592471871385)

As you can see, after 99 iterations the imaginary part failed in the 5th decimal place.
Input:                      (1, 1)
Expected output:            (0.6410264788204891, 0.5236284612571633)
Output after 99 iterations: (0.64102647882049,   0.523628461257164)
Output after 999 iter.:     (0.641026478820489,  0.523628461257163)

In this case after 99 iterations we get the expected precision. In fact, I could iterate until i=1e9 with the same byte count, but that would make the code considerably slower

1 byte saved thanks to an anonymous user.

+1 For the complex class I didn't even know that existed.

@TheLethalCoder neither did I until I googled it. :-)

Jelly, 5 bytes
³*$ÐL

Try it online!

Ruby, 21 20 bytes
->n{eval'n**'*99+?1}

Disclaimer: It seems that Ruby returns some weird values when raising a complex number to a power. I assume it's out of scope for this challenge to fix Ruby's entire math module, but otherwise the results of this function should be correct. Edit: Applied the latest changes from my Python 3 answer and suddenly it somehow gives the same, expected results :)
Try it online!

Take out the space after the eval.

Your original version failed on the complex test case because it evaled the string "0+1i**0+1i**0+1i**...", which parses in the wrong way since ** has higher precedence than +.

@ØrjanJohansen huh, you're right. I guess I was fooled by the fact that #inspect and #to_s return different values. Before submitting the initial answer I did some testing in irb and saw that e.g entering Complex(1,2) in the REPL would give (1+2i), including the parentheses. When stringifying the value however the parentheses are not included, so the precedence, as you point out, messed it up.

I thought eval use was forbidden.

@V.Courtois Ok. But it's not.

TI-BASIC, 16 bytes
The input and output are stored in Ans.
Ans→X
While Ans≠X^Ans
X^Ans
End

R, 36 33 bytes
-3 bytes thanks to Jarko Dubbeldam
Reduce(`^`,rep(scan(,1i),999),,T)

Reads from stdin. Reduces from the right to get the exponents applied in the correct order.
Try it (function)
Try it (stdin)

scan(,1i) works. Similar to how scan(,'') works.

@JarkoDubbeldam of course! sometimes my brain doesn't work.

Javascript, 33 bytes
f=(x,y=x)=>(x**y===y)?y:f(x,x**y)

JavaScript doesn't handle imaginary numbers.

MATL, 20 10 bytes
cut down to half thanks to @LuisMendo
t^`Gw^t5M-

Try it online!
This is my first code-golf and my first time using MATL so i'm sure it could be easily outgolfed.

Welcome to the site, and nice first answer! A few suggestions: XII is equivalent to t. You can also get rid of XH and H using the automatic clipboard M, that is, ttt^\yw^t5M-]bb-x. And in the last part, instead of deleting the unwanted values you can use &, which tells the implicit display function to only show the top. So, you can use [ttt^`yw^t5M-]&`](https://tio.run/##y00syfn/v6SkJC6hsjyuxNRXN1bt/39DPRMA) and save a few bytes.

Also, the first t is not needed, and using G instead of another t you can avoid & and thus leave ] implicit: `t^`Gw^t5M-`. Hey, we've reduced byte count by a half!

@LuisMendo Thanks for the great tips! I have a lot to learn about MATL, but I really like it.

Glad to hear that!

Vyxal r, 4 bytes
‡?eẊ

Try it Online!

PowerShell Core, 165 140 bytes
param($a)$u=1;for($r=$a;$u-join'+'|iex){$r=[Numerics.Complex]::Pow($a,($p=$r))
$u=($p.Real,($p|% I*),-$r.Real,-($r|% I*))|% *g '.0000000'}$r

Try it online!
-7 bytes thanks to mazzy!
55 bytes without complex numbers

[Numerics.Complex] instead [System.Numerics.Complex]?

Thanks @mazzy ! I followed your advice :)

Perl 6, 17 bytes
{[R**] $_ xx 999}

Try it online!
R** is the reverse-exponentiation operator; x R** y is equal to y ** x.  [R**] reduces a list of 999 copies of the input argument with reverse exponentiation.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Primitive Pythagorean Triples
(related)
A Pythagorean Triple is a list (a, b, c) that satisfies the equation a2 + b2 = c2.
A Primitive Pythagorean Triple (PPT) is one where a, b, and c are all coprime (i.e., the only common divisor between the three elements is 1). For example, the (3, 4, 5) right triangle is a famous Primitive Pythagorean Triple.
The Challenge

Given input n, output the nth PPT. Or,
Given input n, output the first n PPTs.

There are multiple ways to order these PPTs to form a well-ordered list, to determine which is the nth. You can choose any ordering you want, so long as you can prove (informally is fine) that your algorithm can generate every possible unique PPT. For example, your code should not output both (3,4,5) and (4,3,5) since those are duplicates of the same triple -- one or the other, please.
Similarly, whether your code is zero- or one-indexed is fine, so long as you state which you're using.
Examples
For the examples below, I'm using one-indexing, outputting the nth PPT, and ordering by smallest c, then smallest a, then smallest b.
n | output
1 | (3, 4, 5)
2 | (5, 12, 13)
5 | (20, 21, 29)
12| (48, 55, 73)

Rules

The input and output can be given in any convenient format.
In your submission, please state how your entries are ordered, and whether your entries are 0-indexed or 1-indexed.
Your chosen ordering cannot create duplicates.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Related

A103606.

What is the highest input we have to support? Can we assume that it fits the capabilities of our language of choice?

@Mr.Xcoder Yes; that's a standard safe assumption, unless you're using that to exploit a loophole (e.g., the language only supports 1-bit numbers) to make the problem trivial.

Should triples only occur in one order (i.e. a < b or a > b)?

@Pietu1998 They should be unique. I'll add some clarifying words.

Is it necessary to output a,b,c, or does a,b suffice?

@LuisMendo The full a,b,c, please, as that is the common nomenclature.

I'd be delighted to see a Python solution to this challenge...

should really a,b,c be coprime? a and b is not enough?

I found the answer to my question: a and b must be coprime and this is enough https://proofwiki.org/wiki/Elements_of_Primitive_Pythagorean_Triple_are_Pairwise_Coprime

Jelly, 27 25 bytes
2 bytes thanks to Jonathan Allan.
²IH;Pµ;ÆḊ
+2ḶḤ‘Œcg/ÐṂÇ€Ṣḣ

Try it online!
Outputs the first n 1-indexed triples [b, a, c], sorted by increasing b and then a.
Uses the algorithm from Wikipedia:

This generates all primitive triples for all unique coprime pairs of odd integers m > n > 0.
Explanation
+2ḶḤ‘Œcg/ÐṂÇ€Ṣḣ    Main link. Argument: n
+2                   Add 2 to n, to get enough results.
  Ḷ                  Get integers [0, 1, ..., n+1].
   Ḥ                 Double to get [0, 2, ..., 2n+2].
    ‘                Increment to get [1, 3, ..., 2n+3].
     Œc              Get all ordered pairs [[1, 3], [1, 5], ..., [2n+1, 2n+3]].
       g/            GCD of each pair.
         ÐṂ          Grab the pairs with minimal GCD (which is 1).
           Ç€        Call the helper link on each pair to get the triples.
             Ṣ       Sort the triples first by a, then by b, then by c.
              ḣ      Get the last n.

²IH;Pµ;ÆḊ    Helper link. Argument: pair [m, n]
²              Square to get [m², n²].
 I             Increments: get [m²-n²].
  H            Halve: get [(m²-n²)/2], i.e. [b].
    P          Product: get mn, i.e. a.
   ;           Append to get [b, a].
     µ         Begin a new monadic chain with argument [b, a].
       ÆḊ      Get the length of the vector, i.e. c.
      ;        Append to get [b, a, c].

That's a really nice explanation. Thanks!

g/Ị$Ðf -> g/ÐṂ to save two bytes (since the minimal gcd is 1 and there will always be at least one such entry).

Another byte may also be saved (although making it less efficient) by replacing +2ḶḤ‘Œc with ²Rm2Œc - scrap that it wont work for an input of 1 :(

@JonathanAllan Thanks for the minimum one. I did try a lot of 2-byte ranges, but unfortunately none were big enough. (²ḶḤ‘Œc was one of the first I thought of.)

MATL, 36 bytes
`@:Ut&+wmR&fZd1Mhw/vXutnGE<]GY)t&2|h

Input is 1-based. The output order guarantees that each triple appears exactly once. The order is explained in the following. The explanation requires delving a little into how the program works.
The code keeps increasing a counter k in a loop, starting at 1. For each k it generates all pairs with a = 1,...,k, b = 1,...,k, a < b, and picks those that give a Pythagorean triple with c <= k. The pairs are obtained in order of increasing b, then a.
Each pair is then divided by its gcd. The resulting (possibly duplicated) pairs are arranged as a two-column matrix. This matrix is vertically concatenated with a similar matrix containing the accumulated results obtained for smaller values of k. The rows of the matrix are then stably deduplicated. This removes two types of duplicates:

Pairs that have been found more than once for the current k (such as 3,4, which also results from 6,8 when dividing by its gcd);
Pairs that were already found with smaller k.

In fact, each iteration k finds all pairs that were already found for previous iterations. But it may find them in a different order. For example, k=25 will find the triple 7,24,25 and not 20,21,29 (because c cannot exceed k). Later on, iteration k=29 will find both, but with 20,21,29 before 7,24,25 (order is increasing b, then a). This is why, instead of keeping all pairs found for the latest k, we append them to the previous ones and deduplicate stably. Doing so assures that the order is the same for any input n.
The above guarantees that each primitive Pythagorean triple will eventually appear, and it will appear only once. For input n, the loop over k finishes when at least n valid triples have been obtained; and then the n-th triple is ouput.
Try it online!
Or use this modified code to see the first n triples:
`@:Ut&+wmR&fZd1Mhw/vXutnGE<]G:Y)tU&2sX^h

Try it online!

Nice explanation.

Haskell, 98 bytes
f 0=(3,4,5)
f n|let(a,b,c)=f$div(n-1)3;r=mod n 3;d=a*(-1)^2^r;e=b*(-1)^r;s=2*(d+e+c)=(s-d,s-e,s+c)

Try it online!
How it works
This interprets the bijective base-3 digits of n as a path down the tree of primitive Pythagorean triples. It runs with no searching in O(log n) operations.

Jelly, 19 18 bytes
*g/²_/
4*œc3UṢÇÐḟḣ

The program takes a 1-based index n and prints the first n PPTs [c, b, a] in lexicographical order.
This is a O(64n) solution, so TIO will choke on inputs 4 and higher. I'll work on making it faster.
Try it online!
Alternate version, O(n3), probably valid
To find the nth triplet – [cn, bn, an] – the solution above assumes that cn ≤ 4n, which is easy to verify. However, A020882 proves that cn ~ 2πn, so there is a k such that cn ≤ kn for all n.
If we can take k = 7, the solution below is also valid (and much, much faster).
*g/²_/
×7œc3UṢÇÐḟḣ

Try it online!
How it works
4*œc3UṢÇÐḟḣ  Main link. Argument: n

4*           Compute 4**n, the n-th power of 4.
  œc3        Take all 3-combinations of the set {1, ..., 4**n}, each sorted in
             ascending order. The triples themselves are sorted lexicographically.
     U       Upend; reverse each triple [a, b, c], yielding [c, b, a].
      Ṣ      Sort the descending triples lexicographically. This ensures that their
             order is independent of n.
       ÇÐḟ   Keep only triples for which the helper link returns a falsy value.
          ḣ  Dyadic head; take the first n triples.

*g/²_/       Helper link. Argument: [c, b, a]

 g/          Reduce [c, b, a] by greatest common divisor, yielding g.
*            Elevate the integers to that power, computing [c**g, b**g, a**g].
   ²         Square, yielding [c**2g, b**2g, a**2g].
    _/       Reduce by subtraction, yielding c**2g - b**2g - a**2g.
             Fermat's Last Theorem assures that this difference will be non-zero
             whenever g > 1, so this yields 0 iff g = 1 and c² = a² = b².

JavaScript (ES7), 106 105 103 bytes
Outputs the Nth PPT. Results are 1-indexed and ordered by the value of b.
n=>(g=(a,b)=>b?g(b,a%b):a,F=a=>(x=a*a+b*b,c=x**.5|0)*c-x*g(a,g(b,c))||--n?F(a-b?a+1:!++b):[a,b,c])(b=1)

Demo

let f =

n=>(g=(a,b)=>b?g(b,a%b):a,F=a=>(x=a*a+b*b,c=x**.5|0)*c-x*g(a,g(b,c))||--n?F(a-b?a+1:!++b):[a,b,c])(b=1)

for(n = 1; n <= 20; n++) {
  console.log('#' + n + ' : ' + f(n));
}

MATL, 63 bytes
3lvi:"t"[HlHllO;aOlOHl]!@Y*2eh]]!XuGY)&*tt[lO;Oa]*ssD2)ED2Xy*ss

Try it online!
A lesson in golfing gone horribly wrong. I'm posting it anyway because I'm wondering if there are ways to golf this better.
I based this on this Wikipedia page in combination with Euclid's formula, to constructively generate all triples rather than trial-and-error approaches.
First, odd coprime pairs are generated as a ternary tree. This is done as a big matrix multiplication, accounting for most of the byte count. Then, Euclid's formula is applied, possibly also in a very byte-wasting manner. If anyone has tips for these two parts, I'd love to hear them.
Note that, to save bytes, this program generates a tree the same depth as the input, rather than log3(n). Also, children are generated for each row rather than only for the last row of the tree, and then filtered again with Xu. So much for an efficient constructive approach.
3lv % Push root node of ternary tree
i:" % Generate a tree of depth of input (WAY too large, but golfy)
t"  % loop over all nodes (golfier than looping over last tree row)
[HlHllO;aOlOHl]! % Matrix to generate three children of current node
@Y* % Multiply with current node to get children
2e  % Reshape to get node pairs
h]] % Append to tree, exit loops
!Xu % Remove duplicates (more efficient to do it before last ] but golfier this way)
GY) % Select n-th odd coprime pair
&*tt % Multiply with it's own transpose to get [m²,m*n;m*n,n²]
[lO;Oa]*ssD % Sum of matrix multiplication = m²-n² to get a
2)ED % Second element doubled for b=2mn
2Xy*ss % Sum of matrix multiplication with identify matrix to get c=m²+n²

Python,  67 50 48 46 Bytes
Using the formulas found on wikipedia,
a=m*n, b=(m^2-n^2)/2, c=(m^2+n^2)/2
where m>n>0 and m and n are coprimes and odd. Here is the code
lambda n:[3+2*n,~-(3+2*n)**2-1/2,-~(3+2*n)**2/2]

-17 bytes thanks to @Martin Ender
Try it Online
Works by always having the value of the n variable in the equation being 1, meaning that m simply is any other odd value, in this case, 3+2*n where n is the number of the primitive Pythagorean triple. This allows us to assume the value of 1 for all n values.

Welcome to PPCG! Unnamed functions are fine, so you don't need to assign the lambda to a (and if you did, you could get rid of the two spaces there). I'm also not sure why you print there, you could just return the values from the lambda itself.

"you can prove (informally is fine) that your algorithm can generate every possible unique PPT". But this method only generates those where the hypotenuse is 1 longer than a leg. It never generates 8,15,17, for example.

Haskell, 65 bytes
([(a,b,c)|c<-[5..],b<-[1..c],gcd c b<2,a<-[1..b],a^2+b^2==c^2]!!)

0-based indexing. For a given c, b runs up to c and a up to b, so c > b > a always holds.
Try it online!

Husk, 18 bytes
↑üOf§=F⌋ȯ¬Ḟ-m□ΠR3N

Try it online!
-4 bytes thank to Zgarb, with inspiration from Dennis
Super-slow brute force approach, won't work on TIO for inputs larger than 1. You can try a more manageable version, limited to a,b≤200 here
Explanation
↑üOf§=F⌋ȯ¬Ḟ-m□ΠR3N
              ΠR3N   Get all triples of natural numbers
   f                 Keep only those triples where
      F⌋                their GCD
    §=                  is equal to
        ȯ¬Ḟ-m□          the logical negation of c²-b²-a²
 üO                  Remove duplicates by their sorted version
↑                    Get the first <input> values of this sequence

20 bytes by combining the map and filter, even slower.

@Zgarb thank you! I managed to golf an extra byte :)

18 bytes with the subtraction trick from Dennis's Jelly answer.

@Zgarb nice! Though I'm having a doubt: could there be two different triples with the same c? in that case this solution would need to be fixed

Hmm, actually there are many triples with the same c. This 18-byte solution (which uses another trick of Dennis) works regardless.

Mathematica, 89 bytes
using Solve ordered by c
SortBy[{a,b,c}/.Solve[a^2+b^2==c^2&&GCD[a,b]==1&&0<a<b<c<9#,{a,b,c},Integers],Last][[#]]&

Mathematica, 124 bytes
(s={};Table[If[IntegerQ[c=Sqrt[a^2+b^2]]&&GCD[a,b]==1,AppendTo[s,{a,b,c}]],{a,9#},{b,9#}];SortBy[Union[Sort/@s],Last][[#]])&

R (+ numbers), 88 bytes
n=scan();while(all(nrow(T)<n))T=numbers::pythagorean_triples(5,5+(F<-F+1));T[n,3:5]

For using a builtin to generate the numbers, it takes actually a surprising amount of bytes to get what we want. The builtin takes two arguments c1 and c2, and returns those triplets that have c >= c1 & c <= c2. This makes it slightly annoying to get to the n-th triplet. This will just keep increasing c2 1 at a time until the output is just enough rows.

PHP, 273 Bytes
function t($n){$x=[];for($c=3;;$c++)for($b=2;$b<$c;$b++)for($a=2;$a<$b;$a++)if(d($a,$b,$c)&&$a**2+$b**2==$c**2){$x[]=[$a,$b,$c];if(--$n==0)return $x;}}function d($a,$b,$c){for($i=2;$i<$a;$i++)if($a%$i==0&&$b%$i==0||$a%$i==0&&$c%$i==0||$b%$i==0&&$c%$i==0)return 0;return 1;}

t($n) returns an array of [a,b,c] with ordering a < b < c
Returns a zero-based index

Try it online! (code is readable there too)

Jelly, 27 25 bytes
⁽0(ḃs
Ɠḃd2Ḥ’×€Ç
3r5DṭÇæ×/

This is an implementation of the tree approach from @AndersKaseorg's Haskell answer, with a different branch order. The program uses 0-based indexing and takes input from STDIN.
Try it online!
Background
As mentioned on the Wikipedia page Tree of primitive Pythagorean triples, every PPT can be obtained by repeatedly left-multiplying the row vector (3, 4, 5) by matrices with certain properties.
In each iteration, the previous result can be left-multiplied by either A, B, or C, which can be chosen as follows.

When A, B, and C are fixed, each PPT can be obtained in a unique fashion.
How it works
3r5DṭÇæ×/  Main link. No arguments.

3          Set the argument and the return value to 3.
 r5        Create a range from 3 to 5, i.e., [3, 4, 5].
   D       Decimal; convert each integer to base 10, yielding [[3], [4], [5]].
     Ç     Call the second helper link with argument 3.
    ṭ      Tack; append [[3], [4], [5]] to the result.
      æ×/  Reduce by matrix multiplication.

Ɠḃd2Ḥ’×€Ç  Second helper link. Argument: 3

Ɠ          Read and evaluate one line of input, yielding an integer n.
 ḃ         Convert n to bijective base 3.
  d2       Divmod 2; map each digit d to [d/2, d%2].
    Ḥ      Unhalve; multiply the results by 2.
     ’     Decrement the doubled results.
           The previous four atoms apply the following mapping to the digits.
               1 -> [0, 1] -> [0, 2] -> [-1,  1]
               2 -> [1, 0] -> [2, 0] -> [ 1, -1]
               3 -> [1, 1] -> [2, 2] -> [ 1,  1]
        Ç  Call the helper link with argument 3, yielding the following 2D array.
               [[ 1,  2,  2],
                [ 2,  1,  2],
                [ 2,  2,  3]]
      ×€   Multiply each [-1,  1], [ 1, -1], and [ 1,  1] by that matrix, using
           vectorizing multiplication (not matrix multiplication), yielding one
           of the following three 2D arrays.

               [[-1,  2,  2],    [[ 1, -2,  2],    [[ 1,  2,  2],
                [-2,  1,  2],     [ 2, -1,  2],     [ 2,  1,  2],
                [-2,  2,  3]]     [ 2, -2,  3]]     [ 2,  2,  3]]

⁽0(ḃs      First helper link. Argument: 3

⁽0(        Numeric literal; yield 13041.
   ḃ       Convert 13041 to bijective base 3, yielding [1, 2, 2, 2, 1, 2, 2, 2, 3].
    s      Split the result into chunks of length 3, yielding the aforementioned
           2D array.

C, 158 bytes
I believe this is my first submission here, so you can most probably do better.
#include<stdio.h>
void f(n){int i=0,j=3,k,l;while(1){for(k=1;k<j;k++){for(l=k;l<j;l++){if(j*j==k*k+l*l)i++;if(i==n){printf("%d %d %d",j,k,l);return;}}}j++;};}

And ungolfed version:
#include <stdio.h>

void f(n)
{
  int i=0, j=3, k, l;
  while (1) {
    for (k=1; k<j; k++) {
      for (l=k; l<j; l++) {
        if (j*j==k*k+l*l)
          i++;
        if (i==n) {
          printf("%d %d %d\n", j, k, l);
          return;
        }
      }
    }
    j++;
  };
}

void main()
{
  int i;

  scanf("%d", &i);

  f(i);
  printf("\n");
}

For a2 + b2 = c2, the ordering is increasing c then increasing a.
There can no be twice the same PPT as b is at leas a in this algorithm.

Welcome to PPCG!

APL(NARS), 90 chars, 180 bytes
{a⊃⍨⍵⊃⍋↑¨a←{⍵[⍋⍵]}¨a/⍨{1=∨/⍵}¨a←{(-/k),(×/2,⍵),+/k←⍵*2}¨a/⍨{>/⍵}¨a←,a∘.,a←⍳(⌊2⍟2+⍵)×9+⌊√⍵}

if the argument of the function above is ⍵, the above function would return the element of the index ⍵ (1 based)
of the array has elements Pythagorean triples (a,b,c) where a<=b<=c and that array is order first for a,
(the side more short), then for b (the other side not hypotenuse). There would be something wrong because
there is not seen where I order for b too... test:
  f←{a⊃⍨⍵⊃⍋↑¨a←{⍵[⍋⍵]}¨a/⍨{1=∨/⍵}¨a←{(-/k),(×/2,⍵),+/k←⍵*2}¨a/⍨{>/⍵}¨a←,a∘.,a←⍳(⌊2⍟2+⍵)×9+⌊√⍵}
  f¨1..10
3 4 5  5 12 13  7 24 25  8 15 17  9 40 41  11 60 61  12 35 37  13 84 85  15 112 113  16 63 65

it is related with http://oeis.org/A020884 and http://oeis.org/A020884/b020884.txt
A020884: Ordered short legs of primitive Pythagorean triangles.
  ↑¨f¨1..23
3 5 7 8 9 11 12 13 15 16 17 19 20 20 21 23 24 25 27 28 28 29 31
  f 999
716 128163 128165
  f 1000
717 28556 28565

I don't know if it is right, it seems function give correct result of first side of triangle until 1000
but I don't know for the remain, and possible could be some triple not right too even <1000.

JavaScript, 101 bytes
By Euclid's formula all primitive Pythagorean triples can be generated from integers m and n with m>n>0, m+n odd gcd(m,n)==1 (Wikipedia)
This function enumerates all m,n pair incrementing m starting from m=2 and decrementing n by 2 starting from m-1 (so that m+n is odd)
c=>eval("g=(a,b)=>b?g(b,a%b):a;for(m=2,n=1;c-=g(m,n)<2;(n-=2)>0||(n=m++));[m*m-n*n,2*m*n,m*m+n*n]")

Less golfed
c => {
  g = (a,b) => b ? g(b,a%b) : a;
  for( m = 2, n = 1;
       g(m,n) < 2 ? --c : c;
       (n -= 2) > 0 || (n = m++))
    /* empty for body */;
  return [m*m - n*n, 2*m*n, m*m + n*n]
}

Test

F=
c=>eval("g=(a,b)=>b?g(b,a%b):a;for(m=2,n=1;c-=g(m,n)<2;(n-=2)>0||(n=m++));[m*m-n*n,2*m*n,m*m+n*n]")

for(i=1;i<=50;i++) console.log(i+' '+F(i))

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Solve a Matchstick puzzle
On puzzling SE there are what are called "matchstick problems" in which math is written in match sticks and you are allowed to move a certain number of them to get a certain property.
In this question we will be considering only integers represented in a 7-segment display format.  Here are all 10 digits in that format:
 __          __   __          __    __    __    __    __
|  |     |   __|  __|  |__|  |__   |__      |  |__|  |__|
|__|     |  |__   __|     |   __|  |__|     |  |__|   __|

Each segment of the display is one "match-stick" which can be moved independently of the rest of the number.  Matchsticks are indivisible and indestructible, the cannot be broken or removed by any means.
A common puzzle is to take a number given in base 10 and try to make the largest number possible in a given number of moves.  A move is considered to be one movement of a matchstick from any occupied slot to any other unoccupied slot.  You are perfectly permitted to make new digits on either side of the number, for example 0 can be made into 77 give 3 moves
 __      __  __      __   __      __   __
|  |    |  |        |  |    |       |    |
|__| ,   __|     ,     |      ,     |    |

However you may not make one slot into 2 or make new slots between existing ones, for example turning a 4 into an 11 in the middle of a number or inserting new digits in between existing ones.  Each move need not make a proper number but the final result should be a proper number in the base 10 seven segment display.  You need not use every move if you do not wish to.  Unlike on puzzling this is a [tag:close ended question] you may not use any operators (multiplication, exponentiation, etc.) or mathematical constants (Pi, Graham's number, etc.) in your answers.
Task
Write a program or function that takes a number and a number of moves as input and returns the largest number that can be made with that many moves on the original number.
This is a code-golf question so answers will be scored in bytes, with less bytes being better.
Test Cases
n, moves -> max
0, 1     -> 9
0, 3     -> 77
0, 4     -> 111
8, 3     -> 74
220, 1   -> 320
220, 2   -> 520
220, 3   -> 7227
220, 4   -> 22111
220, 5   -> 32111
747, 1   -> 747
747, 2   -> 7171
747, 3   -> 7711

Related

I... actually stayed up late last night pondering the Levenshtein distance between various matchstick digits... What an odd coincidence :P

Can empty slots formed in the middle be ignored at the end? E.g. 919, 2 -> 991

Related

wheat wizard,  which grid is being used?

@tuskiomi "However you may not make one slot into 2 or make new slots between existing ones"

So is the wheat wizard grid accurate to this? https://imgur.com/te38cF4

@tuskiomi Yes the one on the bottom is accurate.  I'm not sure how the one on the top would even work.

@WheatWizard its the top one with bars between each digit.  More of a shape recognition way of looking at it.

JavaScript (ES6), 297 286 279 267 bytes
Takes input in currying syntax (s)(k), where s is an array of digit characters and k is the number of moves (integer).
s=>k=>(B=(n,b=0)=>n?B(n^n&-n,b+1):b,b=[...p='u"[k,iy#}m'].map(c=>c.charCodeAt()+2),r=[],g=(n,d='')=>n?n>0&&b.map((v,i)=>g(n-B(v),d+i)):r.push(d))(s.reduce((s,c)=>s+B(b[c]),M=0))&&b.map((_,j)=>r.map(n=>M=[...n+p].reduce((t,d,i)=>t+B(b[d]^b[s[i-j]]),0)>k*2|+n<M?M:n))|M

Test cases

let f=

s=>k=>(B=(n,b=0)=>n?B(n^n&-n,b+1):b,b=[...p='u"[k,iy#}m'].map(c=>c.charCodeAt()+2),r=[],g=(n,d='')=>n?n>0&&b.map((v,i)=>g(n-B(v),d+i)):r.push(d))(s.reduce((s,c)=>s+B(b[c]),M=0))&&b.map((_,j)=>r.map(n=>M=[...n+p].reduce((t,d,i)=>t+B(b[d]^b[s[i-j]]),0)>k*2|+n<M?M:n))|M

console.log("0   / 1 -> " + f([..."0"  ])(1)) // -> 9
console.log("0   / 3 -> " + f([..."0"  ])(3)) // -> 77
console.log("0   / 4 -> " + f([..."0"  ])(4)) // -> 111
console.log("8   / 3 -> " + f([..."8"  ])(3)) // -> 74
console.log("220 / 1 -> " + f([..."220"])(1)) // -> 320
console.log("220 / 2 -> " + f([..."220"])(2)) // -> 520
console.log("220 / 3 -> " + f([..."220"])(3)) // -> 7227
console.log("220 / 4 -> " + f([..."220"])(4)) // -> 22111
console.log("220 / 5 -> " + f([..."220"])(5)) // -> 32111
console.log("747 / 1 -> " + f([..."747"])(1)) // -> 747
console.log("747 / 2 -> " + f([..."747"])(2)) // -> 7171
console.log("747 / 3 -> " + f([..."747"])(3)) // -> 7711

How?
Shape data and helper function

The array b describes the shapes of the digits as 7-bit integers, where each bit is a segment:

For instance, the shape of "7" is 0b0100101 = 37.
The helper function B() returns the number of 1's in the binary representation of a given number:
B = (n, b = 0) => n ? B(n ^ n & -n, b + 1) : b

Step #1
We first count the number of matchsticks used in the input number:
s.reduce((s, c) => s + B(b[c]), 0)

Step #2
We pass this value to the recursive function g(), which populates a list r with all numbers that can be built with exactly this number of matchsticks:
g = (n, d = '') =>
  n ?
    n > 0 &&
    b.map((v, i) => g(n - B(v), d + i))
  :
    r.push(d)

For instance, g(5) will load [ '17', '2', '3', '5', '71' ] into r.
Step #3
We now have to select the highest number M in r which can actually be obtained from the input number, within the allowed number of moves k.
Because each number n in r uses exactly as many matchsticks as the input number s, the number of moves required to transform s into n equals half the number of segment differences between each of their digits.
The number of segment differences between two digits x and y is given by the number of 1's in the binary representation of b[x] XOR b[y].
Finally, it's important to note that we need to try several possible digit alignments, because the first digit of s is not necessarily mapped to the first digit of n. The shift between the digits is given by the variable j in the code.

Mathematica, 188 197 200 203 170 174 bytes
NOTE: The code is still kind of buggy. I'm working on it.
+30 bytes for bug
(p=PadLeft;q=IntegerDigits;g=Join@@(#~q~2~p~7&/@ToCharacterCode["w$]m.k{% o"][[1+q@#]])&;h=(v=g@#2~#~96-g@i~#~96;Tr@v==0&&Tr@Abs@v<=2#3)&;For[i=10^Tr@g@#,!h[p,##]&&!h[PadRight,##],--i];i)&

The character between % and o should be 0x7F but SE won't allow it. You could click pastebin link to copy the original code.
The code takes a lot of time when there're more than 6-7 sticks. (You could modify the starting value of i to a smaller number to test it)
Explanation
g is a helper function converting digits into a list of stick representation (according to here), such as {1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1} for 220.
h is a helper function to deal with left-padding and right-padding between two numbers.
f iterates from 10^Tr@g@# (upper limit) to 1 to look for a integer whose stick representation has a same quantity of 1 -> 0 and 0 -> 1 compared to the original number and the quantity is smaller or equal than second argument.

I gave you a +1 because I've never seen a winning answer have such a lower score than the other answer. I assume it's because it's the lack of online testing options. Maybe some people who have Mathematica could come and test it out and verify that it works well, so you could get some more upvotes. Or maybe someone could convert it to Octave if possible.


text:
THIS ... IS ... FORTRESS!
Fortress was a language being developed by the Sun Programming Language Research Group (R.I.P. Fortress) that had a unique property to it, it was possible to render ("Fortify") programs in different font-styles (i.e. blackboard bold, bold, italics, roman, etc. ). The goal is to represent a one-char Fortress variable in HTML markup.
Here's how the fortification of one-char variables worked (simplified/modified from documentation for code-golfing purposes):

If the variable is a repeated capital (i.e. ZZ), it becomes formatted in blackboard bold (ℂℍℕℙℚℝℤ)
If the variable is preceded by an underscore, the variable is rendered in roman font (left alone)
If the variable is followed by an underscore, the variable is rendered in bold font (v)
If the variable is neither preceded nor followed by an underscore, the variable is rendered in italic font (v)
The codepoints of the blackboard bolds are: :1D538, :1D539,  ℂ:2102, :1D53B, :1D53C, :1D53D, :1D53E, ℍ:210D, :1D540, :1D541, :1D542, :1D543, :1D544, ℕ:2115, :1D546, ℙ:2119, ℚ:211A, ℝ:211D, :1D54A, :1D54B, :1D54C, :1D54D, :1D54E, :1D54F, :1D550, ℤ:2124. These count as one byte each in your program (if your language of choice can handle these characters at all)

Input will be either a repeated ASCII capital, or a single ASCII letter with either no underscore, a leading underscore, or a trailing underscore (AKA _a_ will not be an input). This is code-golf so lowest byte count wins!
Test cases:
a => a
BB =>
c_ => c
_d => d
E => E
G_ => G
_H => H
ZZ => ℤ

Links: Specification, Direct download of version 0.1 alpha.
Reference implementation (This would be in Fortress, but Fortress doesn't like most of the doublestruck characters, so this implementation is in D):
dstring fortify(string arg) {
    import std.string, std.conv;

    alias D = to!dstring; //Convert to a string that accepts the unicode needed
    dstring BB = "ℂℍℕℙℚℝℤ"d; //blackboard bold capitals
    string UC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //normal ASCII capitals

    if(arg.length == 1)
        return D("" ~ arg ~ "");
    if(arg[0] == a[1])
        return D(BB[UC.indexOf(arg[0])]);
    if(arg[0] == '_')
        return D(arg[1]);
    return D("" ~ arg[0] ~ "");
}

I forgot to remove them, sandbox link: https://codegolf.meta.stackexchange.com/a/13383/55550

Are the only uppercase variables the double repeated ones, and are the only lowercase ones the other three?

Uppercase can be normal, italic, and bold. Lowercase can not be doublestruck.

_____ won't be input.

Oh... So it's not a string of characters we're converting, just a single one?

If you're referring to the Fortress variable, then yes.

Why is the reference implementation not in Fortress? I have been scammed!

Why not a => `BB` => c_ => `_d` => E => `G_` => _H => `` or something?

Too much unicode (I might make a separate challenge with more of Fortress's rendering included, and unicode)

Well ... fortress didn't like ``, otherwise it would've been in Fortress.

Neim is probably the only language here that has `` in its codepage... the thing is, it's rule #150.5 compliant (is awful with strings)

I modified the question so the doublestruck characters only count as 1 byte each.

In what way do they "count" as one byte each? If my language has not got them in its code-page I must insert them, is it any code required to do so, or are you favouring languages that can have Unicode strings within their code?

Any usage of them within the code counts as one byte.

Can i output &#120120 instead of ``?

No, you may not.

Jelly, 73 bytes
Turns out that not being able to use the BBB letters in the code is quite expensive.
5ŀ”i
“Ðñṡ’Dẋ@€“¡ḞḄ’ż“¿¿Æ€¢¬µ‘+⁽ø³F⁸ṪO¤+ị¥Ọ
Ṫ
Ḣ5ŀ”b
;j“<>/”ṃ@“¢ʠf’
i”_+LµĿ

A full program taking one argument and printing the result.
Try it online! or see the test suite.
How?
The main entry point is the last line of code ("Main link").
5ŀ”i - Link 1: list of characters, s (length 1 & no underscore)
  ”i - literal character 'i'
5ŀ   - call link 5 as a dyad with s on the left and 'i' on the right

“Ðñṡ’Dẋ@€“¡ḞḄ’ż“¿¿Æ€¢¬µ‘+⁽ø³F⁸ṪO¤+ị¥Ọ - Link 2: list of characters, s (length 2 & no underscore)
“Ðñṡ’                                 - base 250 literal              1007245
     D                                - to decimal list               [1,0,0,7,2,4,5]
         “¡ḞḄ’                        - base 250 literal              111673
      ẋ@€                             - repeat with reversed @rguments for €ach -> [[111673],[],[],[111673,111673,111673,111673,111673,111673,111673],[111673,111673],[111673,111673,111673,111673],[111673,111673,111673,111673,111673]]
               “¿¿Æ€¢¬µ‘              - code page index list          [11,11,13,12,1,7,9]
              ż                       - zip together                  [[111673,11],[11],[13],[[111673,111673,111673,111673,111673,111673,111673],12],[[111673,111673],1],[[111673,111673,111673,111673],7],[[111673,111673,111673,111673,111673],9]]
                         ⁽ø³          - base 250 literal              8382
                        +             - addition (vectorises)         [[120055,8393],[8393],[8395],[[120055,120055,120055,120055,120055,120055,120055],8394],[[120055,120055],8383],[[120055,120055,120055,120055],8389],[[120055,120055,120055,120055,120055],8391]]
                            F         - flatten                       [120055,8393,8393,8395,120055,120055,120055,120055,120055,120055,120055,8394,120055,120055,8383,120055,120055,120055,120055,8389,120055,120055,120055,120055,120055,8391]
                                ¤     - nilad followed by link(s) as a nilad:                                                                                ^
                             ⁸        -   chain's left argument, s  e.g.    "CC"                                                                                |
                              Ṫ       -   tail (last character)             'C'                                                                                |
                               O      -   cast to ordinal                   67                                                                                |
                                   ¥  - last two links as a dyad:                                                                                |
                                  ị   -   index into (1-indexed & modular)  8383 (this is at index 67%26=15 -----------------------------------------------------+ )
                                 +    -   add the ordinal                   8450
                                    Ọ - convert from ordinal to character   'ℂ'

Ṫ - Link 3: list of characters, s (length 2 & underscore at index 1)
Ṫ - tail (get the first character

Ḣ5ŀ”b - Link 4: list of characters, s (length 2 & underscore at index 2)
Ḣ     - head s (the non-_ character)
   ”b - literal character 'b'
 5ŀ   - call link 5 as a dyad with the non-_ character on the left and 'b' on the right

;j“<>/”ṃ@“¢ʠf’ - Link 5, wrap in a tag: element, tagName      e.g. 'a', 'i'
;              - concatenate the element with the tagName          "ai"
  “<>/”        - literal list of characters                        "<>/"
 j             - join                                              "a<>/i"
         “¢ʠf’ - base 250 literal                                  166603
       ṃ@      - base decompression with reversed @rguments
               -   "a<>/i" is 5 long, so 166603 is converted to
               -   base 5 [2,0,3,1,2,4,0,3] with digits "a<>/i"    "a"

i”_+LµĿ - Main link: list of characters, s (as specified only):
 ”_     - literal '_'
i       - index of '_' in s (1-indexed; 0 if not found)
    L   - length of s
   +    - addition
     µĿ - call link with that number as a monad with argument s
        - implicit print

Fails on input ZZ.

Oh, is that in a different place in Unicode? Bizarre choice they made.

Yeah, doublestruck C H N P Q R and Z are at different places in unicode.

(Read the fifth bullet point)

LOL, it's fun to see Jelly flop like that!

Careful what you say, Dennis will show up and post a twelve byter for it :p

I haven't seen Dennis answer on one of my questions yet, I'm hoping for it!

Python 3.6, 159 131 128 bytes
1 byte saved thanks to @Zacharý
3 bytes saved thanks to @VаlueInk
28 bytes saved thanks to @Rod
lambda s:len(s)<2and f"{s}"or s[0]==s[1]and"ℂℍℕℙℚℝℤ"[ord(s[0])-65]or[f"{s[0]}",s[1]][s[0]=='_']

Try it online!

len(s)<2 and=>len(s)<2and

Look at the new edit to the post, ℂℍℕℙℚℝℤ count as 1 byte each.

128 bytes by moving your first condition to the end.

Ruby, 104 106 105+1 = 105 107 106 "bytes"
Probably works even better in Retina. Uses -p flag.
-1 byte from Zacharý.
gsub /^.$/,'\0'
gsub(/(.)\1/){$1.tr"A-Z","ℂ-ℍ-ℕℙℚℝ-ℤ"}
gsub /(.)_/,'\1'
gsub ?_,''

Try it online!

You forgot JJ, KK, LL, TT, UU, VV and WW.!! (Which is probably why MM gives ℙ)

@Zacharý fixed.

I think you can save a byte by making - -.

You didn't update your TIO link for the 1-byte saving. Also, this fails badly in Retina which uses UTF-16 and so can't translate a single A-Y to a two-char16_t blackbold character.

@Neil oops. Fixed link.

JavaScript, 97 chars
([a,b])=>a==b?[...'ℂℍℕℙℚℝℤ'][a.charCodeAt()-65]:b?b=='_'?a.bold():b:a.italics()

Why a language have methods like String.prototype.italics and String.prototype.bold?
Thanks to Neil, save 9 bytes, use [...s] instead of s.match(/./u).

Is this ES6, or ES7?

u flag in RegExp is ES6 feature. String.prototype.italics and String.prototype.bold are just some legacy features.

I knew it was ES6 ... 'cause fat arrows.

change "ES6" to "ES6 or ES7" in the above comment.

[...'ℂℍℕℙℚℝℤ'] should save you some bytes.


text:
Collapse consecutive integers
Related: Tell me how many math problems I have to do!
Challenge
Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's consecutive integer runs of length ≥ N with a single dash -.
Rules

Horizontal whitespace is irrelevant.
You may optionally preserve the introducer, separator, and terminator characters of your language's default list format. See Format examples, below.

Data examples
All these examples use L = 3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24.
N = 3 → 3 5 - 8 10 - 12 14 16 - 22 24
N = 4 → 3 5 - 8 10 11 12 14 16 - 22 24
N = 5 → 3 5 6 7 8 10 11 12 14 16 - 22 24
N = 8 → 3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24
Format examples
For the inputs
 L = [3,5,6,7,8,10,11,12,14,16,17,18,19,20,21,22,24] and N = 3
all the below lines are examples of valid responses, both as actual lists and as strings:
[3,5,"-",8,10,"-",12,14,16,"-",22,24]
[3,5,-,8,10,-,12,14,16,-,22,24]
[3,5-8,10-12,14,16-22,24]
3,5-8,10-12,14,16-22,24

The same applies with other list formats, like {1 2 3} and (1; 2; 3) etc. In doubt? Ask!

Is it necessary to use - or are we allowed to use a different symbol?

@miles Will a different symbol save you bytes?

I am thinking of using infinity _ so that I might remain operating on numeric arrays in J.

@miles Ah, yeah, why don't you go ahead and do that, but make a not about it, and if you can be bothered, write the (I assume much longer) boxed solution with '-'. You might also be able to stringify everything before inserting dashes, no?

Is the following valid? [3,5,-8,10,-12,14,16,-22,24] (this seems to be the format that makes the most sense in terms of types)

@LeakyNun Uh, are those negative numbers? If so, no. Not because the format is bad per se, but because I should have permitted it from the outset so others could do it to. However, can't you just stringify and replace ,- with -?

@EzioMercer all the below lines are examples of valid responses, both as actual lists and as strings:

Python 2, 132 115 bytes
-17 bytes thanks to Leaky Nun

x,n=input()
o=[]
i=1
while x:
 t=x[0]
 while[t+i]==x[i:i+1]:i+=1
 o+=[[t,'-',t+i-1],x[:i]][i<n];x=x[i:];i=1
print o

Try it online!

115 bytes

Would while t+i==x[i]: work? Or am I missing something?

@Zacharý it would break if i get higher than the size of x

Jelly,  26 25  23 bytes
-2 bytes thanks to Erik the Outgolfer (by bringing the if statement into the main link)
Ḣ;Ṫj”-
IỊ¬1;œṗ⁸¹ÇL<¥?€F

A dyadic link returning a list in the [3,5,"-",8,10,"-",12,14,16,"-",22,24] format.
Try it online! (footer separates with spaces, to print the data example format).
How?
Ḣ;Ṫj”- - Link 1, format a run: list R
Ḣ      -     head
  Ṫ    -     tail
 ;     -     concatenate
    ”- -     literal '-'
   j   -     join

IỊ¬1;œṗ⁸¹ÇL<¥?€F - Main link: list L, number N
I                - incremental differences
 Ị               - insignificant? (<=1)
  ¬              - not
   1;            - prepend a 1
       ⁸         - chain's left argument, L
     œṗ          - partition (L) at truthy indexes
              €  - for €ach row, R, in L:
             ?   -   if:
            ¥    -   condition: last two links as a dyad:
          L      -     length of R
           <     -     is less than N?
        ¹        -   then: identity - do nothing, yields R
         Ç       -   else: call the last link (1) as a monad with argument  R
               F - flatten into a single list

A monadic link?

heh, and a "special" one at that.

Rearranging your stuff a bit helps for -2.

Nice stuff, thanks @EriktheOutgolfer!

Pyth, 23 bytes
sm?<ldvzd[hd\-ed).ga=hZ

Try it online
How it works
sm?<ldvzd[hd\-ed).ga=hZkQ

                        Q    autoinitialized to eval(input())
                 .g          group by k ↦
                    =hZ          Z += 1, returning new value (Z is autoinitialized to 0)
                   a   k         absolute difference with k
 m                           map d ↦
  ?                              if
    ld                               length of d
   <  vz                             less than eval(z) (z is autoinitialized to input())
        d                        then d
         [hd\-ed)                else [d[0], '-', d[-1]]
s                            concatenate

Japt, 24 bytes
óÈÄ¥YÃ®l ¨V?Zv +'-+Zo :Z

Try it online!
Explanation
óÈ   Ä ¥ YÃ ®   l ¨ V?Zv +'-+Zo :Z
óXY{X+1==Y} mZ{Zl >=V?Zv +'-+Zo :Z}   Ungolfed
                                      Implicit: U = input array, V = input integer
óXY{      }                           Group U into runs such that for each pair X, Y:
    X+1==Y                              Y is exactly 1 more than X.
            mZ{                   }   Map each run Z to:
               Zl >=V?                  If Z has at least V items:
                      Zv     Zo           Z.unshift() and Z.pop() (the first and last items)
                         +'-+             joined with a hyphen.
                                :       Otherwise:
                                 Z        just Z.
                                      Implicit: output result of last expression

APL, 38 bytes
{∊⍺{⍺>≢⍵:⍵⋄2⌽'-',2↑¯1⌽⍵}¨⍵⊂⍨1,1≠2-⍨/⍵}

Mathematica, 128 bytes
(s=#2;t=r=1;While[t<Length@s,If[s[[t+1]]-s[[t]]==1,r++,r=1];If[r==#,s[[t-#+3;;t]]="-";r--];t++];s//.{b___,a_,a_,c___}:>{b,a,c})&

input

[3,{3,5,6,7,8,10,11,12,14,16,17,18,19,20,21,22,24}]

output

{3, 5, "-", 8, 10, "-", 12, 14, 16, "-", 22, 24}

Try it online!

here

Retina, 101 bytes
\d+
$*
\b(1+) (?=1\1\b)
$1X
T`X` `\b((X)|1)+\b(?=.*¶(?<-2>1)+(?(2)(?!))11)
T`X`-
-1+(?=-)|¶1+

1+
$.&

Try it online! Takes the space-separated list L on the first line and the integer N on the second line. Explanation: The first stage converts the input to unary. The second stage changes the space between consecutive integers to an X. The third stage looks for runs of consecutive integers whose length is less than N and changes their Xs back to spaces. The fourth stage changes the Xs to - (this was 3 bytes shorter than using -s in the first place.) The fifth stage deletes all integers still left in the middle of a run, as well as N, while the final stage converts back to decimal.

PHP 7, 137 136 134 117 110 108 bytes
for($a=$argv,$i=2;$n=$a[$i++];$k<$a[1]||array_splice($a,$i,$k-2,"-"))for($k=print"$n ";$a[$i+$k]-++$k==$n;);

Takes L from first argument, list elements after that. Run with -nr or try it online.
Replace $L=($a=$argv) with $a=$argv,$L= (+1 byte) for PHP<7.
breakdown
for($a=$argv,$i=2;              # import input
    $n=$a[$i++];                # loop $n through list elements
    $k<$a[1]||                      # 3. if streak length ($k) is >=L ($a[1])
        array_splice($a,$i,$k-2,"-")    # then replace with "-"
)
for($k=print"$n ";                  # 1. print element and space
    $a[$i+$k]-++$k==$n;);           # 2. find consecutive numbers

Ruby, 68 bytes
->n,l{l.slice_when{|x,y|x<y-1}.map{|x|x[n-1]?x.minmax.uniq*?-:x}*?,}

Returns a string like for example 3,5-8,10-12,14,16-22,24.
Try it online!

J, 40 bytes
;@((](,_,{:)/)^:(<:#)&.>]<;.1~1,1<}.-}:)

Try it online!
Uses _ instead of -.
Explanation
;@((](,_,{:)/)^:(<:#)&.>]<;.1~1,1<}.-}:)  Input: integer N (LHS), array L (RHS)
                                  }.      Behead L
                                     }:   Curtail L
                                    -     Subtract elementwise to get the increments
                                1<        Test if greater than 1
                              1,          Prepend a 1
                        ]                 Get L
                         <;.1~            Partition L into boxes using the previous array
                     & >                  Operate on each box (partition) with N
              ^:                            If
                   #                          The length of the partition
                 <:                           Is greater than or equal to N
   (](     )/)                                Reduce (right-to-left) it using
         {:                                     Tail
       _,                                       Prepend _
      ,                                         Append to LHS
                     &.>                    Box the result
;@                                        Raze - join the contents in each box

Vyxal, 23 bytes
D0J¨pε⁽ṅḋ•ƛL⁰≥[₍ht\-Y}f

Try it Online!
23 bytes seems to be the standard here, so I figured I'd add my own 23 byter. Takes List then N.
Explained
D0J¨pε⁽ṅḋ•ƛL⁰≥[₍ht\-Y}f
D0J                     # Push 3 copies of the input and append 0 to the last
   ¨pε                  # get the absolute difference of each overlapping pair
      ⁽ṅḋ               # group by diff <= 1
         •              # mold to shape
          ƛ          }  # to each consecutive run:
           L⁰≥[         #   if the length is >= N
               ₍ht\-Y   #     [head, "-", tail]
                      f # flatten that

Dyalog APL v16.0, 82 80 78 76 75 65 62 bytes
{S/⍨1,⍨2≠/S←'-'@(⍸⊃∨/(-0,⍳⍺-3)⌽¨⊂(⍴⍵)↑∧/¨(⍺-1),/¯1⌽1=-2-/⍵)⊢⍵}

Wow, this is ... bad. There's probably a much much shorter solution with stencil.
Try it online!
Golfing suggestions welcome!

Yeah, what about it?

Sorry, wrong place.

^ What do you mean?

My comment was based on a different challenge.

I'm assuming that if you have a solution, Adám, then it utilizes v16 builtins?

No it doesn't. Also, we've hired another golfer.

Dyalog hired him? Or am I misunderstanding something?

He's a summer intern at our office here in England.

Is this him? https://www.dyalog.com/blog/2016/10/winning-the-apl-programming-contest-bioinformatics-category/

Yes. I'm being 100% serious when I say that we want people from PPCG! Interested?

Maybe some day.

Jelly, 39 37 36 bytes
IỊṣ0;€1ṁ@
ÇL€<Ɠ¬TịÇḊ€Ṗ€F;€”-FyµŒgQ€F

Try it online
Takes the array via arguments, and the integer via STDIN. The TIO link uses the footer ÇG so the output is space-separated.
How? (Array: a, Integer: n)
(`f`)
IỊṣ0;€1ṁ@
I          Deltas of `a`
 Ị         Insignificant (x -> abs(x)<=1) applied to each element
  ṣ0       Split at occurrences of `0`.
    ;€1    Append `1` to each element
       ṁ@  `a` shaped like that
ÇL€<Ɠ¬TịÇḊ€Ṗ€F;€”-FyµŒgQ€F
Ç                            `f`
 L€                          Length of each element
   <Ɠ                        x -> x < n applied to each element
     ¬                       Logical not of each element (because Jelly doesn't have <= nor >= atoms)
      T                      Nonzero indexes
       ịÇ                    Index `f` at those indexes
         Ḋ€Ṗ€                x -> x[1:-1] applied to each element
             F               Flatten
              ;€”-           Append a hyphen to each element
                  F          Flatten
                   y         Translate (replaces all elements to be deleted with a hyphen)
                    µ        Start a new monadic link
                     Œg      Group runs of equal elements
                       Q€    Uniquify each element (make runs of hyphens one hypen)
                         F   Flatten, yet again.

I'm guessing I fell ... flat on this one.

JavaScript (ES6), 126 119 bytes
(e,c)=>{for(i=0,R='';i<e.length;R+=(R&&',')+(u-m>=c?m+'-'+--u:e.slice(z,i))){m=u=e[i],z=i;while(e[++i]==++u);}return R}

An anonymous function. Takes input in the order Array L, Integer N and returns the result as a comma-separated string.

M=(e,c)=>{for(i=0,R='';i<e.length;R+=(R&&',')+(u-m>=c?m+'-'+--u:e.slice(z,i))){m=u=e[i],z=i;while(e[++i]==++u);}return R}
console.log(M(eval(prompt()),+prompt()))

Use currying to save a byte e=>c=>.

(e,c)=>eval("for(i=0,R='';m=u=e[z=i],i<e.length;R+=(R&&',')+(u-m<c?e.slice(z,i):m+'-'+--u))while(e[++i]==++u);R") - 113 bytes