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

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

# 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="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• Comments are not for extended discussion; this conversation has been moved to chat. – Dennis Jul 19 '16 at 0:45

## 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^'_ – GamrCorps Jul 18 '16 at 19:07
• Which encoding is this? – Conor O'Brien Jul 18 '16 at 19:11
• @CᴏɴᴏʀO'Bʀɪᴇɴ CP-1252 or Windows-1252 – GamrCorps Jul 18 '16 at 19:12

# 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 Jul 18 '16 at 20:05
• @msh210 Still can't shrink this more... Managed a 25 though: say chr=~/\w/g for 1..255... – Dom Hastings Jul 23 '16 at 1:07

# 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

+++[[<+>->++<]>]<<[-<->]<<-.+<<++[->>+.>+.<<<]<--[->>.+<<]


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


## 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 Jul 19 '16 at 9:10
• @gcampbell 60! (60 factorial) strings might take some time to search... – Neil Jul 19 '16 at 13:53
• You could just use atob. – gcampbell Jul 19 '16 at 13:53
• @gcampbell I have to exclude unrepresentable strings somehow. – Neil Jul 19 '16 at 13:54
• @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("")+"". – Neil Jul 19 '16 at 18:34

'_':['a'..'z']++['A'..'Z']++['0'..'9']


Nothing to explain here.

• question: what's the difference between : and ++? – Downgoat Jul 18 '16 at 17:56
• @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. – nimi Jul 18 '16 at 17:58

## 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 Jul 18 '16 at 19:16
• @Joey Gotta go fast. :D – AdmBorkBork Jul 18 '16 at 19:36
• Especially for the trivial and obvious solutions, I guess ;-) – Joey Jul 18 '16 at 19:38

# 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:

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! – Downgoat Jul 18 '16 at 22:57

# J, 3029 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


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] – Anders Kaseorg Jul 19 '16 at 8:27

# 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) – orlp Jul 18 '16 at 17:41
• There's UB there. You didn't pass the required arguments. – Ven Jul 18 '16 at 18:33
• @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 Jul 18 '16 at 19:43
• @owacoder Oops! – orlp Jul 18 '16 at 19:45
• @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. – Ven Jul 20 '16 at 6:18

# ///, 63 bytes

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

• How is it the valid answer? Looks like it's violating the rules. – nicael Jul 18 '16 at 19:20
• @nicael which rule? – Leaky Nun Jul 18 '16 at 19:29
• "Built-in constants that contain 9 or more of the above characters are disallowed."... Am I missing something obvious, @Leaky? – nicael Jul 18 '16 at 19:32
• Yes, that this didn't use any built-in constants. – Leaky Nun Jul 18 '16 at 19:33
• Ok, but this is weird at least. Definitely OP doesn't ask you to copy-paste the sequence, that's not interesting. – nicael Jul 18 '16 at 19:35

# 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)))) – Leaky Nun Jul 18 '16 at 19:22
• @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'. – TheBikingViking Jul 18 '16 at 19:39
• Python 2 can save one byte with this approach: print''.join(filter(str.isalnum,map(chr,range(123)))),'_' – atlasologist Jul 18 '16 at 19:52

My first attempt at codegolf!

## C#, 168152150147130127117116115109 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. – aloisdg moving to codidact.com Jul 18 '16 at 19:11
• Great - saved me 2 bytes more. I'm really starting to like this codegolf :) – Daniel Jul 18 '16 at 19:37
• AFAIK, the \w regex class covers the alphanumerics and also _, which should make "\\w" valid enough for your regex match function. – Value Ink Jul 18 '16 at 20:57
• Your code should a be function or a full program not a statement. Also use .NetFiddle to share a demonstration of your code :) – aloisdg moving to codidact.com Jul 18 '16 at 23:55
• "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 moving to codidact.com Jul 19 '16 at 13:19

# Pure bash, 32

printf %s {a..z} {A..Z} {0..9} _


# Object Pascal, 8583 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.

• 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 Jul 19 '16 at 8:33
• @manatwork I didn't know that. Oddly enough it now makes pascal competitive here... – hdrz Jul 19 '16 at 10:13
• The language I grew up with. I know that it is not yet dead... – rexkogitans Jul 19 '16 at 12:06
• @rexkogitans Yeah I learned it at school, but can't remember anything from back then... I'm playing with some programming again now – hdrz Jul 19 '16 at 17:46

# 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 – Digital Trauma Jul 18 '16 at 22:26
• @DigitalTrauma Thank you! Experimented and found out \w matches _ and is already case insensitive, so could shorten even more. – user15259 Jul 19 '16 at 10:29
• 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. – YSC Jul 19 '16 at 15:31 • There's no J. My bad. – YSC Jul 19 '16 at 15:39 ## PHP, 40 bytes _0<?for(;$a++^9?$a^q:$a=A;)echo" $a"|$a;

• +1 for excellence. Side note: PHP 7.2 yields warnings mentioning that future versions will throw errors for undefined constants. :-( – Titus Apr 30 '18 at 18:35

# Retina, 30191615 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\;ww_

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. – Martin Ender Jul 18 '16 at 21:26
• @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. – Martin Ender Jul 18 '16 at 21:31

# 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 – James Jul 18 '16 at 18:22
• @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" – Luis Mendo Jul 18 '16 at 18:24
• So why couldn't you do 8W:'\w'XX! which I tried but doesn't work – James Jul 18 '16 at 19:34
• @DrGreenEggsandIronMan Very good question! Let me answer you in chat so I can use a little more characters – Luis Mendo Jul 18 '16 at 21:24

# 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


# 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-{, _-.

# CJam, 1514 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


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

# 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_


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

# Brainfuck, 114103989076 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 Jul 21 '16 at 8:09
• @primo Wow! How does that work? – Blue Jul 21 '16 at 11:26
• 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. – primo Jul 21 '16 at 11:31

# 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.
; 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.
; 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. – Leaky Nun Jul 22 '16 at 8:30
• Alike minds think great! – Dennis Jul 22 '16 at 19:39
• @LeakyNun Hm, kinda late, but it looks like yours is 3 bytes shorter... – Erik the Outgolfer Apr 30 '18 at 11:36
• @EriktheOutgolfer Sesos used to be encoded in a less efficient manner. Both programs are 17 bytes long now. – Dennis Apr 30 '18 at 13:13
• @Dennis Ah, well, the TIO cache can be confusing at times. – Erik the Outgolfer Apr 30 '18 at 13:31

## Pyke, 13 bytes

150m.C#P)\_+s


Try it here!

Generates ascii 0-150 and filters by alphanumericness and adds _ to the end