答:
C (gcc), 94 bytes

```<code>f(n,p)char*p;{for(p+=n-1;isalnum(*p)|*p==95&&n--;--p);for(;isalnum(*++p)|*p==95;putchar(*p));}
</code>```

Zero-indexed, defines a function taking the index, then the string.

Body:
In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.

(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)

For example, let | be your cursor in abc de|f ghi.

Then, when you double click, the substring def will be selected.

Input/Output

You will be given two inputs: a string and an integer.

Your task is to return the word-substring of the string around the index specified by the integer.

Your cursor can be right before or right after the character in the string at the index specified.

If you use right before, please specify in your answer.

Specifications (Specs)

The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.

The string will only contain printable ASCII characters (from U+0020 to U+007E).

The word "word" is defined by the regex (?<!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or "alphanumeric characters in ASCII including underscore".

The index can be 1-indexed or 0-indexed.

If you use 0-indexed, please specify it in your answer.

Testcases

The testcases are 1-indexed, and the cursor is right after the index specified.

The cursor position is for demonstration purpose only, which will not be required to be outputted.

```<code>string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd
</code>```

Body:
C (gcc), 94 bytes

f(n,p)char*p;{for(p+=n-1;isalnum(*p)|*p==95&&n--;--p);for(;isalnum(*++p)|*p==95;putchar(*p));}

Zero-indexed, defines a function taking the index, then the string.


问:
#Hashtag_or_not
In this code golf challenge, you will verify hashtags!

#What_your_code_should_do

Input is a string. Output a truthy value if it is a valid hashtag, and a falsy value otherwise.

We define a string as a valid Hashtag if ...

It starts with a hash (#).

It doesn't have a number right after the hashtag (e.g. #2016USElection isn't a  valid hashtag).

It doesn't have any "special characters" (i.e. any character that isn't an alphabet, underscore (_) or a number).

You can assume that the input only contains ASCII characters. (It would be unfair if we did Unicode too.)

#Rules

Basic code-golf rules apply.

#Examples

Truthy:

```<code>#
#e
#_ABC
#thisisanunexpectedlylongstringxoxoxoxo
#USElection2016
</code>```

Falsy:

```<code>Hello, World!
#12thBday
#not-valid
#alsoNotValid!
#!not_a_hash
</code>```

答:
Python 2, 79 bytes

```<code>lambda x:x=='#'or(1>x[1].isdigit())&x[1:].replace('_','').isalnum()&('#'==x[0])
</code>```

First golfing attempt. Ungolfed version:

```<code>def f(x):
    if x == '#':
        return True
    else:
        return x[0]=='#' and x[1:].replace('_','').isalnum() and not x[1].isdigit()
</code>```

ContentLicense: CC BY-SA 3.0

Title: #Hashtag_or_not

Body:
Python 2, 79 bytes

lambda x:x=='#'or(1>x[1].isdigit())&x[1:].replace('_','').isalnum()&('#'==x[0])

First golfing attempt. Ungolfed version:

def f(x):
    if x == '#':
        return True
    else:
        return x[0]=='#' and x[1:].replace('_','').isalnum() and not x[1].isdigit()


问:
Directory calculation
For this challenge, you will be given an absolute path, and a "new" path (which can be absolute or relative), and you need to return the final path.

For example, if your current directory was /var/tmp/test:

my_dir or my_dir/  should return /var/tmp/test/my_dir

../../my_dir should return /var/my_dir

/my_dir/./ should return /my_dir

../../../../../ should return /

To be more pedantic:

A directory is a non-empty string consisting of alphanumeric characters and the symbols -,_, or .

A path is a list of 0 or more directories, separated using /.  An absolute path starts with a /, a relative path does not.  Paths can include an ending /.

You need to "resolve" the second path, given the first path.

The process of resolving is:

Test if the second path is relative.  If so, then insert the absolute path's directories to the beginning of the second path.

If any of the directories is .., then remove it and the preceding directory.  If it is the first directory, then simply remove it.

If any of the directories is ., then remove it.

Output the final absolute path.  You should not output an ending /.

You do not need to handle incorrect input.  The commands should work, whether or not the directories passed actually exist on your machine.  You can assume that everything is a directory, even if it has an extension.

Test cases

```<code>Absolute      New          Output
"/a/b/c"      "d"       -> "/a/b/c/d"
"/a/b/c/"     "d"       -> "/a/b/c/d"
"/a/b/c/"     "d/"      -> "/a/b/c/d"
"/a/b/c"      "/d"      -> "/d"
"/a/b/c"      "/d/"     -> "/d"
"/../a/b/c/"  "d"       -> "/a/b/c/d"
"/a/../b/c/"  "d"       -> "/b/c/d"
"/a/b/../c"   "d"       -> "/a/c/d"
"/a/b/c/.."   "d"       -> "/a/b/d"
"/a/b/c/"     ".."      -> "/a/b"
"/a/b/c"      "../d"    -> "/a/b/d"
"/a/b/c"      "/../d"   -> "/d"
"/a/b/c"      ""        -> "/a/b/c"
"/a/b/c"      "."       -> "/a/b/c"
"/a/b/c"      "./d"     -> "/a/b/c/d"
"/a/b/c"      "/./d"    -> "/d"
"/a/b/c"      "d.txt"   -> "/a/b/c/d.txt"
"/a/b/c"      "d."      -> "/a/b/c/d."
"/a/b/c"      ".txt"    -> "/a/b/c/.txt"
"/a/b/c"      ".txt/d"  -> "/a/b/c/.txt/d"
"/a/b/."      "./././." -> "/a/b"
"/direc"      "tory"    -> "/direc/tory"
"/a-_.b/"     "__._-."  -> "/a-_.b/__._-."
"/a/b"        "../.."   -> "/"
"/a/b"        "../../.."-> "/"
"/a"          "../../.."-> "/"
"/"           ""        -> "/"
"/"           "a"       -> "/a"
"/.."         "a"       -> "/a"
"/."          ""        -> "/"
</code>```

This is a code-golf, so make your submissions as short as possible in your favorite language!

答:
GNU sed, <s>81</s> 59 + 1 = 60 bytes

+1 byte for -r flag. Expects input on STDIN separates by a single space.

```<code>s:.+ /::
s:/? :/:
:
s:/$|[^/]+/+\.\.|\.(/|$):\1:
t
s:^/*:/:
</code>```

Try it online!

Explanation

```<code>s:.+ /::  # If the second argument starts with a slash, drop the first argument
s:/? :/:  # Join the first and second arguments with a slash, dropping duplicate slashes
:
  s:/$|[^/]+/+\.\.|\.(/|$):\1:  # Drop trailing slashes, resolve double and single dots
  t                             # If the above substitution was made, branch to :
s:^/*:/:  # Ensure output begins with a single slash
</code>```

Title: Directory calculation

Body:
GNU sed, <s>81</s> 59 + 1 = 60 bytes

+1 byte for -r flag. Expects input on STDIN separates by a single space.

s:.+ /::
s:/? :/:
:
s:/$|[^/]+/+\.\.|\.(/|$):\1:
t
s:^/*:/:

Try it online!

Explanation

s:.+ /::  # If the second argument starts with a slash, drop the first argument
s:/? :/:  # Join the first and second arguments with a slash, dropping duplicate slashes
:
  s:/$|[^/]+/+\.\.|\.(/|$):\1:  # Drop trailing slashes, resolve double and single dots
  t                             # If the above substitution was made, branch to :
s:^/*:/:  # Ensure output begins with a single slash


问:
Select the word around the given index in a given string
In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.

(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)

For example, let | be your cursor in abc de|f ghi.

Then, when you double click, the substring def will be selected.

Input/Output

You will be given two inputs: a string and an integer.

Your task is to return the word-substring of the string around the index specified by the integer.

Your cursor can be right before or right after the character in the string at the index specified.

If you use right before, please specify in your answer.

Specifications (Specs)

The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.

The string will only contain printable ASCII characters (from U+0020 to U+007E).

The word "word" is defined by the regex (?<!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or "alphanumeric characters in ASCII including underscore".

The index can be 1-indexed or 0-indexed.

If you use 0-indexed, please specify it in your answer.

Testcases

The testcases are 1-indexed, and the cursor is right after the index specified.

The cursor position is for demonstration purpose only, which will not be required to be outputted.

```<code>string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd
</code>```

答:
Pyke, 19 bytes

```<code>#Q;cjmli<i+s)lttjR@
</code>```

Try it here!

Uses Q; as a no-op to make sure the first input is placed correctly

```<code>#          )   -  first where
   c           -       input.split()
    ml         -      map(len, ^)
      i<       -     ^[:i]
        i+     -    ^+[i]
          s    -   sum(^)
            lt - len(^)-2
</code>```

Body:
Pyke, 19 bytes

#Q;cjmli<i+s)lttjR@

Try it here!

Uses Q; as a no-op to make sure the first input is placed correctly

#          )   -  first where
   c           -       input.split()
    ml         -      map(len, ^)
      i<       -     ^[:i]
        i+     -    ^+[i]
          s    -   sum(^)
            lt - len(^)-2


问:
Print all alphanumeric characters plus underscore
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more:

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

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:

```<code># Language Name, N bytes
</code>```

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:

```<code># Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code># Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the leaderboard snippet:

```<code># [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Pyth, <s>13</s> 12 bytes

```<code>s:#"\w"0rk\|
</code>```

Try it online!

Finds all characters in U+0000 to U+007B that matches the regex /\w/.

Outputs 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz.

alternative approach: 15 bytes

```<code>ssrMc4"0:A[a{_`
</code>```

Try it online!

basically generates the half-inclusive ranges required: 0-:, A-[, a-{, _-`.

Body:
Pyth, <s>13</s> 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-{, _-`.


答:
MATL, 20 bytes

```<code>95 48:57 65:90t32+vc
</code>```

Try it online!

This is a very boring and straightforward answer.

Title: Print all alphanumeric characters plus underscore

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

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

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:

```<code># Language Name, N bytes
</code>```

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:

```<code># Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code># Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the leaderboard snippet:

```<code># [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
MATL, 20 bytes

95 48:57 65:90t32+vc

Try it online!

This is a very boring and straightforward answer.


问:
Dice from Changing Random Generator

Introduction

You are given a random integer generator with the following implementation

The first invocation always returns 1.

The second invocation returns a random integer between 1 and 2.

The third invocation returns a random integer between 1 and 3.

The nth invocation returns a random integer between 1 and n, inclusive.

Based on the above function, write a random dice generator that is perfectly random, returning a value between 1 and 6 (inclusive) with equal probability.

Rules

Your program/function should result in a random integer between 1 and 6, inclusive, in some usable form, i.e., to standard output or as a function return value.

The ascending random number generator above can be defined as a "free" function in your program (i.e., doesn't count toward your character count), or a separate script/program that is executed as needed, assuming the state (n) is persistent between calls.

Assume that no more than 1000 dice rolls will ever be requested in a single use case of your program, and the initial random number generator can be reset to 1 at the end of 1000 dice rolls to avoid overflow of n.

Your program may not use any other source of random numbers except the ascending random generator defined above.  You may of course request multiple random numbers from the random number generator for each single dice roll output.

This is code-golf, so winner is shortest answer or most votes in the event of a tie.  If you can generate 1000 dice rolls using less than 1000 generated random numbers, give yourself a 10-point efficiency bonus.

Example

```<code>./asc-rand
1 # random integer between 1 and 1
./asc-rand
1 # random integer between 1 and 2
./asc-rand
3 # random integer between 1 and 3
./asc-rand
4 # random integer between 1 and 4

# dice-gen generates random dice based on output of asc-rand program.
./dice-gen
3
./dice-gen
6
./dice-gen
5
./dice-gen
1
</code>```

答:
Python, 31 chars

Similarly to scleaver, define the generator like this:

```<code>from random import randint
n=0
def r():
    global n;n+=1
    return randint(1,n)
</code>```

Then a function to return dice rolls:

```<code>D=lambda:eval('r(),'*6)[-1]%6+1
</code>```

Call D() any time you need a uniformly random dice roll.

Title: Dice from Changing Random Generator

Body:
Python, 31 chars

Similarly to scleaver, define the generator like this:

from random import randint
n=0
def r():
    global n;n+=1
    return randint(1,n)

Then a function to return dice rolls:

D=lambda:eval('r(),'*6)[-1]%6+1

Call D() any time you need a uniformly random dice roll.


答:
Pyke, 13 bytes

```<code>150m.C#P)\_+s
</code>```

Try it here!

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

Body:
Pyke, 13 bytes

150m.C#P)\_+s

Try it here!

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


答:
C, 50 bytes

Call f() without any arguments.

```<code>f(n){for(n=128;--n;)isalnum(n)|n==95&&putchar(n);}
</code>```

Prints

```<code>zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210
</code>```

Body:
C, 50 bytes

Call f() without any arguments.

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

Prints

zyxwvutsrqponmlkjihgfedcba_ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210


答:
Ruby, 16 bytes

Since apparently using a method from the standard library is allowed:

```<code>File.expand_path
</code>```

See the test suite on repl.it.

Title: Directory calculation

Body:
For this challenge, you will be given an absolute path, and a "new" path (which can be absolute or relative), and you need to return the final path.

For example, if your current directory was /var/tmp/test:

my_dir or my_dir/  should return /var/tmp/test/my_dir

../../my_dir should return /var/my_dir

/my_dir/./ should return /my_dir

../../../../../ should return /

To be more pedantic:

A directory is a non-empty string consisting of alphanumeric characters and the symbols -,_, or .

A path is a list of 0 or more directories, separated using /.  An absolute path starts with a /, a relative path does not.  Paths can include an ending /.

You need to "resolve" the second path, given the first path.

The process of resolving is:

Test if the second path is relative.  If so, then insert the absolute path's directories to the beginning of the second path.

If any of the directories is .., then remove it and the preceding directory.  If it is the first directory, then simply remove it.

If any of the directories is ., then remove it.

Output the final absolute path.  You should not output an ending /.

You do not need to handle incorrect input.  The commands should work, whether or not the directories passed actually exist on your machine.  You can assume that everything is a directory, even if it has an extension.

Test cases

```<code>Absolute      New          Output
"/a/b/c"      "d"       -> "/a/b/c/d"
"/a/b/c/"     "d"       -> "/a/b/c/d"
"/a/b/c/"     "d/"      -> "/a/b/c/d"
"/a/b/c"      "/d"      -> "/d"
"/a/b/c"      "/d/"     -> "/d"
"/../a/b/c/"  "d"       -> "/a/b/c/d"
"/a/../b/c/"  "d"       -> "/b/c/d"
"/a/b/../c"   "d"       -> "/a/c/d"
"/a/b/c/.."   "d"       -> "/a/b/d"
"/a/b/c/"     ".."      -> "/a/b"
"/a/b/c"      "../d"    -> "/a/b/d"
"/a/b/c"      "/../d"   -> "/d"
"/a/b/c"      ""        -> "/a/b/c"
"/a/b/c"      "."       -> "/a/b/c"
"/a/b/c"      "./d"     -> "/a/b/c/d"
"/a/b/c"      "/./d"    -> "/d"
"/a/b/c"      "d.txt"   -> "/a/b/c/d.txt"
"/a/b/c"      "d."      -> "/a/b/c/d."
"/a/b/c"      ".txt"    -> "/a/b/c/.txt"
"/a/b/c"      ".txt/d"  -> "/a/b/c/.txt/d"
"/a/b/."      "./././." -> "/a/b"
"/direc"      "tory"    -> "/direc/tory"
"/a-_.b/"     "__._-."  -> "/a-_.b/__._-."
"/a/b"        "../.."   -> "/"
"/a/b"        "../../.."-> "/"
"/a"          "../../.."-> "/"
"/"           ""        -> "/"
"/"           "a"       -> "/a"
"/.."         "a"       -> "/a"
"/."          ""        -> "/"
</code>```

This is a code-golf, so make your submissions as short as possible in your favorite language!

Body:
Ruby, 16 bytes

Since apparently using a method from the standard library is allowed:

File.expand_path

See the test suite on repl.it.


答:
Cheddar, <s>31</s> 27 bytes

```<code>->97@"123+65@"91+48@"58+"_"
</code>```

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

```<code>->
  97 @" 123 +
  65 @" 91  +
  48 @" 58  +
  "_"
</code>```

Body:
Cheddar, <s>31</s> 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  +
  "_"


答:
JavaScript (ES6), 62 bytes

```<code>_=>String.fromCharCode(...Array(123).keys()).replace(/\W/g,'')
</code>```

Returns 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz, so only 6 bytes shorter than a function that returns the string literal. Yes, it sucks.

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


Body:
Haskell, 38 bytes

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

Nothing to explain here.


答:
Brachylog, 25 bytes

```<code>"_"w9yrcw"A":"Z"ycL@l:Lcw
</code>```

This prints the following to STDOUT:

```<code>_9876543210abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Explanation

```<code>"_"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
</code>```

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


答:
V, 27 bytes

```<code>i1122ñYpñvHgJ|éidd@"Í×
</code>```

Try it online!

This answer is horribly convoluted. I'll post an explanation later.

Hexdump:

```<code>00000000: 6916 1631 1b31 3232 f159 7001 f176 4867  i..1.122.Yp..vHg
00000010: 4a7c e969 6464 4022 1bcd d7              J|.idd@"...
</code>```

Explanation:

Readable:

```<code>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.
</code>```

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


答:
Ruby, 26 bytes

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

Try it online!

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

Body:
Ruby, 26 bytes

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

Try it online!

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


问:
Sum of Products of Subsets
Given an integer k and a list of integers A of size n, find the product of all subsets in A of size k and sum them together.

For example,

```<code>k = 2
n = 4
A = 1 2 3 4
</code>```

The subsets of size 2 and their products are

```<code>1 2 = 2
1 3 = 3
1 4 = 4
2 3 = 6
2 4 = 8
3 4 = 12
</code>```

which sum together to 35.

Some test cases:

Input

```<code>A = 73 36 86 76 5 25 15 95 27 1
n = 10
k = 4

A = 7 16 56 83 14 97 71 24 65 32 75 61 64 73 94 34 10
n = 17
k = 3
</code>```

Output

```<code>499369377

87409828
</code>```

The input can be in whatever format suits your language best. You can have, for example, the variables A, n, and k set to the input already. The integers in A are not necessarily unique.

Constraints

Functions which solve this question are not allowed, as well as functions which generate subsets. Also, to avoid Θ(n^k) submissions, if a solution is made using a better approach, it will have a -30 character bonus. (-30 is subject to change)

The shortest solution is the winner.

Side Note: It's okay to post solutions which do not follow the rules if it demonstrates the strengths of your language. It just won't be part of the scoring.

For example,

Mathematica (31)

```<code>Times@@#&/@A~Subsets~{k}//Total
</code>```

答:
J, 35 bytes

```<code>[:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]
</code>```

Generates the masks for the powerset of A in binary order, selects the masks for k, and operates on each subset.

Usage

```<code>   f =: [:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]
   2 f 1 2 3 4
35
   4 f 73 36 86 76 5 25 15 95 27 1
499369377
   3 f 7 16 56 83 14 97 71 24 65 32 75 61 64 73 94 34 10
87409828
</code>```

Explanation

```<code>[:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]  Input: k on LHS, A on RHS
                            #        Get the size of A
                    2      ^         Get 2^len(A)
                        i.@          Get the range [0, 1, ..., 2^len(A)-1]
                     #:@             Convert each to binary
        [:     +/"1                  Take the sum of each binary digits
           </.~                      Partition the list of binary digits by their sum
                                     and box each group
       {                             Select the box at index k
     >@                              Unbox it to get the mask for subsets of size k
                                  ]  Get A
                                 #   Copy from A using each mask
                              */@    For each subset, reduce using multiplication
[:+/                                 Reduce the products using addition and return
</code>```

Title: Sum of Products of Subsets

Body:
J, 35 bytes

[:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]

Generates the masks for the powerset of A in binary order, selects the masks for k, and operates on each subset.

Usage

   f =: [:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]
   2 f 1 2 3 4
35
   4 f 73 36 86 76 5 25 15 95 27 1
499369377
   3 f 7 16 56 83 14 97 71 24 65 32 75 61 64 73 94 34 10
87409828

Explanation

[:+/(>@{[:(</.~+/"1)2#:@i.@^#)*/@#]  Input: k on LHS, A on RHS
                            #        Get the size of A
                    2      ^         Get 2^len(A)
                        i.@          Get the range [0, 1, ..., 2^len(A)-1]
                     #:@             Convert each to binary
        [:     +/"1                  Take the sum of each binary digits
           </.~                      Partition the list of binary digits by their sum
                                     and box each group
       {                             Select the box at index k
     >@                              Unbox it to get the mask for subsets of size k
                                  ]  Get A
                                 #   Copy from A using each mask
                              */@    For each subset, reduce using multiplication
[:+/                                 Reduce the products using addition and return


答:
Mathematica 51

The random number generator, r, is reset by setting the global variable, n to 1.

```<code>n = 1; r[c_] := RandomInteger[{1, c}]
</code>```

Code

Not in the running for the shortest code...

```<code>h := (n++; If[n < 4 \[Or] (y = r@n) > 6 Quotient[n, 6], h, y~Mod~6 + 1])
</code>```

Usage

```<code>t = Table[h, {60000}];
n
SortBy[Tally[t], First]
</code>```

60000 rolls of the dice required 60031 calls to h.
Tally shows the breakdown by numbers 1-6.

60031

{{1, 9923}, {2, 9966}, {3, 10016}, {4, 10028}, {5, 10009}, {6, 10058}}

Title: Dice from Changing Random Generator

Body:
Introduction

You are given a random integer generator with the following implementation

The first invocation always returns 1.

The second invocation returns a random integer between 1 and 2.

The third invocation returns a random integer between 1 and 3.

The nth invocation returns a random integer between 1 and n, inclusive.

Based on the above function, write a random dice generator that is perfectly random, returning a value between 1 and 6 (inclusive) with equal probability.

Rules

Your program/function should result in a random integer between 1 and 6, inclusive, in some usable form, i.e., to standard output or as a function return value.

The ascending random number generator above can be defined as a "free" function in your program (i.e., doesn't count toward your character count), or a separate script/program that is executed as needed, assuming the state (n) is persistent between calls.

Assume that no more than 1000 dice rolls will ever be requested in a single use case of your program, and the initial random number generator can be reset to 1 at the end of 1000 dice rolls to avoid overflow of n.

Your program may not use any other source of random numbers except the ascending random generator defined above.  You may of course request multiple random numbers from the random number generator for each single dice roll output.

This is code-golf, so winner is shortest answer or most votes in the event of a tie.  If you can generate 1000 dice rolls using less than 1000 generated random numbers, give yourself a 10-point efficiency bonus.

Example

```<code>./asc-rand
1 # random integer between 1 and 1
./asc-rand
1 # random integer between 1 and 2
./asc-rand
3 # random integer between 1 and 3
./asc-rand
4 # random integer between 1 and 4

# dice-gen generates random dice based on output of asc-rand program.
./dice-gen
3
./dice-gen
6
./dice-gen
5
./dice-gen
1
</code>```

Body:
Mathematica 51

The random number generator, r, is reset by setting the global variable, n to 1.

n = 1; r[c_] := RandomInteger[{1, c}]

Code

Not in the running for the shortest code...

h := (n++; If[n < 4 \[Or] (y = r@n) > 6 Quotient[n, 6], h, y~Mod~6 + 1])

Usage

t = Table[h, {60000}];
n
SortBy[Tally[t], First]

60000 rolls of the dice required 60031 calls to h.
Tally shows the breakdown by numbers 1-6.

60031

{{1, 9923}, {2, 9966}, {3, 10016}, {4, 10028}, {5, 10009}, {6, 10058}}


答:
Dyalog APL, 18 bytes

```<code>∊'\w'⎕S'&'⎕UCS⍳255
</code>```

prints:

```<code>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
</code>```

Body:
Dyalog APL, 18 bytes

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

prints:

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz


答:
MATL, 11 bytes

```<code>7W:'\W'[]YX
</code>```

Try it online!

```<code>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
</code>```

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

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

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:

```<code># Language Name, N bytes
</code>```

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:

```<code># Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code># Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the leaderboard snippet:

```<code># [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

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


答:
SML, <s>70 (lame) bytes, 80 78 71</s> 64 bytes

I did it! The lame solution has been defeated by 6 bytes:

```<code>fun&123="_"| &91= &97| &58= &65| &n=str(chr n)^ &(n+1);print(&48)
</code>```

Try it online!
Better readable:

```<code>fun t 123 = "_"
  | t 91  = t 97
  | t 58  = t 65
  | t n   = str(chr(n)) ^ t (n+1);
print(t 48)
</code>```

Keep reading to see past me whining about not having found this solution yet.

```<code>print"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
</code>```

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:

```<code>print("_"^implode(List.filter Char.isAlphaNum(List.tabulate(123,chr))))
</code>```

Generate Char list, filter, implode (char list -> string), add _, print:

```<code>_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
</code>```

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

```<code>fun&26a=""| &n a=str(chr(n+a))^ &(n+1)a;print(&16 32^ &0 65^ &0 97^"_")
</code>```

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:

```<code>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 ^ "_")
</code>```

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

```<code>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 ^ "_")
</code>```

, would nobody ask here ever.

Because on the one hand this would print

```<code>9876543210ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba_
</code>```

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.

Body:
SML, <s>70 (lame) bytes, 80 78 71</s> 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.


问:
Distinct subsets that sum to a given number
Write a function that gets as an input a sorted array of positive numbers A, and an additional number n. The Task is to print out all distinct subsets of A, that sum to n.

Example:

```<code>Input:
A = [1,2,2,4,4]
n = 9

Output:
[1,2,2,4]
[1,4,4]
</code>```

Bonus:
-50% if your code doesn't store duplicate subset (the same subset but in different order) intern. The function will not store more than one duplicate subset in memory at a time.

Shortest code in bytes wins.

答:
J, 28 bytes

```<code>~.@((=+/@>)#])]<@#~2#:@i.@^#
</code>```

Generates the power set and filters it before removing duplicates.

Usage

Since J does not support ragged arrays, each subset is output within a box.

```<code>   f =: ~.@((=+/@>)#])]<@#~2#:@i.@^#
   9 f 1 2 2 4 4
┌─────┬───────┐
│1 4 4│1 2 2 4│
└─────┴───────┘
</code>```

Explanation

```<code>~.@((=+/@>)#])]<@#~2#:@i.@^#  Input: n on LHS, A on RHS
                           #  Get the size of A
                   2      ^   Get 2^len(A)
                       i.@    Get the range [0, 1, ..., 2^len(A)-1]
                    #:@       Convert each to binary to get the masks for each subset
                 #~           Copy using each mask from A
               <@             Box each subset
      +/@>                    Unbox each and reduce using addition
     =                        Check which sums are equal to n, 1 if true else 0
            ]                 Get the list of boxed subsets
           #                  Copy only those whose sums are equal to n
~.@                           Remove duplicates and return
</code>```

Body:
J, 28 bytes

~.@((=+/@>)#])]<@#~2#:@i.@^#

Generates the power set and filters it before removing duplicates.

Usage

Since J does not support ragged arrays, each subset is output within a box.

   f =: ~.@((=+/@>)#])]<@#~2#:@i.@^#
   9 f 1 2 2 4 4
┌─────┬───────┐
│1 4 4│1 2 2 4│
└─────┴───────┘

Explanation

~.@((=+/@>)#])]<@#~2#:@i.@^#  Input: n on LHS, A on RHS
                           #  Get the size of A
                   2      ^   Get 2^len(A)
                       i.@    Get the range [0, 1, ..., 2^len(A)-1]
                    #:@       Convert each to binary to get the masks for each subset
                 #~           Copy using each mask from A
               <@             Box each subset
      +/@>                    Unbox each and reduce using addition
     =                        Check which sums are equal to n, 1 if true else 0
            ]                 Get the list of boxed subsets
           #                  Copy only those whose sums are equal to n
~.@                           Remove duplicates and return


答:
Python 2, <s>70</s> 66 bytes

```<code>import re
f=lambda x,y,r=re.split:r('\W',x[:y])[-1]+r('\W',x[y:])[0]
</code>```

Splits the string by non-word separators, once on the original string up to the cursor index, then on the string beginning at the cursor index. Returns the last element of the left split plus the first element of the right split.
Thanks to Leaky Nun for saving 4 bytes!

Title: Select the word around the given index in a given string

Body:
In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.

(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)

For example, let | be your cursor in abc de|f ghi.

Then, when you double click, the substring def will be selected.

Input/Output

You will be given two inputs: a string and an integer.

Your task is to return the word-substring of the string around the index specified by the integer.

Your cursor can be right before or right after the character in the string at the index specified.

If you use right before, please specify in your answer.

Specifications (Specs)

The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.

The string will only contain printable ASCII characters (from U+0020 to U+007E).

The word "word" is defined by the regex (?<!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or "alphanumeric characters in ASCII including underscore".

The index can be 1-indexed or 0-indexed.

If you use 0-indexed, please specify it in your answer.

Testcases

The testcases are 1-indexed, and the cursor is right after the index specified.

The cursor position is for demonstration purpose only, which will not be required to be outputted.

```<code>string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd
</code>```

Body:
Python 2, <s>70</s> 66 bytes

import re
f=lambda x,y,r=re.split:r('\W',x[:y])[-1]+r('\W',x[y:])[0]

Splits the string by non-word separators, once on the original string up to the cursor index, then on the string beginning at the cursor index. Returns the last element of the left split plus the first element of the right split.
Thanks to Leaky Nun for saving 4 bytes!


答:
CJam, <s>15</s> <s>14</s> 11 bytes

4 bytes off thanks to @FryAmTheEggman and @Dennis!

```<code>A,'[,_el^'_
</code>```

Try it online!

```<code>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
</code>```

Body:
CJam, <s>15</s> <s>14</s> 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


答:
PowerShell v3+, <s>35</s> 33 bytes

```<code>-join([char[]](1..127)-match'\w')
</code>```

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.

Body:
PowerShell v3+, <s>35</s> 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.


答:
MSM, 79 bytes

```<code>;.;.;.;.;.;.:,,_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
</code>```

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

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


答:
Perl, 20 bytes

Requires -E at no extra cost.

say+a.._,A.._,_..9,_
```

<p>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:</p>

<pre class="lang-pl prettyprint-override"><code>say a..z,A..Z,0..9,_
</code>```

I like @msh210's suggestions in the comments, but they're just a bit too long!

Body:
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!


答:
Python 2, 62 bytes

r=range
print''.join(map(chr,r(97,123)+r(65,91)+r(48,58)))+'_'
```
<p>prints:</p>
```abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
```

This could probably be golfed more but I'm not sure how!

Body:
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!


问:
Ascending matrix
The "ascending matrix" is an infinite matrix of whole numbers (0 included) in which any element is the smallest available element which has not been previously used on the respective row and column:

```<code>  | 1 2 3 4 5 6 ...
--+----------------
1 | 0 1 2 3 4 5 ...
2 | 1 0 3 2 5 4 ...
3 | 2 3 0 1 6 7 ...
4 | 3 2 1 0 7 6 ...
5 | 4 5 6 7 0 1 ...
6 | 5 4 7 6 1 0 ...
. | ...............
</code>```

Your task is to write a program that will output the element found at the row and column specified by the input. (standard input and output)

Test cases:

```<code>5 3 -> 6
2 5 -> 5
</code>```

Code Golf rules apply—the shortest code wins.

P.S. Even if this has an algorithmic nature the code can be very, very concise.

EDIT: I wasn't expecting to see the xor solution so early. I was really hoping to see 10 posts with an algorithmic approach and THEN the xor solution. Now, having in mind that it's not much fun to see how to write xor in different languages I recommend that you also try an algorithmic approach.

So, yes, I think no one can beat the 5 character mark now—therefore I congratulate Ilmari Karonen for the smartest and shortest solution. But there's a new challenge up ahead: write the shortest algorithmic solution.

答:
Python 2, 36

I figure since I'm just starting to learn Python that this would be the perfect time to submit my first answer using it (and no one has answered using Python) and perhaps I could receive some feedback.

Thank you @IlmariKaronen for the very cool shortcut.

Thank you @Gareth for the code below.

import sys
print(input()-1^input()-1)
```

<hr>

<h3>Python 3, 56</h3>

<p>The original program that I had written.</p>

<pre class="lang-python prettyprint-override"><code>import sys
x=int(input())
y=int(input())
x-=1
y-=1
print(x^y)
</code>```

IDEONE with 2 and 5

IDEONE with 3 and 3

Title: Ascending matrix

Body:
Python 2, 36

I figure since I'm just starting to learn Python that this would be the perfect time to submit my first answer using it (and no one has answered using Python) and perhaps I could receive some feedback.

Thank you @IlmariKaronen for the very cool shortcut.

Thank you @Gareth for the code below.

import sys
print(input()-1^input()-1)

Python 3, 56

The original program that I had written.

import sys
x=int(input())
y=int(input())
x-=1
y-=1
print(x^y)

IDEONE with 2 and 5

IDEONE with 3 and 3


答:
Retina, <s>30</s> <s>19</s> <s>16</s> <s>15</s> 12 bytes

I modified my original alphabet attempt for this latest version. Each character is printed in a loop.

The first line is empty.

```<code>
;
+T\`;w`w_</code>```

Try it online

Output:

```<code>_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
</code>```

Thanks to Leaky Nun for golfing 4 bytes off my latest attempt.

Body:
Retina, <s>30</s> <s>19</s> <s>16</s> <s>15</s> 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.


答:
05AB1E, <s>18</s> <s>16</s> 12 bytes

```<code>žyLçá9Ý'_)˜J
</code>```

Explanation

```<code>ž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
</code>```

Try it online

Edit: Saved 4 bytes thank to Adnan

Body:
05AB1E, <s>18</s> <s>16</s> 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


问:
Find the positive divisors!

Definition

A number is positive if it is greater than zero.

A number (A) is the divisor of another number (B) if A can divide B with no remainder.

For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder.

Goal

Your task is to write a program/function that takes a positive number and then find all of its divisors.

Restriction

You may not use any built-in related to prime or factorization.

The complexity of your algorithm must not exceed O(sqrt(n)).

Freedom

The output list may contain duplicates.

The output list does not need to be sorted.

Scoring

This is code-golf. Shortest solution in bytes wins.

Testcases

```<code>input    output
1        1
2        1,2
6        1,2,3,6
9        1,3,9
</code>```

答:
J, 26 bytes

```<code>(],%)1+[:I.0=]|~1+i.@<.@%:
</code>```

Explanation

```<code>(],%)1+[:I.0=]|~1+i.@<.@%:  Input: n
                        %:  Sqrt(n)
                     <.@    Floor(Sqrt(n))
                  i.@       Get the range from 0 to Floor(Sqrt(n)), exclusive
                1+          Add 1 to each
             ]              Get n
              |~            Get the modulo of each in the range by n
           0=               Which values are equal to 0 (divisible by n), 1 if true else 0
       [:I.                 Get the indices of ones
     1+                     Add one to each to get the divisors of n less than sqrt(n)
   %                        Divide n by each divisor
 ]                          Get the divisors
  ,                         Concatenate them and return
</code>```

Title: Find the positive divisors!

Body:
J, 26 bytes

(],%)1+[:I.0=]|~1+i.@<.@%:

Explanation

(],%)1+[:I.0=]|~1+i.@<.@%:  Input: n
                        %:  Sqrt(n)
                     <.@    Floor(Sqrt(n))
                  i.@       Get the range from 0 to Floor(Sqrt(n)), exclusive
                1+          Add 1 to each
             ]              Get n
              |~            Get the modulo of each in the range by n
           0=               Which values are equal to 0 (divisible by n), 1 if true else 0
       [:I.                 Get the indices of ones
     1+                     Add one to each to get the divisors of n less than sqrt(n)
   %                        Divide n by each divisor
 ]                          Get the divisors
  ,                         Concatenate them and return


Body:
J, <s>30</s> <s>29</s> 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


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

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:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](https://esolangs.org/wiki/Fish), 121 bytes
</code>```

/* Configuration */

var QUESTION_ID = 55422; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Rews, 14 CP437 bytes

```<code>ïHello, World!
</code>```

Explanation

```<code>ïHello, World! Insert in the buffer the text "Hello, World!" (the ¿ is not needed at the end of the program)
               Implicit output
</code>```

ContentLicense: CC BY-SA 4.0

Title: "Hello, World!"

Body:
Rews, 14 CP437 bytes

ïHello, World!

Explanation

ïHello, World! Insert in the buffer the text "Hello, World!" (the ¿ is not needed at the end of the program)
               Implicit output


答:
<h1>///, 63 bytes</h1>
```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

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

```<code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
</code>```

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:

```<code># Language Name, N bytes
</code>```

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:

```<code># Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code># Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the leaderboard snippet:

```<code># [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
///, 63 bytes

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_


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

```<code>'{,®\W"Oò
</code>```

Try it online!

Explanation:

```<code>'{,           Array of chars from NUL to 'z
   ®\W"       Regex to match non-word characters
       Oò     Replace all matches with emtpy string
</code>```

Old solution, 10 bytes:

```<code>A,'[,_¬^'_
</code>```

Try it online!

Explanation:

```<code>A,          0-9
'[,_¬^      A-Za-z
'_          _
</code>```

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


答:
C#, 85 bytes

```<code>()=>{var r="_";for(char c='/';c<'z';)r+=char.IsLetterOrDigit(++c)?c+"":"";return r;};
</code>```

C# lambda where the output is a string.

A full string would be 69 bytes...

Code:

```<code>()=>{
    var r="_";
    for(char c='/';c<'z';)
        r+=char.IsLetterOrDigit(++c)?c+"":"";
    return r;
};
</code>```

Try it online!

Body:
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!


答:
Java, 106 bytes

```<code>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;}
</code>```

Returns _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz by abusing for-loops.

Making the above function compilable costs 9 bytes, resulting in a 115-byte program:

```<code>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;}}
</code>```

The equivalent monolithic program which prints _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz is 148 bytes long:

```<code>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);}}
</code>```

Java (lambda expression), 91 bytes

```<code>(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;};
</code>```

This is a java.util.function.BiFunction<Character, String, String>.

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


问:
Forecast the weather
Write the shortest program to forecast the weather for the next 7 days

The input (from stdin) is the weekday and the season

The output (to stdout) is seven lines weekday and the temperature in centigrade

The weekdays begin on the input weekday

The temperatures are random numbers with the range depending on the season

```
Spring 10 - 30 degrees
Summer 20 - 40 degrees
Autumn  5 - 25 degrees  (Fall is a synonym for autumn)
Winter -5 - 15 degrees
```

Sample Input

Thursday Winter

Sample Output

```
Thursday -1
Friday 3
Saturday 8
Sunday 7
Monday 10
Tuesday 10
Wednesday -1
```

Your program must not have identical output every time it is run with the same input

ContentLicense: CC BY-SA 2.5

Title: Forecast the weather

Body:
Mathematica 218

s_~g~d_ :=
Grid@RotateLeft[r = Thread@{DateString[{2012, 1, #}, {"DayName"}] & /@ Range@7,
  RandomInteger[Cases[{{"Spring", {10, 30}}, {"Summer", {20, 40}}, {"Autumn", {5, 25}},
  {"Winter", {-5, 15}}}, {s, _}][[1, 2]], 7]}, Position[r, d][[1, 1]] - 1]

Usage

g["Winter", "Sunday"]


答:
My first attempt at codegolf!

C#, <s>168</s> <s>152</s> <s>150</s> <s>147</s> <s>130</s> <s>127</s> <s>117</s> <s>116</s> <s>115</s> <s>109</s> 106 bytes

```<code>for(var a='0';a<'~';a++){Console.Write(System.Text.RegularExpressions.Regex.IsMatch(a+"","\\w")?a+"":"");}
</code>```

Thanks a lot to aloisdg, AstroDan, Leaky Nun and Kevin Lau - not Kenny for all the help in comments.

Body:
My first attempt at codegolf!

C#, <s>168</s> <s>152</s> <s>150</s> <s>147</s> <s>130</s> <s>127</s> <s>117</s> <s>116</s> <s>115</s> <s>109</s> 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.


答:
Python 3, 58 bytes

```<code>print('_',*filter(str.isalnum,map(chr,range(123))),sep='')
</code>```

A full program that prints to STDOUT.

The output is: _0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

How it works

```<code>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
</code>```

Try it on Ideone

If string constants were allowed, the following would have been 45 bytes:

```<code>from string import*
print('_'+printable[:62])
</code>```

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


答:
Japt, 22 bytes

```<code>0o#{ £YdÃf@Xf"\\\\w"Ãq
</code>```

Try it there.

Body:
Japt, 22 bytes

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

Try it there.


答:
Java 8, <s>86</s> 78 bytes

```<code>(s,p)->{for(String t:s.split("\\W"))if((p-=t.length()+1)<0)return t;return"";}
</code>```

Ungolfed with test cases:

```<code>class Indexer {
    public static String f(String s, int p) {
        for(String t : s.split("\\W"))
            if((p -= t.length()+1) < 0)
                return t;
        return "";
    }

    public static void main(String[] args) {
        System.out.println(f("abc def",2));
        System.out.println(f("abc def",5));
        System.out.println(f("abc abc",2));
        System.out.println(f("ab cd ef",4));
        System.out.println(f("ab   cd",6));
        System.out.println(f("ab!cd",1));
    }
}
</code>```

Splits the string by non-alphanumeric characters, then keeps subtracting the length of each substring, plus 1, from the specified position, until it becomes negative. Since any repeating non-alphanumerics get represented as empty string, the subtraction logic is significantly easier.

This code isn't extensively tested, so I'd like to see if someone can break this. Also, considering that this is Java code, how is this not the longest answer here? :P

Body:
In Windows, when you perform double-click in a text, the word around your cursor in the text will be selected.

(This feature has more complicated properties, but they will not be required to be implemented for this challenge.)

For example, let | be your cursor in abc de|f ghi.

Then, when you double click, the substring def will be selected.

Input/Output

You will be given two inputs: a string and an integer.

Your task is to return the word-substring of the string around the index specified by the integer.

Your cursor can be right before or right after the character in the string at the index specified.

If you use right before, please specify in your answer.

Specifications (Specs)

The index is guaranteed to be inside a word, so no edge cases like abc |def ghi or abc def| ghi.

The string will only contain printable ASCII characters (from U+0020 to U+007E).

The word "word" is defined by the regex (?<!\w)\w+(?!\w), where \w is defined by [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_], or "alphanumeric characters in ASCII including underscore".

The index can be 1-indexed or 0-indexed.

If you use 0-indexed, please specify it in your answer.

Testcases

The testcases are 1-indexed, and the cursor is right after the index specified.

The cursor position is for demonstration purpose only, which will not be required to be outputted.

```<code>string    index     output    cursor position
abc def   2         abc       ab|c def
abc def   5         def       abc d|ef
abc abc   2         abc       ab|c abc
ab cd ef  4         cd        ab c|d ef
ab   cd   6         cd        ab   c|d
ab!cd     1         ab        a|b!cd
</code>```

Body:
Java 8, <s>86</s> 78 bytes

(s,p)->{for(String t:s.split("\\W"))if((p-=t.length()+1)<0)return t;return"";}

Ungolfed with test cases:

class Indexer {
    public static String f(String s, int p) {
        for(String t : s.split("\\W"))
            if((p -= t.length()+1) < 0)
                return t;
        return "";
    }

    public static void main(String[] args) {
        System.out.println(f("abc def",2));
        System.out.println(f("abc def",5));
        System.out.println(f("abc abc",2));
        System.out.println(f("ab cd ef",4));
        System.out.println(f("ab   cd",6));
        System.out.println(f("ab!cd",1));
    }
}

Splits the string by non-alphanumeric characters, then keeps subtracting the length of each substring, plus 1, from the specified position, until it becomes negative. Since any repeating non-alphanumerics get represented as empty string, the subtraction logic is significantly easier.

This code isn't extensively tested, so I'd like to see if someone can break this. Also, considering that this is Java code, how is this not the longest answer here? :P


问:
Is it a leap year?
This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not.

Your input will have no newlines or trailing spaces:

```<code>1954
</code>```

You will output in any way that you like that clearly tells the user if it is or isn't a leap year (I will accept y or n for yes/no)

You can get a list of leap years here: http://kalender-365.de/leap-years.php
I would note that leap years are not ever four years always. 1896 is a leap year, but 1900 is not. The years that follow this "skip" are:

```<code>1900
2100
2200
2300
</code>```

Test cases:

```<code>1936 ->  y
1805 ->  n
1900 ->  n
2272 ->  y
2400 ->  y
</code>```

EDIT: This is based on a standard Gregorian calendar: http://www.epochconverter.com/date-and-time/daynumbers-by-year.php

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

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:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

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:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](https://esolangs.org/wiki/Fish), 121 bytes
</code>```

/* Configuration */

var QUESTION_ID = 50798; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Title: Is it a leap year?

Body:
C, <s>37</s> <s>34</s> 30 bytes

l(y){y=y%(y%25?4:16)?110:121;}

Wandbox