text:
Print all alphanumeric characters plus underscore
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

When printing to stdout, an optional trailing newline after your output is permitted.
Built-in constants that contain 9 or more of the above characters are disallowed.

Shortest code in bytes wins.
This is a very simple challenge, which I believe will generate some interesting answers nevertheless.

Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=85666,OVERRIDE_USER=4162;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

Comments are not for extended discussion; this conversation has been moved to chat.

"Built-in constants that contain 9 or more of the above characters are disallowed" sighs in 05AB1E...

Is duplication of one char allowed?

@l4m2 No. "To be precise, the following characters need to be output, and no more."

and no more can be parsed as "No more kind of chars"

Convex, 9 bytes
New method! Also, I realized that is it pretty much exactly the same as Luis' answer but in Convex, but I came up with this independently.
'{,®\W"Oò

Try it online!
Explanation:
'{,           Array of chars from NUL to 'z
   ®\W"       Regex to match non-word characters
       Oò     Replace all matches with emtpy string

Old solution, 10 bytes:
A,'[,_¬^'_

Try it online!
Explanation:
A,          0-9
'[,_¬^      A-Za-z
'_          _

@mbomb007 Yes it is equivalent to the CJam code A,'[,_el^'_

Which encoding is this?

@CᴏɴᴏʀO'Bʀɪᴇɴ CP-1252 or Windows-1252

Ruby, 26 bytes
Characters can be printed in any order? Don't mind if I do!
Try it online!
$><<(?0..?z).grep(/\w/)*''

Perl, 20 bytes
Requires -E at no extra cost.
say+a.._,A.._,_..9,_

So, my original answer (below) was a bit too boring. The only thing I've managed to come up with is the above, that's exactly the same, but looks a bit more confusing... It's pretty much exactly equivalent to the below:
say a..z,A..Z,0..9,_

I like @msh210's suggestions in the comments, but they're just a bit too long!

+1. Slightly more interesting but longer is any of these, all 27 bytes: say grep/\w/,map chr,1..122 || say map{chr=~/\w/;$&}1..122 || say map{chr=~s/\W//r}1..122

@msh210 Still can't shrink this more... Managed a 25 though: say chr=~/\w/g for 1..255...

JavaScript (ES6), 62 bytes
_=>String.fromCharCode(...Array(123).keys()).replace(/\W/g,'')

Returns 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz, so only 6 bytes shorter than a function that returns the string literal. Yes, it sucks.

You could try finding a string for which btoa returns the required output.

@gcampbell 60! (60 factorial) strings might take some time to search...

You could just use atob.

@gcampbell I have to exclude unrepresentable strings somehow.

@gcampbell It turns out that the btoa version takes 62 bytes anyway: 45 to encode 60 alphanumerics, 3 unencoded chars (including _) and 14 for _=>atob("")+"".

Oh, that didn't help then. You could still add it to your answer maybe.

My approach using getOwnPropertyNames of Math comes out at 87 bytes, but perhaps it is still interesting: [...new Set(Object.getOwnPropertyNames(Math).join(""))].join("")+"456789ABCDFHJKMUVWXYZjkv" (replace ("") with two graves)

Haskell, 38 bytes
'_':['a'..'z']++['A'..'Z']++['0'..'9']

Nothing to explain here.

question: what's the difference between : and ++?

@Downgoat: ++ takes two strings and concatenates them. : takes a char and a string and puts the char in front of the string. "_"++['a'..'z']... also works, but is one byte longer.

Cheddar, 31 27 bytes
->97@"123+65@"91+48@"58+"_"

This showcases the @" operator well
Non-completing because I finally got aroudn to fixing the @" operator. The bug was that it was generating a Cheddar range not a JS range so it couldn't properly work

Explanation
The @" operator was designed by @CᴏɴᴏʀO'Bʀɪᴇɴ, and what it does is generate a string range from LHS to RHS. When used as an unary operator, it returns the char at the given code point (like python's chr)
Ungolfed
->
  97 @" 123 +
  65 @" 91  +
  48 @" 58  +
  "_"

brainfuck, 58 bytes
+++[[<+>->++<]>]<<[-<->]<<-.+<<++[->>+.>+.<<<]<--[->>.+<<]

Try it online.
Initializes the tape to 3·2n, and works from there.
+++[[<+>->++<]>]    initialize the tape
                    |   0 |   3 |   6 |  12 |  24 |  48 |  96 | 192 | 128 |   0 |   0 |
                                                                                ^
<<[-<->]            subract 128 from 192
                    |   0 |   3 |   6 |  12 |  24 |  48 |  96 |  64 |   0 |   0 |   0 |
                                                                        ^
<<-.+<<++           ouput '_'; increment 24 twice
                    |   0 |   3 |   6 |  12 |  26 |  48 |  96 |  64 |   0 |   0 |   0 |
                                                ^
[->>+.>+.<<<]       output aAbBcC ~ zZ
                    |   0 |   3 |   6 |  12 |   0 |  48 | 122 |  90 |   0 |   0 |   0 |
                                                ^
<--[->>.+<<]        decrement 12 twice; output 0 ~ 9
                    |   0 |   3 |   6 |   0 |   0 |  58 | 122 |  90 |   0 |   0 |   0 |
                                          ^

V, 27 bytes
i1122ñYpñvHgJ|éidd@"Í×

Try it online!
This answer is horribly convoluted. I'll post an explanation later.
Hexdump:
00000000: 6916 1631 1b31 3232 f159 7001 f176 4867  i..1.122.Yp..vHg
00000010: 4a7c e969 6464 4022 1bcd d7              J|.idd@"...

Explanation:
Readable:
i<C-v><C-v>1<esc>                                   "Insert the text "<C-v>1"
                                                    "<C-v> means "literal"
                 122ñ       ñ                       "122 times,
                     Yp                             "Duplicate this line
                       <C-a>                        "And increment the first number on this line
                             vHgJ                   "Join every line together
                                 |éi                "Insert an 'i' at the beginning of this line
                                    dd              "Delete this line
                                      @"<esc>       "And execute it as V code.
                                                    "That will generate every ascii value from 1-123
                                             Í×     "Now remove every non-word character.

:D :D :D Cheddar is tied with a golfing lang!

J, 30 29 28 bytes
Saved a byte thanks to randomra!
~.u:95,;48 65 97+i."*10,,~26

Output:
   ~.u:95,;48 65 97+i."*10,,~26
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Explanation
I wont provide an explanation per se, but will provide intermediate results.
   10,,~26
10 26 26
   i. b. 0
1 _ _
   *  b. 0
0 0 0
   i."* b. 0
   i."*2 3 4
0 1 0 0
0 1 2 0
0 1 2 3
   i. 2
0 1
   i. 3
0 1 2
   i. 4
0 1 2 3
   i."*10,,~26
0 1 2 3 4 5 6 7 8 9  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   0 1 2 + i."*10,,~26
0 1 2 3 4 5 6 7  8  9  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
1 2 3 4 5 6 7 8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
   48 65 97+i."*10,,~26
48 49 50  51  52  53  54  55  56  57  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48  48
65 66 67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
   ;48 65 97+i."*10,,~26
48 49 50 51 52 53 54 55 56 57 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
   95,;48 65 97+i."*10,,~26
95 48 49 50 51 52 53 54 55 56 57 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 ...
   u:95,;48 65 97+i."*10,,~26
_01234567890000000000000000ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
   ~.u:95,;48 65 97+i."*10,,~26
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

PowerShell v3+, 35 33 bytes
-join([char[]](1..127)-match'\w')

Constructs a dynamic array 1..127, casts it as a char array. That's fed to the -match operator working on the regex \w, which will return all elements that match (i.e., exactly alphanumeric and underscore). We encapsulate those array elements in a -join to bundle it up as one string. That's left on the pipeline and output is implicit.

Hey, that's not fair. My own solution is identical except I started at 0 ...

@Joey Gotta go fast. :D

Especially for the trivial and obvious solutions, I guess ;-)

Haskell, 31 bytes
do(x,y)<-zip"aA0_""zZ9_";[x..y]

The expression zip "aA0_" "zZ9_" gives the list of endpoints [('a','z'),('A','Z'),('0','9'),('_','_')]. The do notation takes each (x,y) to the inclusive \(x,y)->[x..y] and concatenates the results. Thanks to Anders Kaseorg for two bytes with do instead of >>=.
Compare to alternatives:
do(x,y)<-zip"aA0_""zZ9_";[x..y]

zip"aA0_""zZ9_">>= \(x,y)->[x..y]
f(x,y)=[x..y];f=<<zip"aA0_""zZ9_"
id=<<zipWith enumFromTo"aA0_""zZ9_"
[c|(a,b)<-zip"aA0_""zZ9_",c<-[a..b]]
f[x,y]=[x..y];f=<<words"az AZ 09 __"

do notation saves two bytes: do(x,y)<-zip"aA0_""zZ9_";[x..y]

Pascal (FPC),  85 83 73 bytes
Just plain object pascal using a set of chars. Writing a full program instead of a procedure shaves off 2 bytes. Removing the program keyword shaves 10 more bytes.
var c:char;begin for c in['a'..'z','A'..'Z','0'..'9','_']do write(c);end.

Try it online!

I always was and probably will always be confused by the exact classification of Object Pascal. Turbo/Borland Pascal and FreePascal are certainly happy without the useless program keyword.

@manatwork I didn't know that. Oddly enough it now makes pascal competitive here...

The language I grew up with. I know that it is not yet dead...

@rexkogitans Yeah I learned it at school, but can't remember anything from back then... I'm playing with some programming again now

Pyth, 13 12 bytes
s:#"\w"0rk\|

Try it online!
Finds all characters in U+0000 to U+007B that matches the regex /\w/.
Outputs 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.
alternative approach: 15 bytes
ssrMc4"0:A[a{_`

Try it online!
basically generates the half-inclusive ranges required: 0-:, A-[, a-{, _-`.

C, 50 bytes
Call f() without any arguments.
f(n){for(n=128;--n;)isalnum(n)|n==95&&putchar(n);}

Prints
zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210

isalnum(n)|n==95&&putchar(n)

There's UB there. You didn't pass the required arguments.

@orlp - You used putc instead of putchar. putc expects a stream to write to as well, which you didn't pass. The function itself works fine (try removing your putc altogether, and it works).

@owacoder Oops!

@ven No, it's not. In C, calling a function without giving arguments leaves the variables uninitialized. Then, in the for, n is initialized before it's used, so all's well.

@QPaysTaxes that's wrong. If the number of arguments does not equal the number of parameters, the behavior is undefined. 6.5.2.2/6, see N1570.

If what you said only applies to some ancient C version (my link is the C11 draft), please point out the legalese, I'm interested.

Huh, that's odd. I just tested it on GCC and it seems to act that way. It might be that way from C89, lemme see if I can dig up the spec after class.

I'm pretty sure it is undefined behavior, but what matters is that it actually works with one or more implementations (at least GCC).

@Ven  Maybe he just needs to say that it relies on undefined behaviour?
https://codegolf.meta.stackexchange.com/questions/21/c-c-golfing-should-undefined-behaviour-be-allowed

Retina, 30 19 16 15 12 bytes
I modified my original alphabet attempt for this latest version. Each character is printed in a loop.
The first line is empty.

;
+T\`;w`w_
Try it online
Output:
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Thanks to Leaky Nun for golfing 4 bytes off my latest attempt.

I'd say that w counts as a constant containing 9 or more of the required characters. You'll probably have to expand the right hand side and replace the w on the left with o. Although you can save a byte by using EO instead of d since they only contain 5 characters each.

@mbomb007 w inside the transliteration stage has nothing to do regex. It's a shorthand that expands to a list of the required 63 characters. At least I'd ask orlp about this case specifically, since it's quite different from using \w in a regex.

///, 63 bytes
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

How is it the valid answer? Looks like it's violating the rules.

@nicael which rule?

"Built-in constants that contain 9 or more of the above characters are disallowed."... Am I missing something obvious, @Leaky?

Yes, that this didn't use any built-in constants.

Ok, but this is weird at least. Definitely OP doesn't ask you to copy-paste the sequence, that's not interesting.

@nicael They are default constants, not built-in ones. You can modify them.

My first attempt at codegolf!
C#, 168 152 150 147 130 127 117 116 115 109 106 bytes
for(var a='0';a<'~';a++){Console.Write(System.Text.RegularExpressions.Regex.IsMatch(a+"","\\w")?a+"":"");}

Thanks a lot to aloisdg, AstroDan, Leaky Nun and Kevin Lau - not Kenny for all the help in comments.

Welcome to PPCG! Feel free to remove all the space! Also check Tips for golfing in C# for some tips.

Also don't forgot System.Text.RegularExpressions. It is sad, but we have to use it.

I can't check right now but I believe that you can save some bytes by using +"" instead of .ToString().

Can you use [\w_] instead of [a-zA-Z0-9_]?

You are both right, @LeakyNun I need one more \ to escape, but still shorter :)

What's those spaces there doing?

var a=(char)i;Console.Write(Regex.IsMatch(a+"", "[\\w_]") ?a+"":""); to var a=""+(char)i;Console.Write(Regex.IsMatch(a,"[\\w_]")?a:"");

Great - saved me 2 bytes more. I'm really starting to like this codegolf :)

Actually saved me 5 bytes - didn't know about ""+ instant string conversion :)

Try this (117 bytes) using System.Text.RegularExpressions;for(char a='0';a<='~';a++){Console.Write(Regex.IsMatch(a+"","[\w_]")?a+"":"");}

Very impressive @AstroDan !

@Daniel 2 more, try Debug.Write instead of Console.Write (make sure it works with your compiler / ide)

Doesn't seem to work in VS2015. And I'll also have to include System.Diagnostics correct?

@Daniel Worked for me in LINQPad 4 without System.Diagnostics. But only counts if it works for you. Also if you @ someones name they will get a message directly.

AFAIK, the \w regex class covers the alphanumerics and also _, which should make "\\w" valid enough for your regex match function.

You are right @KevinLau-notKenny - Thanks

Your code should a be function or a full program not a statement. Also use .NetFiddle to share a demonstration of your code :)

First of all welcome to PPCG! Maybe this challenge in C# isn't the best to codegolf, since just printing everything manually: Console.Write("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"); (81 bytes) is shorter. ;) Or, even slightly shorter: var s="abcdefghijklmnopqrstuvwxyz";Console.Write(s+s.ToUpper()+"0123456789_"); for 78 bytes. I would also take a look at the link @aloisdg gave you for Golfing tips in C# for future reference. Once again welcome, and have fun here!

"C# isn't the best to codegolf" I find C# fun enough to code golf. I think it is a great mainstream language to play with. If you are here to win, you will loose. Define your objective as learning and having a good time and you will win all the times.

@aloisdg I completely agree with everything you've said, but you've taken it out of context. The entire sentence is "Maybe this challenge in C# isn't the best to codegolf". If you look at all my answers you only see Java 7 answers which are usually longer than C# and never win. Why do I post them anyway? Because it's fun, just like you've stated. I was merely stating that this particular challenge it's shorter to just print the hardcoded string, and therefore C# (and Java as well) isn't really suitable for this challenge, imho. ;)

@KevinCruijssen Indeed. Sorry I mistook your words :)

@aloisdg No problem, I also realized that printing the hard-coded string is a default loophole despite being shorter in C# and Java..

A bit late to the party, but I figured we should be able to avoid that whole regex ordeal by doing something like this:
for(var a='/';a++<'~';)if(char.IsLetterOrDigit(a)||a=='_')Console.Write(a); (75 bytes)
I also removed braces, replaced ternary with if, and shortened the loop.

@PatrikWesterlund Not bad - will check it out later :)

Python 3, 58 bytes
print('_',*filter(str.isalnum,map(chr,range(123))),sep='')

A full program that prints to STDOUT.
The output is: _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
How it works
map(chr,range(123))       Yield an iterator containing all ascii characters with
                          code-points in [0,122]...
*filter(str.isalnum,...)  ...keep characters if alphanumeric and unpack into tuple...
print('_',...,sep='')     ...add underscore and print all characters with no separating
                          space

Try it on Ideone
If string constants were allowed, the following would have been 45 bytes:
from string import*
print('_'+printable[:62])

print('_'+*filter(str.isalnum,map(chr,range(123))))

@LeakyNun That throws a syntax error. I thought about doing something similar with print('_',*filter(str.isalnum,map(chr,range(123)))), but that prints separating spaces; the OP said in the comments that '...no spaces are permitted in the output at all'.

Python 2 can save one byte with this approach: print''.join(filter(str.isalnum,map(chr,range(123)))),'_'

bash – 47 37 bytes
man sh|egrep -o \\w|sort -u|tr -d \\n

Output on my system is:
_0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ

Thanks to Digital Trauma for helpful suggestions.
On some systems you might be able to use ascii instead of man sh to save a byte.

man sh|egrep -io _\|\\w|sort -u|tr -d \\n

@DigitalTrauma Thank you! Experimented and found out \w matches _ and is already case insensitive, so could shorten even more.

env instead of man sh should work on most environments. It does on mine. $ env|egrep -o \\w|sort -u|tr -d \\n -> 0123456789ABCDEFGHIKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.

There's no J. My bad.

Pure bash, 32
printf %s {a..z} {A..Z} {0..9} _

Ideone.

Sesos, 17 bytes
00000000: a854be 2cbc9e 71d597 14bc56 1ad99e 713b           .T.,..q....V...q;

Output
0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz_

Try it online! Check Debug to see the generated binary code.
How it works
The binary file above has been generated by assembling the following SASM code.
add 48     ; Set cell 0 to 48 ('0').
fwd 1      ; Advance to cell 1.
add 10     ; Set cell 1 to 10.
jmp        ; Set an entry marker and jump to the jnz instruction.
    rwd 1  ;   Retrocede to cell 0.
    put    ;   Print its content (initially '0').
    add 1  ;   Increment cell 0 ('0' -> '1', etc.).
    fwd 1  ;   Advance to cell 1.
    sub 1  ;   Decrement cell 1.
jnz        ; While cell 1 in non-zero, jump to 'rwd 1'.
           ; This loop will print "0123456789".
rwd 1      ; Retrocede to cell 0, which holds 48 + 10 = 58.
add 7      ; Set cell 0 to 65 ('A').
fwd 1      ; Advance to cell 1.
add 26     ; Set cell 1 to 26.
jmp        ; Set an entry marker and jump to the jnz instruction.
    rwd 1  ; Retrocede to cell 0.
    put    ; Print its content (initially 'A').
    add 32 ; Add 32 to convert to lowercase ('A' -> 'a', etc.).
    put    ; Print the cell's content.
    sub 31 ; Subtract 31 to switch to the next uppercase letter ('a' -> 'B', etc.).
    fwd 1  ; Advance to cell 1.
    sub 1  ;   Decrement cell 1.
jnz        ; While cell 1 in non-zero, jump to 'rwd 1'.
           ; This loop will print "AaBb...YyZz".
rwd 1      ; Retrocede th cell 0, which holds 65 + 26 = 91.
add 4      ; Set cell 0 to 95 ('_').
put        ; Print its content.

Wow, I was about to post a solution very similar to yours.

Alike minds think great!

@LeakyNun Hm, kinda late, but it looks like yours is 3 bytes shorter...

@EriktheOutgolfer Sesos used to be encoded in a less efficient manner. Both programs are 17 bytes long now.

@Dennis Ah, well, the TIO cache can be confusing at times.

@EriktheOutgolfer I'm not sure what you mean. The cache cover the last few weeks and didn't even exist in 2016.

PHP, 40 bytes
_0<?for(;$a++^9?$a^q:$a=A;)echo" $a"|$a;

Online Demo.

+1 for excellence. Side note: PHP 7.2 yields warnings mentioning that future versions will throw errors for undefined constants. :-(

Brachylog, 25 bytes
"_"w9yrcw"A":"Z"ycL@l:Lcw

This prints the following to STDOUT:
_9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

Explanation
"_"w               Write "_"
9y                 Get the list [0:1:2:3:4:5:6:7:8:9]
  rcw              Reverse it, concatenate into one number, write
"A":"Z"y           Get the list of all uppercase letters
        cL         Concatenate into a single string L
          @l:Lcw   Concatenate L to itself lowercased and write

Dyalog APL, 18 bytes
∊'\w'⎕S'&'⎕UCS⍳255

prints:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

@user Built-in constants that contain 9 or more of the above characters are disallowed.

MATL, 11 bytes
7W:'\W'[]YX

Try it online!
7W     % Push  2 raised to 7, i.e. 128
:      % Range [1 2 ... 128]
'\W'   % Push string to be used as regex pattern
[]     % Push empty array
YX     % Regex replace. Uses (and consumes) three inputs: source text, regex pattern,
       % target text. The first input (source text) is implicitly converted to char.
       % So this replaces non-word characters by nothing.
       % Implicitly display

2 bytes shorter: 8W:'\w'XX

@DrGreenEggsandIronMan Thanks! But I think newlines are not allowed as separators. The challenge says " a string of the alphanumeric characters plus underscore... and no more"

So why couldn't you do 8W:'\w'XX! which I tried but doesn't work

@DrGreenEggsandIronMan  Very good question! Let me answer you in chat so I can use a little more characters

CJam, 15 14 11 bytes
4 bytes off thanks to @FryAmTheEggman and @Dennis!
A,'[,_el^'_

Try it online!
A,    e# Push range [0 1 ... 9]
'[,   e# Push range of chars from 0 to "Z" ("[" minus 1)
_el   e# Duplicate and convert to lowercase
^     e# Symmetric difference. This keeps letters only, both upper- and lower-case
'_    e# Push "_".
      e# Implicitly display stack contents, without separators

05AB1E, 18 16 12 bytes
žyLçá9Ý'_)˜J

Explanation
žyL               # push [1..128]
   ç              # convert to char
    á             # keep only members of the alphabet
     9Ý           # push [0..9]
       '_         # push underscore
         )˜J      # add to lists of lists, flatten and join
                  # implicit output

Try it online
Edit: Saved 4 bytes thank to Adnan

Does this also work: žyLçJá9ÝJ'_J?

@Adnan: Yes of course :) Much better!

Alternatively žyLçá9Ý'_)˜J also works for the same byte count.

Alternatively, žj non-competing.

Brainfuck, 114 103 98 90 76 71 bytes
Another trivial (now non-trivial) solution, but this time is BF!
Saved 14 (!) bytes thanks to @primo.
Saved 4 more bytes thanks to @primo's suggestion to generate the range backwards, and I saved another by incrementing before printing for the lowercase letters.
New (recurrence 4, 71):
+[--[<+++++++>->+<]>-]<<+++<--<-<-----<++++.+>>>[-<<.+<+.>>>]>[-<<.+>>]

Old (values, 114):
-[----->+<]>--->++++++++++>--[----->+<]>-------.++>----[---->+<]>++>++++[->++++++<]>++[-<<.+<<.+>>>>]<<<<<<[-<.+>]

Old (recurrence 1, 103):
++++++++++[[<+>->+<]>+++++++++++++++]<<[<]>>+>++++++++>>----->>-----.++<<<<<[->>>.+>>.+<<<<<]<[->>.+<<]

Old (recurrence 2, 90):
+++++++[[<+>->+<]>>+++[-<+++++++>]<]<<[<]>+++>-->->----->++++.++<<<[->>.+>.+<<<]<[->>.+<<]

Old (recurrence 3, 76):
+[[<+++++++>->+<]>+++]<<[<]>+++>-->->----->++++.++<<<[->>.+>.+<<<]<[->>.+<<]

Assumes 8 bit wrapping cells and wrapping memory. I used Try it online.
All print out _AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789
First, this part
+[--[<+++++++>->+<]>-]<<

initializes the tape with these values
[91, 70, 49, 21, 7]
                 ^

This works because the recurrence relation I modeled basically is f(x) = 7 * (3 * x + 1), backwards. See @primo's Hello, World! Answer for an explanation of what a recurrence relation is.
Then, it's fairly simple to change these values to useful ones. (and print the underscore)
Code: +++<--<-<-----<++++.+

Tape: [96, 65, 48, 26, 10]
       ^

Then, the simple loops use the values to print the rest of characters. I save 1 byte by having an increment before the print.
>>>[-<<.+<+.>>>]>[-<<.+>>]

I really need to find a shorter sequence generation.
I found a recurrence relation that seems to work well, but there might be a shorter one w/ less hunt and peck.
I used a linear regression calculator to find what should be the shortest possible linear recurrence relation, so I should probably find some other formula if I want to improve.
@primo really improved the recurrence relation a lot, thanks.

How about a backwards construction? +[--[<+++++++>->+<]>-]

@primo Wow! How does that work?

3 is uneven so it will loop a full 256 times. By ending with >-], you can be sure that the final term will be 1 (x7). Actually, you should probably start with -, it finishes a lot faster.

F#, 50 59 bytes
Seq.iter(printf"%c"<<char)(95::[48..57]@[65..90]@[97..122])

Output:
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Edit: missed the digits the first time
Edit2, inspired by this Haskell solution this F# snippet is 67 bytes.
Seq.zip"aA0_""zZ9_"|>Seq.iter(fun(x,y)->Seq.iter(printf"%c")[x..y])

Output:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

Brainfuck, 89 bytes
+++++++++[>+++++>+<<-]>+++.>[<+.>-]<+++++++>>+++++++++++++[<+<+.+.>>-]<<+++++.+>[<+.+.>-]

Try it here
Details:
+++++++++[>+++++>+<<-]>+++.  Goes to '0' while remembering a 9 for the 9 other numbers
[<+.>-]                      Simply prints for the next 9 characters
<+++++++>                    Moves it 7 space to the letters
>+++++++++++++               Saves a 13
[<+<+.+.>>-]                 Prints 2 char at a time while making a second '13' space
<<+++++.+>                   Moves 5, prints '_' and moves to the lowercases
[<+.+.>-]                    And again the double print

If I could have commented, I would have to improve others answers. But since I can't, I might as well post my own. As I started writing this the lowest BF one was 96 long.

Hexagony, 33
"A}_8_47<='>({a/_x.@.9!\356);');

Expanded:
    " A }
  _ 8 _ 4 7
 < = ' > ( {
a / _ x . @ .
 9 ! \ 3 5 6
  ) ; ' ) ;
   . . . .

Output:
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1203568479_

Try it online!
Note that there is an unprintable character 0x1A as the first byte of the program. This also makes the first row of the expanded Hexagon look sort of off. Many thanks to Martin for showing me this trick, as well as for suggesting the algorithm for printing the alphabet!
This prints the alphabet by storing a and A on two edges of a hexagon and the number 26 on the edge of the hexagon that touches the joint between the letters. This looks something like this:
A \ / a
   |
   26

Then it enters a loops that prints the letters and then increments them, and then decrements the number. After one iteration we would have:
B \ / b
   |
   25

And so on. The linear code for the initialisation is: 0x1A " A } a. The linear code for the loops outside of control flow changes is: ; ) ' ; ) { ( ' =.
Once the counter reaches zero, we follow a different path to print the numbers and an underscore. Written out linearly this is: x 3 5 6 8 4 7 9 ! ; { @. This replaces the current memory edge's value with the number 1203568479 (note that x's ASCII code is 120), which contains all of the decimal digits. We print out this number and then we use a neat feature of Hexagony: we print out the number mod 256 as an ASCII character. This just happens to be 95, or underscore.

SMBF, 29 bytes
<[<.-<.->>-]<<-.<[<.->-]9
zZ

Try it online
The last byte is a literal \x1A (decimal 26). It shows in the "edit" mode of this answer as a tiny arrow, but cannot otherwise be seen for some reason...
I use literals in the source code to provide a starting value and how many times to loop. 26 times for the loop printing Z-A and z-a, then subtract and print _, then use the newline (decimal 10) to print 9 and subtract, looping 10 times.
Output:
ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa_9876543210

R, 40 bytes
Inspired by this answer.

cat(intToUtf8(c(97:122,65:90,48:57,95)))

Try it online!

x86-16 machine code, PC DOS, 26 bytes
Binary:
00000000: be12 01ad 918a c1cd 293a cde0 f83c 5f75  ........):...<_u
00000010: f2c3 7a61 5a41 3930 5f5f                 ..zaZA90__

Listing:
BE 0112     MOV  SI, OFFSET TBL     ; SI to range table
        RLOOP:
AD          LODSW                   ; AL = high, AH = low
91          XCHG AX, CX             ; move to CX
        CLOOP:
8A C1       MOV  AL, CL             ; move current char to AL for display
CD 29       INT  29H                ; write to console
3A CD       CMP  CL, CH             ; high and low char the same yet?
E0 F8       LOOPNZ CLOOP            ; if not, decrement and keep looping
3C 5F       CMP  AL, '_'            ; was last char displayed a '_'?
75 F2       JNZ  RLOOP              ; loop until then
C3          RET                     ; return to DOS
        TBL DB 'zaZA90__'           ; handy table of ranges to display

Uses a table with a range of chars to display.  Turned out that it wasn't any longer to do it this way than unroll all of the 4 different conditions in code (though I'm positive I can be proven wrong there).
Standalone PC DOS executable (COM) program.
Runtime:

NoRAL, 173 169 bytes
psh 0a1a
sto 0100 41
sto 011a 61
orr 0201 0201
jpz 0220
sto 0134 30
inc 0215
inc 0216
dec 0201
inc 0205
inc 0206
inc 0209
inc 020a
dec 0202
jpz 0235
jmp 0203
sto 013e 5f

NoRAL is a toy assembly language I found on Esolangs.org. Let's give it a whirl (using a minimally adapted version of the Python implementation): Try it online!
There's also a browser-based interpreter here if you want to step through the code.
Explanation
Everything in NoRAL is stored in addressable memory, including the output (256 consecutive bytes, displayed as a 32x8 rectangle) and the program itself, which is self-modifying.
# We use two memory locations in the code, 0x0201 and 0x0202, as counters
# Set digit counter to ten (0x0a), letter counter to twenty-six (0x1a)
# The psh instruction pushes something to the stack, which we're not using, so it's
# effectively a no-op
psh 0a1a
# The output section of memory runs from addresses 0x0100 to 0x01ff
# We're going to put A-Z at 0100-0119, a-z at 011a-0133, 0-9 at 0134-013d, and _ at 013e
# Output uppercase and lowercase letter, starting with A (ASCII 0x41) & a (0x61)
# These instructions will be modified later to output the other letters
sto 0100 41
sto 011a 61
# OR digit counter with itself (no-op, but sets the zero flag if counter is zero)
orr 0201 0201
# If the digit counter is now zero, skip next section:
jpc 0220
#     Output digit, starting with 0 (ASCII 0x30)
sto 0134 30
#     Increment memory location and ASCII code in previous statement
inc 0215
inc 0216
#     Decrement digit counter
dec 0201
# Increment letters' memory locations and ASCII codes
inc 0205
inc 0206
inc 0209
inc 020a
# Decrement letter counter
dec 0202
# If letter counter is now zero, skip next instruction:
jpz 0235
#   Jump back to "output uppercase and lowercase letter"
jmp 0203
# Output underscore (ASCII 0x5f)
sto 013e 5f

There's no permalink feature in the interpreter, that's purely awful.

...Eh. The thing I found more problematic was that the code disappears out of the input box every time you click Run, but I just kept my code in a text editor and pasted it in whenever I was ready to run it. No big deal.

Vyxal dr, 9 8 7 bytes
‛\w₇ɾCẎ

Try it Online!
-1 thanks to @emanresu A
-1 thanks to @pxeger
Beats almost everything.
‛\w122ɾCẎ # Takes no input
‛\w       # The string "\w"
   122r   # inclusive range 1-122
       C  # Cast to character
        Ẏ # Regex groups
          # "d" flag prints the deep sum of the top of the stack

Vyxal Ṫ, 11 bytes
122ɾCkr↔ṅ\_

Try it Online!
An alternative solution requiring no regex. Possibly cheating.
122ɾCkr↔ṅ\_ # Takes no input
122r        # inclusive range 1-122
    C       # Cast to character
     kr     # Uppercase letters, lowercase letters, and digits
       ↔    # Remove all not found in the second argument
        ṅ   # Join by nothing
         \_ # String "_"
            # "Ṫ" flag outputs sum of stack

Nice! 122 -> ⁺¢

You can use ₇ instead

Apparently someone switched around the order of Ẏ, so you now need the r flag

Python 3, 69 bytes
for i in range(65,123):x=chr(i);print(''if x in'[\\]^`'else x,end='')

Try it online!
Nice

Pyke, 13 bytes
150m.C#P)\_+s

Try it here!
Generates ascii 0-150 and filters by alphanumericness and adds _ to the end

Python 2, 62 bytes
r=range
print''.join(map(chr,r(97,123)+r(65,91)+r(48,58)))+'_'

prints:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

This could probably be golfed more but I'm not sure how!

Since the output can be in any order, try fiddling with combining ranges and using slices. You may be able to shave off a few bytes that way.

Jelly, 14 bytes
“09AZaz_”Or2/Ọ

Try it online!

Golfscript, 18 bytes
10,123,65>'[\]^`'^

JavaScript, 55 bytes
x=>[...new Set(Object.keys(this).join`j345689`)].join``

The code works correctly only when executed inside the global Firefox browser console (tested with Firefox 47.0 on Linux Mint inside a freshly created profile).

To be able to open the console, you first have to set devtools.chrome.enabled to true in about:config. (You can then open it using Ctrl + Shift + J).

Even the most ridiculously small change to the browser will likely break this code. In fact, I'm not sure if it will even work on another operating system.

The name of the profile might matter as well. I've named mine Default User.

Mathematica, 49 bytes
a=CharacterRange;"_"<>{48~a~57,65~a~90,97~a~122}&

Anonymous function. Takes no input and returns the string "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" as output. Just concatenates a few character ranges.

ZX Spectrum, (Machine Code) 27 bytes
start in BASIC with PRINT "" AND USR 4e4
      org 40000
      dump 40000

      ld b,"z"
      ld a,"_"
      rst 16
nchar ld a,b
      cp "/"
      ret z
      cp ":"
      jr c,ok ; print numbers
      sub "A"
      cp "Z"+1-“A”
      ld a,b ; undo change
      jr c,ok ; print A-Z
      cp "a"
      jr c,fnext ; in between ranges
ok    rst 16
fnext djnz nchar

Hexcode
067A3E5FD778D641fe1a78380b
413809FE5B3804FE613801D710Ea

Output: _zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA9876543210

Can we have a hexdump of the compiled version?

Will make it later.

Lua, 64 bytes
s="abcdefghijklmnopqrstuvwxyz"print(s..s:upper().."_0123456789")

Try it online!

I tried your code with this and it doesn't print numbers.

@PrzemysławP Just ran it in the demo environment and it ran just fine (printing out abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_)

Yes, but question was to output also 0123456789, right?

@PrzemysławP Wow, how did I missed that ?! Thanks, it's fixed now, it should be printing abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789

V, 5 bytes
¬ ~Ó×

Try it online!
Explanation
¬ ~                      " Outputs characters in the range " " to `~`
Ó×                       " Removes all non alphanumeric characters
                         " Synonym of vim's :s/\W//g

K, 28 bytes
_ci,/(97 65+\:!26),95,48+!10

Generates [97..122]++[65..90]++[95]++[48..57] and maps the numbers to chars.

Pure Zsh, 35 29 bytes
-6 bytes inspired by @pxeger's Zsh+coreutils answer
>{0..z};printf %c [[:IDENT:]]
Try it online!

Attempt This Online!
The [:IDENT:] character class is exactly this. We use empty fallback ${:- } to a brace expansion, remove all non-[:IDENT:] characters, and then (j::)oin.
Turns out it's shorter to use multios to create a file for each character, then glob all matching files, joined with printf %c.

APL (Dyalog Extended), 12 bytes
Full program.
'_',∊⍳¨'zZ9'

Try it online!
⍳¨'zZ9' "ɩndices" until each of the three characters
∊ ϵnlist (flatten)
'_', prepend an underscore

Pip, 9 7 bytes
C,E7~XW

Attempt This Online!
Explanation
C,E7~XW
  E7     2 to the 7th power (128)
 ,       Range
C        Cast each integer in the range to a character
    ~XW  In each character, find the first regex match of `\w`

The result is a list of values, some of which are nil, some of which are an alphanumeric or underscore character. By default, Pip outputs lists with no separator, and nil outputs nothing; so the output of the program is simply the requested characters plus a trailing newline.

Zsh, 27 26 bytes
ls>{0..z}|tr -d '
:-@[-^`'
Attempt This Online!
Explanation:

>{0..z}: create files named 0 1 ... (all the ASCII characters in between) ... y z
ls: list all those newly created files
tr -d '¶:-@[-^`': remove the additional punctuation characters and the newlines

ls> works on arrays (unlike <<<), but is shorter than echo. (doesn't work if you care about order or duplicates). There's your newly discovered golfing tip of the day!

Java (JDK), 71, 70 bytes
(b,B)->{B="_";for(b=47;b++<122;)B+=b>57&b<65|b>90&b<97?"":b;return B;}

Try it online!
Inspired by an answer from dorukayhan this is a java.util.function.BiFunction<Character, String, String>

Excel, 54 48 bytes
-6 bytes thanks to @TaylorRaine
=CONCAT(ROW(1:10)-1,CHAR({64,96}+ROW(1:26)))&"_"

Original Answer
=CONCAT(ROW(1:10)-1,CHAR(ROW(2:3)*32+COLUMN(A:Z)))&"_"

Link to Spreadsheet

If you replace the innards of the Char statement with {64,96}+ROW(1:26), you can get this down to 48 bytes

Thanks.  That's what happens when you get locked in on a way to do something.

Haskell, 36 bytes
[c|c<-['('..'~'],(_,"")<-lex['a',c]]

Try it online!
Not the shortest answer but I thought of a cute way to solve this: pick out all the chars c such that ['a',c] lexes into a single identifier.
lex "a(" returns [("a","(")] but lex "ak"  returns [("ak","")].
The only false positive is a' which is a valid identifier in Haskell even though ' is not A-Za-z0-9_.
We can eliminate it by starting the range at ( (one past ').

MATL, 20 bytes
95 48:57 65:90t32+vc

Try it online!
This is a very boring and straightforward answer.

You can replace 95  by '_' or by 95c and then h casts numbers to chars automatically, so you save the final c. Also, you can replace 32+  by ck. And changing the order allows you to remove a space: 65:90tck95c48:57v

SML, 70 (lame) bytes, 80 78 71 64 bytes
I did it! The lame solution has been defeated by 6 bytes:
fun&123="_"| &91= &97| &58= &65| &n=str(chr n)^ &(n+1);print(&48)

Try it online!
Better readable:
fun t 123 = "_"
  | t 91  = t 97
  | t 58  = t 65
  | t n   = str(chr(n)) ^ t (n+1);
print(t 48)

Keep reading to see past me whining about not having found this solution yet.

print"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

The sad truth so far: I didn't manage to get something shorter than this, and believe me, I've tried.
Straight forward using build-in functions:
print("_"^implode(List.filter Char.isAlphaNum(List.tabulate(123,chr))))

Generate Char list, filter, implode (char list -> string), add _, print:
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Uses 71 bytes and is thereby 2 bytes to long to beat the lame solution. As more or less only keywords remain, I'm pretty sure this approach can't be golfed any further.
Let's build our own function!
This approach yielded multiple solutions of which the shortest one
fun&26a=""| &n a=str(chr(n+a))^ &(n+1)a;print(&16 32^ &0 65^ &0 97^"_")

also still needs 71 bytes. At least some a bit more interesting stuff is happening here. Let's name the function f instead of & and have closer look:
1  fun f 26 a = ""
2    | f  n a = str(chr(n+a)) ^ f (n+1) a
3  ;
4  print(f 16 32 ^ f 0 65 ^ f 0 97 ^ "_")

4 f n a returns a string of 26-n consecutive ascii-chars starting at char number a. ^ concats two strings.
1 Pattern matching. If the second argument is 26, return an empty string.
2 Recursion: If n is not yet 26, get the current char, convert it into a string and append it to the (recursively build) rest of the string.
3 Tell the interpreter that we are finished with declaring f so we can use it afterwards.

26-n? Why not do something more intuitive like
fun f 0 a = ""
  | f n a = str(chr(n+a)) ^ f (n-1) a;
print(f 10 47 ^ f 26 64 ^ f 26 96 ^ "_")

, would nobody ask here ever.

Because on the one hand this would print
9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba_

which albeit correct doesn't look very nice. However, more importantly in this case we have one 0 and two 26 and in the other case two 0 and one 26, which saves 1 byte.
Nevertheless it's still two bytes to go to underbid the infamous solution. At least for this approach remains a tiny bit of hope to achieve this goal, some time, in a brighter future ...
But probably not.

There's no lowercase z. Typo?

@owacoder Thanks! That was a typical off-by-one error, as z is char number 122, but List.tabulate has to count to 123 to reach it.

MSM, 79 bytes
;.;.;.;.;.;.:,,_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.

There's no shorter way to get all the letters, numbers and the underscore than explicitly writing them down. I also need 62 . commands to concatenate all the chars into a single string. These are generated by starting with a single . (on the very right), duplicating an concatenating (-> ;.) 8 times, splitting into 64 single dots again (-> :) and dropping two of them (-> ,,).

C#, 85 bytes
()=>{var r="_";for(char c='/';c<'z';)r+=char.IsLetterOrDigit(++c)?c+"":"";return r;};

C# lambda where the output is a string.
A full string would be 69 bytes...
Code:
()=>{
    var r="_";
    for(char c='/';c<'z';)
        r+=char.IsLetterOrDigit(++c)?c+"":"";
    return r;
};

Try it online!

Java, 106 bytes
String A(char b){String B="_";for(b=48;b++<58;)B+=b;for(b=65;b++<91;)B+=b;for(b=97;b++<123)B+=b;return B;}

Returns _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz by abusing for-loops.
Making the above function compilable costs 9 bytes, resulting in a 115-byte program:
class a{String A(char b){String B="_";for(b=48;b++<58;)B+=b;for(b=65;b++<91;)B+=b;for(b=97;b++<123)B+=b;return B;}}

The equivalent monolithic program which prints _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz is 148 bytes long:
interface a{static void main(String[]A){char b;String B="_";for(b=48;b++<58;)B+=b;for(b=65;b++<91;)B+=b;for(b=97;b++<123)B+=b;System.out.print(B);}}

Java (lambda expression), 91 bytes
(b,B)->{B="_";for(b=48;b++<58;)B+=b;for(b=65;b++<91;)B+=b;for(b=97;b++<123)B+=b;return B;};

This is a java.util.function.BiFunction<Character, String, String>.

Maybe it's a bit boring, but just manually printing everything: void f(){System.out.print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");} (94 bytes) is shorter in Java. ;)

yay under 100 ''void f(){char c=97;String r="";while(c<='z')r+=c++;System.out.print(r+r.toUpperCase()+"_");}

91 my final form, void f(){char c=65;String r="";while(c<=90)r+=c++;System.out.print(r.toLowerCase()+r+"_");}

@KevinCruijssen shorter, as function: ()->"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" ("only" 69 bytes).

79 void d(){for(char b=1;b<127;b++)System.out.print((b+"").replaceAll("\W",""));}

This is missing a semicolon after the 123:   for(b=97;b++<123)

74 bytes (b,B)->{B="_";for(b=47;b++<122;)if(b<58||b>64&&b<91||b>96)B+=b;return B;};

Japt, 22 bytes
0o#{ £YdÃf@Xf"\\\\w"Ãq

Try it there.

PHP, 60 48 bytes
New version that's much shorter!
<?=preg_replace('/\W/','',join(range(' ','z')));

Try it on Ideone
Inspired by TimmyD's solution. Takes a range of all characters from   to z, joins them into a string, then replaces all characters that match \W (which is any character not specified in this challenge) with nothing.
Old version:
0123456789_<?php for($i=64;++$i<91;)echo chr($i).chr($i+32);

Ungolfed:
0123456789_
<?php
    for($i=64;++$i<91;) echo chr($i).chr($i+32);

Anything written outside the <?php tag is considered plain text. The for loop in the PHP code echoes the uppercase and lowercase of each letter.

Jolf, 17 bytes
RψΜz@~dpAHd mHLSE

Try it here!
Explanation
RψΜz@~dpAHd mHLSE
   z@~             range from 1 to 126
  Μ   dpAH         chars of
 ψ        d mHLS   filter all that don't match "\w+" (LS)
R               E  join by ""

K, 21 bytes
_ci95,(97+!26),65+!26

O, 40 bytes
[[D2*(,]B6*(+{n.84*+}dC8*(C4*.9+mr]{nc}d

C--, 230 bytes
target byteorder little;export main;import putchar,isalnum;foreign"C"main(){bits32 v,t;v = 48;T:t=foreign"C"isalnum(v);if (t!=0){foreign"C"putchar(v);}if (v==95){foreign"C"putchar(v);}v=v+1;if (v<123){goto T;}foreign"C"return(0);}

Ungolfed:
target byteorder little;

export main;
import putchar, isalnum;

foreign "C" main(){
    bits32 v, tmp;
    v = 48;
Top:
    tmp = foreign "C" isalnum(v);
    if (tmp != 0){
        foreign "C" putchar(v);
    }

    if (v == 95){
        foreign "C" putchar(v);
    }

    v=v+1;
    if (v < 123) { goto Top; }

    foreign "C" return (0);
}

Groovy, 36 characters
print(("0".."z").grep(~/\w/).join())

Sample run:
bash-4.3$ groovy -e 'print(("0".."z").grep(~/\w/).join())'
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

LINQ, 88 bytes
from c in Enumerable.Range(0,123)where char.IsLetterOrDigit((char)c)|c==95 select(char)c

A LINQ expression (OK it is almost C#) where the output is an IEnumerable<char>. You can try it with LinqPad.

Brainfuck 36 Bytes (96 commands)
>++++++[-<++++++++>]+++++[<.+.+>-]<+++++++>+++++++++++++[-<.+.+>]<++++.++>+++++++++++++[-<.+.+>]

Explanation:
 >++++++[-<++++++++>]    Increment to '0'
 +++++[<.+.+>-]          Print 10 characters (0 to 9)
 <+++++++>               Increment to lower upper characters
 +++++++++++++[-<.+.+>]  Print 26 characters (A to Z)
 <++++.++>               Increment to '_' Print it and move to a
 +++++++++++++[-<.+.+>]  Print 26 characters (a to z)

EDIT: Most straightforward solution IMHO, still shorter than the others

That's not how we count bytes. In brainfuck, this is a 96-bytes solution, because every command is stored in one byte. You could port it to CompressedFuck though.

Common Lisp, 160 bytes

(setq a 47)(loop(setq a(+ a 1))(princ(code-char a))(when(and(> a 56)( a 89)( a 121)(return)))(princ'_)

Python 2.x, 63 bytes
print''.join(chr(a)for a in range(123)if chr(a).isalnum())+'_'

Try it online.
Explanation:
chr(a)for a in range(123)if chr(a).isalnum() # generates a list iterating through ascii
                                             #  symbols, picking just numbers alphabet characters

''.join(...)+'_'                             # joins a list of items with no spacing;
                                             # appends '_' at the end

My first golfing attempt; thanks to mbomb007 for the hints

You can remove some spaces.

where for example? I thought I got rid of each one I could

print''.join(chr(a)for a in range(48,123)if chr(a).isalnum())+'_'. Quotes and parentheses/brackets are delimiters. You don't have any, but you can also do something like print 1if 1else 0. See the Tips for golfing in Python page.

C, 56 55 bytes
i;k(){for(;putchar(i%26+"aA0"[i++/26])^57;);puts("_");}

Output:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

16-bit x86 machine code, 26 bytes
In hex:
B030B90A00AA40E2FCB05FAA40B11A5040AAE2FC5834207BF4C3

Input: DI: pointer to an array of at least 63 bytes. Function outputs the sequence
0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

without any termination, since its length is constant.
Disassembly:
00: B0 30       mov    al,'0'
02: B9 0A 00    mov    cx,10
_00000005:
05: AA          stosb              ;*DI++=AL
06: 40          inc    ax          ;AL++
07: E2 FC       loop   _00000005   ;Print digits
09: B0 5F       mov    al,'_'      ;0x5f
0B: AA          stosb
0C: 40          inc    ax          ;AX=0x60
_0000000D:
0D: B1 1A       mov    cl,26
0F: 50          push   ax
_00000010:
10: 40          inc    ax
11: AA          stosb
12: E2 FC       loop   _00000010   ;Print single-case letters
14: 58          pop    ax
15: 34 20       xor    al,020      ;Flip "case" bit
17: 7B F4       jnp    _0000000D   ;Repeat if "not parity", i.e. AX is back to 0x40
19: C3          ret

Julia, 35 bytes
()->join(['a':'z','A':'Z',0:9,'_'])

Alternative solution, also 35 bytes:
()->replace(join('0':'z'),r"\W","")

SmileBASIC, 52 bytes
FOR I=65TO 90?CHR$(I);CHR$(I+32);
NEXT?1234567890;"_

Tcl, 68 bytes
puts abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

Try it online!

tcl, 99
time {append s [incr i]} 9
set i 64;time {set s $s[format %c%c [incr i] [expr $i+32]]} 26
puts _0$s

demo

tcl, 100
time {append s [incr i]} 9
time {set s $s[format %c%c [expr [incr i]+55] [expr $i+87]]} 26
puts _0$s

demo

T-SQL, 70 bytes
PRINT'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'

Procedural solutions in SQL are just too long, due to the length of keywords. A couple of my best attempts:
76 Bytes, store the alphabet then UPPER it:
DECLARE @ CHAR(26)='abcdefghijklmnopqrstuvwxyz'PRINT'0123456789_'+@+UPPER(@)

100 Bytes, add all chars from 65-122, then strip out the ones I don't want:
DECLARE @ VARCHAR(99)='0123456789'A:SET @+=CHAR(LEN(@)+55)IF LEN(@)<68GOTO A
PRINT STUFF(@,37,6,'_')

MATLAB, 30 bytes
['a':'z','A':'Z','0':'9','_']

Very simple :)
Or, at the same cost:
char(48+[49:74,17:42,0:9,47])

or
char([97:122,65:90,48:57,95])

Japt, 13 12 bytes
;C+B+9ô ¬+'_

Try it online!

Keg, 15B(The Keg SBCS is in Keg wiki.)
\_\0\9ɧZAɧzaɧ(,

Explanation:
\_#             Push _
  \0\9ɧ#        Push range 0-9
       ZAɧ#     Push range Z-A
          zaɧ#  Push range z-a
             (,#Output

TIO

x86_16 machine code - 57 bytes
B4 0E         MOV AH, 0EH
        LOWERCASE:
B0 61         MOV AL, "a"
8A D8         MOV BL, AL
CD 10         INT 10H
           LOOP1:
FE C0         INC AL
CD 10         INT 10H
3C 7A         CMP AL, "z"
74 02         JE UPPERCASE
75 F6         JNE LOOP1
        UPPERCASE:
8A C3         MOV AL, BL
24 DF         AND AL, 0DFH
CD 10         INT 10H
           LOOP2:
FE C0         INC AL
CD 10         INT 10H
3C 5A         CMP AL, "Z"
74 02         JE NUMBER
75 F6         JNE LOOP2
          NUMBER:
B0 30         MOV AL, "0"
CD 10         INT 10H
           LOOP3:
FE C0         INC AL
CD 10         INT 10H
3C 39         CMP AL, "9"
74 02         JE UNDERSCORE
75 F6         JNE LOOP3
       UNDERSCORE:
B0 5F         MOV AL, "_"
CD 10         INT 10H
            EXIT:
B8 4C00       MOV AX, 4C00h
CD 21         INT 21H

Running with DOSBox :

Stax, 7 bytes
ë½óG╨}S

Run and debug it

JavaScript (Node.js), 51 bytes
f=n=>n>>8?'':(/\w/.test(c=Buffer([n]))?c:'')+f(-~n)

Try it online!
Trivial one

Noether, 35 bytes
65~a26(a`+BPa`32++BP!`)10(zP!z)95BP

Try it online!

Factor, 41 bytes
"Aa0_""   \0"[ dupd + [a,b] write ] 2each

Attempt This Online!

I don't know how this lang works, but shouldn't you mention the  USING: kernel math.ranges math io sequences ; header somewhere? not necessarily as part of your bytecount, but it doesn't seem like a default, correct me if im wrong

@thejonymyster Factor is a whole can of worms when it comes to imports. Factor's byte counting policy for imports was painstakingly developed by @Bubbler and others as a balancing act of various factors. Long story short: EVERYTHING has to be imported in Factor. I would have to USE: math if I want to add two numbers. No one wants to see that in every answer. Factor is image-based, so I can have any vocabs I want loaded without explicitly loading them.

The rule is - vocabularies must be mentioned before the byte count unless they are auto-use vocabularies, which most are.

Regenerate -as "", 12 bytes
[0-9A-Z_a-z]

Attempt This Online!
If Regenerate supported character class shortcuts, then \w would work as a 2-byte solution.

Dyalog APL, 27 bytes
'_',⎕UCS∊47 64 96+⍳¨10,2⍴26

Nice answer! I suggest you add a short explanation to help people understand how the code works.

brainfuck, 105
first code golf attempt using this
>++++++[<++++++++>-]++++++++++[-<.+>]<+++++++>>+++++[<+++++>-]<+[-<.+>]<++++.++>>+++++[<+++++>-]<+[-<.+>]

ungolfed
>++++++[<++++++++>-]         // p1=48
++++++++++                   // p2=10
[-<.+>]<                     // print 0-9, p1=58, p2=0
+++++++                      // p1=65
>>+++++[<+++++>-]<+          // p2=26
[-<.+>]<                     // print A-Z, p1=91, p2=0
++++.++                      // print underscore, p1=97
>>+++++[<+++++>-]<+          // p2=26
[-<.+>]                      // print a-z

++++++++++++++++++++++++++++++++++++++++++++++++ That can be done better.

improved the +x26 as well

R
cat(letters,LETTERS,0:9,"_",sep="")

I believe this does not count as letters and LETTERS are built-in constants. But this one should be fine:
cat(intToUtf8(c(65:90,97:122)),0:9,"_",sep="")

PHP, 74 71 bytes
echo 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';

Brainfuck - 116 commands
>++++++++[<++++++>-]>+++[<+++>-]<+[<.+>-]++[<+++>-]<+>>++++[<++++++>-]<++[<.+>-]<++++.++>>++++[<++++++>-]<++[<.+>-]

Output: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
How it works
>++++++++[<++++++>-]
Get yourself up to \48, the start of [0-9]
>+++[<+++>-]<+
Count up 10
[<.+>-]
Then print each character and bump it up
++[<+++>-]<+>
jump up to the start of [A-Z]
>++++[<++++++>-]<++
start a counter of 26
[<.+>-]
and print and increment 26 values
<++++.++>
jump to [a-z], stopping in at _
>++++[<++++++>-]<++
counter of 26
[<.+>-]
and print and increment 26 values
there's got to be a way to simplify that counter to 26 and the print happening twice, but I'm not nearly good enough with brainfuck to do so

48 doubled is 96, so you could use replace the initial loop with >++++[>++++++[>++>++++<<-]<-] to get both. Probably shorter than two output loops.

dc, 50 bytes
[la1+ddsaPlc>b]dddsb96saC2scx64sa90scx47sa57scx95P

This doesn't feel very elegant.
[              # Open macro definition
 la 1+         #  Load a, increment
 dd            #  Duplicate a+1 twice
 sa            #  Store a+1 as `a'
 P             #  Print new value of a as a character
 lc>b          #  If c>a, do this again
]              # Close macro definition
ddd sb         # DDDuplicate and store as `b'
96sa C2sc x    # Set lower and upper bounds (`a' and `c') for [a-z] and execute a copy of b
64sa 90sc x    # Set bounds for [A-Z] and execute a copy of b
47sa 57sc x    # Set bounds for [0-9] and execute a copy of b
95P            # Print underscore

Actually, 24 bytes
"[\]^`""A{"Oix♂c-9ur♂$+Σ

Try it online!
There's probably a shorter way
Explanation:
"[\]^`""A{"Oix♂c-9ur♂$+Σ
       "A{"O              push a list containing the ordinals of "A" and "{"
            ix            flatten the list, end-exclusive range
              ♂c          convert each ordinal into its corresponding character
"[\]^`"         -         remove non-alphabetic characters except "_"
                 9ur♂$+   push range(10), convert to strings, concatenate lists
                       Σ  concatenate strings in the list

Perl 6
put |grep /<alnum>/,'0'..'z'
put |grep /\w/,'0'..'z'
Explanation:
put # ｢print()｣ but with trailing newline

# turn the following into a Slip so that there aren't
# any spaces in the output
|

grep
  /\w/,      # match wordchars
  '0' .. 'z' # in this Range

( grep returns a List, which puts spaces between each element when stringified )

Erlang, 56 bytes
f()->[X||X<-lists:seq(1,$z),re:run([X],"\\w")/=nomatch].

Erlang, 57 bytes
f()->S=fun lists:seq/2,[$_|S($0,$9)]++S($A,$Z)++S($a,$z).

Excel VBA, 130 bytes
Have fun hitting enter...
Sub q()
For i = 1 To 123
If i > 47 And i < 58 Or i > 64 And i < 91 Or i > 96 And i < 123 Or i = 95 Then MsgBox Chr(i)
Next
End Sub

Javascript (Using external library) (105 bytes)
_.Range(97,26).Concat(_.Range(65,26).Concat(_.Range(48,10))).Push(95).Write("",x=>String.fromCharCode(x))

What this does is gets the char code ranges from a-z, concats with A-Z, then concats 0-9, then pushes the code for _. Write takes a delimiter and joins everything together
Library: https://github.com/mvegh1/Enumerable/blob/master/linq.js

RETURN, 20 bytes
'_0 9
'a'z
'A'Z
,,,,

Try it here.
Creates a series of charcode ranges and outputs them.

, 10 chars / 13 bytes
Ⓒ…⩥ṻ)ŋ/\W⌿

Try it here (ES6 browsers only).
Translated roughly to ES6:
String.fromCharCode(_.range(123)).replace(/\W/g,'')

Common Lisp, 61 bytes
using formule for lowercase'ing from Practical Lisp, namely (format t "~(~a~)" "ExAMpleStRINg")
(format t"~a~:*~(~a~)0123456789_"'abcdefghijklmnopqrstuvwxyz)

Ideas for improvement are welcomed.

QBIC, 66 41 bytes
Had some coffee and re-read the specs:
[65,90|?chr$(a)+chr$(a+32)]?@0123456789_`

This prints Aa\n all the way up to Zz\n, then the literal 0123456789_.

There are quite a lot of ways QBIC can approach this challenge if we want to print the string in the order provided.
By adding all the requested ranges to Z$ (Z$ gets printed implicitly), 71 bytes
[97,122|Z=Z+chr$(a)][65,90|Z=Z+chr$(b)][48,57|Z=Z+chr$(c)]Z=Z+chr$(95)

Printing each range to screen, with ';` to prevent newlines, 67 bytes
[97,122|?chr$(a)';`][65,90|?chr$(b)';`][48,57|?chr$(c)';`]?chr$(95)

Creates one range, printing only substrings, 70 bytes
[48,122|A=A+chr$(a)]?mid$(A,50,26)+mid$(A,18,26)+left$(A,10)+chr$(95)

Creating one range, but with modified start of that range, 69 bytes
[122|A=A+chr$(a)]?mid$(A,96,26)+mid$(A,64,26)+mid$(A,47,10)+chr$(95)

But sadly the best at 66 bytes, just plainly printing this string:
?@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_`

q/kdb+, 35 bytes
Solution:
("c"$48+(!)75)except":;<=>?@[\\]^`"

Example:
q)("c"$48+(!)75)except":;<=>?@[\\]^`"
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"

Notes:
Turns out I cannot read :) Q.an solves this in 5 bytes. I'll try to golf this new solution.

"Built-ins that contain 9 or more of these characters are disallowed."

RProgN 2, 9 bytes
•zR.'\W'-

Explained
•zR.'\W'-
•           # Push a space
 z          # Push the character 'z'
  R         # Create a stack of all characters from space to z.
   .        # Concatenate them into a single string.
    '\W'-   # Filter out everything that matches the regex '\W' (Non-alpha-numeric characters)
            # Implicit print

Try it online!

JavaScript (ES7), 60 57 bytes
Shame we can't return an array or set of the characters, I could've saved quite a few bytes there.
_=>[...new Set(Object.keys(this).join`4Z_`+2**29)].join``

Test it
The second line is sorted to make it easy to check all characters are included.

f=
_=>[...new Set(Object.keys(this).join`4Z_`+2**29)].join``
o.innerText=f()+`\n`+[...f()].sort().join``

G J K N Q U missing on Firefox 97.0

Fortran 95, 131 bytes
write(*,1)(char(i),i=97,122)
write(*,1)(char(i),i=65,90)
write(*,2)(i,i=0,9)
write(*,1)'_'
1 format(1A,25A,$)
2 format(10I1,$)
end

Just because every challenge is improved by a Fortran entry.
You'd think it would be easy to golf this down, but the required variable declarations get expensive very quickly so I think this is about as short as it's going to get.
If delimiters (\n) were allowed between characters in the output, this could be reduced to 83 bytes:
print*,(char(i),i=97,122)
print*,(char(i),i=65,90)
print*,(i,i=0,9)
print*,'_'
end

><>, 39 bytes
"AaZ_"o\9:n:?!;1-80.
+}$:@=?\}:o1+}::o1

Try it online!
Fairly simple, prints _, loop prints a, A then increments and compares to Z.
At the end it'll print 9-0.

Thunno J, \$12\log_{256}(96)\approx\$ 10 bytes
(Actually \$\approx\$ 9.88 bytes but the leaderboard doesn't take decimals)
123RCJ"\w"Af

Attempt This Online!
Explanation
123R # range(123)
CJ   # converted from codepoints
"\w" # string "\w"
Af   # regex findall
     # Implicit output, joined

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


text:
Listing all closed cycles in a list
I'm new here. I tried seeing if this challenge was introduced before. Found a close call one counting the number of cycles, but didn;t find one for listing them. So I'm writing this one. Sorry if I'm repeating...
Anyway, I'm looking for the shortest function to return all close cycles in a shuffled list of indices. For good order's sake let's start counting with 0 as the first index. A cycle uses the value in a certain position as the index for its next one. Repeating this process creates a closed cycle. Exhausting all indices in the original list eventually organize it into few such close chains. And this organization is what we're after here.
In this challenge the order between chains is not important. The order within a chain should be kept as in the original, but it can be cyclically shifted (i.e. [5, 1, 4], [1, 4, 5] and [4, 5, 1] are all equivalent).
The input list is guaranteed to contain all the integers from 0 to n and only them.
This is code-golf - i.e. looking for the most compact implementation.
Few examples:
[4, 8, 0, 6, 7, 5, 2, 3, 9, 1] --> [[0, 4, 7, 3, 6, 2], [1, 8, 9], [5]]

[8, 1, 4, 2, 9, 6, 7, 5, 0, 3] --> [[0, 8], [1], [2, 4, 9, 3], [5, 6, 7]]

[3, 4, 0, 1, 2, 9, 5, 8, 6, 7] --> [[0, 3, 1, 4, 2], [5, 9, 7, 8, 6]]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] --> [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]

[1, 2, 3, 4, 5, 6, 7, 8, 9, 0] -->  [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]

[9, 8, 7, 6, 5, 4, 3, 2, 1, 0] --> [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]

I feel like this is a duplicate, but even if it isn't, nice first challenge!

source: Stack Exchange

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

sort: votes


text:
Generate the Rummy Sequence
Your task is to take an input n and output element n of the Rummy Sequence, a sequence which I made (looking on OEIS will not help you).
Definition
Each element of the Rummy Sequence is a set of truthy or falsey values. Ex.: [true, false].
The steps to producing a member of the Rummy Sequence are quite simple:

Start out with the first index, [] (this is element 0).
Set the leftmost falsey to truthy. If there are no falseys to change, then increase the length of the list by 1 and set all members of the new list to falsey.
Repeat step 2 until reaching element n.

Example
Let's define our function as rummy(int n) (stuff in {} is a step taken to get to the answer):
>>> rummy(5)
{[]}
{[false]}
{[true]}
{[false, false]}
{[true, false]}
[true, true]

Rules

Standard loopholes apply.
Must work for inputs 0 through your language's upper numerical bound.
You may output in any way you see fit, provided that it is clear that the output is a set of truthy/falseys.

Trivia
I call this the "Rummy Sequence" because, starting at index 2, it defines the sets you would need to lay down in each round of Progressive Rummy, where falsey is a book and truthy is a run.
Test Cases
>>> rummy(0)
[]

>>> rummy(1)
[false]

>>> rummy(6)
[false, false, false]

>>> rummy(20)
[true, true, true, true, true]

>>> rummy(1000)
[true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]

This is kinda like counting binary in reverse

@ThreeFx Except that, when adding 1 to 11, you get 000 instead of 100. ;P

Can our answer be one-indexed?

I think you should include a few more test cases, even if the outputs are implicitly mentioned in the example. My first revision broke with the corner case 1...

@VTCAKAVSMoACE That would make it bijective binary (which we also have a challenge for), but there are more differences in that every number is always of the form 1*0*.

@Downgoat You may, but you should note that in your answer.

@Dennis Sure thing. :D

JavaScript ES6, 94 92 72 70 66 64 bytes
Saved 6 bytes thanks to Neil!
n=>[...Array(a=Math.sqrt(8*n+1)-1>>1)].map((_,l)=>l<n-a*(a+1)/2)

I don't think this can be golfed more. At least with the equations.
Explanation
They are two main equations (n is input):
(Math.sqrt(8*n+1)-1)/2

This will give the total size the output array will need to be. In my program I used >>1 instead of (...)/2 these are the same as the first bit in binary has a value of 2. Shifting it will result in in floor(.../2)

n-a*(a+1)/2

This is the amount of trues there will be. a is the result of the previous expression.

This is what the syntax does:
[...Array(n)]

This code generates an array with range [0, n) in this answer n is the first equation.

.map((_,l)=>l<n) this will loop through the above range, l is the variable containing the current item in the range. If the item is less than the amount of trues they are (determined by second equation), then it will return true, else false.

Use >>1 instead of /2|0. Use (_,l)=> instead of .keys().

@Neil thanks! That saved a quite a bit. By your last point, do you mean to use Array.from()?, fill, or something else?

No, I was thinking of [...Array(a)].map((_,l)=>) which I believe is slightly shorter, but good catch on removing some of the ()s when switching to >>1, I hadn't spotted that!

Oh, there's also a*-~a/2; I don't know why I didn't think of it before.

Python, 51 bytes
f=lambda n,i=0:n>i and f(n+~i,i+1)or[1]*n+[0]*(i-n)

Outputs a list of 1's and 0's.

Jelly, 13 11 bytes
Ḷṗ2SÞ⁸ị1,0x

The code does not work in the latest version of Jelly before the challenge was posted, but it did work in this version, which predates the challenge.
Indices are 1-based. Try it online! (takes a few seconds) or verify multiple inputs at once.
How it works
Ḷṗ2SÞ⁸ị1,0x  Main link. Argument: n (integer)

Ḷ            Unlength; yield [0, ..., n - 1].
 ṗ2          Take the second Cartesian power, i.e., generate the array of all
             pairs of elements of [0, ..., n - 1].
   SÞ        Sort the pairs by their sum. The sort is stable, so ties are broken
             by lexicographical order.
     ⁸ị      Retrieve the pair at index n.
       1,0x  Map [a, b] to a copies of 1 and b copies of 0.

Pyth, 8 bytes
_@{y/RQy

Try it online: Demonstration or Test Suite
This is exponentially slow.
Explanation:
_@{y/RQyQQ    implicit Qs at the end, (Q = input)
       yQ     2*Q
    /RQ       divide each number in [0, 1, ..., 2*Q-1] by Q
              this results in a list of Q zeros and Q ones
   y          take all subsets
  {           remove duplicates
 @       Q    take the Qth element
_             print it reversed

05AB1E, 27 bytes
8*>t<;ïÐ>*;¹s-ïD1s×Š-0s×JSï

Will see if I can golf it some more and add an explanation in the morning.
Try it online

Java, 117 110 bytes
enum B{T,F};B[]r(int n){int i=0,c=0,j=0;while(n>=i)i+=++c;B[]a=new B[c-1];for(;j<n-i+c;)a[j++]=B.T;return a;}

created my own boolean type, which allowed me to save 7bytes

That use of the enum is clever. +1

Python 2, 69 63 bytes
a=b=0
exec'a,b=[a-1,b+1,0][a<1:][:2];'*input()
print[1]*b+[0]*a

Test it on Ideone.

Python 2, 61 bytes
j=(2*input()+.25)**.5-.5
print[i/j<j%1for i in range(int(j))]

Solves for n = j·(j+1)/2. Input is taken from stdin.
Sample Usage
$ echo 20 | python rummy-seq.py
[True, True, True, True, True]

$ echo 50 | python rummy-seq.py
[True, True, True, True, True, False, False, False, False]

Demo.

APL (Dyalog Extended), 21 bytesSBCS
{⍵⌷↑,/(↓0 1↓⍳≥\⍳)¨⍳⍵}

Try it online!

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


text:
Visualize a Difference Pyramid
A difference pyramid is a pyramid where each new diagonal is the absolute value of the differences between the elements of the last diagonal. For example, if we start with the array
2 5 4 9 3 4

Now, we arrange these in a diagonal column:
     2
      5
       4
        9
         3
          4

Now, we fill in the next diagonal. The absolute differences between the consecutive elements of this array are:
3 1 5 6 1

So that is our next diagonal.
     2
    3 5
     1 4
      5 9
       6 3
        1 4

Repeat until the pyramid is filled in:
     2
    3 5
   2 1 4
  2 4 5 9
 1 3 1 6 3
0 1 4 5 1 4

The Challenge
Given a list of positive integers in the range [0, 9], generate this ASCII-art representation of the difference pyramid for that particular array. The input is guaranteed to contain at least two elements. You may take these numbers in any reasonable format. (Array/list/whatever you call it, a string, command line arguments, etc.) Trailing spaces on each line and up to one trailing newline are allowed.
Test IO
[1, 2, 3, 4, 5, 6, 7, 8, 9]

        1
       1 2
      0 1 3
     0 0 1 4
    0 0 0 1 5
   0 0 0 0 1 6
  0 0 0 0 0 1 7
 0 0 0 0 0 0 1 8
0 0 0 0 0 0 0 1 9

[4, 7]

 4
3 7

[3, 3, 3]

  3
 0 3
0 0 3

[1, 3, 6, 3, 4, 9]

     1
    2 3
   1 3 6
  1 0 3 3
 1 2 2 1 4
1 0 2 4 5 9

[8, 7, 3, 2, 4, 5, 9, 1, 6]

        8
       1 7
      3 4 3
     0 3 1 2
    2 2 1 2 4
   0 2 0 1 1 5
  0 0 2 2 3 4 9
 1 1 1 1 1 4 8 1
0 1 0 1 0 1 3 5 6

As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins!

Inspired by this OEIS and this conjecture.

Jelly, 16 bytes
IA$ṖÐ¿UṚz”@ṚGḟ”@

Try it online!
Background
Generating the differences is quite straightforward. For input
[1, 2, 3, 4, 5, 6, 7, 8, 9]

IA$ṖÐ¿ (absolute value of increments while there is more than one element) yields the following ragged 2D array.
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 1, 1, 1, 1, 1, 1, 1]
[0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0]
[0, 0]
[0]

U reverses the order of the columns and Ṛ the order of the rows, yielding the following.
[0]
[0, 0]
[0, 0, 0]
[0, 0, 0, 0]
[0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 1, 1, 1]
[9, 8, 7, 6, 5, 4, 3, 2, 1]

Now, we transpose rows and columns with z”@, which pads all rows to the same length before transposing. The result is the following.
[0, 0, 0, 0, 0, 0, 0, 1, 9]
[@, 0, 0, 0, 0, 0, 0, 1, 8]
[@, @, 0, 0, 0, 0, 0, 1, 7]
[@, @, @, 0, 0, 0, 0, 1, 6]
[@, @, @, @, 0, 0, 0, 1, 5]
[@, @, @, @, @, 0, 0, 1, 4]
[@, @, @, @, @, @, 0, 1, 3]
[@, @, @, @, @, @, @, 1, 2]
[@, @, @, @, @, @, @, @, 1]

Reversing the rows gives
[@, @, @, @, @, @, @, @, 1]
[@, @, @, @, @, @, @, 1, 2]
[@, @, @, @, @, @, 0, 1, 3]
[@, @, @, @, @, 0, 0, 1, 4]
[@, @, @, @, 0, 0, 0, 1, 5]
[@, @, @, 0, 0, 0, 0, 1, 6]
[@, @, 0, 0, 0, 0, 0, 1, 7]
[@, 0, 0, 0, 0, 0, 0, 1, 8]
[0, 0, 0, 0, 0, 0, 0, 1, 9]

To turn the 2D array into a whitespace-separated string, we use the built-in grid atom (G). It joins columns by spaces and rows by linefeeds, yielding the following result.
@ @ @ @ @ @ @ @ 1
@ @ @ @ @ @ @ 1 2
@ @ @ @ @ @ 0 1 3
@ @ @ @ @ 0 0 1 4
@ @ @ @ 0 0 0 1 5
@ @ @ 0 0 0 0 1 6
@ @ 0 0 0 0 0 1 7
@ 0 0 0 0 0 0 1 8
0 0 0 0 0 0 0 1 9

All that's left to do is removing the padding character with ḟ”@, yielding
        1
       1 2
      0 1 3
     0 0 1 4
    0 0 0 1 5
   0 0 0 0 1 6
  0 0 0 0 0 1 7
 0 0 0 0 0 0 1 8
0 0 0 0 0 0 0 1 9

which is the desired output.

J, 46 42 39 36 bytes
(#\-#)|."_1#{.[:":@|./.<@#2&(|@-/\)]

A straight-forward implementation. Generates a table of successive differences between each pair and repeats it a number of times equal to the length of the input array. Then traverses each diagonal of that table to form the rows of the triangle. The rest is formatting the rows into a pyramid.
Usage
   f =: (#\-#)|."_1#{.[:":@|./.<@#2&(|@-/\)]
   f 2 5 4 9 3 4
     2
    3 5
   2 1 4
  2 4 5 9
 1 3 1 6 3
0 1 4 5 1 4
   f 4 7
 4
3 7
   f 8 7 3 2 4 5 9 1 6
        8
       1 7
      3 4 3
     0 3 1 2
    2 2 1 2 4
   0 2 0 1 1 5
  0 0 2 2 3 4 9
 1 1 1 1 1 4 8 1
0 1 0 1 0 1 3 5 6

Explanation
(#\-#)|."_1#{.[:":@|./.<@#2&(|@-/\)]  Input: list A
                         #            Get len(A)
                       <@             Box it
                                   ]  Get A
                          2&(     )   Repeat len(A) times on A initially
                          2      \      Get each iverlapping sublist of size 2
                                /       Reduce it using
                             |@-          The absolute value of the difference

                                      This will form a table where each row contains the
                                      successive differences
              [:     /.               Operate on the diagonals of that table
                   |.                 Reverse each diagonal
                ":@                   Format each into a string
           #                          Get len(A)
            {.                        Take that many from the strings of diagonals
 #\                                   Get the length of each prefix of A
                                      Makes the range [1, 2, ..., len(A)]
    #                                 Get len(A)
   -                                  Subtract the len(A) from each in the prefix range
                                      Makes [-len(A)+1, ..., -1, 0]
      |."_1                           Rotate each string left using each value
                                      A negative rotate left = rotate right
                                      Output the pyramid

CJam, 29 bytes
q~{_2ew::-:z}h]W%zzeeSff*W%N*

Try it online! (The first and last line enable a linefeed-separated test suite.)
This uses the triangle-rotation and layouting code from this answer and the triangle itself is generated with the same principle as in this answer.

Python 3, 144 bytes
def f(x):
 y=[x]
 for i in range(len(x)-1):y+=[['']*-~i+[abs(y[i][j]-y[i][j+1])for j in range(i,len(y[i])-1)]]
 for i in zip(*y):print(*i[::-1])

A function that takes input of a list x via argument and prints the result to STDOUT.
How it works
The program takes input of a list x, and initialises a nested list y such that y[0] = x. The absolute differences for the last list in y (initially x) are then generated and appended as a list to y until a list of length 1 is reached; at each stage, the list is pre-padded with spaces such that all lists in y have the same length as x. Next, y is transposed, leaving it containing a tuple for each output line, but reversed. Each tuple in the transpose is unpacked, reversed and printed, leaving the difference pyramid on STDOUT.
Try it on Ideone

Pyth, 22 bytes
jmX-jN_Pd;N;_.t_M.uaVt

Try it online!


text:
Binary Recurrence Sequences
A binary recurrence sequence is a recursively-defined sequence of the following form:
$$F(1) = a_1 \\ \vdots \\ F(y) = a_y \\
F(n) = \alpha F(n-x) + \beta F(n-y), n > y$$
This is a generalization of the Fibonacci (\$x = 1, y = 2, a = [1, 1], \alpha = 1, \beta = 1\$) sequence and the Lucas (\$x = 1, y = 2, a = [2, 1], \alpha = 1, \beta = 1\$) sequence.
The Challenge
Given \$n, x, y, a, \alpha\$, and \$\beta\$, in any reasonable format, output the \$n\$th term of the corresponding binary recurrence sequence.
Rules

You may choose for the sequence to be either 1-indexed or 0-indexed, but your choice must be consistent across all inputs, and you must make note of your choice in your answer.
You may assume that no invalid inputs would be given (such as a sequence that terminates prior to \$n\$, or a sequence that references undefined terms, like \$F(-1)\$ or \$F(k)\$ where \$k > n\$). As a result of this, \$x\$ and \$y\$ will always be positive.
The inputs and outputs will always be integers, within the boundaries of your language's natural integer type. If your language has unbounded integers, the inputs and outputs will be within the range \$[-2^{31}, 2^{31}-1]\$ (i.e. the range for a 32-bit signed two's complement integer).
\$a\$ will always contain exactly \$y\$ values (as per the definition).

Test Cases
Note: all test cases are 0-indexed.
x = 1, y = 2, a = [1, 1], alpha = 1, beta = 1, n = 6 => 13
x = 1, y = 2, a = [2, 1], alpha = 1, beta = 1, n = 8 => 47
x = 3, y = 5, a = [2, 3, 5, 7, 11], alpha = 2, beta = 3, n = 8 => 53
x = 1, y = 3, a = [-5, 2, 3], alpha = 1, beta = 2, n = 10 => -67
x = 5, y = 7, a = [-5, 2, 3, -7, -8, 1, -9], alpha = -10, beta = -7, n = 10 => 39

Does taking a in reversed order count as reasonable?

@Dennis Yes, it does.

OK, thanks for clarifying.

Jelly, 11 bytes
⁴Cịæ.⁵ṭµ¡⁶ị

Try it online!  1  |  2  |  3  |  4  |  5
How it works
⁴Cịæ.⁵ṭµ¡⁶ị  Main link. Arguments: a; [x, y]; [α, β]; n (1-based)

       µ     Combine the links to the left into a chain.
        ¡    Execute that chain n times, updating a after each execution.
⁴              Yield [x, y].
 C             Complement; yield [1 - x, 1 - y].
  ị            Retrieve the elements of a at those indices.
               Indexing is 1-based and modular in Jelly, so this retrieves
               [a[-x], a[-y]] (Python syntax).
     ⁵         Yield [α, β].
   æ.          Take the dot product of [a[-x], a[-y]] and [α, β].
         ⁶   Yield n.
          ị  Retrieve the element of a at index n.

JavaScript (ES6), 51 44 bytes
(x,y,z,a,b)=>g=n=>n<y?z[n]:a*g(n-x)+b*g(n-y)

Note that the function is partially curried, e.g. f(1,2,[1,1],1,1)(8) returns 34. It would cost 2 bytes to make the intermediate functions independent of each other (currently only the last generated function works correctly).
Edit: Saved 7 bytes thanks to @Mego pointing out that I'd overlooked that the the passed-in array always contains the first y elements of the result.

@Mego I know I often overlook details of questions but that one struck me as particularly subtle.

Python 2, 62 bytes
x,y,l,a,b=input();f=lambda n:l[n]if n<y else a*f(n-x)+b*f(n-y)

A direct recursive solution. All inputs are taken from STDIN except for n as a function argument, a split that's is allowed by default (though contentiously).
There doesn't seem to be a way to save bytes with and/or in place of if/else because l[n] could be falsey as 0.

Haskell, 54 48 bytes
l@(x,y,a,p,q)%n|n<y=a!!n|k<-(n-)=p*l%k x+q*l%k y

Python 2, 59 bytes
x,y,A,a,b,n=input()
exec'A+=a*A[-x]+b*A[-y],;'*n
print A[n]

Test it on Ideone.

J, 43 bytes
{:{](],(2>@{[)+/ .*]{~1-@>@{[)^:(3>@{[)>@{.

Given an initial sequence of terms A, computes the next term n times using the parameters of x, y, α, and β. Afterwards, it selects the nth term in the extended sequence and outputs it as the result.
Usage
Since J only supports 1 or 2 arguments, I group up all the parameters as a list of boxed lists. The initial seed values A are first, followed by the parameters of x and y as a list, followed by the parameters of α and β as a list, and ending with the value n.
   f =: {:{](],(2>@{[)+/ .*]{~1-@>@{[)^:(3>@{[)>@{.
   2 3 5 7 11;3 5;2 3;8
┌──────────┬───┬───┬─┐
│2 3 5 7 11│3 5│2 3│8│
└──────────┴───┴───┴─┘
   f 2 3 5 7 11;3 5;2 3;8
53
   f _5 2 3 _7 _8 1 _9;5 7;_10 _7;10
39

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