12
6
What is a Word Signature?
The signature of a word are all of it's letters put in order - the signatures of this
, hist
and hits
are all hist
.
The Challenge
Write a program program should ask for an input, then print out the signature of that word. So an example program run might look like this:
Give me a string: this
The signature signature of 'this' is hist.
There is no required interaction, as long as it takes an input and prints the signature, it is OK.
Scoring
The program with the smallest 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=54945;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>
Challenged Finished!
WINNER: jimmy23013
3We don't have to print the sentences
Give me a string:
andThe signature signature of 'this' is
right? We can just take the input directly and print the result? – Fatalize – 2015-08-19T07:24:41.467Also are inputs consisting only of lowercase characters or can there be uppercase letters? – Fatalize – 2015-08-19T07:28:18.513
4What about duplicate letters? e.g. is the signature of
broom
bmoor
orbmor
? – samgak – 2015-08-19T07:39:51.110@Fatalize Yes, there is no required interaction with the user. Just take the input and print the result. – None – 2015-08-19T07:50:25.833
@samgak bmoor. Duplicates are put in. – None – 2015-08-19T07:51:05.993
1I'm voting to close this as too broad/trivial. – isaacg – 2015-08-19T10:24:51.703
3@isaacg why are you? – Tim – 2015-08-19T10:52:26.987
This looks essentially like a duplicate of this question.
– Peter Taylor – 2015-08-19T10:56:10.2273@Tim I don't think we should have challenges that are this straightforward. I'll ask about it on meta - it's not really about this question in particular. – isaacg – 2015-08-19T11:00:54.107
Well, I'm a few hours late, and every competitive language I know has already been done. :/ – kirbyfan64sos – 2015-08-19T13:44:37.543
2I think this would have been a more interesting challenge if you couldn't use built-in sorting functions. – Glen O – 2015-08-20T04:34:16.260
1@GlenO, or duplicate letters and multicase need to be supported. – James Webster – 2015-08-20T11:50:08.853
@JamesWebster Duplicate letters do. – None – 2015-08-20T17:26:28.020
These suggestions will be addressed in Sign that word 2, being posted soon. That one will have a stricter set of rules. – None – 2015-08-20T19:25:58.437
1
Added second edition. http://codegolf.stackexchange.com/questions/55090/sign-that-word-2 Not a duplicate because the answers from this question are not transposable to that one.
– None – 2015-08-21T07:13:28.930