问:
Print the alphabet four times
The program must print the alphabet four times: first in the normal alphabetical order, second in the order of a qwerty keyboard, third in the order of a dvorak keyboard, and lastly in reverse alphabetical order. The output should resemble this:

```<code>abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
pyfgcrlaoeuidhtnsqjkxbmwvz
zyxwvutsrqponmlkjihgfedcba
</code>```

The output is not case-sensitive, and you can add or omit newlines or spaces wherever you wish.

The catch: the program must be less than 104 characters, or, in other words, smaller than the length of the alphabet times four.

I will accept the answer with the shortest code, unless I see something really clever or interesting that I am more impressed with.

EDIT: I will accept the shortest answer on Wednesday, 4/27/2011.

EDIT2: And the winner is (as usual) Golfscript in 64 chars! Second place, which is behind by only three chars, is also in Golfscript, with 67 chars, followed by Bash in third place with 72 chars.

But there were a few others I wanted to mention, such as this one, which, depending on your definition, only used 52 "characters", and this one where he wrote it in a language he created.

There were a few people who broke an unwritten rule and did not qualify, but I will mention them just for their way of thinking without the box.

答:
RProgN, 62 Bytes Noncompeting

```<code>a S . "qwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvz" a
</code>```

I'm a bit disappointed RProgN didn't exist at the time of this question. It could have won something!

Try it Online!

Title: Print the alphabet four times

Body:
RProgN, 62 Bytes Noncompeting

a S . "qwertyuiopasdfghjklzxcvbnmpyfgcrlaoeuidhtnsqjkxbmwvz" a

I'm a bit disappointed RProgN didn't exist at the time of this question. It could have won something!

Try it Online!


问:
What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '
' + c.body.replace(OVERRIDE_REG, '') + '
'; }); var match = body.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

答:
NTFJ, 111111111111111111111111111111 (30 ones)

Code:

```<code>#(#~~~#@::::::)$::::*****(~#^
</code>```

Explanation

One the first run through we push six 49s (ASCII value for one) to set up for the loop this only runs the first time because # is used to enter the loop.  On all subsequent runs the # is skipped and thus the loop is skipped as well.

After that as well as with all future runs we pop a value $ which for the first run is a 49 but for all subsequent runs is the zero used to skip the loop.  We then duplicate the TOS four times and output five times decreasing the total by one.  If the TOS is zero (i.e. not 49) we end the program otherwise we jump back to the first instruction immediately skipping to back to four duplications.

This outputs 30 ones and has a length of 29.

Additional solution

I thought since Conor O'Brien forgot about the : operator I'd do a solution without it to be fair to him.

```<code>#(##################~)~##~~~#@*~~##~~~~@*~~##~~~~@*$(~#^
</code>```

This prints

```<code>100100100100100100100100100100100100100100100100100100100
</code>```

I was going to make an explanation for this but I forgot how it works.

ContentLicense: CC BY-SA 3.0

Body:
NTFJ, 111111111111111111111111111111 (30 ones)

Code:

#(#~~~#@::::::)$::::*****(~#^

Explanation

One the first run through we push six 49s (ASCII value for one) to set up for the loop this only runs the first time because # is used to enter the loop.  On all subsequent runs the # is skipped and thus the loop is skipped as well.

After that as well as with all future runs we pop a value $ which for the first run is a 49 but for all subsequent runs is the zero used to skip the loop.  We then duplicate the TOS four times and output five times decreasing the total by one.  If the TOS is zero (i.e. not 49) we end the program otherwise we jump back to the first instruction immediately skipping to back to four duplications.

This outputs 30 ones and has a length of 29.

Additional solution

I thought since Conor O'Brien forgot about the : operator I'd do a solution without it to be fair to him.

#(##################~)~##~~~#@*~~##~~~~@*~~##~~~~@*$(~#^

This prints

100100100100100100100100100100100100100100100100100100100

I was going to make an explanation for this but I forgot how it works.


问:
Find the super palindromes!

Consider the number 99999999. That number is obviously a palindrome.  The largest prime factor of 99999999 is 137. If you divide 99999999 by 137, you get 729927. This number is also a palindrome.

The largest prime factor of 729927 is 101. 729927/101=7227 which again is a palindrome.

The largest prime factor of 7227 is 73. 7227/73=99 which again is a palindrome.

By further dividing by the largest prime factor, you get 9, 3 and finally 1, which, being one-digit numbers, are also palindromes. Since 1 has no prime factors, the procedure ends here.

Now generalizing this observation, I define a super-palindrome as a palindrome which is either 1, or which gives another super-palindrome if divided by its largest prime factor.

Credits: https://math.stackexchange.com/questions/200835/are-there-infinitely-many-super-palindromes

Given a number N, determine if it is a super palindrome or not, and print a truthy or falsey value accordingly.

Your program should print a truthy value for these inputs:

```<code>1
101
121
282
313
353
373
393
474
737
919
959
1331
1441
2882
6446
7887
8668
9559
9779
</code>```

Your program should print a falsey value for these inputs:

```<code>323
432
555
583
585
646
642
696
777
969
989
2112
3553
4554
5242
5225
5445
8080
8118
9988
</code>```

Remember, this is code-golf, so the code with the shortest amount of bytes wins.

Title: Find the super palindromes!

Body:
J, 30 bytes

0:`(%1>.{:@q:)@.((-:|.)@":)^:_

Error for falsey, 1 for truthy.

Initial attempt, does not error for falsey, 40 bytes:

0:`(([:$:]%{:@q:)`[@.(1&=))@.((-:|.)@":)

Explanation

0:`(%1>.{:@q:)@.((-:|.)@":)^:_
                           ^:_  repeat until convergent
              @.((-:|.)@":)     if the number is palindromic:
   (         )                   do the stuff inside, which is a 4-train
        {:@q:                    largest prime factor
     1>.                         (or 1, if smaller than 1)
    %                            divide the original number by this value
0:`                             otherwise, return 0
                                (because of ^:_, this will be passed into q:, which will
                                error because 0 cannot be factored.)

Test cases

   NB. collect errors; 0 if errored, otherwise the result of the function
   NB. left arg: values; right arg: boxed name of function
   errors =: 4 : 0
    f =. y`:6
    l =: ''
    for_e. x do.
        try.
            l =. l , f e
        catch.
            l =. l , 0
        end.
    end.
    l
)
   s =: 0:`(%1>.{:@q:)@.((-:|.)@":)^:_
   t =: 1 101 121 282 313 353 373 393 474 737 919 959 1331 1441 2882 6446 7887 8668 9559 9779
   f =: 323 432 555 583 585 646 642 696 777 969 989 2112 3553 4554 5242 5225 5445 8080 8118 9988
   t ,. f
   1  323
 101  432
 121  555
 282  583
 313  585
 353  646
 373  642
 393  696
 474  777
 737  969
 919  989
 959 2112
1331 3553
1441 4554
2882 5242
6446 5225
7887 5445
8668 8080
9559 8118
9779 9988
   (t ,. f) errors"1 0 <'s'
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0


Title: Calculate the permanent as quickly as possible

Body:
The challenge is to write the fastest code possible for computing the permanent of a matrix.

The permanent of an n-by-n matrix A = (ai,j) is defined as

Here S_n represents the set of all permutations of [1, n].

As an example (from the wiki):

In this question matrices are all square and will only have the values -1 and 1 in them.

Examples

Input:

```<code>[[ 1 -1 -1  1]
 [-1 -1 -1  1]
 [-1  1 -1  1]
 [ 1 -1 -1  1]]
</code>```

Permanent:

```<code>-4
</code>```

Input:

```<code>[[-1 -1 -1 -1]
 [-1  1 -1 -1]
 [ 1 -1 -1 -1]
 [ 1 -1  1 -1]]
</code>```

Permanent:

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

Input:

```<code>[[ 1 -1  1 -1 -1 -1 -1 -1]
 [-1 -1  1  1 -1  1  1 -1]
 [ 1 -1 -1 -1 -1  1  1  1]
 [-1 -1 -1  1 -1  1  1  1]
 [ 1 -1 -1  1  1  1  1 -1]
 [-1  1 -1  1 -1  1  1 -1]
 [ 1 -1  1 -1  1 -1  1 -1]
 [-1 -1  1 -1  1  1  1  1]]
</code>```

Permanent:

```<code>192
</code>```

Input:

```<code>[[1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1],
 [1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1],
 [-1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1],
 [-1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1],
 [-1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1],
 [1, -1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1],
 [1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1],
 [1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1],
 [1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1],
 [-1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1],
 [-1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1],
 [1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
 [-1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1],
 [1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1],
 [1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1],
 [1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1],
 [-1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1],
 [1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, 1],
 [1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, -1, -1, 1],
 [-1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1]]
</code>```

Permanent:

```<code>1021509632
</code>```

The task

You should write code that, given an n by n matrix, outputs its permanent.

As I will need to test your code it would be helpful if you could give a simple way for me to give a matrix as input to your code, for example by reading from standard in.

Be warned that the permanent can be large (the all 1s matrix is the extreme case).

Scores and ties

I will test your code on random +-1 matrices of increasing size and stop the first time your code takes more than 1 minute on my computer.  The scoring matrices will be consistent for all submissions in order to ensure fairness.

If two people get the same score then the winner is the one which is fastest for that value of n. If those are within 1 second of each other then it is the one posted first.

Languages and libraries

You can use any available language and libraries you like but no pre-existing function to compute the permanent. Where feasible, it would be good to be able to run your code so please include a full explanation for how to run/compile your code in Linux if at all possible.`

Reference implementations

There is already a codegolf question question with lots of code in different languages for computing the permanent for small matrices. Mathematica and Maple also both have permanent implementations if you can access those.

My Machine The timings will be run on my 64-bit machine. This is a standard ubuntu install with 8GB RAM, AMD FX-8350 Eight-Core Processor and Radeon HD 4250.  This also means I need to be able to run your code.

Low level information about my machine

cat /proc/cpuinfo/|grep flags gives

flags     : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
  pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt
  pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid
  aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt
  aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a
  misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 tce
  nodeid_msr tbm topoext perfctr_core perfctr_nb cpb hw_pstate vmmcall
  bmi1 arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid
  decodeassists pausefilter pfthreshold

I will ask a closely related follow up multi-language question that doesn't suffer from the big Int problem so lovers of Scala, Nim, Julia, Rust, Bash can show off their languages too.

Leader board

n = 33 (45 seconds. 64 seconds for n = 34). Ton Hospel in C++ with g++ 5.4.0.

n = 32 (32 seconds). Dennis in C with gcc 5.4.0 using Ton Hospel's gcc flags.

n = 31 (54 seconds). Christian Sievers in Haskell

n = 31 (60 seconds). primo in rpython

n = 30 (26 seconds). ezrast in Rust

n = 28 (49 seconds). xnor with Python + pypy 5.4.1

n = 22 (25 seconds). Shebang with Python + pypy 5.4.1

Note. In practice the timings for Dennis and Ton Hospel's vary a lot for mysterious reasons. For example they seem to be faster after I have loaded a web browser! The timings quoted are the fastest in all the tests I have done.

Body:
Racket 84 bytes

Following simple function works for smaller matrices but hangs on my machine for larger matrices:

(for/sum((p(permutations(range(length l)))))(for/product((k l)(c p))(list-ref k c)))

Ungolfed:

(define (f ll)
  (for/sum ((p (permutations (range (length ll)))))
    (for/product ((l ll)(c p))
      (list-ref l c))))

The code can easily be modified for unequal number of rows and columns.

Testing:

(f '[[ 1 -1 -1  1]
     [-1 -1 -1  1]
     [-1  1 -1  1]
     [ 1 -1 -1  1]])

(f '[[ 1 -1  1 -1 -1 -1 -1 -1]
 [-1 -1  1  1 -1  1  1 -1]
 [ 1 -1 -1 -1 -1  1  1  1]
 [-1 -1 -1  1 -1  1  1  1]
 [ 1 -1 -1  1  1  1  1 -1]
 [-1  1 -1  1 -1  1  1 -1]
 [ 1 -1  1 -1  1 -1  1 -1]
 [-1 -1  1 -1  1  1  1  1]])

Output:

-4
192

As I mentioned above, it hangs on testing following:

(f '[[1 -1 1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 1 1 -1 1 1 -1]
 [1 -1 1 1 1 1 1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 -1]
 [-1 -1 1 1 1 -1 -1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1]
 [-1 -1 -1 1 1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 1 -1]
 [-1 1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 1 1 1 1 1]
 [1 -1 1 1 -1 -1 1 -1 1 1 1 1 -1 1 1 -1 1 -1 -1 -1]
 [1 -1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1 -1 -1 1 1 1 -1]
 [1 -1 -1 1 -1 1 1 -1 1 1 1 -1 1 -1 1 1 1 -1 1 1]
 [1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1]
 [-1 -1 1 -1 1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 1 1]
 [-1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1]
 [1 1 -1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 1 1 1 1 1]
 [-1 1 1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 1 -1 1]
 [1 1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 1 -1 1 1 -1 1 -1 1]
 [1 1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 1 1 1 -1 1 1]
 [1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1]
 [-1 1 1 1 -1 1 1 -1 -1 1 1 1 -1 -1 1 1 -1 -1 1 1]
 [1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 -1 1 1 -1 1 -1 1]
 [1 1 1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 1]
 [-1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1]])


问:
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>```

答:
Python 2, <s>98</s> <s>95</s> 92 bytes

lambda x:'%x'%(`[''.join('%x'%int(s[i:i+4],2)for s in x)for i in range(9)]`.find('beef')+15)
```

Input is a list of strings, output is the string XY (1-based indices).

Test it on Ideone.

ContentLicense: CC BY-SA 4.0

Title: Where's the 0xBEEF?

Body:
Python 2, <s>98</s> <s>95</s> 92 bytes

lambda x:'%x'%(`[''.join('%x'%int(s[i:i+4],2)for s in x)for i in range(9)]`.find('beef')+15)

Input is a list of strings, output is the string XY (1-based indices).

Test it on Ideone.


答:
Jelly, score 100

```<code>³
</code>```

Prints 100 when counting as 2 bytes in UTF-8.

Try it Online!

Title: What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

Body:
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '
' + c.body.replace(OVERRIDE_REG, '') + '
'; }); var match = body.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

Body:
Jelly, score 100

³

Prints 100 when counting as 2 bytes in UTF-8.

Try it Online!


答:
Slip, 28 bytes

27 bytes of code, +1 for p option.

```<code>(?|1011)(\(?|1110)){2}\1111
</code>```

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

```<code>(?|1011)                     Match 1011; reset pointer to beginning of match
        (         ){2}       Do the following twice:
         \                     Slip (moves pointer down one row)
          (?|1110)             Match 1110; reset pointer to beginning of match
                      \1111  Slip and match 1111
</code>```

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.

Title: Where's the 0xBEEF?

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

Body:
Slip, 28 bytes

27 bytes of code, +1 for p option.

(?|1011)(\(?|1110)){2}\1111

Requires input as a multiline rectangle of 1's and 0's without spaces. Try it here (with third testcase as input).

Explanation

Slip is a language from the 2-D Pattern Matching challenge. Sp3000 could say a lot more about it than I can, but basically it's an extended form of regex with some directional commands that let you match in two dimensions. The above code uses the eponymous "slip" command \, which doesn't change the match pointer's direction but moves it sideways by one character. It also uses "stationary group" (?|...), which matches something and then resets the pointer to its previous location.

The code breaks down as follows:

(?|1011)                     Match 1011; reset pointer to beginning of match
        (         ){2}       Do the following twice:
         \                     Slip (moves pointer down one row)
          (?|1110)             Match 1110; reset pointer to beginning of match
                      \1111  Slip and match 1111

This matches the 0xBEEF square. The p option outputs the coordinates of the match, 0-indexed.


答:
Java 7,182 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}
```

<h1>Ungolfed</h1>

<pre class="lang-java prettyprint-override"><code>class Beef {

    public static void main(String[] args) {
        int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
        System.out.println(x >> 4);
        System.out.println(x & 15);
    }

    static int f(int[] a) {
        int x = 9,
            y,
            z = 0;

        for (; x-- > 0; ) {
            for (y = 0; y < 9; a[y++] /= 2)
                if ((a[y] & 15) == 11
                  & (a[y + 1] & 15) == 14
                  & (a[y + 2] & 15) == 14
                  & (a[y + 3] & 15) == 15)
                    z = (x << 4) + y;

            a[y] /= 2;
            a[10] /= 2;
            a[11] /= 2;
        }
        return z;
    }

}
</code>```

Title: Where's the 0xBEEF?

Body:
Java 7,182 177 bytes

I ported Karl Napf C answer to JAVA And Thanks to Karl Napf for saving 5 bytes by reminding me Bit magic.(Btw i came up with this idea too but @KarlNapf return part idea was yours not mine).Sorry if i displeased you.

(0-based)

int f(int[]a){int x=9,y,z=0;for(;x-->0;){for(y=0;y<9;a[y++]/=2) if((a[y]&15)==11&(a[y+1]&15)==14&(a[y+2]&15)==14&(a[y+3]&15)==15)z=(x<<4)+y;a[y]/=2;a[10]/=2;a[11]/=2;}return z;}

Ungolfed

class Beef {

    public static void main(String[] args) {
        int x = f(new int[] { 1222, 3107, 1508, 3997, 1906, 379, 2874, 2926, 1480, 1487, 3565, 633 });
        System.out.println(x >> 4);
        System.out.println(x & 15);
    }

    static int f(int[] a) {
        int x = 9,
            y,
            z = 0;

        for (; x-- > 0; ) {
            for (y = 0; y < 9; a[y++] /= 2)
                if ((a[y] & 15) == 11
                  & (a[y + 1] & 15) == 14
                  & (a[y + 2] & 15) == 14
                  & (a[y + 3] & 15) == 15)
                    z = (x << 4) + y;

            a[y] /= 2;
            a[10] /= 2;
            a[11] /= 2;
        }
        return z;
    }

}


问:
Output the Hebrew alphabet
Your task is to print this exact text:

```<code>אבגדהוזחטיכךלמםנןסעפףצץקרשת
</code>```

(You are allowed to print a trailing newline)

SHA256 hash of the UTF-8 encoding of the text:

```<code>0ab6f1e0bf216a0db52a4a5a247f95cba6f51496de7a24dfd01f3985dfcf6085
</code>```

Base64 encoding:

```<code>15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeq
</code>```

Rules

You can't use a builtin outputting this text.

Standard loopholes are disallowed.

This is code-golf, so the shortest answer wins.

Good luck!

答:
C#6+, <s>76</s> <s>86</s> 82 bytes

```<code>void f()=>Console.Write("אבגדהוזחטיכךלמםנןסעפףצץקרשת");
</code>```

First attempt at Golfing. Am I doing this right?

EDIT: +6 bytes for forgetting to enclose in a function. Thanks @Kevin

C#5 and below version, <s>86</s> 82 bytes

```<code>void f(){Console.Write("אבגדהוזחטיכךלמםנןסעפףצץקרשת");}
</code>```

Title: Output the Hebrew alphabet

Body:
C#6+, <s>76</s> <s>86</s> 82 bytes

void f()=>Console.Write("אבגדהוזחטיכךלמםנןסעפףצץקרשת");

First attempt at Golfing. Am I doing this right?

EDIT: +6 bytes for forgetting to enclose in a function. Thanks @Kevin

C#5 and below version, <s>86</s> 82 bytes

void f(){Console.Write("אבגדהוזחטיכךלמםנןסעפףצץקרשת");}


问:
N(e(s(t))) a string
To "function nest" a string, you must:

Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was Hello, then the first step would be:

```<code>H(ello)
</code>```

Then, repeat this same step for every substring. So we get:

```<code>H(ello)
H(e(llo))
H(e(l(lo)))
H(e(l(l(o))))
</code>```

Your task is to write a program or function that "function nests" a string. For example, if the input string was Hello world!, then you should output:

```<code>H(e(l(l(o( (w(o(r(l(d(!)))))))))))
</code>```

The input will only ever contain printable ASCII, and you may take the input and the output in any reasonable format. For example, STDIN/STDOUT, function arguments and return value, reading and writing to a file, etc.

For simplicity's sake, you may also assume the input will not contain parentheses, and will not be empty.

```<code>Input:
Nest a string
Output:
N(e(s(t( (a( (s(t(r(i(n(g))))))))))))

Input:
foobar
Output:
f(o(o(b(a(r)))))

Input:
1234567890
Output:
1(2(3(4(5(6(7(8(9(0)))))))))

Input:
code-golf
Output:
c(o(d(e(-(g(o(l(f))))))))

Input:
a
Output:
a

Input:
42
Output:
4(2)
</code>```

As usual, all of our default rules and loopholes apply, and the shortest answer scored in bytes wins!

答:
Actually, 10 bytes

```<code>lD')*ß'(j+
</code>```

Try it online!

Explanation:

```<code>lD')*ß'(j+
lD')*       ")"*(len(input)-1)
     ß'(j   insert a "(" between every pair of characters in the input
         +  append the closing parens
</code>```

Title: N(e(s(t))) a string

Body:
Actually, 10 bytes

lD')*ß'(j+

Try it online!

Explanation:

lD')*ß'(j+
lD')*       ")"*(len(input)-1)
     ß'(j   insert a "(" between every pair of characters in the input
         +  append the closing parens


答:
아희(Aheui), 309 bytes (100 chars * 3 bytes + 9 newlines)

```<code>방빩반룸있쁏멐솔쌀잌
앟놂숙참뿔썁썸뻙솝셜
본서번분번뮴딸냥별쀼
슉눇번낢퉅쑫썬쌀본묳
뽇서본석첫삭뽑롷떵춤
분촐럶사눙읽숟뗘분뻨
듐삭빶쏘윙잉썩손뵬괆
쌰뭉쇼텰궮변번첳웅텩
뽇흶아희쾯볻훼윺엄솝
코드골프욉쁍숙쌉삼쏩
</code>```

I'm so happy that I actually finished it!

I'm new to this language, so any tip on improving byte count is welcome.

Try it here! (copy and paste the code)

Cleaner version

```<code>방빠반루ㅇ쀼머솔쌀이
아노숙차뿌썁썸뻐솝셜
본서번분번뮤따냐별쀼
슉누번나투쑫썬쌀본묘
뽀서본석처삭뽀로떠추
분초러사누이숟뗘분뻐
듀삭빠쏘ㅇ이썩손뵬ㅇ
쌰뭉쇼텨이변번처우텨
뽀희ㅇㅇㅇ볻ㅇ유어솝
ㅇㅇㅇㅇㅇㅇ숙쌉삼쏩
</code>```

Title: Find the super palindromes!

Body:
Consider the number 99999999. That number is obviously a palindrome.  The largest prime factor of 99999999 is 137. If you divide 99999999 by 137, you get 729927. This number is also a palindrome.

The largest prime factor of 729927 is 101. 729927/101=7227 which again is a palindrome.

The largest prime factor of 7227 is 73. 7227/73=99 which again is a palindrome.

By further dividing by the largest prime factor, you get 9, 3 and finally 1, which, being one-digit numbers, are also palindromes. Since 1 has no prime factors, the procedure ends here.

Now generalizing this observation, I define a super-palindrome as a palindrome which is either 1, or which gives another super-palindrome if divided by its largest prime factor.

Credits: https://math.stackexchange.com/questions/200835/are-there-infinitely-many-super-palindromes

Given a number N, determine if it is a super palindrome or not, and print a truthy or falsey value accordingly.

Your program should print a truthy value for these inputs:

```<code>1
101
121
282
313
353
373
393
474
737
919
959
1331
1441
2882
6446
7887
8668
9559
9779
</code>```

Your program should print a falsey value for these inputs:

```<code>323
432
555
583
585
646
642
696
777
969
989
2112
3553
4554
5242
5225
5445
8080
8118
9988
</code>```

Remember, this is code-golf, so the code with the shortest amount of bytes wins.

Body:
아희(Aheui), 309 bytes (100 chars * 3 bytes + 9 newlines)

방빩반룸있쁏멐솔쌀잌
앟놂숙참뿔썁썸뻙솝셜
본서번분번뮴딸냥별쀼
슉눇번낢퉅쑫썬쌀본묳
뽇서본석첫삭뽑롷떵춤
분촐럶사눙읽숟뗘분뻨
듐삭빶쏘윙잉썩손뵬괆
쌰뭉쇼텰궮변번첳웅텩
뽇흶아희쾯볻훼윺엄솝
코드골프욉쁍숙쌉삼쏩

I'm so happy that I actually finished it!

I'm new to this language, so any tip on improving byte count is welcome.

Try it here! (copy and paste the code)

Cleaner version

방빠반루ㅇ쀼머솔쌀이
아노숙차뿌썁썸뻐솝셜
본서번분번뮤따냐별쀼
슉누번나투쑫썬쌀본묘
뽀서본석처삭뽀로떠추
분초러사누이숟뗘분뻐
듀삭빠쏘ㅇ이썩손뵬ㅇ
쌰뭉쇼텨이변번처우텨
뽀희ㅇㅇㅇ볻ㅇ유어솝
ㅇㅇㅇㅇㅇㅇ숙쌉삼쏩


答:
Perl 5 + -n -M5.10.0, 51 bytes

Uses 0-based indices. Expects input as a string of 1s and 0s and outputs space separated co-ordinates.

Thanks to @wullxz and @GabrielBenamy for helping me save 9 bytes, and to @Taemyr's comment on my Retina answer for pointing out an issue!

/1011.{9}(1110.{9}){2}1111/;say"@-"%13,$","@-"/13|0
```

Try it online!

Title: Where's the 0xBEEF?

Body:
Perl 5 + -n -M5.10.0, 51 bytes

Uses 0-based indices. Expects input as a string of 1s and 0s and outputs space separated co-ordinates.

Thanks to @wullxz and @GabrielBenamy for helping me save 9 bytes, and to @Taemyr's comment on my Retina answer for pointing out an issue!

/1011.{9}(1110.{9}){2}1111/;say"@-"%13,$","@-"/13|0

<a href="https://tio.run/##VVRBTsNADLznFVYEAqSm8VD1gLjwAR7BgQMSaivKBZV@nSUbz3iTaKuu47Uznpnk9P71uS9lhAPby9P1HoDXzcPl8TrtMT6f3376l6G/xW5z02/qdsTu10upRx3z5Tb9auT1svk/ErC4HSsC1hlr69loEAFrlGIQ/YwlDKIW7ObOEnSugNjcicnitOBkN68ZYZhqonHcsYQ8A3VwwdktmreAcFheW3tOhI6A554WeJ3dnERFBuIQFqfUDcmuk4MWiKm5RvRUbJnL4RwkZIEtR5UknpMmgEWgDOUnvdFSaouQnEdUefKWyscxDWtyVD3RiejmKvEGzknzIcUT0HlZ2i1c1Qxjup3SS@L1c6R1ikWqJ78lo2t9ZMtA14wU9EJqw9Lha6A00mJsJEEC6ssRaOXUHt4l6HSv3samQTMs0tfNVWgymKdFnGKRLGtSxaTtE6DHN/MR3V33dzx9fxwP5zK87rfTp8fLcPgH" rel="nofollow noreferrer" title="Perl 5 – Try It Online">Try it online!


答:
Java 7, 85 bytes

```<code>void c(){System.out.print("אבגדהוזחטיכךלמםנןסעפףצץקרשת");}
</code>```

I'm not even gonna bother posting test code or a 'Try it here' like I usually do..

Title: Output the Hebrew alphabet

Body:
Your task is to print this exact text:

```<code>אבגדהוזחטיכךלמםנןסעפףצץקרשת
</code>```

(You are allowed to print a trailing newline)

SHA256 hash of the UTF-8 encoding of the text:

```<code>0ab6f1e0bf216a0db52a4a5a247f95cba6f51496de7a24dfd01f3985dfcf6085
</code>```

Base64 encoding:

```<code>15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeq
</code>```

Rules

You can't use a builtin outputting this text.

Standard loopholes are disallowed.

This is code-golf, so the shortest answer wins.

Good luck!

Body:
Java 7, 85 bytes

void c(){System.out.print("אבגדהוזחטיכךלמםנןסעפףצץקרשת");}

I'm not even gonna bother posting test code or a 'Try it here' like I usually do..


问:
Antsy permutations

Introduction

Suppose you have a ruler with numbers from 0 to r-1.
You place an ant between any two of the numbers, and it starts to crawl erratically on the ruler.
The ruler is so narrow that the ant cannot walk from one position to another without walking on all the numbers in between.
As the ant walks on a number for the first time, you record it, and this gives you a permutation of the r numbers.
We say that a permutation is antsy if it can be generated by an ant in this way.
Alternatively, a permutation p is antsy if every entry p[i] except the first is within distance 1 from some previous entry.

Examples

The length-6 permutation

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

is antsy, because 3 is within distance 1 of 4, 5 is within distance 1 of 4, 2 is within distance 1 from 3, 1 is within distance 1 from 2, and 0 is within distance 1 from 1.
The permutation

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

is not antsy, because 5 is not within distance 1 of either 3 or 2; the ant would have to pass through 4 to get to 5.

The task

Given a permutation of the numbers from 0 to r-1 for some 1 ≤ r ≤ 100 in any reasonable format, output a truthy value if the permutation is antsy, and a falsy value if not.

Test cases

```<code>[0] -> True
[0, 1] -> True
[1, 0] -> True
[0, 1, 2] -> True
[0, 2, 1] -> False
[2, 1, 3, 0] -> True
[3, 1, 0, 2] -> False
[1, 2, 0, 3] -> True
[2, 3, 1, 4, 0] -> True
[2, 3, 0, 4, 1] -> False
[0, 5, 1, 3, 2, 4] -> False
[6, 5, 4, 7, 3, 8, 9, 2, 1, 0] -> True
[4, 3, 5, 6, 7, 2, 9, 1, 0, 8] -> False
[5, 2, 7, 9, 6, 8, 0, 4, 1, 3] -> False
[20, 13, 7, 0, 14, 16, 10, 24, 21, 1, 8, 23, 17, 18, 11, 2, 6, 22, 4, 5, 9, 12, 3, 15, 19] -> False
[34, 36, 99, 94, 77, 93, 31, 90, 21, 88, 30, 66, 92, 83, 42, 5, 86, 11, 15, 78, 40, 48, 22, 29, 95, 64, 97, 43, 14, 33, 69, 49, 50, 35, 74, 46, 26, 51, 75, 87, 23, 85, 41, 98, 82, 79, 59, 56, 37, 96, 45, 17, 32, 91, 62, 20, 4, 9, 2, 18, 27, 60, 63, 25, 61, 76, 1, 55, 16, 8, 6, 38, 54, 47, 73, 67, 53, 57, 7, 72, 84, 39, 52, 58, 0, 89, 12, 68, 70, 24, 80, 3, 44, 13, 28, 10, 71, 65, 81, 19] -> False
[47, 48, 46, 45, 44, 49, 43, 42, 41, 50, 40, 39, 38, 51, 37, 36, 52, 35, 34, 33, 32, 53, 54, 31, 30, 55, 56, 29, 28, 57, 58, 59, 60, 27, 26, 61, 25, 62, 63, 64, 65, 66, 67, 24, 23, 22, 21, 68, 69, 20, 19, 18, 17, 70, 71, 16, 15, 72, 73, 74, 75, 76, 14, 13, 12, 77, 11, 10, 9, 8, 78, 7, 79, 80, 6, 81, 5, 4, 3, 82, 2, 83, 84, 1, 85, 86, 87, 0, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] -> True
</code>```

Fun fact: for r ≥ 1, there are exactly 2r-1 antsy permutations of length r.

答:
Pyth (fork), 13 bytes

```<code>!sstMM.+MSM._
</code>```

No Try It Online link for this fork of Pyth.  The fork includes the deltas function .+, which is not part of the standard Pyth library.

Explanation:

```<code>           ._  For each of the prefixes:
         SM    Sort it
      .+M      Get deltas (differences between consecutive elements), which for antsy
                 permutations would all be 1s
   tMM         Decrement each of the elements (all 0s for antsy permutations)
 ss            Sum all the results from the above together, 0 for antsy and >0 for non-antsy
!              Logical negation.
</code>```

Title: Antsy permutations

Body:
Pyth (fork), 13 bytes

!sstMM.+MSM._

No Try It Online link for this fork of Pyth.  The fork includes the deltas function .+, which is not part of the standard Pyth library.

Explanation:

           ._  For each of the prefixes:
         SM    Sort it
      .+M      Get deltas (differences between consecutive elements), which for antsy
                 permutations would all be 1s
   tMM         Decrement each of the elements (all 0s for antsy permutations)
 ss            Sum all the results from the above together, 0 for antsy and >0 for non-antsy
!              Logical negation.


答:
Brachylog, 22 bytes

```<code>:@[fb:{oLtT,Lh:T:efL}a
</code>```

Try it online!

Explanation

I haven't found a concise way of checking whether a list contains consecutive integers or not. The shortest I found is to generate a range between the first and last element of that list and check that that range is the original list.

```<code>:@[fb                       Take all but the first prefixes of the Input
     :{             }a      This predicate is true for all those prefixes
       oLtT,                Sort the prefix, call it L, its last element is T
            Lh:T            The list [First element of L, T]
                :efL        Find all integers between the First element of L and T. It must
                              result in L
</code>```

Title: Antsy permutations

Body:
Introduction

Suppose you have a ruler with numbers from 0 to r-1.
You place an ant between any two of the numbers, and it starts to crawl erratically on the ruler.
The ruler is so narrow that the ant cannot walk from one position to another without walking on all the numbers in between.
As the ant walks on a number for the first time, you record it, and this gives you a permutation of the r numbers.
We say that a permutation is antsy if it can be generated by an ant in this way.
Alternatively, a permutation p is antsy if every entry p[i] except the first is within distance 1 from some previous entry.

Examples

The length-6 permutation

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

is antsy, because 3 is within distance 1 of 4, 5 is within distance 1 of 4, 2 is within distance 1 from 3, 1 is within distance 1 from 2, and 0 is within distance 1 from 1.
The permutation

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

is not antsy, because 5 is not within distance 1 of either 3 or 2; the ant would have to pass through 4 to get to 5.

The task

Given a permutation of the numbers from 0 to r-1 for some 1 ≤ r ≤ 100 in any reasonable format, output a truthy value if the permutation is antsy, and a falsy value if not.

Test cases

```<code>[0] -> True
[0, 1] -> True
[1, 0] -> True
[0, 1, 2] -> True
[0, 2, 1] -> False
[2, 1, 3, 0] -> True
[3, 1, 0, 2] -> False
[1, 2, 0, 3] -> True
[2, 3, 1, 4, 0] -> True
[2, 3, 0, 4, 1] -> False
[0, 5, 1, 3, 2, 4] -> False
[6, 5, 4, 7, 3, 8, 9, 2, 1, 0] -> True
[4, 3, 5, 6, 7, 2, 9, 1, 0, 8] -> False
[5, 2, 7, 9, 6, 8, 0, 4, 1, 3] -> False
[20, 13, 7, 0, 14, 16, 10, 24, 21, 1, 8, 23, 17, 18, 11, 2, 6, 22, 4, 5, 9, 12, 3, 15, 19] -> False
[34, 36, 99, 94, 77, 93, 31, 90, 21, 88, 30, 66, 92, 83, 42, 5, 86, 11, 15, 78, 40, 48, 22, 29, 95, 64, 97, 43, 14, 33, 69, 49, 50, 35, 74, 46, 26, 51, 75, 87, 23, 85, 41, 98, 82, 79, 59, 56, 37, 96, 45, 17, 32, 91, 62, 20, 4, 9, 2, 18, 27, 60, 63, 25, 61, 76, 1, 55, 16, 8, 6, 38, 54, 47, 73, 67, 53, 57, 7, 72, 84, 39, 52, 58, 0, 89, 12, 68, 70, 24, 80, 3, 44, 13, 28, 10, 71, 65, 81, 19] -> False
[47, 48, 46, 45, 44, 49, 43, 42, 41, 50, 40, 39, 38, 51, 37, 36, 52, 35, 34, 33, 32, 53, 54, 31, 30, 55, 56, 29, 28, 57, 58, 59, 60, 27, 26, 61, 25, 62, 63, 64, 65, 66, 67, 24, 23, 22, 21, 68, 69, 20, 19, 18, 17, 70, 71, 16, 15, 72, 73, 74, 75, 76, 14, 13, 12, 77, 11, 10, 9, 8, 78, 7, 79, 80, 6, 81, 5, 4, 3, 82, 2, 83, 84, 1, 85, 86, 87, 0, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] -> True
</code>```

Fun fact: for r ≥ 1, there are exactly 2r-1 antsy permutations of length r.

Body:
Brachylog, 22 bytes

:@[fb:{oLtT,Lh:T:efL}a

Try it online!

Explanation

I haven't found a concise way of checking whether a list contains consecutive integers or not. The shortest I found is to generate a range between the first and last element of that list and check that that range is the original list.

:@[fb                       Take all but the first prefixes of the Input
     :{             }a      This predicate is true for all those prefixes
       oLtT,                Sort the prefix, call it L, its last element is T
            Lh:T            The list [First element of L, T]
                :efL        Find all integers between the First element of L and T. It must
                              result in L


答:
Charcoal, 11111111

```<code>Ｆ⁸1
</code>```

Try it online!

for(8)Print('1').

Charcoal could have done better (1111 score) if source was measured in Charcoal bytes.

Body:
Charcoal, 11111111

Ｆ⁸1

Try it online!

for(8)Print('1').

Charcoal could have done better (1111 score) if source was measured in Charcoal bytes.


答:
Python 2, 49 bytes

f=lambda l:l==[]or max(l)-min(l)<len(l)*f(l[:-1])
```

<p>Checks whether each prefix of the list contains all numbers between its min and max inclusive. It does so by checking if the difference of the max and min is less than its length.</p>

<hr>

<p><strong>54 bytes:</strong></p>

<pre class="lang-python prettyprint-override"><code>f=lambda l:1/len(l)or-~l.pop()in[min(l),max(l)+2]*f(l)
</code>```

Checks if the last element is either one less than the min of the other elements, or one more than their max. Then, removes the last element and recurses. On a single-element list, outputs True.

This can also be checked via an amusing but longer list comprehension.

lambda l:all(l.pop()in[min(l)-1,max(l)+1]for _ in l[1:])
```

I'd like to use the inequality min(l)-2<l.pop()<max(l)+2, but the pop needs to happen first. Using a program to output via error code would likely be shorter.

Title: Antsy permutations

Body:
Python 2, 49 bytes

f=lambda l:l==[]or max(l)-min(l)<len(l)*f(l[:-1])

Checks whether each prefix of the list contains all numbers between its min and max inclusive. It does so by checking if the difference of the max and min is less than its length.

54 bytes:

f=lambda l:1/len(l)or-~l.pop()in[min(l),max(l)+2]*f(l)

Checks if the last element is either one less than the min of the other elements, or one more than their max. Then, removes the last element and recurses. On a single-element list, outputs True.

This can also be checked via an amusing but longer list comprehension.

lambda l:all(l.pop()in[min(l)-1,max(l)+1]for _ in l[1:])

I'd like to use the inequality min(l)-2<l.pop()<max(l)+2, but the pop needs to happen first. Using a program to output via error code would likely be shorter.


答:
JavaScript (ES6), 45

a=>a.every((v,i)=>a[v]=!i|a[v-1]|a[v+1],a=[])
```
<p>I thought it's too simple to need as explanation, but there is a trick, and just in case, here is my first version, pre-golf</p>
<pre class="lang-js prettyprint-override"><code>a => {
  k = []; // I'll put a 1 in this array at position of each value
          // that I find scanning the input list
  return a.every((v,i) => { // execute for each element v at position i
    // the index i is needed to manage the first iteration
    // return 1/true if ok, 0/false if not valid
    // .every will stop and return false if any iteration return falsy
    k[v] = 1; // mark the current position
    if ( i == 0 )
    {  // the first element is always valid
       return true;
    }
    else
    {
       return k[v-1] == 1 // valid if near a lesser value
              || k[v+1] == 1; // or valid if near a greater value
    }
  })
}
</code>```

Note: in the golfed code a is used instead of k, as I need no reference to the original array inside the every call. So I avoid to pollute the global namespace reusing the parameter

Test

antsy=
a=>a.every((v,i)=>a[v]=!i|a[v-1]|a[v+1],a=[])

var OkAll=true
;`[0] -> True
[0, 1] -> True
[1, 0] -> True
[0, 1, 2] -> True
[0, 2, 1] -> False
[2, 1, 3, 0] -> True
[3, 1, 0, 2] -> False
[1, 2, 0, 3] -> True
[2, 3, 1, 4, 0] -> True
[2, 3, 0, 4, 1] -> False
[0, 5, 1, 3, 2, 4] -> False
[6, 5, 4, 7, 3, 8, 9, 2, 1, 0] -> True
[4, 3, 5, 6, 7, 2, 9, 1, 0, 8] -> False
[5, 2, 7, 9, 6, 8, 0, 4, 1, 3] -> False
[20, 13, 7, 0, 14, 16, 10, 24, 21, 1, 8, 23, 17, 18, 11, 2, 6, 22, 4, 5, 9, 12, 3, 15, 19] -> False
[34, 36, 99, 94, 77, 93, 31, 90, 21, 88, 30, 66, 92, 83, 42, 5, 86, 11, 15, 78, 40, 48, 22, 29, 95, 64, 97, 43, 14, 33, 69, 49, 50, 35, 74, 46, 26, 51, 75, 87, 23, 85, 41, 98, 82, 79, 59, 56, 37, 96, 45, 17, 32, 91, 62, 20, 4, 9, 2, 18, 27, 60, 63, 25, 61, 76, 1, 55, 16, 8, 6, 38, 54, 47, 73, 67, 53, 57, 7, 72, 84, 39, 52, 58, 0, 89, 12, 68, 70, 24, 80, 3, 44, 13, 28, 10, 71, 65, 81, 19] -> False
[47, 48, 46, 45, 44, 49, 43, 42, 41, 50, 40, 39, 38, 51, 37, 36, 52, 35, 34, 33, 32, 53, 54, 31, 30, 55, 56, 29, 28, 57, 58, 59, 60, 27, 26, 61, 25, 62, 63, 64, 65, 66, 67, 24, 23, 22, 21, 68, 69, 20, 19, 18, 17, 70, 71, 16, 15, 72, 73, 74, 75, 76, 14, 13, 12, 77, 11, 10, 9, 8, 78, 7, 79, 80, 6, 81, 5, 4, 3, 82, 2, 83, 84, 1, 85, 86, 87, 0, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] -> True`
.split`\n`.forEach(row => {
  var rowElements = row.match(/\w+/g),
      expected = rowElements.pop()=='True',
      input = rowElements.map(x => +x),
      result = antsy(input),
      ok = result == expected;
  OkAll = OkAll && ok;
  console.log(ok?'OK':'KO', input+' -> '+result)
})
console.log(OkAll ? 'All passed' : 'Failed')```

Title: Antsy permutations

Body:
JavaScript (ES6), 45

a=>a.every((v,i)=>a[v]=!i|a[v-1]|a[v+1],a=[])

I thought it's too simple to need as explanation, but there is a trick, and just in case, here is my first version, pre-golf

a => {
  k = []; // I'll put a 1 in this array at position of each value
          // that I find scanning the input list
  return a.every((v,i) => { // execute for each element v at position i
    // the index i is needed to manage the first iteration
    // return 1/true if ok, 0/false if not valid
    // .every will stop and return false if any iteration return falsy
    k[v] = 1; // mark the current position
    if ( i == 0 )
    {  // the first element is always valid
       return true;
    }
    else
    {
       return k[v-1] == 1 // valid if near a lesser value
              || k[v+1] == 1; // or valid if near a greater value
    }
  })
}

Note: in the golfed code a is used instead of k, as I need no reference to the original array inside the every call. So I avoid to pollute the global namespace reusing the parameter

Test

antsy=
a=>a.every((v,i)=>a[v]=!i|a[v-1]|a[v+1],a=[])

var OkAll=true
;`[0] -> True
[0, 1] -> True
[1, 0] -> True
[0, 1, 2] -> True
[0, 2, 1] -> False
[2, 1, 3, 0] -> True
[3, 1, 0, 2] -> False
[1, 2, 0, 3] -> True
[2, 3, 1, 4, 0] -> True
[2, 3, 0, 4, 1] -> False
[0, 5, 1, 3, 2, 4] -> False
[6, 5, 4, 7, 3, 8, 9, 2, 1, 0] -> True
[4, 3, 5, 6, 7, 2, 9, 1, 0, 8] -> False
[5, 2, 7, 9, 6, 8, 0, 4, 1, 3] -> False
[20, 13, 7, 0, 14, 16, 10, 24, 21, 1, 8, 23, 17, 18, 11, 2, 6, 22, 4, 5, 9, 12, 3, 15, 19] -> False
[34, 36, 99, 94, 77, 93, 31, 90, 21, 88, 30, 66, 92, 83, 42, 5, 86, 11, 15, 78, 40, 48, 22, 29, 95, 64, 97, 43, 14, 33, 69, 49, 50, 35, 74, 46, 26, 51, 75, 87, 23, 85, 41, 98, 82, 79, 59, 56, 37, 96, 45, 17, 32, 91, 62, 20, 4, 9, 2, 18, 27, 60, 63, 25, 61, 76, 1, 55, 16, 8, 6, 38, 54, 47, 73, 67, 53, 57, 7, 72, 84, 39, 52, 58, 0, 89, 12, 68, 70, 24, 80, 3, 44, 13, 28, 10, 71, 65, 81, 19] -> False
[47, 48, 46, 45, 44, 49, 43, 42, 41, 50, 40, 39, 38, 51, 37, 36, 52, 35, 34, 33, 32, 53, 54, 31, 30, 55, 56, 29, 28, 57, 58, 59, 60, 27, 26, 61, 25, 62, 63, 64, 65, 66, 67, 24, 23, 22, 21, 68, 69, 20, 19, 18, 17, 70, 71, 16, 15, 72, 73, 74, 75, 76, 14, 13, 12, 77, 11, 10, 9, 8, 78, 7, 79, 80, 6, 81, 5, 4, 3, 82, 2, 83, 84, 1, 85, 86, 87, 0, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] -> True`
.split`\n`.forEach(row => {
  var rowElements = row.match(/\w+/g),
      expected = rowElements.pop()=='True',
      input = rowElements.map(x => +x),
      result = antsy(input),
      ok = result == expected;
  OkAll = OkAll && ok;
  console.log(ok?'OK':'KO', input+' -> '+result)
})
console.log(OkAll ? 'All passed' : 'Failed')


答:
Dart 44 bytes

p(s)=>s.split("").join("(")+")"*~-s.length;
```

<p>I tried to be clever, but nothing beat this simple version.
Notable mention:</p>

<pre class="lang-dart prettyprint-override"><code>r(s,[x=0])=>s[x++]+(x<s.length?"(${r(s,x)})":"");
q(s)=>s[0]+((s=s.substring(1))==""?s:"(${q(s)})");
</code>```

but they drowned in necessary parentheses.

Title: N(e(s(t))) a string

Body:
To "function nest" a string, you must:

Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was Hello, then the first step would be:

```<code>H(ello)
</code>```

Then, repeat this same step for every substring. So we get:

```<code>H(ello)
H(e(llo))
H(e(l(lo)))
H(e(l(l(o))))
</code>```

Your task is to write a program or function that "function nests" a string. For example, if the input string was Hello world!, then you should output:

```<code>H(e(l(l(o( (w(o(r(l(d(!)))))))))))
</code>```

The input will only ever contain printable ASCII, and you may take the input and the output in any reasonable format. For example, STDIN/STDOUT, function arguments and return value, reading and writing to a file, etc.

For simplicity's sake, you may also assume the input will not contain parentheses, and will not be empty.

```<code>Input:
Nest a string
Output:
N(e(s(t( (a( (s(t(r(i(n(g))))))))))))

Input:
foobar
Output:
f(o(o(b(a(r)))))

Input:
1234567890
Output:
1(2(3(4(5(6(7(8(9(0)))))))))

Input:
code-golf
Output:
c(o(d(e(-(g(o(l(f))))))))

Input:
a
Output:
a

Input:
42
Output:
4(2)
</code>```

As usual, all of our default rules and loopholes apply, and the shortest answer scored in bytes wins!

Body:
Dart 44 bytes

p(s)=>s.split("").join("(")+")"*~-s.length;

I tried to be clever, but nothing beat this simple version.
Notable mention:

r(s,[x=0])=>s[x++]+(x<s.length?"(${r(s,x)})":"");
q(s)=>s[0]+((s=s.substring(1))==""?s:"(${q(s)})");

but they drowned in necessary parentheses.


答:
///, 27 bytes

```<code>ABCDEFGHIQSRTVUXWYbdcfeghiq
</code>```

Try it online!

Output is encoded in CP424.

To verify it yourself:

```<code>$ echo ABCDEFGHIQSRTVUXWYbdcfeghiq | ./slashes.pl | python3 -c 'print(bytes(input(), "utf-8").decode("cp424"))' | base64
15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeqCg==
</code>```

Title: Output the Hebrew alphabet

Body:
///, 27 bytes

ABCDEFGHIQSRTVUXWYbdcfeghiq

Try it online!

Output is encoded in CP424.

To verify it yourself:

$ echo ABCDEFGHIQSRTVUXWYbdcfeghiq | ./slashes.pl | python3 -c 'print(bytes(input(), "utf-8").decode("cp424"))' | base64
15DXkdeS15PXlNeV15bXl9eY15nXm9ea15zXnted16DXn9eh16LXpNej16bXpden16jXqdeqCg==


答:
Jelly, <s>9</s> <s>8</s> 7 bytes

```<code>;@UŒPċṢ
</code>```

Try It Online!

A Jelly translation of xnor's answer.

Old solutions:

```<code>;\Ṣ€IỊȦ
;\Ṣ€IE€P
</code>```

Try it online!

Works very similarly to my Pyth answer below:

```<code>;\          All prefixes (Accumulate (\) over concatenation (;))
  Ṣ€        (Ṣ)ort each (€) prefix
    I       (I)ncrements of each prefix (differences between consecutive elements).  Implicit vectorization.
     E€     Check if all elements are (E)qual (they will be iff the permutation is antsy,
               and all elements will be 1) for each (€) prefix
       P    Is this true for all prefixes?
     ỊȦ     For the other answer, are (Ȧ)ll elements 1 or less (Ị)?
</code>```

Title: Antsy permutations

Body:
Jelly, <s>9</s> <s>8</s> 7 bytes

;@UŒPċṢ

Try It Online!

A Jelly translation of xnor's answer.

Old solutions:

;\Ṣ€IỊȦ
;\Ṣ€IE€P

Try it online!

Works very similarly to my Pyth answer below:

;\          All prefixes (Accumulate (\) over concatenation (;))
  Ṣ€        (Ṣ)ort each (€) prefix
    I       (I)ncrements of each prefix (differences between consecutive elements).  Implicit vectorization.
     E€     Check if all elements are (E)qual (they will be iff the permutation is antsy,
               and all elements will be 1) for each (€) prefix
       P    Is this true for all prefixes?
     ỊȦ     For the other answer, are (Ȧ)ll elements 1 or less (Ị)?


答:
MATL, 11 bytes

```<code>&-|R1=a4L)A
</code>```

Try it online! Or verify all test cases.

Explanation

This computes a matrix of all pairwise absolute differences and keeps the upper triangular part. The result is true iff there is at least a 1 value in all columns except the first.

```<code>&-     % All pairwise differences
|      % Absolute value
R      % Upper triangular part
1=     % Does each entry equal 1?
a      % Logical "or" along each column
4L)    % Remove first value
A      % Logical "and" of all results
</code>```

Title: Antsy permutations

Body:
MATL, 11 bytes

&-|R1=a4L)A

Try it online! Or <a href="http://matl.tryitonline.net/#code=YAomLXxSMT1hNEwpQQpEVA&input=WzBdClswLCAxXQpbMSwgMF0KWzAsIDEsIDJdClswLCAyLCAxXQpbMiwgMSwgMywgMF0KWzMsIDEsIDAsIDJdClsxLCAyLCAwLCAzXQpbMiwgMywgMSwgNCwgMF0KWzIsIDMsIDAsIDQsIDFdClswLCA1LCAxLCAzLCAyLCA0XQpbNiwgNSwgNCwgNywgMywgOCwgOSwgMiwgMSwgMF0KWzQsIDMsIDUsIDYsIDcsIDIsIDksIDEsIDAsIDhdCls1LCAyLCA3LCA5LCA2LCA4LCAwLCA0LCAxLCAzXQpbMjAsIDEzLCA3LCAwLCAxNCwgMTYsIDEwLCAyNCwgMjEsIDEsIDgsIDIzLCAxNywgMTgsIDExLCAyLCA2LCAyMiwgNCwgNSwgOSwgMTIsIDMsIDE1LCAxOV0KWzM0LCAzNiwgOTksIDk0LCA3NywgOTMsIDMxLCA5MCwgMjEsIDg4LCAzMCwgNjYsIDkyLCA4MywgNDIsIDUsIDg2LCAxMSwgMTUsIDc4LCA0MCwgNDgsIDIyLCAyOSwgOTUsIDY0LCA5NywgNDMsIDE0LCAzMywgNjksIDQ5LCA1MCwgMzUsIDc0LCA0NiwgMjYsIDUxLCA3NSwgODcsIDIzLCA4NSwgNDEsIDk4LCA4MiwgNzksIDU5LCA1NiwgMzcsIDk2LCA0NSwgMTcsIDMyLCA5MSwgNjIsIDIwLCA0LCA5LCAyLCAxOCwgMjcsIDYwLCA2MywgMjUsIDYxLCA3NiwgMSwgNTUsIDE2LCA4LCA2LCAzOCwgNTQsIDQ3LCA3MywgNjcsIDUzLCA1NywgNywgNzIsIDg0LCAzOSwgNTIsIDU4LCAwLCA4OSwgMTIsIDY4LCA3MCwgMjQsIDgwLCAzLCA0NCwgMTMsIDI4LCAxMCwgNzEsIDY1LCA4MSwgMTldCls0NywgNDgsIDQ2LCA0NSwgNDQsIDQ5LCA0MywgNDIsIDQxLCA1MCwgNDAsIDM5LCAzOCwgNTEsIDM3LCAzNiwgNTIsIDM1LCAzNCwgMzMsIDMyLCA1MywgNTQsIDMxLCAzMCwgNTUsIDU2LCAyOSwgMjgsIDU3LCA1OCwgNTksIDYwLCAyNywgMjYsIDYxLCAyNSwgNjIsIDYzLCA2NCwgNjUsIDY2LCA2NywgMjQsIDIzLCAyMiwgMjEsIDY4LCA2OSwgMjAsIDE5LCAxOCwgMTcsIDcwLCA3MSwgMTYsIDE1LCA3MiwgNzMsIDc0LCA3NSwgNzYsIDE0LCAxMywgMTIsIDc3LCAxMSwgMTAsIDksIDgsIDc4LCA3LCA3OSwgODAsIDYsIDgxLCA1LCA0LCAzLCA4MiwgMiwgODMsIDg0LCAxLCA4NSwgODYsIDg3LCAwLCA4OCwgODksIDkwLCA5MSwgOTIsIDkzLCA5NCwgOTUsIDk2LCA5NywgOTgsIDk5XQ" rel="nofollow noreferrer">verify all test cases.

Explanation

This computes a matrix of all pairwise absolute differences and keeps the upper triangular part. The result is true iff there is at least a 1 value in all columns except the first.

&-     % All pairwise differences
|      % Absolute value
R      % Upper triangular part
1=     % Does each entry equal 1?
a      % Logical "or" along each column
4L)    % Remove first value
A      % Logical "and" of all results


答:
Pyth, 7 bytes

```<code>/y+_QQS
</code>```

Try it online. (Only small test cases are included due to exponential run-time.) Outputs 2 for Truthy, 0 for Falsey.

```<code>/          Count the number of occurences of
      S     the sorted input (implicit Q)
 y          in the order-preserved power set
  +_QQ       of the input prepended by its reverse
</code>```

In other words,

```<code>lambda l: subseq(sorted(l), concat(reverse(l), l))
</code>```

where subseq outputs whether the elements of the first list appear in order in the second list, not necessarily adjacent. The subseq is done in Pyth by taking all subsets of the second list, which keep the order of the elements, and counting the number of occurrences of the first list. This takes exponential time.

Why does this work? For a permutation to be antsy, stepping from 0 to n-1 must consist of going only left, then going only right. This is because the elements greater than the first element must increase left to right, and those less than it must decrease left to right.

```<code>[2, 3, 1, 4, 0]
             ^
       ^     0
 ^     1
 2  ^
    3     ^
          4
</code>```

If we mirror the list by putting a reversed copy to its left, this walk now only goes right.

```<code>[0, 4, 1, 3, 2, 2, 3, 1, 4, 0]
 ^            |
 0     ^      |
       1      | ^
              | 2  ^
              |    3     ^
              |          4
</code>```

Conversely, any rightward of this mirror list corresponds to a left-then-right walk of the original list. This rightward just is a sorted subsequence of 0 to n-1. In an antsy list, this sorted subsequence is unique, except for an arbitrary choice between the two adjacent copies of the original first element.

Title: Antsy permutations

Body:
Pyth, 7 bytes

/y+_QQS

<a href="http://pyth.herokuapp.com/?code=%2Fy%2B_QQS&input=%5B0%5D%0A%5B0%2C%201%5D%0A%5B1%2C%200%5D%0A%5B0%2C%201%2C%202%0A%5B0%2C%202%2C%201%5D%0A%5B2%2C%201%2C%203%2C%200%5D%0A%5B3%2C%201%2C%200%2C%202%5D%0A%5B1%2C%202%2C%200%2C%203%5D%0A%5B2%2C%203%2C%201%2C%204%2C%200%5D%0A%5B2%2C%203%2C%200%2C%204%2C%201%5D%0A%5B0%2C%205%2C%201%2C%203%2C%202%2C%204%5D%0A%5B6%2C%205%2C%204%2C%207%2C%203%2C%208%2C%209%2C%202%2C%201%2C%200%5D%0A%5B4%2C%203%2C%205%2C%206%2C%207%2C%202%2C%209%2C%201%2C%200%2C%208%5D%0A%5B5%2C%202%2C%207%2C%209%2C%206%2C%208%2C%200%2C%204%2C%201%2C%203%5D&test_suite=1&test_suite_input=%5B0%5D%0A%5B0%2C%201%5D%0A%5B1%2C%200%5D%0A%5B0%2C%201%2C%202%5D%0A%5B0%2C%202%2C%201%5D%0A%5B2%2C%201%2C%203%2C%200%5D%0A%5B3%2C%201%2C%200%2C%202%5D%0A%5B1%2C%202%2C%200%2C%203%5D%0A%5B2%2C%203%2C%201%2C%204%2C%200%5D%0A%5B2%2C%203%2C%200%2C%204%2C%201%5D%0A%5B0%2C%205%2C%201%2C%203%2C%202%2C%204%5D&debug=1">Try it online. (Only small test cases are included due to exponential run-time.) Outputs 2 for Truthy, 0 for Falsey.

/          Count the number of occurences of
      S     the sorted input (implicit Q)
 y          in the order-preserved power set
  +_QQ       of the input prepended by its reverse

In other words,

lambda l: subseq(sorted(l), concat(reverse(l), l))

where subseq outputs whether the elements of the first list appear in order in the second list, not necessarily adjacent. The subseq is done in Pyth by taking all subsets of the second list, which keep the order of the elements, and counting the number of occurrences of the first list. This takes exponential time.

Why does this work? For a permutation to be antsy, stepping from 0 to n-1 must consist of going only left, then going only right. This is because the elements greater than the first element must increase left to right, and those less than it must decrease left to right.

[2, 3, 1, 4, 0]
             ^
       ^     0
 ^     1
 2  ^
    3     ^
          4

If we mirror the list by putting a reversed copy to its left, this walk now only goes right.

[0, 4, 1, 3, 2, 2, 3, 1, 4, 0]
 ^            |
 0     ^      |
       1      | ^
              | 2  ^
              |    3     ^
              |          4

Conversely, any rightward of this mirror list corresponds to a left-then-right walk of the original list. This rightward just is a sorted subsequence of 0 to n-1. In an antsy list, this sorted subsequence is unique, except for an arbitrary choice between the two adjacent copies of the original first element.


答:
R, <s>72</s> <s>64</s> 60 bytes

```<code>v=scan();for(i in seq(v))T=c(T,diff(sort(v[1:i])));all(T==1)
</code>```

A permutation is antsy if and only if all its left subpermutations are continuous (i.e. have difference one when sorted).

<s>If input is guaranteed to have length more than one, then we can replace 1:sum(1|v) with seq(v), which saves four bytes.</s>

The seq(v) in the if condition behaves differently when the input is of length one --- it generates the sequence 1:v instead of seq_along(v). However, fortunately, the output turns out to be TRUE in this case, which is the desired behaviour. The same also happens for zero-length input.

In R, T is a preset variable equal to TRUE (but R allows you to redefine it). TRUE is also deemed to be equal to 1.

Thanks to @Billywob for some helpful improvements to the original solution.

Title: Antsy permutations

Body:
R, <s>72</s> <s>64</s> 60 bytes

v=scan();for(i in seq(v))T=c(T,diff(sort(v[1:i])));all(T==1)

A permutation is antsy if and only if all its left subpermutations are continuous (i.e. have difference one when sorted).

<s>If input is guaranteed to have length more than one, then we can replace 1:sum(1|v) with seq(v), which saves four bytes.</s>

The seq(v) in the if condition behaves differently when the input is of length one --- it generates the sequence 1:v instead of seq_along(v). However, fortunately, the output turns out to be TRUE in this case, which is the desired behaviour. The same also happens for zero-length input.

In R, T is a preset variable equal to TRUE (but R allows you to redefine it). TRUE is also deemed to be equal to 1.

Thanks to @Billywob for some helpful improvements to the original solution.


答:
Retina, 47 bytes

I'd like to preface this with an apology. I think this is probably terrible and a bad example of how to use the language, but since I used a Regex for my Perl answer, I thought I'd try Retina. I'm not very good. :( The snippets on github helped me greatly though!

Thanks to @wullzx for his comment on my Perl answer for -3 bytes and to @Taemyr for pointing out an issue with my method!

Expects input as a space-separated binary string and outputs co-ordinates space separated.

```<code>(.{13})*(.)*1011(.{9}1110){2}.{9}1111.*
$#2 $#1
</code>```

Try it online!

Verify all tests at once.

Title: Where's the 0xBEEF?

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

Body:
Retina, 47 bytes

I'd like to preface this with an apology. I think this is probably terrible and a bad example of how to use the language, but since I used a Regex for my Perl answer, I thought I'd try Retina. I'm not very good. :( The snippets on github helped me greatly though!

Thanks to @wullzx for his comment on my Perl answer for -3 bytes and to @Taemyr for pointing out an issue with my method!

Expects input as a space-separated binary string and outputs co-ordinates space separated.

(.{13})*(.)*1011(.{9}1110){2}.{9}1111.*
$#2 $#1

Try it online!

<a href="http://retina.tryitonline.net/#code=JShgKC57MTN9KSooLikqMTAxMSguezl9MTExMCl7Mn0uezl9MTExMS4qCiQjMiAkIzE&input=MTExMDAxMTExMTEwIDExMDEwMDEwMDAwMCAwMTAwMDExMTExMDEgMTAwMTAwMTAwMTAwIDEwMDEwMTEwMDExMSAxMTExMTEwMDAwMTAgMTEwMTExMDAwMDAxIDEwMDExMTEwMDAwMSAxMDAxMTEwMTExMTEgMTExMTEwMDExMTExIDEwMDAwMTAxMDExMSAxMTAwMTEwMDAwMTEKMDEwMDExMDAwMTEwIDExMDAwMDEwMDAxMSAwMTAxMTExMDAxMDAgMTExMTEwMDExMTAxIDAxMTEwMTExMDAxMCAwMDAxMDExMTEwMTEgMTAxMTAwMTExMDEwIDEwMTEwMTEwMTExMCAwMTAxMTEwMDEwMDAgMDEwMTExMDAxMTExIDExMDExMTEwMTEwMSAwMDEwMDExMTEwMDEKMTAxMDExMTAxMTAwIDAwMDAxMTAwMTExMCAwMDAwMTAwMTAxMDAgMDAxMDExMTExMDExIDAwMDExMDEwMTEwMSAwMTAwMTExMTEwMTAgMTAwMDAxMTExMDEwIDEwMDExMDExMTExMSAwMDAwMDAxMDEwMTAgMDExMDAxMTAxMTEwIDAwMDEwMTEwMTAxMSAwMTAwMDExMTEwMDEKMTEwMTEwMDExMTEwIDExMDExMDEwMTExMCAwMTExMDEwMTEwMTAgMDExMTAxMDExMTEwIDAxMTExMTAxMDAxMSAwMTAxMTAxMDAwMTAgMTAwMTAxMDAxMTExIDEwMTAxMTExMTAwMCAwMTAxMTAwMDEwMDAgMDExMTEwMDAwMDExIDEwMTAwMDExMDEwMSAwMDEwMDAwMDAxMTEKMTExMDAxMDAxMTAxIDEwMDEwMTAwMTExMCAxMDAwMTAxMDAwMDAgMDExMDAwMTAxMTExIDAxMTEwMTAwMTAwMSAxMTExMTAwMDAwMDEgMTAxMTAwMTEwMDAwIDExMDAwMDAwMDAxMCAwMDAxMTEwMTEwMTEgMTAwMTAxMDAxMTEwIDAxMTEwMDEwMTExMCAwMDAwMDExMTExMTEKMDAwMTAxMTAxMDAxIDAxMDAxMTExMTAxMSAxMTAwMTExMDEwMDAgMTAxMTAwMTExMTEwIDExMTAxMDAxMDEwMSAxMTEwMTExMTEwMDEgMTExMTEwMDAwMDExIDExMDEwMTAwMTEwMSAxMDExMDEwMDAxMTAgMDAwMTExMDAwMDAwIDExMDAwMDAxMTEwMSAwMDAwMDAwMTAxMTAKMTExMDAxMDExMDEwIDEwMTEwMDEwMDEwMCAwMTEwMDAxMDAwMTEgMTEwMTExMTExMTEwIDAxMDEwMTExMTAxMCAxMTAxMDAwMDAwMTEgMDExMDExMDAxMTAxIDEwMTAwMTExMDExMCAxMDAwMDAwMTExMDAgMTAxMDAxMTExMTAxIDAwMTAxMTAxMTExMCAwMDAxMDAwMDAxMDE" rel="nofollow noreferrer">Verify all tests at once.


问:
Output the ALONED numbers
Consider the natural sequence up-to 6 (disregard 1):

```<code>2,3,4,5,6
</code>```

We start scanning from the left (in this case from 2), search for a number divisible by 2 (here 4) and then remove both the numbers from the list (here 2 & 4), such that the list reduces to:

```<code>3,5,6
</code>```

We continue the same process, here leftmost is 3, so we search for number divisible by 3. 6 is surely that number and thus 3 and 6 are removed,

```<code>5
</code>```

Now, no further such searches can be made Thus, this becomes the list of ALONED numbers for n=6.

OBJECTIVE

Given a number n greater than 1, print all the corresponding aloned numbers.

INPUT

```<code>2
6
15
20
22
</code>```

OUTPUT

```<code>2
5
8,9,11,12,13,15
11,12,13,15,17,19,20
12,13,15,17,19,20,21
</code>```

YET ANOTHER WORKED OUT EXAMPLE

For n= 22

```<code>=>2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
=>3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 (remove 2 & 4)
=>5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 (remove 3 & 6)
=>7,8,9,11,12,13,14,15,16,17,18,19,20,21,22 (remove 5 & 10)
=>8,9,11,12,13,15,16,17,18,19,20,21,22 (remove 7 & 14)
=>9,11,12,13,15,17,18,19,20,21,22 (remove 8 & 16)
=>11,12,13,15,17,19,20,21,22 (remove 9 & 18)
=>12,13,15,17,19,20,21 (remove 11 & 22) (OUTPUT)
</code>```

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

答:
Java 7, 210 bytes

```<code>import java.util.*;List c(int n){List<Integer>l=new ArrayList();int i=1;for(;i++<n;l.add(i));for(i=1;i++<n;)for(int x:l)if(i!=x&x%i<1&l.indexOf(i)>=0){l.remove((Integer)i);l.remove((Integer)x);break;}return l;}
</code>```

Can definitely be golfed some more by using a different approach, probably by using an array with some tricks. Due to the cast, break, typed-list and if-checks it is a bit longer than expected, but it works.

Ungolfed & test code:

Try it here.

```<code>import java.util.*;
class M{
  static List c(int n){
    List<Integer> l = new ArrayList();
    int i = 1;
    for(; i++ < n; l.add(i));
    for(i = 1; i++ < n;){
      for(int x : l){
        if(i != x & x%i < 1 & l.indexOf(i) >= 0){
          l.remove((Integer)i);
          l.remove((Integer)x);
          break;
        }
      }
    }
    return l;
  }

  public static void main(String[] a){
    System.out.println(Arrays.toString(c(2).toArray()));
    System.out.println(Arrays.toString(c(6).toArray()));
    System.out.println(Arrays.toString(c(15).toArray()));
    System.out.println(Arrays.toString(c(20).toArray()));
    System.out.println(Arrays.toString(c(22).toArray()));
  }
}
</code>```

Output:

```<code>[2]
[5]
[8, 9, 11, 12, 13, 15]
[11, 12, 13, 15, 17, 19, 20]
[12, 13, 15, 17, 19, 20, 21]
</code>```

Title: Output the ALONED numbers

Body:
Java 7, 210 bytes

import java.util.*;List c(int n){List<Integer>l=new ArrayList();int i=1;for(;i++<n;l.add(i));for(i=1;i++<n;)for(int x:l)if(i!=x&x%i<1&l.indexOf(i)>=0){l.remove((Integer)i);l.remove((Integer)x);break;}return l;}

Can definitely be golfed some more by using a different approach, probably by using an array with some tricks. Due to the cast, break, typed-list and if-checks it is a bit longer than expected, but it works.

Ungolfed & test code:

Try it here.

import java.util.*;
class M{
  static List c(int n){
    List<Integer> l = new ArrayList();
    int i = 1;
    for(; i++ < n; l.add(i));
    for(i = 1; i++ < n;){
      for(int x : l){
        if(i != x & x%i < 1 & l.indexOf(i) >= 0){
          l.remove((Integer)i);
          l.remove((Integer)x);
          break;
        }
      }
    }
    return l;
  }

  public static void main(String[] a){
    System.out.println(Arrays.toString(c(2).toArray()));
    System.out.println(Arrays.toString(c(6).toArray()));
    System.out.println(Arrays.toString(c(15).toArray()));
    System.out.println(Arrays.toString(c(20).toArray()));
    System.out.println(Arrays.toString(c(22).toArray()));
  }
}

Output:

[2]
[5]
[8, 9, 11, 12, 13, 15]
[11, 12, 13, 15, 17, 19, 20]
[12, 13, 15, 17, 19, 20, 21]


问:
Fill in the Minesweeper clues
Minesweeper is a popular puzzle game where you must discover which tiles are "mines" without clicking on those tiles. Each tile is either a mine (represented by *) or a clue, i.e. a number from 0 to 8 representing how many of the 8 neighboring tiles are mines. Your task today is to take a board containing the mines and fill in all of the clues. For example, look at the following 5x4 board, with 5 mines:

```<code> *
*  *
  *
    *
</code>```

After filling in the clues, the board will look like this:

```<code>2*211
*33*1
12*32
0112*
</code>```

Details

You must write either a full-program or a function that takes in a grid of characters containing only spaces and asterisks and outputs another grid where each space is replaced with the number of adjacent mines (asterisks). Any of these are acceptable formats for your grids:

A string with newlines in it

A 2D list of characters/single character strings

A list of strings

You can assume the grid will be at least 1x1, although it is possible for it to be all mines or all spaces.

The input grid will always be padded with the appropriate number of spaces. As usual, this is code-golf, so standard loopholes apply and the shortest answer in bytes wins!

Sample IO

So that you can see the whitespace, I will show all sample IO with brackets around it.

```<code>Input:
[    * ]
[*     ]
[      ]
[      ]
[  **  ]
[ *  * ]

Output:
[1101*1]
[*10111]
[110000]
[012210]
[12**21]
[1*33*1]

Input:
[****]
[****]

Output:
[****]
[****]

Input:
[   ]
[   ]
[   ]
[   ]

Output:
[000]
[000]
[000]
[000]

Input:
[*   ]
[**  ]
[    ]
[   *]

Ouput:
[*310]
[**10]
[2221]
[001*]

Input:
[**    ]
[*    *]
[  *   ]
[      ]
[*     ]
[****  ]

Output:
[**1011]
[*4211*]
[12*111]
[121100]
[*43210]
[****10]

Input:
[     *    ]
[        * ]
[     *    ]
[**   ***  ]
[      *** ]
[          ]
[       ** ]
[  * *     ]
[*      ** ]
[       ** ]

Output:
[00001*1111]
[00002221*1]
[22102*4321]
[**102***31]
[221013***1]
[0000013542]
[0112111**1]
[12*2*12442]
[*212112**2]
[1100002**2]
</code>```

Title: Fill in the Minesweeper clues

Body:
R, <s>127</s> 112 bytes

function(M){a=nrow(M);for(i in seq(M))if(M[i]!="*")M[i]=sum(M[pmax(i+c(-1,1,-a+-1:1,a+-1:1),0)]=="*",na.rm=T);M}

thanks to @gtwebb and @sebastian-c for improvements.

Notable points:

Matrices are vectors in R. You don't need 2-D indexing to get elements out.

seq(M) will return a sequence of the same "length" (rows x columns) as M.

You can't mix positive and negative extraction indices in R. M[-3] is legitimate R code, but not what is desired.

Input is in the form of an R matrix. Some examples:

> M <- matrix("",5,5)
> M[3,3] <- "*"
> f(M)
     [,1] [,2] [,3] [,4] [,5]
[1,] "0"  "0"  "0"  "0"  "0"
[2,] "0"  "1"  "1"  "1"  "0"
[3,] "0"  "1"  "*"  "1"  "0"
[4,] "0"  "1"  "1"  "1"  "0"
[5,] "0"  "0"  "0"  "0"  "0"
> M[2,2] <- "*"
> f(M)
     [,1] [,2] [,3] [,4] [,5]
[1,] "1"  "1"  "1"  "0"  "0"
[2,] "1"  "*"  "2"  "1"  "0"
[3,] "1"  "2"  "*"  "1"  "0"
[4,] "0"  "1"  "1"  "1"  "0"
[5,] "0"  "0"  "0"  "0"  "0"
> M[3,2] <- "*"
> f(M)
     [,1] [,2] [,3] [,4] [,5]
[1,] "1"  "1"  "1"  "0"  "0"
[2,] "2"  "*"  "3"  "1"  "0"
[3,] "2"  "*"  "*"  "1"  "0"
[4,] "1"  "2"  "2"  "1"  "0"
[5,] "0"  "0"  "0"  "0"  "0"
>


答:
Carrot, 11111

```<code>1^*4

1     //"1" is pushed into the stack
 ^    //The stack is finished
  *   //Multiply or duplicate string operator (in this case it is the latter)
   4  //Duplicate the string 5 times (4+1)
</code>```

"1" is pushed into the stack. Then the * operator duplicates the string 5 times, not 4 times because the * operator on strings always duplicates the strings 1 time more than what is stated, because duplicating it once is meaningless and hence it is removed. So the program outputs 11111.

Body:
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; }
function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; }
function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) { return a.owner.display_name; }
function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '
' + c.body.replace(OVERRIDE_REG, '') + '
'; }); var match = body.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

Body:
Carrot, 11111

1^*4

1     //"1" is pushed into the stack
 ^    //The stack is finished
  *   //Multiply or duplicate string operator (in this case it is the latter)
   4  //Duplicate the string 5 times (4+1)

"1" is pushed into the stack. Then the * operator duplicates the string 5 times, not 4 times because the * operator on strings always duplicates the strings 1 time more than what is stated, because duplicating it once is meaningless and hence it is removed. So the program outputs 11111.


问:
Let's get ready for Halloween
I don't know about you all but I'm not preparing for Halloween––never did never will––but, my neighbor is, so we'll help her out.

She needs help figuring out which brand of candy she has, but she has so much candy she would not be able to finish before Halloween.

She has:

Snickers

KitKat

Starburst

GummyBears

Twix

Input

A multiline string (or any other reasonable form) containing only letters and spaces.

Output

A falsy value if it is not a valid candy, or which candy it is if it is a candy.

How to decide which candy it is

A candy is valid if it says one of the above brands on it. However, it's not that simple, because this is a valid candy:

```<code>K i t
       K a
           t
</code>```

A valid candy is one where:

the letters are in order from left to right

the letters are capitalized correctly

the letters, going from left to right, do not both ascend and descend

the letters with whitespace removed form one of the above brands

This is code-golf, so shortest code in byte wins!

Examples

Truthys:

```<code>1.
              kers
           c
        i
       n
    S

2.
  Kit K a t

3.
St a
    r b u
         r st

4.
         Bear s
G ummy

5.
T w i
                          x
</code>```

Falsys:

```<code>1.
SNICKERS

2.
 C   n

   a   d y

3.
xiwT

4.
S C I
       ss o
              r       s

5.
Kit
Kat
</code>```

答:
R, 199 chars

```<code>function(M){if(any(outer(z<-diff(apply(M,1,function(r)which.min(r==" ")))),z<0))return(F);C=c("Twix","KitKat","Starburst","Snickers","GummyBears");C[match(paste0(gsub(" ","",c(t(M))),collapse=""),C)}
</code>```

Input is in the form of a character matrix.

match takes care of which candy it is (it checks capitalisation too).

To check that the letters are an "ascending" or "descending" sequence, we just need to check that the locations of the first non-space character (if there) in each row is increasing or decreasing. To do, this we

take the first location of a nonspace character in each row, using apply

take the diff. This might have some zero in it, otherwise should either be all positive or all negative

name the diff z, and take the outer product with itself. If the diff had mixed positive and negative entries, there will be a negative entry somewhere in its outer product. If so, return FALSE.

Note that cases like

```<code>"    i "
"   w x"
"  T   "
</code>```

will return an empty character vector (in particular not "Twix"), since match will be trying to match "Twxi".

Title: Let's get ready for Halloween

Body:
R, 199 chars

function(M){if(any(outer(z<-diff(apply(M,1,function(r)which.min(r==" ")))),z<0))return(F);C=c("Twix","KitKat","Starburst","Snickers","GummyBears");C[match(paste0(gsub(" ","",c(t(M))),collapse=""),C)}

Input is in the form of a character matrix.

match takes care of which candy it is (it checks capitalisation too).

To check that the letters are an "ascending" or "descending" sequence, we just need to check that the locations of the first non-space character (if there) in each row is increasing or decreasing. To do, this we

take the first location of a nonspace character in each row, using apply

take the diff. This might have some zero in it, otherwise should either be all positive or all negative

name the diff z, and take the outer product with itself. If the diff had mixed positive and negative entries, there will be a negative entry somewhere in its outer product. If so, return FALSE.

Note that cases like

"    i "
"   w x"
"  T   "

will return an empty character vector (in particular not "Twix"), since match will be trying to match "Twxi".