Print all alphanumeric characters plus underscore

37

2

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="<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>

orlp

Posted 2016-07-18T17:23:30.843

Reputation: 37 067

2

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

– Dennis – 2016-07-19T00:45:18.967

Answers

11

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

GamrCorps

Posted 2016-07-18T17:23:30.843

Reputation: 7 058

1@mbomb007 Yes it is equivalent to the CJam code A,'[,_el^'_ – GamrCorps – 2016-07-18T19:07:08.230

Which encoding is this? – Conor O'Brien – 2016-07-18T19:11:20.190

@CᴏɴᴏʀO'Bʀɪᴇɴ CP-1252 or Windows-1252 – GamrCorps – 2016-07-18T19:12:07.317

12

Ruby, 26 bytes

Characters can be printed in any order? Don't mind if I do!

Try it online!

$><<(?0..?z).grep(/\w/)*''

Value Ink

Posted 2016-07-18T17:23:30.843

Reputation: 10 608

12

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!

Dom Hastings

Posted 2016-07-18T17:23:30.843

Reputation: 16 415

1+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 – 2016-07-18T20:05:58.407

1@msh210 Still can't shrink this more... Managed a 25 though: say chr=~/\w/g for 1..255... – Dom Hastings – 2016-07-23T01:07:52.407

10

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  +
  "_"

Downgoat

Posted 2016-07-18T17:23:30.843

Reputation: 27 116

10

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

primo

Posted 2016-07-18T17:23:30.843

Reputation: 30 891

9

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.

Neil

Posted 2016-07-18T17:23:30.843

Reputation: 95 035

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

– gcampbell – 2016-07-19T09:10:21.493

@gcampbell 60! (60 factorial) strings might take some time to search... – Neil – 2016-07-19T13:53:01.580

You could just use atob. – gcampbell – 2016-07-19T13:53:39.633

@gcampbell I have to exclude unrepresentable strings somehow. – Neil – 2016-07-19T13:54:42.260

@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 – 2016-07-19T18:34:34.057

Oh, that didn't help then. You could still add it to your answer maybe. – gcampbell – 2016-07-19T18:36:04.897

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) – Conor O'Brien – 2016-07-19T19:33:02.353

9

Haskell, 38 bytes

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

Nothing to explain here.

nimi

Posted 2016-07-18T17:23:30.843

Reputation: 34 639

2question: what's the difference between : and ++? – Downgoat – 2016-07-18T17:56:48.647

3@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 – 2016-07-18T17:58:52.107

8

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.

AdmBorkBork

Posted 2016-07-18T17:23:30.843

Reputation: 41 581

1Hey, that's not fair. My own solution is identical except I started at 0 ... – Joey – 2016-07-18T19:16:37.693

@Joey Gotta go fast. :D – AdmBorkBork – 2016-07-18T19:36:37.427

Especially for the trivial and obvious solutions, I guess ;-) – Joey – 2016-07-18T19:38:13.167

7

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.

James

Posted 2016-07-18T17:23:30.843

Reputation: 54 537

5:D :D :D Cheddar is tied with a golfing lang! – Downgoat – 2016-07-18T22:57:51.930

7

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

Conor O'Brien

Posted 2016-07-18T17:23:30.843

Reputation: 36 228

6

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 __"

xnor

Posted 2016-07-18T17:23:30.843

Reputation: 115 687

2do notation saves two bytes: do(x,y)<-zip"aA0_""zZ9_";[x..y] – Anders Kaseorg – 2016-07-19T08:27:03.413

4

C, 50 bytes

Call f() without any arguments.

f(n){for(n=128;--n;)isalnum(n)|n==95&&putchar(n);}

Prints

zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210

owacoder

Posted 2016-07-18T17:23:30.843

Reputation: 1 556

1isalnum(n)|n==95&&putchar(n) – orlp – 2016-07-18T17:41:12.120

There's UB there. You didn't pass the required arguments. – Ven – 2016-07-18T18:33:55.027

@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 – 2016-07-18T19:43:01.323

@owacoder Oops! – orlp – 2016-07-18T19:45:11.670

@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. – Fund Monica's Lawsuit – 2016-07-19T21:49:42.800

1

@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 – 2016-07-20T06:18:00.523

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. – Ven – 2016-07-20T06:18:58.980

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. – Fund Monica's Lawsuit – 2016-07-20T10:25:28.867

I'm pretty sure it is undefined behavior, but what matters is that it actually works with one or more implementations (at least GCC). – owacoder – 2016-07-20T11:23:47.433

4

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.

mbomb007

Posted 2016-07-18T17:23:30.843

Reputation: 21 944

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 – 2016-07-18T21:26:02.480

@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 – 2016-07-18T21:31:37.223

4

///, 63 bytes

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

Erik the Outgolfer

Posted 2016-07-18T17:23:30.843

Reputation: 38 134

How is it the valid answer? Looks like it's violating the rules. – nicael – 2016-07-18T19:20:24.237

@nicael which rule? – Leaky Nun – 2016-07-18T19:29:35.563

"Built-in constants that contain 9 or more of the above characters are disallowed."... Am I missing something obvious, @Leaky? – nicael – 2016-07-18T19:32:30.080

4Yes, that this didn't use any built-in constants. – Leaky Nun – 2016-07-18T19:33:54.703

Ok, but this is weird at least. Definitely OP doesn't ask you to copy-paste the sequence, that's not interesting. – nicael – 2016-07-18T19:35:17.843

@nicael They are default constants, not built-in ones. You can modify them. – Erik the Outgolfer – 2016-07-19T08:04:27.257

4

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.

Daniel

Posted 2016-07-18T17:23:30.843

Reputation: 1 808

2

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 – 2016-07-18T19:11:31.720

Also don't forgot System.Text.RegularExpressions. It is sad, but we have to use it. – aloisdg moving to codidact.com – 2016-07-18T19:19:49.740

I can't check right now but I believe that you can save some bytes by using +"" instead of .ToString(). – AstroDan – 2016-07-18T19:30:43.293

Can you use [\w_] instead of [a-zA-Z0-9_]? – Leaky Nun – 2016-07-18T19:31:33.080

You are both right, @LeakyNun I need one more \ to escape, but still shorter :) – Daniel – 2016-07-18T19:34:20.680

What's those spaces there doing? – Leaky Nun – 2016-07-18T19:35:29.673

var a=(char)i;Console.Write(Regex.IsMatch(a+"", "[\\w_]") ?a+"":""); to var a=""+(char)i;Console.Write(Regex.IsMatch(a,"[\\w_]")?a:""); – Leaky Nun – 2016-07-18T19:36:28.270

1Great - saved me 2 bytes more. I'm really starting to like this codegolf :) – Daniel – 2016-07-18T19:37:20.400

Actually saved me 5 bytes - didn't know about ""+ instant string conversion :) – Daniel – 2016-07-18T19:39:12.910

Try this (117 bytes) using System.Text.RegularExpressions;for(char a='0';a<='~';a++){Console.Write(Regex.IsMatch(a+"","[\w_]")?a+"":"");} – AstroDan – 2016-07-18T19:41:22.463

Very impressive @AstroDan ! – Daniel – 2016-07-18T19:41:54.767

@Daniel 2 more, try Debug.Write instead of Console.Write (make sure it works with your compiler / ide) – AstroDan – 2016-07-18T19:44:13.667

Doesn't seem to work in VS2015. And I'll also have to include System.Diagnostics correct? – Daniel – 2016-07-18T19:51:40.750

@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. – AstroDan – 2016-07-18T19:55:18.207

1AFAIK, the \w regex class covers the alphanumerics and also _, which should make "\\w" valid enough for your regex match function. – Value Ink – 2016-07-18T20:57:46.303

You are right @KevinLau-notKenny - Thanks – Daniel – 2016-07-18T20:59:57.667

1Your 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 – 2016-07-18T23:55:08.810

1First 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! – Kevin Cruijssen – 2016-07-19T07:03:00.237

2"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 – 2016-07-19T13:19:11.667

1@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. ;) – Kevin Cruijssen – 2016-07-21T07:39:15.757

@KevinCruijssen Indeed. Sorry I mistook your words :) – aloisdg moving to codidact.com – 2016-07-21T11:03:36.373

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

– Kevin Cruijssen – 2016-07-21T11:07:02.787

1A 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. – Patrik Westerlund – 2017-02-07T22:18:20.070

@PatrikWesterlund Not bad - will check it out later :) – Daniel – 2017-02-08T07:35:59.933

4

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

TheBikingViking

Posted 2016-07-18T17:23:30.843

Reputation: 3 674

1print('_'+*filter(str.isalnum,map(chr,range(123)))) – Leaky Nun – 2016-07-18T19:22:46.763

@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 – 2016-07-18T19:39:47.990

Python 2 can save one byte with this approach: print''.join(filter(str.isalnum,map(chr,range(123)))),'_' – atlasologist – 2016-07-18T19:52:07.907

4

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.

user15259

Posted 2016-07-18T17:23:30.843

Reputation:

1man sh|egrep -io _\|\\w|sort -u|tr -d \\n – Digital Trauma – 2016-07-18T22:26:30.893

1@DigitalTrauma Thank you! Experimented and found out \w matches _ and is already case insensitive, so could shorten even more. – None – 2016-07-19T10:29:10.990

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 – 2016-07-19T15:31:26.267

There's no J. My bad. – YSC – 2016-07-19T15:39:39.387

4

Pure bash, 32

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

Ideone.

Digital Trauma

Posted 2016-07-18T17:23:30.843

Reputation: 64 644

4

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

hdrz

Posted 2016-07-18T17:23:30.843

Reputation: 321

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 – 2016-07-19T08:33:44.837

@manatwork I didn't know that. Oddly enough it now makes pascal competitive here... – hdrz – 2016-07-19T10:13:02.990

The language I grew up with. I know that it is not yet dead... – rexkogitans – 2016-07-19T12:06:46.523

@rexkogitans Yeah I learned it at school, but can't remember anything from back then... I'm playing with some programming again now – hdrz – 2016-07-19T17:46:43.293

4

PHP, 40 bytes

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

Online Demo.

primo

Posted 2016-07-18T17:23:30.843

Reputation: 30 891

1+1 for excellence. Side note: PHP 7.2 yields warnings mentioning that future versions will throw errors for undefined constants. :-( – Titus – 2018-04-30T18:35:33.060

3

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

Leaky Nun

Posted 2016-07-18T17:23:30.843

Reputation: 45 011

3

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

Fatalize

Posted 2016-07-18T17:23:30.843

Reputation: 32 976

3

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

Luis Mendo

Posted 2016-07-18T17:23:30.843

Reputation: 87 464

2 bytes shorter: 8W:'\w'XX – James – 2016-07-18T18:22:30.287

2@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 – 2016-07-18T18:24:24.857

1So why couldn't you do 8W:'\w'XX! which I tried but doesn't work – James – 2016-07-18T19:34:57.687

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

– Luis Mendo – 2016-07-18T21:24:52.120

3

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

Luis Mendo

Posted 2016-07-18T17:23:30.843

Reputation: 87 464

3

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.

Blue

Posted 2016-07-18T17:23:30.843

Reputation: 1 986

How about a backwards construction? +[--[<+++++++>->+<]>-] – primo – 2016-07-21T08:09:25.080

@primo Wow! How does that work? – Blue – 2016-07-21T11:26:42.700

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 – 2016-07-21T11:31:30.527

3

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.

Dennis

Posted 2016-07-18T17:23:30.843

Reputation: 196 637

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

– Leaky Nun – 2016-07-22T08:30:53.757

Alike minds think great! – Dennis – 2016-07-22T19:39:40.317

@LeakyNun Hm, kinda late, but it looks like yours is 3 bytes shorter... – Erik the Outgolfer – 2018-04-30T11:36:02.617

@EriktheOutgolfer Sesos used to be encoded in a less efficient manner. Both programs are 17 bytes long now. – Dennis – 2018-04-30T13:13:24.587

@Dennis Ah, well, the TIO cache can be confusing at times. – Erik the Outgolfer – 2018-04-30T13:31:34.593

@EriktheOutgolfer I'm not sure what you mean. The cache cover the last few weeks and didn't even exist in 2016. – Dennis – 2018-04-30T13:33:11.700

3

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_

asibahi

Posted 2016-07-18T17:23:30.843

Reputation: 371

3

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.

Robijoe

Posted 2016-07-18T17:23:30.843

Reputation: 31

3

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.

FryAmTheEggman

Posted 2016-07-18T17:23:30.843

Reputation: 16 206

2

R, 40 bytes

Inspired by this answer.

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

Try it online!

JayCe

Posted 2016-07-18T17:23:30.843

Reputation: 2 655

2

Pyke, 13 bytes

150m.C#P)\_+s

Try it here!

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

Blue

Posted 2016-07-18T17:23:30.843

Reputation: 26 661

2

Dyalog APL, 18 bytes

∊'\w'⎕S'&'⎕UCS⍳255

prints:

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

Adám

Posted 2016-07-18T17:23:30.843

Reputation: 37 779

2

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!

Cowabunghole

Posted 2016-07-18T17:23:30.843

Reputation: 1 590

2Since 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. – El'endia Starman – 2016-07-18T18:40:19.903

2

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

Emigna

Posted 2016-07-18T17:23:30.843

Reputation: 50 798

Does this also work: žyLçJá9ÝJ'_J? – Adnan – 2016-07-18T21:11:14.943

@Adnan: Yes of course :) Much better! – Emigna – 2016-07-18T21:58:18.057

1Alternatively žyLçá9Ý'_)˜J also works for the same byte count. – Emigna – 2016-07-18T22:04:03.263

Alternatively, žj non-competing. – Magic Octopus Urn – 2017-06-16T22:05:37.797

2

Golfscript, 18 bytes

10,123,65>'[\]^`'^

primo

Posted 2016-07-18T17:23:30.843

Reputation: 30 891

2

JavaScript, 55 bytes

x=>[...new Set(Object.keys(this).join`j345689`)].join``
  1. 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).
  2. 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.

user2428118

Posted 2016-07-18T17:23:30.843

Reputation: 2 000

2

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.

LegionMammal978

Posted 2016-07-18T17:23:30.843

Reputation: 15 731

2

Jelly, 14 bytes

“09AZaz_”Or2/Ọ

Try it online!

Lynn

Posted 2016-07-18T17:23:30.843

Reputation: 55 648

1

SmileBASIC, 52 bytes

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

12Me21

Posted 2016-07-18T17:23:30.843

Reputation: 6 110

1

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

mbomb007

Posted 2016-07-18T17:23:30.843

Reputation: 21 944

1

K, 28 bytes

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

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

uryga

Posted 2016-07-18T17:23:30.843

Reputation: 71

1

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

user85052

Posted 2016-07-18T17:23:30.843

Reputation:

1

MATL, 20 bytes

95 48:57 65:90t32+vc

Try it online!

This is a very boring and straightforward answer.

James

Posted 2016-07-18T17:23:30.843

Reputation: 54 537

1You 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 – Luis Mendo – 2016-07-18T17:58:42.390

1

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.

Laikoni

Posted 2016-07-18T17:23:30.843

Reputation: 23 676

1There's no lowercase z. Typo? – owacoder – 2016-07-18T18:05:07.500

1@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. – Laikoni – 2016-07-18T18:10:07.710

1

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 (-> ,,).

nimi

Posted 2016-07-18T17:23:30.843

Reputation: 34 639

1

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!

aloisdg moving to codidact.com

Posted 2016-07-18T17:23:30.843

Reputation: 1 767

1

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

user8397947

Posted 2016-07-18T17:23:30.843

Reputation: 1 242

Maybe it's a bit boring, but just manually printing everything: void f(){System.out.print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");} (94 bytes) is shorter in Java. ;) – Kevin Cruijssen – 2016-07-19T07:08:52.313

yay under 100 ''void f(){char c=97;String r="";while(c<='z')r+=c++;System.out.print(r+r.toUpperCase()+"_");} – dwana – 2016-07-19T10:42:25.130

91 my final form, void f(){char c=65;String r="";while(c<=90)r+=c++;System.out.print(r.toLowerCase()+r+"_");} – dwana – 2016-07-19T10:49:01.210

1@KevinCruijssen shorter, as function: ()->"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345‌​6789_" ("only" 69 bytes). – Olivier Grégoire – 2016-07-19T13:43:28.273

179 void d(){for(char b=1;b<127;b++)System.out.print((b+"").replaceAll("\W",""));} – PeterK – 2016-07-20T11:18:37.277

1

Japt, 22 bytes

0o#{ £YdÃf@Xf"\\\\w"Ãq

Try it there.

nicael

Posted 2016-07-18T17:23:30.843

Reputation: 4 585

1

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.

Business Cat

Posted 2016-07-18T17:23:30.843

Reputation: 8 927

1

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

Conor O'Brien

Posted 2016-07-18T17:23:30.843

Reputation: 36 228

1

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.

aloisdg moving to codidact.com

Posted 2016-07-18T17:23:30.843

Reputation: 1 767

1

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

Hans

Posted 2016-07-18T17:23:30.843

Reputation: 111

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.

– Dennis – 2016-07-20T15:43:25.190

1

Common Lisp, 160 bytes

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

CocoaBean

Posted 2016-07-18T17:23:30.843

Reputation: 309

1

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

harry

Posted 2016-07-18T17:23:30.843

Reputation: 11

You can remove some spaces. – mbomb007 – 2016-07-19T15:51:56.453

where for example? I thought I got rid of each one I could – harry – 2016-07-19T17:58:15.757

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. – mbomb007 – 2016-07-19T19:03:31.187

1

C, 56 55 bytes

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

Output:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_

o79y

Posted 2016-07-18T17:23:30.843

Reputation: 509

1

ZX Spectrum, (Machine Code) 28 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
      cp "A"
      jr c,fnext ; in between ranges
      cp "Z"+1
      jr c,ok ; print A-Z
      cp "a"
      jr c,fnext ; in between ranges
ok    rst 16
fnext djnz nchar

Hexcode

067A3E5FD778FE2FC8FE3A390CFE
413809FE5B3804FE613801D710E9

Output: _zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA9876543210

Johan Koelman

Posted 2016-07-18T17:23:30.843

Reputation: 21

Can we have a hexdump of the compiled version? – NoOneIsHere – 2016-07-19T17:37:32.413

Will make it later. – Johan Koelman – 2016-07-19T21:02:58.253

1

K, 21 bytes

_ci95,(97+!26),65+!26

kirbyfan64sos

Posted 2016-07-18T17:23:30.843

Reputation: 8 730

1

O, 40 bytes

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

kirbyfan64sos

Posted 2016-07-18T17:23:30.843

Reputation: 8 730

1

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);
}

kirbyfan64sos

Posted 2016-07-18T17:23:30.843

Reputation: 8 730

1

Julia, 35 bytes

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

Alternative solution, also 35 bytes:

()->replace(join('0':'z'),r"\W","")

Mama Fun Roll

Posted 2016-07-18T17:23:30.843

Reputation: 7 234

1

Lua, 64 Bytes

s="abcdefghijklmnopqrstuvwxyz"print(s..s:upper().."_0123456789")

Katenkyo

Posted 2016-07-18T17:23:30.843

Reputation: 2 857

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

– None – 2017-02-10T19:53:28.867

@PrzemysławP Just ran it in the demo environment and it ran just fine (printing out abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_) – Katenkyo – 2017-02-14T15:23:23.427

Yes, but question was to output also 0123456789, right? – None – 2017-02-14T15:42:47.220

1@PrzemysławP Wow, how did I missed that ?! Thanks, it's fixed now, it should be printing abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 – Katenkyo – 2017-02-14T16:05:46.263

0

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

sergiol

Posted 2016-07-18T17:23:30.843

Reputation: 3 055

0

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

user41805

Posted 2016-07-18T17:23:30.843

Reputation: 16 320

0

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.

user65167

Posted 2016-07-18T17:23:30.843

Reputation:

0

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

steenbergh

Posted 2016-07-18T17:23:30.843

Reputation: 7 772

0

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,'_')

BradC

Posted 2016-07-18T17:23:30.843

Reputation: 6 099

0

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.

streetster

Posted 2016-07-18T17:23:30.843

Reputation: 3 635

1"Built-ins that contain 9 or more of these characters are disallowed." – CalculatorFeline – 2017-06-22T23:34:35.663

0

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!

ATaco

Posted 2016-07-18T17:23:30.843

Reputation: 7 898

0

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``
<pre id=o></pre>

Shaggy

Posted 2016-07-18T17:23:30.843

Reputation: 24 623

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

georgewatson

Posted 2016-07-18T17:23:30.843

Reputation: 291

0

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

Teal pelican

Posted 2016-07-18T17:23:30.843

Reputation: 1 338

0

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

PieCot

Posted 2016-07-18T17:23:30.843

Reputation: 1 039

0

Japt, 13 12 bytes

;C+B+9ô ¬+'_

Try it online!

Oliver

Posted 2016-07-18T17:23:30.843

Reputation: 7 160

0

Zsh, 35 bytes

<<<${(j::)${:-{0..z}}#[^[:IDENT:]]}

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

GammaFunction

Posted 2016-07-18T17:23:30.843

Reputation: 2 838

0

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

Kevin L

Posted 2016-07-18T17:23:30.843

Reputation: 1 251

++++++++++++++++++++++++++++++++++++++++++++++++ That can be done better. – orlp – 2016-07-18T20:30:35.983

improved the +x26 as well – Kevin L – 2016-07-19T13:23:36.190

0

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="")

djhurio

Posted 2016-07-18T17:23:30.843

Reputation: 1 113

0

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

Mego

Posted 2016-07-18T17:23:30.843

Reputation: 32 998

0

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 )

Brad Gilbert b2gills

Posted 2016-07-18T17:23:30.843

Reputation: 12 713

0

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

c.P.u1

Posted 2016-07-18T17:23:30.843

Reputation: 1 049

0

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

tjb1

Posted 2016-07-18T17:23:30.843

Reputation: 561

0

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

enter image description here

applejacks01

Posted 2016-07-18T17:23:30.843

Reputation: 989

0

PHP, 74 71 bytes

echo 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';

MonkeyZeus

Posted 2016-07-18T17:23:30.843

Reputation: 461

0

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

Jack Baker

Posted 2016-07-18T17:23:30.843

Reputation: 11

48 doubled is 96, so you could use replace the initial loop with >++++[>++++++[>++>++++<<-]<-] to get both. Probably shorter than two output loops. – primo – 2016-07-20T09:23:37.710

0

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

Joe

Posted 2016-07-18T17:23:30.843

Reputation: 895

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

manatwork

Posted 2016-07-18T17:23:30.843

Reputation: 17 865

0

RETURN, 20 bytes

'_0 9
'a'z
'A'Z
,,,,

Try it here.

Creates a series of charcode ranges and outputs them.

Mama Fun Roll

Posted 2016-07-18T17:23:30.843

Reputation: 7 234

0

, 10 chars / 13 bytes

Ⓒ…⩥ṻ)ŋ/\W⌿

Try it here (ES6 browsers only).

Translated roughly to ES6:

String.fromCharCode(_.range(123)).replace(/\W/g,'')

Mama Fun Roll

Posted 2016-07-18T17:23:30.843

Reputation: 7 234

0

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

meden

Posted 2016-07-18T17:23:30.843

Reputation: 711