答:
Python 2, 54 bytes

lambda s:[2<len(set(s))<s[::b]==sorted(s)for b in-1,1]
```

<p>Takes input as a list of characters. Outputs:</p>

<pre class="lang-python prettyprint-override"><code>[False, True] for ascending
[True, False] for descending
[False, False] for neither
</code>```

Checks if the sorted input string equals its original or reverse. Does so by slicing with step sizes of 1 and -1. At the same time, we check whether the word has at least 2 distinct letters.

If "exit with error" can be used an output for the neither case, we can go down to 51 bytes:

lambda s:[s,s[::-(len(set(s))>2)]].index(sorted(s))
```

Title: Find the Wavy Words!

Body:
Python 2, 54 bytes

lambda s:[2<len(set(s))<s[::b]==sorted(s)for b in-1,1]

Takes input as a list of characters. Outputs:

[False, True] for ascending
[True, False] for descending
[False, False] for neither

Checks if the sorted input string equals its original or reverse. Does so by slicing with step sizes of 1 and -1. At the same time, we check whether the word has at least 2 distinct letters.

If "exit with error" can be used an output for the neither case, we can go down to 51 bytes:

lambda s:[s,s[::-(len(set(s))>2)]].index(sorted(s))


问:
Encode the alphabet cipher
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15

Pad each number to two characters with 0s. Example: 08 05 12 12 15

Join. Example: 0805121215

Test cases

```<code>helloworld -> 08051212152315181204
codegolf -> 0315040507151206
alphabetcipher -> 0112160801020520030916080518
johncena -> 1015081403051401
</code>```

Remember, this is code-golf, so the code with the fewest number of bytes wins.

答:
PHP, 58 Bytes

```<code>foreach(str_split($argv[1])as$c)printf("%02d",ord($c)%32);
</code>```

ContentLicense: CC BY-SA 4.0

Title: Encode the alphabet cipher

Body:
PHP, 58 Bytes

foreach(str_split($argv[1])as$c)printf("%02d",ord($c)%32);

ContentLicense: CC BY-SA 3.0


答:
PowerShell v2+, 44 bytes

```<code>-join([char[]]$args[0]|%{"{0:D2}"-f($_%32)})
</code>```

Takes input $args[0], casts it as a char-array, feeds into a loop. Each iteration, we take the current character $_ modulo 32, which implicitly casts as the ASCII value. Conveniently ;-), this lines up so a = 1, b = 2, etc. That fed into the -format operator, operating on string "{0:D2}", which specifies a two digit minimum (i.e., it prepends a leading zero if required). Those strings of digits are encapsulated in parens, -joined together into one string, and left on the pipeline. Output via implicit Write-Output happens at program conclusion.

```<code>PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'hello'
0805121215

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'helloworld'
08051212152315181204

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'codegolf'
0315040507151206

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'johncena'
1015081403051401
</code>```

Title: Encode the alphabet cipher

Body:
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15

Pad each number to two characters with 0s. Example: 08 05 12 12 15

Join. Example: 0805121215

Test cases

```<code>helloworld -> 08051212152315181204
codegolf -> 0315040507151206
alphabetcipher -> 0112160801020520030916080518
johncena -> 1015081403051401
</code>```

Remember, this is code-golf, so the code with the fewest number of bytes wins.

Body:
PowerShell v2+, 44 bytes

-join([char[]]$args[0]|%{"{0:D2}"-f($_%32)})

Takes input $args[0], casts it as a char-array, feeds into a loop. Each iteration, we take the current character $_ modulo 32, which implicitly casts as the ASCII value. Conveniently ;-), this lines up so a = 1, b = 2, etc. That fed into the -format operator, operating on string "{0:D2}", which specifies a two digit minimum (i.e., it prepends a leading zero if required). Those strings of digits are encapsulated in parens, -joined together into one string, and left on the pipeline. Output via implicit Write-Output happens at program conclusion.

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'hello'
0805121215

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'helloworld'
08051212152315181204

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'codegolf'
0315040507151206

PS C:\Tools\Scripts\golfing> .\encode-alphabet-cipher.ps1 'johncena'
1015081403051401


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,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:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,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=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();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,})});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(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)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}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
05AB1E, 14 bytes

Shortest proper 05AB1E quine?

```<code>0"D34çý"D34çý
</code>```

With  trailing newline.

Try it online!

Explanation:

```<code>0              # Push '0'
                   # Stack: ['0']
 "D34çý"       # Push 'D34çý'
                   # Stack: ['0', 'D34çý']
        D      # Duplicate
                   # Stack: ['0', 'D34çý', 'D34çý']
         34ç   # Push '"'
                   # Stack: ['0', 'D34çý', 'D34çý', '"']
            ý  # Join rest of the stack with '"'
                   # Stack: ['0"D34çý"D34çý']
               # Implicit print
</code>```

Title: Golf you a quine for great good!

Body:
05AB1E, 14 bytes

Shortest proper 05AB1E quine?

0"D34çý"D34çý

With  trailing newline.

Try it online!

Explanation:

0              # Push '0'
                   # Stack: ['0']
 "D34çý"       # Push 'D34çý'
                   # Stack: ['0', 'D34çý']
        D      # Duplicate
                   # Stack: ['0', 'D34çý', 'D34çý']
         34ç   # Push '"'
                   # Stack: ['0', 'D34çý', 'D34çý', '"']
            ý  # Join rest of the stack with '"'
                   # Stack: ['0"D34çý"D34çý']
               # Implicit print


问:
Next Friday the 13th
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?

Must be an complete functioning program (not just a function/subroutine)

Must print out date in the following format: YYYY-MM-DD

Allow user to provide a start date either as a command line argument or through STDIN

If user provides no start date, use today as the start date.

If the start date is a Friday the 13th, the program should find the next Friday the 13th.

If I were to run the program today (Feb 16 2011) I should get the following output.

```<code>$ ./fr13th 2013-05-09
2013-09-13
$ ./fr13th 2007-06-29
2007-07-13
$ ./fr13th 2007-07-13
2008-06-13
$ ./fr13th
2011-05-13
</code>```

ContentLicense: CC BY-SA 2.5

Title: Next Friday the 13th

Body:
PHP - 103

(brute force)

<?for($d=date_create(@$argv[1]);$d->modify('next fri')&&$d->format(@d)-13;);die($d->format("Y-m-d\n"));

Ungolfed:

<?
$d = new DateTime(@$argv[1]);
while ($d->modify('next fri')) {
        if ($d->format('d') == 13) {
                die($d->format("Y-m-d\n"));
        }
}

Test:

$ php 979.php 2013-05-09
2013-09-13
$ php 979.php 2007-06-29
2007-07-13
$ php 979.php 2007-07-13
2008-06-13
$ php 979.php
2011-05-13


问:
Ghosts and Pumpkins
Here's an ASCII pumpkin carved into a Jack-o-Lantern. Isn't it cute?

```<code>((^v^))
</code>```

Here's an ASCII ghost. Look how spooky it is!

```<code>\{O.O}/
</code>```

Obviously, the pumpkins have to be on the ground, with a space between them so they don't rot.

Ghosts, however, like to stand on top of pumpkins, so they're even spookier. However, they have to stand on two pumpkins, else their ghostly weight will crush the pumpkin beneath them. But, due to how their ghostly magic works, multiple ghosts can stack and share pumpkins, provided that the ghosts are either split evenly on the lower pumpkins or the lower ghosts. In other words, forming a shape like a human pyramid. Note that ghosts can't stack on ghosts unless there's a pumpkin underneath (that's how the magic works).

Given two non-negative integers, g and p, representing the number of ghosts and pumpkins, output the most-compact left-most formation possible, following the above pyramid stacking rules. Leftover pumpkins and ghosts (that is, those not forming the pyramid) go on the ground to the right.

For clarification, these formations are OK (blank newline separated), and serve as example I/O:

```<code>0p 1g
\{O.O}/

1p 0g
((^v^))

1p 1g
((^v^)) \{O.O}/

2p 1g
    \{O.O}/
((^v^)) ((^v^))

2p 2g
    \{O.O}/
((^v^)) ((^v^)) \{O.O}/

3p 1g
    \{O.O}/
((^v^)) ((^v^)) ((^v^))

3p 2g
    \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^))

3p 3g
        \{O.O}/
    \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^))

0p 4g
\{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/

3p 0g
((^v^)) ((^v^)) ((^v^))

7p 6g
            \{O.O}/
        \{O.O}/ \{O.O}/
    \{O.O}/ \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^))
</code>```

These formations are Not OK

```<code>\{O.O}/
((^v^))

    \{O.O}/
((^v^))

((^v^)) ((^v^)) \{O.O}/

    \{O.O}/
    \{O.O}/
((^v^)) ((^v^))

            \{O.O}/
\{O.O}/ ((^v^)) ((^v^))

    ((^v^))
((^v^)) ((^v^))

      \{O.O}/
((^v^)) ((^v^))
</code>```

Input

Two non-negative integers in any convenient format. At least one of the numbers will be non-zero. You can take the inputs in either order (i.e., in the examples I had pumpkins first) -- please specify how you take input in your answer.

Output

An ASCII-art representation of the ghosts and pumpkins, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the ghosts and pumpkins line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Title: Ghosts and Pumpkins

Body:
Perl, 246 bytes (newlines are not part of the code and are provided solely for readability)

($c,$d)=<>=~/(\d+)/g;
$p="((^v^)) ";$g="\\{O.O}/ ";
for($f[0]=$c;$d>0;$d--){$f[$b+1]+1<$f[$b]?$f[++$b]++:$f[$b]++;$f[0]+=$d,$d=0 if$b==$c-1;$f[$b]==1?$b=0:1}
$h[0]=($p x$c).$g x($f[0]-$c);$h[$_].=$"x(4*$_).$g x$f[$_]for(1..$#f);
say join$/,reverse@h;

Accepts two numbers: pumpkins first, followed by ghosts.
Sample input:

5 20

Sample output:

                \{O.O}/
            \{O.O}/ \{O.O}/
        \{O.O}/ \{O.O}/ \{O.O}/
    \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^)) \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/


问:
Generate a modulo rosace

The cool stuff

The following rosace can help calculate numbers modulo 7.

In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each successive digit, follow the arrow and then turn clockwise the number of steps given by that digit.

Here is how you proceed for number 294:

You start at circle 0.

You turn clockwise the number of steps given by the first digit (which is a 2, you end up at 2).

You follow the arrow there (you end up at 6).

You turn clockwise the number of steps given by the second digit (which is a 9, you end up at 1).

You follow the arrow there (you end up at 3).

You turn clockwise the number of steps given by the third number (which is 4, you end up at 0).

294 mod 7 = 0 (meaning 294 is multiple of 7).

(Video explanation if you still didn't get it)

The goal

Figure out how that works (I know but I won't tell you).

Create a program that takes a number n in parameter and that generates a rosace for mod n.

The rosace can be displayed by any means you want (ASCII, generate PNG, generate SVG, ...) as long as it could be used by a 8 years old child (so no list of rules, I want a picture)!

You can use strait lines, even if it's a bit less clear than what I made for the example, but you must show clearly the numbers that point to themselves with some kind of tail-biting arrow.

Test cases

(I only give the links between the numbers, feel free to edit my question once your program sucessfully generates them)

mod 2:

```<code>0 -> 0
1 -> 0
</code>```

mod 3:

```<code>0 -> 0
1 -> 1
2 -> 2
</code>```

mod 4:

```<code>0 -> 0
1 -> 2
2 -> 0
3 -> 2
</code>```

mod 5:

```<code>0 -> 0
1 -> 0
2 -> 0
3 -> 0
4 -> 0
</code>```

mod 6:

```<code>0 -> 0
1 -> 4
2 -> 2
3 -> 0
4 -> 4
5 -> 2
</code>```

mod 7:

```<code>0 -> 0
1 -> 3
2 -> 6
3 -> 2
4 -> 5
5 -> 1
6 -> 4
</code>```

mod 8:

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

mod 9:

```<code>0 -> 0
1 -> 1
2 -> 2
3 -> 3
4 -> 4
5 -> 5
6 -> 6
7 -> 7
8 -> 8
</code>```

mod 10:

```<code>0 -> 0
1 -> 0
2 -> 0
3 -> 0
4 -> 0
5 -> 0
6 -> 0
7 -> 0
8 -> 0
9 -> 0
</code>```

Rules

This is code-golf, shortest code in bytes wins.

As usual, loopholes and cheats are forbidden.

答:
Mathematica, 192 bytes

This type of challenge (nontrivial mathematical computation together with high-level graphics output) is what Mathematica is made for!

```<code>(d=#;r_~t~n_:=r{Sin[#],Cos[#]}&[6.3n/d];m=Mod[10#,d]&;Graphics@{Array[#~Text~t[9,#]&,d,0],Array[Arrow@{t[9,#+1/7],t[9,#+6/7]}&,d],Array[Arrow@BezierCurve@{t[8,#+1/9],{0,0},t[8,m@#-1/9]}&,d]})&
</code>```

Expanded and explained:

```<code>[1] (
[2] d = #; r_~t~n_ := r {Sin[#], Cos[#]} &[6.3 n/d]; m = Mod[10 #, d] &;
[3] Graphics@{
[4]   Array[#~Text~t[9, #] &, d, 0],
[5]   Array[Arrow@{t[9, # + 1/7], t[9, # + 6/7]} &, d],
[6]   Array[Arrow@BezierCurve@{t[8, # + 1/9], {0, 0}, t[8, m@# - 1/9]} &, d]
[7]          }
[8] ) &
</code>```

Lines 1 and 8 delimit an unnamed function of one argument. Lines 3 and 7 delimit several commands that output graphics.

Lines 2 stores the input as d; defines a binary function t giving the coordinates of a point n/d of the way around the circle of radius r, clockwise from the top (in the spirit of this site, I saved a byte by rounding 2π to 6.3!); and defines a unary function m calculating the destination of the arrow starting at its argument.

Line 4 renders the numbers 0 to d–1 equally spaced around the circle of radius 9 (the exact radius unimportant, chosen to maximize aesthetics subject to fitting in one byte).

Line 5 renders the clockwise straight arrows around the circumference of the circle. The 1/7 and 6/7 leave enough space to read the numbers.

Line 6 renders the curved arrows from each number to (10 times the number modulo d). BezierCurve automatically draws a Bézier curve using the given control points. Fortunately, using the origin as a single interior control point produces reasonable output.

Sample output (note that the cases 9, 10, and 11 are trivial in different ways):

d = 7

d = 8

d = 9

d = 10

d = 11

d = 12

d = 13

d = 37

This last input was chosen because 37 divides 10^3–1, and so the interior arrows (not counting the obligatory self-arrow from 0 to 0) form lots of triangular cycles.

Title: Generate a modulo rosace

Body:
Mathematica, 192 bytes

This type of challenge (nontrivial mathematical computation together with high-level graphics output) is what Mathematica is made for!

(d=#;r_~t~n_:=r{Sin[#],Cos[#]}&[6.3n/d];m=Mod[10#,d]&;Graphics@{Array[#~Text~t[9,#]&,d,0],Array[Arrow@{t[9,#+1/7],t[9,#+6/7]}&,d],Array[Arrow@BezierCurve@{t[8,#+1/9],{0,0},t[8,m@#-1/9]}&,d]})&

Expanded and explained:

[1] (
[2] d = #; r_~t~n_ := r {Sin[#], Cos[#]} &[6.3 n/d]; m = Mod[10 #, d] &;
[3] Graphics@{
[4]   Array[#~Text~t[9, #] &, d, 0],
[5]   Array[Arrow@{t[9, # + 1/7], t[9, # + 6/7]} &, d],
[6]   Array[Arrow@BezierCurve@{t[8, # + 1/9], {0, 0}, t[8, m@# - 1/9]} &, d]
[7]          }
[8] ) &

Lines 1 and 8 delimit an unnamed function of one argument. Lines 3 and 7 delimit several commands that output graphics.

Lines 2 stores the input as d; defines a binary function t giving the coordinates of a point n/d of the way around the circle of radius r, clockwise from the top (in the spirit of this site, I saved a byte by rounding 2π to 6.3!); and defines a unary function m calculating the destination of the arrow starting at its argument.

Line 4 renders the numbers 0 to d–1 equally spaced around the circle of radius 9 (the exact radius unimportant, chosen to maximize aesthetics subject to fitting in one byte).

Line 5 renders the clockwise straight arrows around the circumference of the circle. The 1/7 and 6/7 leave enough space to read the numbers.

Line 6 renders the curved arrows from each number to (10 times the number modulo d). BezierCurve automatically draws a Bézier curve using the given control points. Fortunately, using the origin as a single interior control point produces reasonable output.

Sample output (note that the cases 9, 10, and 11 are trivial in different ways):

d = 7

d = 8

d = 9

d = 10

d = 11

d = 12

d = 13

d = 37

This last input was chosen because 37 divides 10^3–1, and so the interior arrows (not counting the obligatory self-arrow from 0 to 0) form lots of triangular cycles.


问:
Traveling Pumpkin Problem

Background:

Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween.  However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because nobody can see him.  In past years, he has only been able to spook a small amount of villages due to his poor decision making, but now that he has you to help him, he will be able to spook as many villages as possible!

Task:

Given a list of village locations and a candle lifespan, output the maximum number of villages Jack can visit.  You do not have to print the path itself.

Input:

The lifespan of the candle and a list of village locations in a Cartesian coordinate system.  The pumpkin patch Jack originates from will always be at 0,0.  You may format the input in anyway you wish.  To simplify Jack's movements, he can only move horizontally, vertically, or diagonally, meaning his candle will either lose 1 or 1.5 (he takes a bit longer diagonally) units of life every move.  The candle burns out when the lifespan is less than or equal to 0.

Output:

An integer equal to the maximum number of villages Jack can visit before the candle burns out.

Rules:

This is code-golf, so shortest code in bytes wins.  Standard loopholes are not allowed.

Test cases:

```<code>// Format [lifespan] [list of village coordinates] -> [maximum visit-able villages]

4 -1,0 1,0 2,0 3,0 4,0 5,0 -> 3
4 1,1 2,2 3,3 -> 2
5 1,1 2,1 3,1 4,1 5,0 5,1 -> 4
</code>```

答:
Python, 175 bytes

```<code>def f(c,l):
 def r(t):p=abs(t[0]-x);q=abs(t[1]-y);return p+q-.5*min(p,q)
 v=0;x,y=0,0
 while c>0 and len(l)>0:
  l.sort(key=r);c-=r(l[0]);x,y=l.pop(0)
  if c>=0:v+=1
 return v
</code>```

c is the lifespan of the candle, l is a list of tuples - village coordinates, v is the number of visited villages, (x,y) is pair of coordinates of the village Jack is currently in.

r(t) is a function which calculates the distance to the current position and is used to sort the list so that the closest becomes l[0]. The formula used is |Δx| + |Δy| - min(|Δx|, |Δy|) / 2.

Try it here!

Title: Traveling Pumpkin Problem

Body:
Python, 175 bytes

def f(c,l):
 def r(t):p=abs(t[0]-x);q=abs(t[1]-y);return p+q-.5*min(p,q)
 v=0;x,y=0,0
 while c>0 and len(l)>0:
  l.sort(key=r);c-=r(l[0]);x,y=l.pop(0)
  if c>=0:v+=1
 return v

c is the lifespan of the candle, l is a list of tuples - village coordinates, v is the number of visited villages, (x,y) is pair of coordinates of the village Jack is currently in.

r(t) is a function which calculates the distance to the current position and is used to sort the list so that the closest becomes l[0]. The formula used is |Δx| + |Δy| - min(|Δx|, |Δy|) / 2.

Try it here!


问:
Print some JSON
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace.  Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas.  The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

```<code>4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings
</code>```

However, the following would be valid:

```<code>{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential
</code>```

Non-programming languages are allowed on this challenge.  You may return a string from a function, or print it out.  This is a code-golf, so answer it with as little code as possible!

答:
JavaScript, 17 bytes

```<code>_=>'{"'+{}+'":0}'
</code>```

outputs

{"[object Object]":0}

passes validator at jslint

This works because {} will implicitly be cast to string with the + concatenation, and calling toString on an object returns "[object Object]".

Title: Print some JSON

Body:
JavaScript, 17 bytes

_=>'{"'+{}+'":0}'

outputs

{"[object Object]":0}

passes validator at jslint

This works because {} will implicitly be cast to string with the + concatenation, and calling toString on an object returns "[object Object]".


答:
Hexagony, 33 bytes

```<code>10}{'a({=!{{\.@29$\,<.-":!\>Oct\%
</code>```

Try it Online!

Mm.. got a few no-ops in the Hexagon so I put today's date in.

Expanded Form with date replaced by no-ops

```<code>   1 0 } {
  ' a ( { =
 ! { { \ . @
. . $ \ , < .
 - " : ! \ >
  . . . \ %
   . . . .
</code>```

Initialise a 10 and move Memory Pointer to somewhere...

$ skips the mirror and , reads a byte. < branches:

If end of string (-1 which is non-positive) it goes to @ and terminates the program.

Otherwise it subtracts 95 (decremented a), and then we print result / 10 (integer division) and result % 10 and loop again.

Title: Encode the alphabet cipher

Body:
Hexagony, 33 bytes

10}{'a({=!{{\.@29$\,<.-":!\>Oct\%

Try it Online!

Mm.. got a few no-ops in the Hexagon so I put today's date in.

Expanded Form with date replaced by no-ops

   1 0 } {
  ' a ( { =
 ! { { \ . @
. . $ \ , < .
 - " : ! \ >
  . . . \ %
   . . . .

Initialise a 10 and move Memory Pointer to somewhere...

$ skips the mirror and , reads a byte. < branches:

If end of string (-1 which is non-positive) it goes to @ and terminates the program.

Otherwise it subtracts 95 (decremented a), and then we print result / 10 (integer division) and result % 10 and loop again.


问:
Encode the column cipher
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

```<code>1 2 3
</code>```

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
MATL, 4 bytes

```<code>e!1e
</code>```

Try it online!

This is about as straightforward as possible. e is a builtin that reshapes a matrix into n rows. So we read in input1 as a string, and shape into a matrix with input2 rows:

```<code>Hl r!
eowl
l,od
</code>```

Then, we transpose it to get this:

```<code>Hel
lo,
 wo
rld
!
</code>```

After that, we just call 1e to reshape it into a single row, and display it as a string.

As you can see in this sample program, the "reshape" function conveniently adds as many zeroes as necessary for the matrix to be a perfect rectangle. When displaying as a string, MATL treats '0's as spaces, so this automatically fills in the necessary number of spaces for no extra work.

Title: Encode the column cipher

Body:
MATL, 4 bytes

e!1e

Try it online!

This is about as straightforward as possible. e is a builtin that reshapes a matrix into n rows. So we read in input1 as a string, and shape into a matrix with input2 rows:

Hl r!
eowl
l,od

Then, we transpose it to get this:

Hel
lo,
 wo
rld
!

After that, we just call 1e to reshape it into a single row, and display it as a string.

As you can see in this sample program, the "reshape" function conveniently adds as many zeroes as necessary for the matrix to be a perfect rectangle. When displaying as a string, MATL treats '0's as spaces, so this automatically fills in the necessary number of spaces for no extra work.


答:
Perl, 87 bytes

```<code>($a,$b)=@ARGV;for$c(1..$a){for(0..(length$a)/$b){$e.=substr($a,$b*$_+$f,1)}$f++;}say$e;
</code>```

Accepts two arguments as parameters and
Usage:

```<code>perl -M5.010 encol.pl "Hello, World!" 3
Hl r!eoWll,od
</code>```

Title: Encode the column cipher

Body:
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

```<code>1 2 3
</code>```

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Perl, 87 bytes

($a,$b)=@ARGV;for$c(1..$a){for(0..(length$a)/$b){$e.=substr($a,$b*$_+$f,1)}$f++;}say$e;

Accepts two arguments as parameters and
Usage:

perl -M5.010 encol.pl "Hello, World!" 3
Hl r!eoWll,od


答:
Jelly, 3 bytes

```<code>sz⁶
</code>```

TryItOnline!

How?

```<code>sz⁶ - Main link: string, columns
s   - split string (a list of characters) into chunks of length column
 z  - transpose the resulting list of lists with filler
  ⁶ - literal ' '
    - implicit print
</code>```

Title: Encode the column cipher

Body:
Jelly, 3 bytes

sz⁶

TryItOnline!

How?

sz⁶ - Main link: string, columns
s   - split string (a list of characters) into chunks of length column
 z  - transpose the resulting list of lists with filler
  ⁶ - literal ' '
    - implicit print


Title: Encode the column cipher

Body:
PHP, 85 Bytes

for(;$i<$x=$argv[2];$i++)for($j=0;$j<strlen($t=$argv[1])/$x;)echo$t[$i+$j++*$x]??" ";

PHP, 90 Bytes

for(;$i<$x=$argv[2];$i++)foreach(array_chunk(str_split($argv[1]),$x)as$a)echo$a[+$i]??" ";


答:
 Ruby, 89 bytes

```<code>->s,i{t="";i.times{|n|s.ljust(i*(s.size*1.0/i).ceil).scan(/#{?.*i}/).each{|j|t<<j[n]}};t}
</code>```

Terrible score, tips appreciated.

Title: Encode the column cipher

Body:
 Ruby, 89 bytes

->s,i{t="";i.times{|n|s.ljust(i*(s.size*1.0/i).ceil).scan(/#{?.*i}/).each{|j|t<<j[n]}};t}

Terrible score, tips appreciated.


答:
Actionscript 3, 27 bytes

trace(JSON.stringify(int));

outputs

{"MAX_VALUE":2147483647,"length":1,"MIN_VALUE":-2147483648,"prototype":{}}

Title: Print some JSON

Body:
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace.  Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas.  The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

```<code>4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings
</code>```

However, the following would be valid:

```<code>{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential
</code>```

Non-programming languages are allowed on this challenge.  You may return a string from a function, or print it out.  This is a code-golf, so answer it with as little code as possible!


答:
Japt, 15 bytes

```<code>U+SpV f'.pV)y q
</code>```

Test it online!

Japt has an "all subsections of length N" built-in, but neither a "all non-overlapping subsections" nor "every Nth char". Suddenly, there is a gaping hole in my life...

Explanation

```<code>U+SpV            // Take U concatenated with V spaces.
      f'.pV)     // Take every substring of 3 chars.
            y    // Transpose the resulting array.
              q  // Join on the empty string.
                 // Implicit: output last expression
</code>```

Title: Encode the column cipher

Body:
Japt, 15 bytes

U+SpV f'.pV)y q

Test it online!

Japt has an "all subsections of length N" built-in, but neither a "all non-overlapping subsections" nor "every Nth char". Suddenly, there is a gaping hole in my life...

Explanation

U+SpV            // Take U concatenated with V spaces.
      f'.pV)     // Take every substring of 3 chars.
            y    // Transpose the resulting array.
              q  // Join on the empty string.
                 // Implicit: output last expression


问:
Chained Binary Operations

Chained Binary Operations

Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations:

To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple values of q and the operations to be performed. For instance, f(T,[[T,0],[T,1]]) would return ContradictionOP(T,T)=F. You would then chain the output of this result into the next operation, which would be LogicalNOR(F,T)=F, where the 2nd p is the previous output of F. The final result being false. A better breakdown of what each operation actually is is described below:

The first part should be rather simplistic in nature, as the operators are arranged in an increasing binary pattern (hint, hint). However, recursing through the additional inputs to chain binary operations is probably the harder part to accomplish.

Examples:

```<code>f(T,[])=T
f(F,[[F,15]])=T
f(T,[[F,15],[T,0],[F,6]])=F
f(T,[[F,15],[F,14],[F,13],[F,12],[F,11]])=F
</code>```

Extrapolated Example:

```<code>f(T,[[F,15],[F,14],[F,13],[F,12],[F,11]])=F
[T,[F,15]]=T*
[T*,[F,14]=T*
[T*,[F,13]=T*
[T*,[F,12]=T*
[T*,[F,11]=F
FALSE.
</code>```

Rules:

You MUST use the order specified for the operations as stated above.

The input format for a can be a 2D array, array of tuples, command line pairwise arguments or any other representation of pairs of boolean/operations. Could even be a single array that you parse pairwise.

You may use 0 for false and 1 for true, it is not acceptable to reverse the two.

The output should be simply a truthy or falsy value.

No loopholes, this is code-golf, standard CG rules apply.

Example Single Iteration Algorithm:

```<code>f={
    p,q,o->
    op=Integer.toBinaryString(o);     // Calculate the binary OP string (15=1111)
    binaryIndex="$p$q"                // Calculate binary combination of p/q (T/F=10)
    i=Integer.parseInt(binaryIndex,2) // Convert to decimal index (T/F=2)
    op.charAt(i)                      // Get the binary char at the calculated index (T/F/15=1).
}
f(1,0,15)                             // "1"
</code>```

答:
CJam (15 bytes)

```<code>{{+)2@2b#/1&}/}
</code>```

Online demo. This is an anonymous block (function) which takes the two values on the stack and leaves the result on the stack.

Dissection

```<code>{         e# Define a block:
  {       e#   For each pair in the array...
    +)2@  e#     Prepend the accumulator, pop the op, push a 2, and rot 3
          e#     Stack is now: op 2 [accum arg]
    2b#   e#     Find 2**(2*accum + arg)
    /1&   e#     Test the corresponding bit of op, setting it as the new accum
  }/
}
</code>```

Title: Chained Binary Operations

Body:
CJam (15 bytes)

{{+)2@2b#/1&}/}

Online demo. This is an anonymous block (function) which takes the two values on the stack and leaves the result on the stack.

Dissection

{         e# Define a block:
  {       e#   For each pair in the array...
    +)2@  e#     Prepend the accumulator, pop the op, push a 2, and rot 3
          e#     Stack is now: op 2 [accum arg]
    2b#   e#     Find 2**(2*accum + arg)
    /1&   e#     Test the corresponding bit of op, setting it as the new accum
  }/
}


Title: Encode the column cipher

Body:
Ruby, <s>78</s> <s>67</s> 65 bytes

->s,k{s.gsub!(/(.)(.{,#{k-=1}})/){$><<$1
$2.ljust k}while s=~/./}

See it on eval.in: https://eval.in/668412

Ungolfed

->s,k{
  s.gsub!(/(.)(.{,#{ k -= 1 }})/) {
    $> << $1
    $2.ljust k
  } while s =~ /./
}


问:
Find the Wavy Words!
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) )

Definition of a Wavy Word:

If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously going toward right or toward left and never changing direction, like in the diagrams below.

A Wavy Word can be:

Raising if each consecutive character is at the right (on the alphabet) of the previous one.

Decreasing if each consecutive character is at the left (on the alphabet) of the previous one.

All the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, or symbols.

If a word has double characters, like "SPOON", you must collapse the doubles to one character: "SPOON" > "SPON" (because if you go from O to O is zero distance).

The Wavy Words will contain at least 3 distinct characters (even after doubles collapsing).

Here there are some examples:

Task:

Write a full program or function that will take a word from standard input and will output if it is a Wavy Word or not, and in positive case, output if it is raising or decreasing. The output can be True/False/Null, 2/1/0, 1/Null/0, -1/0/1, NO/WR/WD, etc, you decide how to represent it.

Test cases:

```<code>WAVY WORDS:
  ADEPT, BEGIN, BILL, BOSS, BOOST, CHIMP,
  KNOW, SPONGE, SPOON, TROLL, WOLF

ADEPT  > YES > RAISING
BEGIN  > YES > RAISING
BILL   > YES > RAISING
BOSS   > YES > RAISING
BOOST  > YES > RAISING
CHIMP  > YES > RAISING
KNOW   > YES > RAISING
SPONGE > YES > DECREASING
SPOON  > YES > DECREASING
TROLL  > YES > DECREASING
WOLF   > YES > DECREASING

NOT WAVY WORDS:
  WATCH, EARTH, NINON, FOO, BAR, WAVE, SELECTION,
  YES, NO, DEFINITION, WATER, WINE, CODE, AAAHHHH, I, MM, ABCA
</code>```

Rules:

Shortest code wins.

Optional Task:

Find, as a list, as many Wavy Words as you can in an English dictionary, and the longest as well. You can take for example as reference the complete list of English words here.

答:
Python 2, <s>53</s> <s>52</s> 50 bytes

Expects input enclosed in quotes, e.g. "watch"

As unnamed lambda:

lambda s:(sum(map(cmp,s[1:],s))+1)/min(len(s)-1,3)
```

Sums the sign of difference between each letters and integer-divides by len-1. If all were 1 (increasing) the sum is len-1 it displays 1, similar for decreasing -1 and for mixed 1,-1 the sum is smaller than len-1 so it displays 0.

-1 byte for changing cmp,s[1:],s[:-1]) to cmp,s[1:],s)+1

Title: Find the Wavy Words!

Body:
Python 2, <s>53</s> <s>52</s> 50 bytes

Expects input enclosed in quotes, e.g. "watch"

As unnamed lambda:

lambda s:(sum(map(cmp,s[1:],s))+1)/min(len(s)-1,3)

Sums the sign of difference between each letters and integer-divides by len-1. If all were 1 (increasing) the sum is len-1 it displays 1, similar for decreasing -1 and for mixed 1,-1 the sum is smaller than len-1 so it displays 0.

-1 byte for changing cmp,s[1:],s[:-1]) to cmp,s[1:],s)+1


答:
JavaScript (ES6), <s>84</s> 81 bytes

```<code>s=>(new Set(t=[...s]).size>2)*(!t.some((c,i)=>c>s[i+1])-!t.some((c,i)=>c<s[i+1]))
</code>```

Assumes the input is all in the same case. Returns 1 for raising wavy, -1 for decreasing wavy, 0 or -0 (both are falsy) for not wavy. Edit: Saved 3 bytes thanks to @RobertHickman.

Title: Find the Wavy Words!

Body:
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) )

Definition of a Wavy Word:

If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously going toward right or toward left and never changing direction, like in the diagrams below.

A Wavy Word can be:

Raising if each consecutive character is at the right (on the alphabet) of the previous one.

Decreasing if each consecutive character is at the left (on the alphabet) of the previous one.

All the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, or symbols.

If a word has double characters, like "SPOON", you must collapse the doubles to one character: "SPOON" > "SPON" (because if you go from O to O is zero distance).

The Wavy Words will contain at least 3 distinct characters (even after doubles collapsing).

Here there are some examples:

Task:

Write a full program or function that will take a word from standard input and will output if it is a Wavy Word or not, and in positive case, output if it is raising or decreasing. The output can be True/False/Null, 2/1/0, 1/Null/0, -1/0/1, NO/WR/WD, etc, you decide how to represent it.

Test cases:

```<code>WAVY WORDS:
  ADEPT, BEGIN, BILL, BOSS, BOOST, CHIMP,
  KNOW, SPONGE, SPOON, TROLL, WOLF

ADEPT  > YES > RAISING
BEGIN  > YES > RAISING
BILL   > YES > RAISING
BOSS   > YES > RAISING
BOOST  > YES > RAISING
CHIMP  > YES > RAISING
KNOW   > YES > RAISING
SPONGE > YES > DECREASING
SPOON  > YES > DECREASING
TROLL  > YES > DECREASING
WOLF   > YES > DECREASING

NOT WAVY WORDS:
  WATCH, EARTH, NINON, FOO, BAR, WAVE, SELECTION,
  YES, NO, DEFINITION, WATER, WINE, CODE, AAAHHHH, I, MM, ABCA
</code>```

Rules:

Shortest code wins.

Optional Task:

Find, as a list, as many Wavy Words as you can in an English dictionary, and the longest as well. You can take for example as reference the complete list of English words here.

Body:
JavaScript (ES6), <s>84</s> 81 bytes

s=>(new Set(t=[...s]).size>2)*(!t.some((c,i)=>c>s[i+1])-!t.some((c,i)=>c<s[i+1]))

Assumes the input is all in the same case. Returns 1 for raising wavy, -1 for decreasing wavy, 0 or -0 (both are falsy) for not wavy. Edit: Saved 3 bytes thanks to @RobertHickman.


答:
JavaScript (ES6), 34 bytes

```<code>a=>a.reduce((l,[r,o])=>o>>l+l+r&1)
</code>```

Accepts true/false but prefers 1/0 format.

Title: Chained Binary Operations

Body:
Chained Binary Operations

Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations:

To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple values of q and the operations to be performed. For instance, f(T,[[T,0],[T,1]]) would return ContradictionOP(T,T)=F. You would then chain the output of this result into the next operation, which would be LogicalNOR(F,T)=F, where the 2nd p is the previous output of F. The final result being false. A better breakdown of what each operation actually is is described below:

The first part should be rather simplistic in nature, as the operators are arranged in an increasing binary pattern (hint, hint). However, recursing through the additional inputs to chain binary operations is probably the harder part to accomplish.

Examples:

```<code>f(T,[])=T
f(F,[[F,15]])=T
f(T,[[F,15],[T,0],[F,6]])=F
f(T,[[F,15],[F,14],[F,13],[F,12],[F,11]])=F
</code>```

Extrapolated Example:

```<code>f(T,[[F,15],[F,14],[F,13],[F,12],[F,11]])=F
[T,[F,15]]=T*
[T*,[F,14]=T*
[T*,[F,13]=T*
[T*,[F,12]=T*
[T*,[F,11]=F
FALSE.
</code>```

Rules:

You MUST use the order specified for the operations as stated above.

The input format for a can be a 2D array, array of tuples, command line pairwise arguments or any other representation of pairs of boolean/operations. Could even be a single array that you parse pairwise.

You may use 0 for false and 1 for true, it is not acceptable to reverse the two.

The output should be simply a truthy or falsy value.

No loopholes, this is code-golf, standard CG rules apply.

Example Single Iteration Algorithm:

```<code>f={
    p,q,o->
    op=Integer.toBinaryString(o);     // Calculate the binary OP string (15=1111)
    binaryIndex="$p$q"                // Calculate binary combination of p/q (T/F=10)
    i=Integer.parseInt(binaryIndex,2) // Convert to decimal index (T/F=2)
    op.charAt(i)                      // Get the binary char at the calculated index (T/F/15=1).
}
f(1,0,15)                             // "1"
</code>```

Body:
JavaScript (ES6), 34 bytes

a=>a.reduce((l,[r,o])=>o>>l+l+r&1)

Accepts true/false but prefers 1/0 format.


问:
The Last Monday
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?

Input

A positive integer in any convenient format representing a year, 10000 > y > 0.

The input can be padded with zeros (e.g., 0025 for year 25) if
required.

Output

A list of the months of that year where the last day of the month is a Monday.

This can be as month names (e.g., January, March, October), or shortnames (Jan, Mar, Oct), or numbers (1, 3, 10), as separate lines or a list or delimited, etc., just so long as it's unambiguous to the reader.

The output format must be consistent:

For all years input (meaning, you can't output month names for some inputs, and month numbers for other inputs)

As well as consistent per output (meaning, you can't output 1 for January in the same output as Jul for July)

Basically, pick one format and stick to it.

Rules

Assume the Gregorian calendar for input/output, even down to y = 1.

Leap years must be properly accounted for (as a reminder: every year divisible by 4, except not years divisible by 100, unless also divisible by 400 -- 1700, 1800, 1900 all weren't leap years, but 2000 was).

You may use any built-ins or other date calculation tools you like.

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

```<code>   1 --> Apr, Dec
 297 --> May
1776 --> Sep
2000 --> Jan, Jul
2016 --> Feb, Oct
3385 --> Jan, Feb, Oct
</code>```

Leaderboard

var QUESTION_ID=97585,OVERRIDE_USER=42963;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;width:290px;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

```

答:
C, <s>175</s> 217 bytes

```<code>#define R return
#define L(i) for(;i-->0;)
u(y,m){R m-1?30+((2773>>m)&1):28+(y%4==0&&y%100||y%400==0);}s(y,m,g){g+=4;L(m)g+=u(y,m),g%=7;L(y)g+=1+u(y,1),g%=7;R g;}w(y,m,r){m=12;L(m)s(y,m,u(y,m))||(r|=1<<(m+1));R r;}
</code>```

Code for to find the last day for febrary taken from K&R2; try http://ideone.com/XtuhGj the function for debug is w

```<code>z(y,m,r){m=12;L(m)s(y,m,13)-4||(r|=1<<(m+1));R r;}

/*
// ritorna il numero dei giorni di anno=y mese=m con mese in 0..11
// m==1 significa febbraio   y%4?0:y%100?1:!(y%400) non funziona
u(y,m){R m-1?30+((2773>>m)&1):28+(y%4==0&&y%100||y%400==0);}

// argomenti anno:y[0..0xFFFFFFF]  mese:m[0..11]  giorno:g[1..u(y,m)]
// ritorna il numero del giorno[0..6]
s(y,m,g)
{g+=4; // correzione per il giorno di partenza anno mese giorno = 0,1,1
 L(m)g+=  u(y,m),g%=7; // m:0..m-1  somma mod 7 i giorni del mese dell'anno y
 L(y)g+=1+u(y,1),g%=7; // y:0..y-1  somma mod 7 gli anni da 0..y-1
                       // g+=1+u(y,1) poiche' (365-28)%7=1 e 1 e' febbraio
 R g;
}

// argomenti anno:y[0..0xFFFFFFF], m=0 r=0
// calcola tutti gli ultimi giorni del mese dell'anno y che cadono di lunedi'
// e mette tali mesi come bit, dal bit 1 al bit 12 [il bit 0 sempre 0] in r
w(y,m,r){m=12;L(m)s(y,m,u(y,m))||(r|=1<<(m+1));R r;}

// argomenti anno:y[0..0xFFFFFFF], m=0 r=0
//ritorna in r il numero dei mesi che ha giorno 13 di venerdi[==4]
// e mette tali mesi come bit, dal bit 1 al bit 12 [il bit 0 sempre 0] in r
z(y,m,r){m=12;L(m)s(y,m,13)-4||(r|=1<<(m+1));R r;}
*/

#define P printf
#define W while
#define M main
#define F for
#define U unsigned
#define N int
#define B break
#define I if
#define J(a,b)  if(a)goto b
#define G goto
#define P printf
#define D double
#define C unsigned char
#define A getchar()
#define O putchar
#define Y malloc
#define Z free
#define S sizeof
#define T struct
#define E else
#define Q static
#define X continue
M()
{N y,m,g,r,arr[]={1,297,1776,2000,2016,3385}, arr1[]={2016,1,1997,1337,123456789};
 C*mese[]={"gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"};
 C*giorno[]={"Lun","Mar","Mer","Gio","Ven","Sab","Dom"};
 P("Inserisci Anno mese giorno>");r=scanf("%d %d %d", &y, &m, &g);
 P("Inseriti> %d %d %d r=%d\n", y, m, g, r);
 I(r!=3||m>12||m<=0||g>u(y,m-1))R 0;
 r=s(y,m-1,g);// 12-> 11 -> 0..10
 P("Risultato=%d giorno=%s\n", r, giorno[r]);
 r=w(y,0,0);P(" r=%d ", r);P("\n");
 F(m=0;m<6;++m)
        {P("N anno=%d -->",arr[m]);
         r=w(arr[m],0,0); // ritorna in r i mesi tramite i suoi bit...
         F(y=1;y<13;++y) I(r&(1<<y))P("%s ",mese[y-1]);
         P("\n");
        }
 F(m=0;m<4;++m)
        {P("N anno=%d -->",arr1[m]);
         r=z(arr1[m],0,0); // ritorna in r i mesi tramite i suoi bit...
         F(y=1;y<13;++y) I(r&(1<<y))P("%s ",mese[y-1]);
         P("\n");
        }

}
</code>```

Title: The Last Monday

Body:
C, <s>175</s> 217 bytes

#define R return
#define L(i) for(;i-->0;)
u(y,m){R m-1?30+((2773>>m)&1):28+(y%4==0&&y%100||y%400==0);}s(y,m,g){g+=4;L(m)g+=u(y,m),g%=7;L(y)g+=1+u(y,1),g%=7;R g;}w(y,m,r){m=12;L(m)s(y,m,u(y,m))||(r|=1<<(m+1));R r;}

Code for to find the last day for febrary taken from K&R2; try http://ideone.com/XtuhGj the function for debug is w

z(y,m,r){m=12;L(m)s(y,m,13)-4||(r|=1<<(m+1));R r;}

/*
// ritorna il numero dei giorni di anno=y mese=m con mese in 0..11
// m==1 significa febbraio   y%4?0:y%100?1:!(y%400) non funziona
u(y,m){R m-1?30+((2773>>m)&1):28+(y%4==0&&y%100||y%400==0);}

// argomenti anno:y[0..0xFFFFFFF]  mese:m[0..11]  giorno:g[1..u(y,m)]
// ritorna il numero del giorno[0..6]
s(y,m,g)
{g+=4; // correzione per il giorno di partenza anno mese giorno = 0,1,1
 L(m)g+=  u(y,m),g%=7; // m:0..m-1  somma mod 7 i giorni del mese dell'anno y
 L(y)g+=1+u(y,1),g%=7; // y:0..y-1  somma mod 7 gli anni da 0..y-1
                       // g+=1+u(y,1) poiche' (365-28)%7=1 e 1 e' febbraio
 R g;
}

// argomenti anno:y[0..0xFFFFFFF], m=0 r=0
// calcola tutti gli ultimi giorni del mese dell'anno y che cadono di lunedi'
// e mette tali mesi come bit, dal bit 1 al bit 12 [il bit 0 sempre 0] in r
w(y,m,r){m=12;L(m)s(y,m,u(y,m))||(r|=1<<(m+1));R r;}

// argomenti anno:y[0..0xFFFFFFF], m=0 r=0
//ritorna in r il numero dei mesi che ha giorno 13 di venerdi[==4]
// e mette tali mesi come bit, dal bit 1 al bit 12 [il bit 0 sempre 0] in r
z(y,m,r){m=12;L(m)s(y,m,13)-4||(r|=1<<(m+1));R r;}
*/

#define P printf
#define W while
#define M main
#define F for
#define U unsigned
#define N int
#define B break
#define I if
#define J(a,b)  if(a)goto b
#define G goto
#define P printf
#define D double
#define C unsigned char
#define A getchar()
#define O putchar
#define Y malloc
#define Z free
#define S sizeof
#define T struct
#define E else
#define Q static
#define X continue
M()
{N y,m,g,r,arr[]={1,297,1776,2000,2016,3385}, arr1[]={2016,1,1997,1337,123456789};
 C*mese[]={"gen","feb","mar","apr","mag","giu","lug","ago","set","ott","nov","dic"};
 C*giorno[]={"Lun","Mar","Mer","Gio","Ven","Sab","Dom"};
 P("Inserisci Anno mese giorno>");r=scanf("%d %d %d", &y, &m, &g);
 P("Inseriti> %d %d %d r=%d\n", y, m, g, r);
 I(r!=3||m>12||m<=0||g>u(y,m-1))R 0;
 r=s(y,m-1,g);// 12-> 11 -> 0..10
 P("Risultato=%d giorno=%s\n", r, giorno[r]);
 r=w(y,0,0);P(" r=%d ", r);P("\n");
 F(m=0;m<6;++m)
        {P("N anno=%d -->",arr[m]);
         r=w(arr[m],0,0); // ritorna in r i mesi tramite i suoi bit...
         F(y=1;y<13;++y) I(r&(1<<y))P("%s ",mese[y-1]);
         P("\n");
        }
 F(m=0;m<4;++m)
        {P("N anno=%d -->",arr1[m]);
         r=z(arr1[m],0,0); // ritorna in r i mesi tramite i suoi bit...
         F(y=1;y<13;++y) I(r&(1<<y))P("%s ",mese[y-1]);
         P("\n");
        }

}


问:
Trick or Treat polyglot
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

This is code-golf,  so the solution with the fewest bytes wins.

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

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=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;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

```

答:
Cubix / Hexagony, 31 bytes

```<code>t;./e;_a]"kcirt">o?@;=v=./r;\;/
</code>```

Trick it out! Treat it online!

Halloween themed? Note the horrifying facts about these languages and the code:

If and even if you do nothing (just put no-ops), you can never get out of the loop that is determined to be running forever...

And being stuck in the middle of a 3D and a 2D programming language (Oh agony...)

Inside the dimensions, you'll gradually lost where you are... where you were...

And there is a =v= smiling at you which acts at no-ops in the code

Let's dig into the mystery of the hidden 31-bytes communication protocol of dimensions and terror...

trick

When the code folds or unfolds itself... That is cubified, the layout looks like this:

```<code>      t ; .
      / e ;
      _ a ]
" k c i r t " > o ? @ ;
= v = . / r ; \ ; / . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .
</code>```

And the main part is this part in the middle:

```<code>" k c i r t " > o ? @ .
. . . . . . . \ ; / . .
</code>```

It pushes k,c,i,r,t onto the stack and o outputs and ; pops within a loop bounded by reflectors and ? which guides you depending on the value on the top of the stack...

treat

All of a sudden, the code transforms from a cube to a Hexagon. (Imagine that)

```<code>   t ; . /
  e ; _ a ]
 " k c i r t
" > o ? @ ; =
 v = . / r ;
  \ ; / . .
   . . . .
</code>```

And the main part is this part:

```<code>   t ; . /
  e ; _ a ]
 . . . . . .
. . . . @ ; =
 . . . / r ;
  . . . . .
   . . . .
</code>```

It runs t; which prints t and hits the mirror and turns its direction to NW starting from the SE corner and hits another mirror.  This runs r; and wraps to e;_a and the ] brings it to the Instruction Pointer 1 which starts at corner NE pointing SE and hits / which reflects horizontally to ; then t.

Then it wraps to =, ;, and @ ends the mess.

So... What is _ doing there?

Why is it inside the t e a (the first 3 letters in the code)?

Here comes the end of the story -

it does nothing.

Does it sound like the end of a horror story?

Title: Trick or Treat polyglot

Body:
Cubix / Hexagony, 31 bytes

t;./e;_a]"kcirt">o?@;=v=./r;\;/

Trick it out! Treat it online!

Halloween themed? Note the horrifying facts about these languages and the code:

If and even if you do nothing (just put no-ops), you can never get out of the loop that is determined to be running forever...

And being stuck in the middle of a 3D and a 2D programming language (Oh agony...)

Inside the dimensions, you'll gradually lost where you are... where you were...

And there is a =v= smiling at you which acts at no-ops in the code

Let's dig into the mystery of the hidden 31-bytes communication protocol of dimensions and terror...

trick

When the code folds or unfolds itself... That is cubified, the layout looks like this:

      t ; .
      / e ;
      _ a ]
" k c i r t " > o ? @ ;
= v = . / r ; \ ; / . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

And the main part is this part in the middle:

" k c i r t " > o ? @ .
. . . . . . . \ ; / . .

It pushes k,c,i,r,t onto the stack and o outputs and ; pops within a loop bounded by reflectors and ? which guides you depending on the value on the top of the stack...

treat

All of a sudden, the code transforms from a cube to a Hexagon. (Imagine that)

   t ; . /
  e ; _ a ]
 " k c i r t
" > o ? @ ; =
 v = . / r ;
  \ ; / . .
   . . . .

And the main part is this part:

   t ; . /
  e ; _ a ]
 . . . . . .
. . . . @ ; =
 . . . / r ;
  . . . . .
   . . . .

It runs t; which prints t and hits the mirror and turns its direction to NW starting from the SE corner and hits another mirror.  This runs r; and wraps to e;_a and the ] brings it to the Instruction Pointer 1 which starts at corner NE pointing SE and hits / which reflects horizontally to ; then t.

Then it wraps to =, ;, and @ ends the mess.

So... What is _ doing there?

Why is it inside the t e a (the first 3 letters in the code)?

Here comes the end of the story -

it does nothing.

Does it sound like the end of a horror story?


答:
Haskell, <s>fortyfour 30</s> 28 bytes

(>>=tail.show.(+4).fromEnum)
```
<p>Using the <code>+4</code> approach from Adnan's answer saves 14 bytes.</p>
<p>Try it on Ideone. Usage:</p>
<pre class="lang-haskell prettyprint-override"><code>> (>>=tail.show.(+4).fromEnum)"codegolf"
"0315040507151206"
</code>```

Two bytes off thanks to xnor. Old version:

f a=['0'|a<'k']++(show$fromEnum a-96)
(f=<<)
```

Title: Encode the alphabet cipher

Body:
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.

To encode with the alphabet cipher (I will be using the example hello):

First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15

Pad each number to two characters with 0s. Example: 08 05 12 12 15

Join. Example: 0805121215

Test cases

```<code>helloworld -> 08051212152315181204
codegolf -> 0315040507151206
alphabetcipher -> 0112160801020520030916080518
johncena -> 1015081403051401
</code>```

Remember, this is code-golf, so the code with the fewest number of bytes wins.

Body:
Haskell, <s>fortyfour 30</s> 28 bytes

(>>=tail.show.(+4).fromEnum)

Using the +4 approach from Adnan's answer saves 14 bytes.

Try it on Ideone. Usage:

> (>>=tail.show.(+4).fromEnum)"codegolf"
"0315040507151206"

Two bytes off thanks to xnor. Old version:

f a=['0'|a<'k']++(show$fromEnum a-96)
(f=<<)


答:
JavaScript (ES7), <s>166</s> <s>164</s> 159 bytes

Saved 5 bytes thanks to Neil

f=(p,g,j=(g*2)**.5+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''
```

<h3>Formatted and commented</h3>

<pre class="lang-js prettyprint-override"><code>f = (                                    // given:
  p,                                     // - p = number of pumpkins
  g,                                     // - g = number of ghosts
  j = (g * 2) ** .5 + .5 | 0,            // - j = ceil(triangular root of g)
  G = j > p - 1 ? p ? p - 1 : 0 : j,     // - G = max(0, min(p - 1, j))
  P = '\n',                              // - P = padding string (+ line-break)
  i = ~j ?                               // - i =
    g - G * ++G / 2                      //   first iteration: g - G * (G + 1) / 2
  : G,                                   //   next iterations: G
  n = i > 0 ? i > g ? g : i : 0          // - n = max(0, min(i, g)) = number of
) =>                                     //   ghosts to print at this iteration
p | g ?                                  // if there's still something to print:
  f(                                     //   do a recursive call with:
    0,                                   //   - no pumpkin anymore
    g - n,                               //   - the updated number of ghosts
    -1,                                  //   - j = -1 (so that ~j == 0)
    G - 1,                               //   - one less ghost on the pyramid row
    P + '    '                           //   - updated padding string
  ) +                                    //
  P +                                    //   append padding string
  '((^v^)) '.repeat(p) +                 //   append pumpkins
  '\\{O.O}/ '.repeat(n)                  //   append ghosts
: ''                                     // else: stop
</code>```

Underlying math

The tricky part is to find out the optimal width G of the ghost pyramid.

The number of ghosts g in such a pyramid is given by:

```<code>g = 1 + 2 + 3 + ... + G = G(G + 1) / 2
</code>```

Reciprocally, the width of a pyramid containing g ghosts is the real root of the resulting quadratic equation:

```<code>G² + G - 2g = 0

Δ = 1² - 4(-2g)
Δ = 8g + 1

G = (-1 ± √Δ) / 2
</code>```

Which leads to the following real root (also known as the triangular root):

```<code>G = (√(8g + 1) - 1) / 2
</code>```

However, the width of the pyramid is also limited by the number of pumpkins: we can have no more than p-1 ghosts over p pumpkins. Hence the final formula used in the code:

```<code>j = ⌈(√(8g + 1) - 1) / 2⌉
G = max(0, min(p - 1, j))
</code>```

ES6 version, <s>173</s> <s>171</s> 166 bytes

f=(p,g,j=Math.pow(g*2,.5)+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''
```

<h3>Test cases (ES6)</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=(p,g,j=Math.pow(g*2,.5)+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''

console.log(f(0, 1));
console.log(f(1, 0));
console.log(f(1, 1));
console.log(f(2, 1));
console.log(f(2, 2));
console.log(f(3, 1));
console.log(f(3, 2));
console.log(f(3, 3));
console.log(f(0, 4));
console.log(f(3, 0));
console.log(f(7, 6));</code>```

Title: Ghosts and Pumpkins

Body:
Here's an ASCII pumpkin carved into a Jack-o-Lantern. Isn't it cute?

```<code>((^v^))
</code>```

Here's an ASCII ghost. Look how spooky it is!

```<code>\{O.O}/
</code>```

Obviously, the pumpkins have to be on the ground, with a space between them so they don't rot.

Ghosts, however, like to stand on top of pumpkins, so they're even spookier. However, they have to stand on two pumpkins, else their ghostly weight will crush the pumpkin beneath them. But, due to how their ghostly magic works, multiple ghosts can stack and share pumpkins, provided that the ghosts are either split evenly on the lower pumpkins or the lower ghosts. In other words, forming a shape like a human pyramid. Note that ghosts can't stack on ghosts unless there's a pumpkin underneath (that's how the magic works).

Given two non-negative integers, g and p, representing the number of ghosts and pumpkins, output the most-compact left-most formation possible, following the above pyramid stacking rules. Leftover pumpkins and ghosts (that is, those not forming the pyramid) go on the ground to the right.

For clarification, these formations are OK (blank newline separated), and serve as example I/O:

```<code>0p 1g
\{O.O}/

1p 0g
((^v^))

1p 1g
((^v^)) \{O.O}/

2p 1g
    \{O.O}/
((^v^)) ((^v^))

2p 2g
    \{O.O}/
((^v^)) ((^v^)) \{O.O}/

3p 1g
    \{O.O}/
((^v^)) ((^v^)) ((^v^))

3p 2g
    \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^))

3p 3g
        \{O.O}/
    \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^))

0p 4g
\{O.O}/ \{O.O}/ \{O.O}/ \{O.O}/

3p 0g
((^v^)) ((^v^)) ((^v^))

7p 6g
            \{O.O}/
        \{O.O}/ \{O.O}/
    \{O.O}/ \{O.O}/ \{O.O}/
((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^)) ((^v^))
</code>```

These formations are Not OK

```<code>\{O.O}/
((^v^))

    \{O.O}/
((^v^))

((^v^)) ((^v^)) \{O.O}/

    \{O.O}/
    \{O.O}/
((^v^)) ((^v^))

            \{O.O}/
\{O.O}/ ((^v^)) ((^v^))

    ((^v^))
((^v^)) ((^v^))

      \{O.O}/
((^v^)) ((^v^))
</code>```

Input

Two non-negative integers in any convenient format. At least one of the numbers will be non-zero. You can take the inputs in either order (i.e., in the examples I had pumpkins first) -- please specify how you take input in your answer.

Output

An ASCII-art representation of the ghosts and pumpkins, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the ghosts and pumpkins line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Body:
JavaScript (ES7), <s>166</s> <s>164</s> 159 bytes

Saved 5 bytes thanks to Neil

f=(p,g,j=(g*2)**.5+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''

Formatted and commented

f = (                                    // given:
  p,                                     // - p = number of pumpkins
  g,                                     // - g = number of ghosts
  j = (g * 2) ** .5 + .5 | 0,            // - j = ceil(triangular root of g)
  G = j > p - 1 ? p ? p - 1 : 0 : j,     // - G = max(0, min(p - 1, j))
  P = '\n',                              // - P = padding string (+ line-break)
  i = ~j ?                               // - i =
    g - G * ++G / 2                      //   first iteration: g - G * (G + 1) / 2
  : G,                                   //   next iterations: G
  n = i > 0 ? i > g ? g : i : 0          // - n = max(0, min(i, g)) = number of
) =>                                     //   ghosts to print at this iteration
p | g ?                                  // if there's still something to print:
  f(                                     //   do a recursive call with:
    0,                                   //   - no pumpkin anymore
    g - n,                               //   - the updated number of ghosts
    -1,                                  //   - j = -1 (so that ~j == 0)
    G - 1,                               //   - one less ghost on the pyramid row
    P + '    '                           //   - updated padding string
  ) +                                    //
  P +                                    //   append padding string
  '((^v^)) '.repeat(p) +                 //   append pumpkins
  '\\{O.O}/ '.repeat(n)                  //   append ghosts
: ''                                     // else: stop

Underlying math

The tricky part is to find out the optimal width G of the ghost pyramid.

The number of ghosts g in such a pyramid is given by:

g = 1 + 2 + 3 + ... + G = G(G + 1) / 2

Reciprocally, the width of a pyramid containing g ghosts is the real root of the resulting quadratic equation:

G² + G - 2g = 0

Δ = 1² - 4(-2g)
Δ = 8g + 1

G = (-1 ± √Δ) / 2

Which leads to the following real root (also known as the triangular root):

G = (√(8g + 1) - 1) / 2

However, the width of the pyramid is also limited by the number of pumpkins: we can have no more than p-1 ghosts over p pumpkins. Hence the final formula used in the code:

j = ⌈(√(8g + 1) - 1) / 2⌉
G = max(0, min(p - 1, j))

ES6 version, <s>173</s> <s>171</s> 166 bytes

f=(p,g,j=Math.pow(g*2,.5)+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''

Test cases (ES6)

f=(p,g,j=Math.pow(g*2,.5)+.5|0,G=j>p-1?p?p-1:0:j,P=`
`,i=~j?g-G*++G/2:G,n=i>0?i>g?g:i:0)=>p|g?f(0,g-n,-1,G-1,P+'    ')+P+'((^v^)) '.repeat(p)+'\\{O.O}/ '.repeat(n):''

console.log(f(0, 1));
console.log(f(1, 0));
console.log(f(1, 1));
console.log(f(2, 1));
console.log(f(2, 2));
console.log(f(3, 1));
console.log(f(3, 2));
console.log(f(3, 3));
console.log(f(0, 4));
console.log(f(3, 0));
console.log(f(7, 6));


问:
Alphabet Pattern Matching
We've had a lot of alphabet challenges.  For this challenge, you are passed the output of an alphabet challenge, and you need to output the pattern scaled to size N.

For example, if N=5 and you were passed the L-phabet:

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ
</code>```

You would need to output:

```<code>ABCDE
BBCDE
CCCDE
DDDDE
EEEEE
</code>```

For the purposes of explanation, I'll be using only ABCD, instead of the full alphabet.  You need to be able to match the L-phabet (above), as well as the following patterns:

The single line:

```<code>ABCD    or     A
               B
               C
               D
</code>```

The single line repeated N times

```<code>ABCD    or    AAAA
ABCD          BBBB
ABCD          CCCC
ABCD          DDDD
</code>```

The Tabula Recta:

```<code>ABCD
BCDA
CDAB
DABC
</code>```

This alphabet triangle:

```<code>A      or   AAAAAAA
AB           BBBBB
ABC           CCC
ABCD           D
ABC
AB
A
</code>```

We also have half triangles in lots of varieties:

```<code>A           AAAA      A        ABCD
BB          BBB       AB       ABC
CCC         CC        ABC      AB
DDDD        D         ABCD     A
</code>```

Finally, the square:

```<code>AAAAAAA
ABBBBBA
ABCCCBA
ABCDCBA
ABCCCBA
ABBBBBA
AAAAAAA
</code>```

All of the above patterns are of size 4.  However, you will be passed a pattern of size 26, as well as an N between 1 and 26, and you need to scale the pattern.  You do not need to handle any other patterns.

The output for 1 will always be the single character A

The output for 26 will always be the same, full-sized pattern passed in.

Trailing spaces are allowed at the end of each line, as well as a trailing newline at the end

You can find all patterns of size 26 here

This is a code-golf, so do it in as few bytes as possible!

Title: Alphabet Pattern Matching

Body:
PHP, 502 Bytes

<?$c=count($x=explode("\n",$_GET[p]));for($t=$u=$o="",$f="substr",$n=0;$n<$g=$_GET["n"];$n++){if(2651==$l=strlen($s))$o.=$f($x[$n],0,$g).$f($x[$n],1-$g)."\n";elseif($l==1026)echo($t=$f($x[$n],0,$g)).$f(strrev($t),1)."\n";elseif($f($s,-1)=="Y")echo$f($x[$n],0,$g-$n).$f($x[$n],-$n,$n)."\n";elseif($l==376&&$f($s,-2,1)=="\n")echo$f($x[$n],0,$g-$n)."\n";elseif($l==726){$t.=$x[$n]."\n";$n+1==$g?:$u=$x[$n]."\n".$u;}else echo$f($x[$n]??"",0,$g)."\n";}if($o)echo$o.substr(strrev($o),2*$g+1);if($t)echo$t.$u;

Works with the string length of a pattern. A pattern has these conditions.
Letter at begin an end. CR are removed.

Expanded

foreach($p as$s){ # all patterns in an array
    $c=count($x=explode("\n",$s));
    for($t=$u=$o="",$f="substr",$n=0;$n<$g=$_GET["n"];$n++){
    if(2651==$l=strlen($s))$o.=$f($x[$n],0,$g).$f($x[$n],1-$g)."\n";
# square pattern
    elseif($l==1026)echo($t=$f($x[$n],0,$g)).$f(strrev($t),1)."\n";
#alphabet triangle up down
    elseif($f($s,-1)=="Y")echo$f($x[$n],0,$g-$n).$f($x[$n],-$n,$n)."\n";
# Tabula recta
    elseif($l==376&&$f($s,-2,1)=="\n")echo$f($x[$n],0,$g-$n)."\n";
# two half triangle
    elseif($l==726){$t.=$x[$n]."\n";$n+1==$g?:$u=$x[$n]."\n".$u;}
#alphabet triangle left right
    else echo$f($x[$n]??"",0,$g)."\n";
# all other
    }
    if($o)echo$o.substr(strrev($o),2*$g+1);
    if($t)echo$t.$u;
}


答:
Ruby, 54 bytes

```<code>->w{c=w.chars.uniq;c==(s=c.sort)?2:(c==s.reverse)?1:0}
</code>```

Returns 0 if the word is not wavy, 1 if backwards wavy, and 2 if forwards wavy.

Title: Find the Wavy Words!

Body:
Ruby, 54 bytes

->w{c=w.chars.uniq;c==(s=c.sort)?2:(c==s.reverse)?1:0}

Returns 0 if the word is not wavy, 1 if backwards wavy, and 2 if forwards wavy.


问:
Where's the 0xBEEF?
This challenge was inspired by this Wendy's commercial from 1984.

Illustration by T S Rogers

Your task is to find a hexadecimal 0xBEEF on a binary bun.

The 'beef' consists of the following pattern:

```<code>1 0 1 1  (0xB)
1 1 1 0  (0xE)
1 1 1 0  (0xE)
1 1 1 1  (0xF)
</code>```

And the 'bun' consists of a 12x12 binary matrix, such as:

```<code>1 1 1 0 0 1 1 1 1 1 1 0
1 1 0 1 0 0 1 0 0 0 0 0
0 1 0 0 0 1 1 1 1 1 0 1
1 0 0 1 0 0 1 0 0 1 0 0
1 0 0 1 0 1 1 0 0 1 1 1
1 1 1 1 1 1 0 0 0 0 1 0
1 1 0 1 1 1 0 0 0 0 0 1
1 0 0 1 1 1 1 0 0 0 0 1
1 0 0 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 0 1 1 1 1 1
1 0 0 0 0 1 0 1 0 1 1 1
1 1 0 0 1 1 0 0 0 0 1 1
</code>```

Input

Your program or function will take the binary matrix as input. The matrix format is very flexible, but it must be clearly described in your answer.

For instance:

a single binary string, with or without separators between the rows:

"111001111110 110100100000..."

or:

"111001111110110100100000..."

an array of binary strings:

["111001111110", "110100100000", ...]

an array of numbers (each number describing a row once converted back to binary and left-padded with zeros):

[3710, 3360, ...]

Output

The coordinates (X, Y) of the 'beef', (0, 0) being the top left corner of the bun.

Alternatively, you may use 1-based coordinates (but not a mix of both formats, like 0-based for X and 1-based for Y).

For the above example, the expected answer is (3, 4) (0-based) or (4, 5) (1-based):

```<code>   00 01 02 03 04 05 06 07 08 09 10 11
00  1  1  1  0  0  1  1  1  1  1  1  0
01  1  1  0  1  0  0  1  0  0  0  0  0
02  0  1  0  0  0  1  1  1  1  1  0  1
03  1  0  0  1  0  0  1  0  0  1  0  0
04  1  0  0 [1  0  1  1] 0  0  1  1  1
05  1  1  1 [1  1  1  0] 0  0  0  1  0
06  1  1  0 [1  1  1  0] 0  0  0  0  1
07  1  0  0 [1  1  1  1] 0  0  0  0  1
08  1  0  0  1  1  1  0  1  1  1  1  1
09  1  1  1  1  1  0  0  1  1  1  1  1
10  1  0  0  0  0  1  0  1  0  1  1  1
11  1  1  0  0  1  1  0  0  0  0  1  1
</code>```

Again, any reasonable format would work as long as it is specified in your answer. Please also mention if you're using 0-based or 1-based coordinates.

Rules

You can safely assume that there is always exactly one 'beef' on the bun. Your code is not required to support cases with more than one beef or no beef at all.

The beef pattern will always appear as described. It will never be rotated or mirrored in any way.

This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Test cases

In the following test cases, each row of the matrix is expressed as its decimal representation.

```<code>Input : [ 3710, 3360, 1149, 2340, 2407, 4034, 3521, 2529, 2527, 3999, 2135, 3267 ]
Output: [ 3, 4 ]

Input : [ 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 ]
Output: [ 3, 7 ]

Input : [ 2796, 206, 148, 763, 429, 1274, 2170, 2495, 42, 1646, 363, 1145 ]
Output: [ 6, 4 ]

Input : [ 3486, 3502, 1882, 1886, 2003, 1442, 2383, 2808, 1416, 1923, 2613, 519 ]
Output: [ 1, 1 ]

Input : [ 3661, 2382, 2208, 1583, 1865, 3969, 2864, 3074, 475, 2382, 1838, 127 ]
Output: [ 8, 8 ]

Input : [ 361, 1275, 3304, 2878, 3733, 3833, 3971, 3405, 2886, 448, 3101, 22 ]
Output: [ 0, 3 ]

Input : [ 3674, 2852, 1571, 3582, 1402, 3331, 1741, 2678, 2076, 2685, 734, 261 ]
Output: [ 7, 7 ]
</code>```

答:
F# - 260 bytes

Full program, including the required EntryPoint designator (so count fewer if you wish I suppose).

Input: each row as separate string:
"111001111110" "110100100000" "010001111101" "100100100100" "100101100111" "111111000010" "110111000001" "100111100001" "100111011111" "111110011111" "100001010111" "110011000011"

Code:

```<code>[<EntryPoint>]
let main a=
 let rec f r:int=
  let b=a.[r].IndexOf"1011"
  if(b>0)then if(a.[r+1].[b..b+3].Equals"1110"&&a.[r+2].[b..b+3].Equals"1110"&&a.[r+3].[b..b+3].Equals"1111")then r else f(r+1)
  else f(r+1)
 printfn"%d%d"(a.[f 0].IndexOf"1011")(f 0);0
</code>```

Not the most elegant solution most likely, but i wanted to keep with strings, so this is how i did it. I almost got it to be a single line and smaller using pipes, but there is something with the double if block that was getting me that i couldn't resolve. So oh well!

I thought too about porting Karl's answer into F# as it's a good one, and may still do that for fun as another approach, but wanted to stick with this one to be different.

Title: Where's the 0xBEEF?

Body:
F# - 260 bytes

Full program, including the required EntryPoint designator (so count fewer if you wish I suppose).

Input: each row as separate string:
"111001111110" "110100100000" "010001111101" "100100100100" "100101100111" "111111000010" "110111000001" "100111100001" "100111011111" "111110011111" "100001010111" "110011000011"

Code:

[<EntryPoint>]
let main a=
 let rec f r:int=
  let b=a.[r].IndexOf"1011"
  if(b>0)then if(a.[r+1].[b..b+3].Equals"1110"&&a.[r+2].[b..b+3].Equals"1110"&&a.[r+3].[b..b+3].Equals"1111")then r else f(r+1)
  else f(r+1)
 printfn"%d%d"(a.[f 0].IndexOf"1011")(f 0);0

Not the most elegant solution most likely, but i wanted to keep with strings, so this is how i did it. I almost got it to be a single line and smaller using pipes, but there is something with the double if block that was getting me that i couldn't resolve. So oh well!

I thought too about porting Karl's answer into F# as it's a good one, and may still do that for fun as another approach, but wanted to stick with this one to be different.


答:
C#, 39 bytes

```<code>string j(){return"{\""+1.0/0+"\":42}";}
</code>```

In C#, division of 0 with a double (hence the inclusion of .0), will result in Infinity.

Output:

{"Infinity":42}

Title: Print some JSON

Body:
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace.  Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas.  The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

```<code>4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings
</code>```

However, the following would be valid:

```<code>{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential
</code>```

Non-programming languages are allowed on this challenge.  You may return a string from a function, or print it out.  This is a code-golf, so answer it with as little code as possible!

Body:
C#, 39 bytes

string j(){return"{\""+1.0/0+"\":42}";}

In C#, division of 0 with a double (hence the inclusion of .0), will result in Infinity.

Output:

{"Infinity":42}


问:
FOIL Python's strong typing!
Your task is to write some code in Python 2 or 3 such that this expression:

```<code>(a+b)(c+d) == a*c + b*c + a*d + b*d
</code>```

will evaluate to True without raising any exceptions.

To clarify, I will copy your code into a file, then from the file import *. Then I will type the expression into the console and verify that it is True.

This is code-golf, so the answer with the shortest length (in bytes) wins.

答:
54 bytes

class m(int):__call__=__add__=lambda*x:m()
a=b=c=d=m()
```

<p>Make an object that inherits from <code>int</code>, except adding or calling just returns a copy of itself.</p>

<p>Same length:</p>

<pre class="lang-python prettyprint-override"><code>class m(int):__call__=__add__=lambda a,b:a
a=b=c=d=m()
</code>```

I thought min or {}.get would work in place of lambda a,b:a, but for some reason they act only on the second argument.

Title: FOIL Python's strong typing!

Body:
54 bytes

class m(int):__call__=__add__=lambda*x:m()
a=b=c=d=m()

Make an object that inherits from int, except adding or calling just returns a copy of itself.

Same length:

class m(int):__call__=__add__=lambda a,b:a
a=b=c=d=m()

I thought min or {}.get would work in place of lambda a,b:a, but for some reason they act only on the second argument.


答:
Perl, 61 bytes

54 bytes of codes and -F -pi flags.

for$l(1..$^I){$\.=$F[$^I*$_+~-$l]//$"for 0..$#F/$^I}}{
```
<p>Takes the input string without final newline, and the key should be placed after <code>-i</code> flag :</p>
```$ echo -n "Hello, World!" | perl -F -pi3 -E 'for$l(1..$^I){$\.=$F[$^I*$_+~-$l]//$"for 0..$#F/$^I}}{'
Hl r!eoWl l,od
```

Title: Encode the column cipher

Body:
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

```<code>1 2 3
</code>```

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Perl, 61 bytes

54 bytes of codes and -F -pi flags.

for$l(1..$^I){$\.=$F[$^I*$_+~-$l]//$"for 0..$#F/$^I}}{

Takes the input string without final newline, and the key should be placed after -i flag :

$ echo -n "Hello, World!" | perl -F -pi3 -E 'for$l(1..$^I){$\.=$F[$^I*$_+~-$l]//$"for 0..$#F/$^I}}{'
Hl r!eoWl l,od


答:
<s>81</s> 66 bytes

class e:__mul__=lambda*o:0;__add__=lambda*o:lambda x:0
a=b=c=d=e()
```

Title: FOIL Python's strong typing!

Body:
Your task is to write some code in Python 2 or 3 such that this expression:

```<code>(a+b)(c+d) == a*c + b*c + a*d + b*d
</code>```

will evaluate to True without raising any exceptions.

To clarify, I will copy your code into a file, then from the file import *. Then I will type the expression into the console and verify that it is True.

This is code-golf, so the answer with the shortest length (in bytes) wins.


答:
Pyth, 40 bytes

```<code>=Zw=+Z*d+Q-*Q/lZQlZV*QlZIq%%NlZQ/NlZp@ZN
</code>```

Test it here

Probably the ugliest Pyth code ever, but this is my first attempt at Pyth.

```<code>=Zw=+Z*d+Q-*Q/lZQlZV*QlZIq%%NlZQ/NlZp@ZN
         Q                               Set Q to eval(input())
=Zw                                      Initialises Z to next input string
              lZ                         Gets the length of Z
             /lZQ                        Integer divides lZ by Q
           *Q/lZQ                        Multiplies that result by Q
          -*Q/lZQlZ                      Subtracts the length of Z from that
        +Q-*Q/lZQlZ                      Adds Q to that
                                         (This is how many spaces to pad)
      *d+Q-*Q/lZQlZ                      Gets that many spaces (d is set to ' ')
   =+Z*d+Q-*Q/lZQlZ                      Appends that to Z
                    *QlZ                 Multiplies Q by lZ
                   V*QlZ                 Does a for loop for integers in that range, on N
                           %NlZ          Gets N modulo lZ
                          %%NlZQ         Gets that modulo Q
                                         This is the column of the letter at index N mod Q
                                /NlZ     Gets the column that is being printed
                        Iq%%NlZQ/NlZ     If they are equal...
                                    p@ZN Print the index of N into Z without a newline
                                         (This is implicitly modulo the length of Z)
</code>```

If anyone has tips to improve my golfing, please leave a comment!

Title: Encode the column cipher

Body:
Pyth, 40 bytes

=Zw=+Z*d+Q-*Q/lZQlZV*QlZIq%%NlZQ/NlZp@ZN

Test it here

Probably the ugliest Pyth code ever, but this is my first attempt at Pyth.

=Zw=+Z*d+Q-*Q/lZQlZV*QlZIq%%NlZQ/NlZp@ZN
         Q                               Set Q to eval(input())
=Zw                                      Initialises Z to next input string
              lZ                         Gets the length of Z
             /lZQ                        Integer divides lZ by Q
           *Q/lZQ                        Multiplies that result by Q
          -*Q/lZQlZ                      Subtracts the length of Z from that
        +Q-*Q/lZQlZ                      Adds Q to that
                                         (This is how many spaces to pad)
      *d+Q-*Q/lZQlZ                      Gets that many spaces (d is set to ' ')
   =+Z*d+Q-*Q/lZQlZ                      Appends that to Z
                    *QlZ                 Multiplies Q by lZ
                   V*QlZ                 Does a for loop for integers in that range, on N
                           %NlZ          Gets N modulo lZ
                          %%NlZQ         Gets that modulo Q
                                         This is the column of the letter at index N mod Q
                                /NlZ     Gets the column that is being printed
                        Iq%%NlZQ/NlZ     If they are equal...
                                    p@ZN Print the index of N into Z without a newline
                                         (This is implicitly modulo the length of Z)

If anyone has tips to improve my golfing, please leave a comment!


答:
54 52 50 49 48 45 39 bytes

Removed 4 bytes thanks to Dennis.

The latest version is inspired by the "some reason" in xnor's answer.

```<code>class t(int):__add__=type
a=b=t()
c=d=0
</code>```

Title: FOIL Python's strong typing!

Body:
54 52 50 49 48 45 39 bytes

Removed 4 bytes thanks to Dennis.

The latest version is inspired by the "some reason" in xnor's answer.

class t(int):__add__=type
a=b=t()
c=d=0


答:
Pyth - 5 bytes

```<code>s.tcF
</code>```

Try it online here.

Title: Encode the column cipher

Body:
Pyth - 5 bytes

s.tcF

Try it online here.