17
3
Sign that word 2!
Not that long ago, I posted a challenge called Sign that word!. In the challenge, you must find the signature of word, which is the letters put in order (e.g. The signature of this
is hist
). Now then, that challenge did quite well, but there was one key issue: it was WAY too easy (see the GolfScript answer). So, I've posted a similar challenge, but with more rules, most of which have been suggested by PPCG users in the comments on the previous puzzle. So, here we go!
Rules
- Your program must take an input, then output the signature to STDOUT or the equivalent in whatever language your using.
- You are not allowed to use built-in sorting functions, so stuff like
$
in GolfScript is not allowed. - Multicase must be supported - your program must group letters of both uppercase and lowercase together. So the signature of
Hello
iseHllo
, notHello
as you are given by the GolfScript answer on the first version. - There must be a free interpreter/compiler for your program, which you should link to.
Scoring
Your score is your byte count. Lowest byte count wins.
Leaderboard
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
var QUESTION_ID=55090;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),e.has_more?getAnswers():process()}})}function shouldHaveHeading(e){var a=!1,r=e.body_markdown.split("\n");try{a|=/^#/.test(e.body_markdown),a|=["-","="].indexOf(r[1][0])>-1,a&=LANGUAGE_REG.test(e.body_markdown)}catch(n){}return a}function shouldHaveScore(e){var a=!1;try{a|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(r){}return a}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading),answers.sort(function(e,a){var r=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0],n=+(a.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0];return r-n});var e={},a=1,r=null,n=1;answers.forEach(function(s){var t=s.body_markdown.split("\n")[0],o=jQuery("#answer-template").html(),l=(t.match(NUMBER_REG)[0],(t.match(SIZE_REG)||[0])[0]),c=t.match(LANGUAGE_REG)[1],i=getAuthorName(s);l!=r&&(n=a),r=l,++a,o=o.replace("{{PLACE}}",n+".").replace("{{NAME}}",i).replace("{{LANGUAGE}}",c).replace("{{SIZE}}",l).replace("{{LINK}}",s.share_link),o=jQuery(o),jQuery("#answers").append(o),e[c]=e[c]||{lang:c,user:i,size:l,link:s.share_link}});var s=[];for(var t in e)e.hasOwnProperty(t)&&s.push(e[t]);s.sort(function(e,a){return e.lang>a.lang?1:e.lang<a.lang?-1:0});for(var o=0;o<s.length;++o){var l=jQuery("#language-template").html(),t=s[o];l=l.replace("{{LANGUAGE}}",t.lang).replace("{{NAME}}",t.user).replace("{{SIZE}}",t.size).replace("{{LINK}}",t.link),l=jQuery(l),jQuery("#languages").append(l)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/,NUMBER_REG=/\d+/,LANGUAGE_REG=/^#*\s*([^,]+)/;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;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>
2Must lowercase and uppercase be ordered? For example, for
ThHihs
, can we outputhHhist
or do we have to outputhhHist
orHhhist
? – Fatalize – 2015-08-21T07:20:54.033I cannot comprehend rule 3. – feersum – 2015-08-21T07:20:55.123
@Fatalize As long as they are grouped together, it doesn't matter. It can be any of those. – None – 2015-08-21T07:23:09.080
@feersum Try running the GolfScript answer on the first version of this challenge with the string "Hello" (without the quotes). Then you should see what I mean. – None – 2015-08-21T07:26:57.270
2@Kslkgh I do not wish to install a GolfScript interpreter in order to understand the question. The requirements should be clearly specified in the question itself. – feersum – 2015-08-21T07:29:56.307
1@feersum You don't need to. There is a link in the answer to an online interpreter. But I will make it clearer. – None – 2015-08-21T07:35:09.003
So what you really mean is that the sorting should be case-insensitive? Why not simply say so? – feersum – 2015-08-21T08:07:41.277
Let us continue this discussion in chat.
– None – 2015-08-21T08:44:41.3878Correctly handling lower/upper case in Unicode is scary, so is this question voluntarily limited to ASCII letters: [a-zA-Z]? – Matthieu M. – 2015-08-21T09:03:16.637
3
You forgot to close the parenthesis after "see this GolfScript answer". https://xkcd.com/859/
– nyuszika7h – 2015-08-21T09:24:19.1231"Your score is your byte count." So I rank better when I have more bytes? Maybe you should update that one :P – BlueWizard – 2015-08-21T17:51:21.917
1@JonasDralle: remember, this is golf, where scoring is always backwards! – Lynn – 2015-08-21T22:11:45.900