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>
Réponses:
Convexe, 9 octets
Nouvelle méthode! En outre, j'ai réalisé que c'était à peu près exactement la même chose que la réponse de Luis, mais que dans Convex, mais je suis venue à cela indépendamment.
Essayez-le en ligne!
Explication:
Ancienne solution, 10 octets:
Essayez-le en ligne!
Explication:
la source
A,'[,_el^'_
Ruby, 26 octets
Les caractères peuvent être imprimés dans n'importe quel ordre? Ça ne me dérange pas si je le fais!
Essayez-le en ligne!
la source
Perl, 20 octets
Requiert
-E
sans frais supplémentaires.Donc, ma réponse initiale (ci-dessous) était un peu trop ennuyeuse. La seule chose que j'ai réussi à trouver est ce qui précède, c'est exactement la même chose, mais cela semble un peu plus déroutant ... C'est à peu près exactement l'équivalent de ce qui suit:
J'aime les suggestions de @ msh210 dans les commentaires, mais elles sont un peu trop longues!
la source
say grep/\w/,map chr,1..122
||say map{chr=~/\w/;$&}1..122
||say map{chr=~s/\W//r}1..122
say chr=~/\w/g for 1..255
...Cheddar,
31 à27 octetsCela met en valeur le
@"
bien en opérateurNon terminé parce que j'ai finalement appris à réparer l'
@"
opérateur. Le problème était qu’il générait une gamme de cheddar et non une gamme de JS, donc cela ne pouvait pas fonctionner correctementExplication
le
@"
opérateur a été conçu par @ CᴏɴᴏʀO'Bʀɪᴇɴ et génère une gamme de chaînes allant de LHS à RHS. Lorsqu'il est utilisé en tant qu’opérateur unaire, il renvoie le caractère au point de code donné (comme pythonchr
)Ungolfed
la source
brainfuck, 58 octets
Essayez-le en ligne .
Initialise la bande à 3,2 n et fonctionne à partir de là.
la source
JavaScript (ES6), 62 octets
Renvoie
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
, donc seulement 6 octets plus court qu'une fonction qui renvoie le littéral de chaîne. Oui ça craint.la source
btoa
renvoie la sortie requise.atob
._
) et 14 pour_=>atob("")+""
.Haskell, 38 octets
Rien à expliquer ici.
la source
:
et++
?++
prend deux chaînes et les concatène.:
prend un caractère et une chaîne et met le caractère devant la chaîne."_"++['a'..'z']...
fonctionne également, mais est un octet plus long.PowerShell v3 +,
3533 octetsConstruit un tableau dynamique
1..127
, le jette comme unchar
tableau. Ceci est fourni à l'-match
opérateur qui travaille sur la regex\w
, qui retournera tous les éléments correspondants (c'est-à-dire exactement alphanumériques et soulignés). Nous encapsulons ces éléments dans un tableau-join
pour le regrouper en une seule chaîne. Cela reste sur le pipeline et la sortie est implicite.la source
0
...V, 27 octets
Essayez-le en ligne!
Cette réponse est horriblement compliquée. Je posterai une explication plus tard.
Hexdump:
Explication:
Lisible:
la source
J,
302928 octetsEnregistré un octet grâce à randomra!
Sortie:
Explication
Je ne fournirai pas d'explication en soi , mais je fournirai des résultats intermédiaires.
la source
Haskell, 31 octets
L'expression
zip "aA0_" "zZ9_"
donne la liste des points de terminaison[('a','z'),('A','Z'),('0','9'),('_','_')]
. Lado
notation prend chacun(x,y)
à l'inclus\(x,y)->[x..y]
et concatène les résultats. Merci à Anders Kaseorg pour deux octets avecdo
au lieu de>>=
.Comparez aux alternatives:
la source
do
La notation sauve deux octets:do(x,y)<-zip"aA0_""zZ9_";[x..y]
C, 50 octets
Appelez
f()
sans aucun argument.Impressions
la source
isalnum(n)|n==95&&putchar(n)
putc
au lieu deputchar
.putc
attend un flux à écrire également, que vous n'avez pas réussi. La fonction elle-même fonctionne bien (essayez de supprimer votreputc
ensemble, et cela fonctionne).If the number of arguments does not equal the number of parameters, the behavior is undefined.
6.5.2.2/6, voir N1570 ./// , 63 octets
la source
Python 3, 58 octets
Un programme complet qui imprime sur STDOUT.
La sortie est:
_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Comment ça marche
Essayez sur Ideone
Si les constantes de chaîne étaient autorisées, les octets suivants auraient été de 45 octets:
la source
print('_'+*filter(str.isalnum,map(chr,range(123))))
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'.print''.join(filter(str.isalnum,map(chr,range(123)))),'_'
My first attempt at codegolf!
C#,
168152150147130127117116115109106 bytesThanks a lot to aloisdg, AstroDan, Leaky Nun and Kevin Lau - not Kenny for all the help in comments.
la source
\w
regex class covers the alphanumerics and also_
, which should make"\\w"
valid enough for your regex match function.Pure bash, 32
Ideone.
la source
Object Pascal,
858373 bytesJust 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.
la source
program
keyword.bash –
4737 bytesOutput on my system is:
Thanks to Digital Trauma for helpful suggestions.
On some systems you might be able to use
ascii
instead ofman sh
to save a byte.la source
man sh|egrep -io _\|\\w|sort -u|tr -d \\n
\w
matches_
and is already case insensitive, so could shorten even more.env
instead ofman sh
should work on most environments. It does on mine.$ env|egrep -o \\w|sort -u|tr -d \\n
->0123456789ABCDEFGHIKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
.J
. My bad.PHP, 40 bytes
Online Demo.
la source
Retina,
3019161512 bytesI modified my original alphabet attempt for this latest version. Each character is printed in a loop.
The first line is empty.
Try it online
Output:
Thanks to Leaky Nun for golfing 4 bytes off my latest attempt.
la source
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 thew
on the left witho
. Although you can save a byte by usingEO
instead ofd
since they only contain 5 characters each.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.MATL, 11 bytes
Try it online!
la source
8W:'\w'XX
8W:'\w'XX!
which I tried but doesn't workBrachylog, 25 bytes
This prints the following to
STDOUT
:Explanation
la source
Pyth,
1312 bytesTry it online!
Finds all characters in U+0000 to U+007B that matches the regex
/\w/
.Outputs
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
.alternative approach: 15 bytes
Try it online!
basically generates the half-inclusive ranges required:
0-:, A-[, a-{, _-`
.la source
CJam,
151411 bytes4 bytes off thanks to @FryAmTheEggman and @Dennis!
Try it online!
la source
Brainfuck, 89 bytes
Try it here
Details:
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.
la source
F#,
5059 bytesOutput:
Edit: missed the digits the first time
Edit2, inspired by this Haskell solution this F# snippet is 67 bytes.
Output:
la source
Hexagony, 33
Expanded:
Output:
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
andA
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:Then it enters a loops that prints the letters and then increments them, and then decrements the number. After one iteration we would have:
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 thatx
'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.la source
Brainfuck,
11410398907671 bytesAnother
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
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)
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.
la source
+[--[<+++++++>->+<]>-]
>-]
, you can be sure that the final term will be 1 (x7). Actually, you should probably start with-
, it finishes a lot faster.Sesos, 17 bytes
Output
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.
la source
Pyke, 13 bytes
Try it here!
Generates ascii 0-150 and filters by alphanumericness and adds
_
to the endla source