Find the generating function of a sequence Given a set of space-delimited integers, you've gotta either return a function that can generate that sequence, or return "There isn't any such function".

Sample input:

"1 11 41 79"
 - x^3+x^2-1

"12 38 78"
 - 7x^2 + 5x

The operations that the functions can contain are: +-/* and exponentiation.

If anyone has any other ideas LMK. As this is a code-golf, the shortest code will win.

Python 256 bytes

a=raw_input().split();r=range(len(a));m=[[(i+1.)**p for p in r]+[int(a[i])]for i in r]
for j in r:s=m[j];m=[map(lambda a,b:a-b*(i[j]-(i==s))/s[j],i,s)for i in m]
while~j:
 c=m[j][-1]
 if c:print('%+.15g'%c)[s>c>0:j>=c*c==1or 18]+('x^%d'%j)[:j*j],;s=0
 j-=1

Sets up a system of linear equations, matrix style, and then uses Gaussian elimination to solve. Quite a few bytes are spent pretty-printing the output. Non-integer solutions are displayed to 15 digits of accuracy.

As every sequence of n real numbers can be generated by a polynomial of order no more than n-1, the "function does not exist" case is not handled.

Sample usage:

$ echo 1 11 41 79 | python find-poly.py
-2x^3 +22x^2 -42x +23

$ echo 1 11 35 79 | python find-poly.py
x^3 +x^2 -1

$ echo 12 38 78 | python find-poly.py
7x^2 +5x

$ echo 43 12 -5 19 57 | python find-poly.py
-2.25x^4 +27x^3 -98.75x^2 +110x +7


Reading Code in 8 Ways to Output 8 Numbers The English language and most programming languages are written and read from left-to-right, top-to-bottom, but that needn't be the case.
In fact for the block of text
ABC
DEF

I can think of eight related ways it might be read:

Left-to-right, top-to-bottom (LTR-TTB): ABCDEF
Top-to-bottom, left-to-right (TTB-LTR): ADBECF
Left-to-right, bottom-to-top (LTR-BTT): DEFABC
Bottom-to-top, left-to-right (BTT-LTR): DAEBFC
Right-to-left, top-to-bottom (RTL-TTB): CBAFED
Top-to-bottom, right-to-left (TTB-RTL): CFBEAD
Right-to-left, bottom-to-top (RTL-BTT): FEDCBA
Bottom-to-top, right-to-left (BTT-RTL): FCEBDA

Challenge
Write a rectangular block of text that can be read in each of the eight ways above as eight single line programs in your language of choice. Each of these programs should output a different integer from one to eight.
It doesn't matter which reading direction outputs which number, they do not have to match the numbers above. For example, if your text block were still
ABC
DEF

then the program ABCDEF might output 5 and FEDCBA might output 2, and the other six programs would output 1, 3, 4, 6, 7, and 8 in some order.
The text block may contain any characters except line terminators.
Output should go to stdout or a similar alternative if your language doesn't have a proper stdout. There is no input. You may assume the programs are run in a REPL environment.
Pietu1998 charitably wrote a JSFiddle that gives the 8 different single line programs when given a block of text. I've made it into a stack snippet:

<textarea onkeyup="f(this.value)" id="c" placeholder="Code"></textarea>
<input type="checkbox" id="b" onchange="f(document.getElementById('c').value)" checked/>&nbsp;Show directions

You can still find Martin's CJam version here.
Scoring
Your score is the area of your block of text (the width times the height). The submission with the lowest score wins. (Essentially the smallest code wins, hence the code-golf tag.) Tiebreaker goes to the earlier posted submission.
The example is 2 by 3 so its score is 6. A score less than 4 (2 by 2) is impossible because then some of the 8 programs would be identical and couldn't output two different values.

J, 3 * 3 = 9

1[2
+2+
2+2

Executing all directions:

       ". '1[2+2+2+2','2+2+2+1[2','1+2[2+2+2','2+2[2+1+2','2+2+2+2[1','2[1+2+2+2','2+2+2[2+1',:'2+1+2[2+2'
1 7 3 4 8 2 6 5

Explanation:

In J execution goes from right to left and there is no operator precedence.
The [ (left) takes the left side of its two operand so it essentially cancels the whole right side of our expression e.g. 1+2[2+2+2 becomes 1+2[6 and then 1+2.
The left expressions are additions with a total of 1, 2, 3 and 4 operands. There are two of each n-operand expressions one with the number 1 and one with only 2s. The additions with 1 generate the odd numbers and the others generate the even ones.


Code-Golf: Count Islands A simple contest, inspired by this stackoverflow question:

  You are given an image of a surface photographed by a satellite.The image is a bitmap where water is marked by '.' and land is marked by '*'. Groups of adjacent '*'s form an island. (Two '*' are adjacent if they are horizontal, vertical or diagonal neighbours). Your task is to print the number of islands in the bitmap.

A single * also counts as an island.

Sample Input:

.........**
**......***
...........
...*.......
*........*.
*.........*

Sample Output:

5

Winner is entry with smallest number of bytes in the code.

Mathematica 188 185 170 115 130 46 48 chars
Explanation
In earlier versions, I made a graph of positions having a chessboard distance of 1 from each other.  GraphComponents then revealed the number of islands, one per component.
The present version uses MorphologicalComponents to find and number clusters of ones in the array--regions where 1's are physically contiguous. Because graphing is unnecessary, this results in a huge economy of code.

Code
Max@MorphologicalComponents[#/.{"."->0,"*"->1}]&

Example
Max@MorphologicalComponents[#/.{"."->0,"*"->1}]&[{{".", ".", ".", ".", ".", ".", ".", ".", ".", "*", "*"}, {"*", "*", ".", ".", ".", ".", ".", ".", "*", "*", "*"}, {".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "."}, {".", ".", ".", "*", ".", ".", ".", ".", ".", ".", "."}, {"*", ".", ".", ".", ".", ".", ".", ".", ".", "*", "."}, {"*", ".", ".", ".", ".", ".", ".", ".", ".", ".", "*"}}]

5

How it works
Data are input as an array; in Mathematica, this is a list of lists.
In the input array, data are converted to 1's and 0's by the replacement
/.{"."->0,"*"->1}

where /. is an infix form of ReplaceAll followed by replacement rules. This essentially converts the array into a black and white image.  All we need to do is apply the function, Image.
Image[{{".", ".", ".", ".", ".", ".", ".", ".", ".", "*", "*"}, {"*", "*", ".", ".", ".", ".", ".", ".", "*", "*", "*"}, {".", ".", ".", ".", ".", ".", ".", ".", ".", ".", "."}, {".", ".", ".", "*", ".", ".", ".", ".", ".", ".", "."}, {"*", ".", ".", ".", ".", ".", ".", ".", ".", "*", "."}, {"*", ".", ".", ".", ".", ".", ".", ".", ".", ".", "*"}} /. {"." -> 0, "*" -> 1}]

The white squares correspond to the cells having the value, 1.
The picture below shows a some steps the approach uses. The input matrix contains only 1's and 0's.   The output matrix labels each morphological cluster with a number.  (I wrapped both the input and output matrices in MatrixForm to highlight their two dimensional structure.)
MorphologicalComponents replaces 1s with an integer corresponding to the cluster number of each cell.

Max returns the largest cluster number.

Displaying the Islands
Colorize will color each island uniquely.


Alphabet completion rate Introduction
How much of the English alphabet does a given string use? The previous sentence uses 77%. It has 20 unique letters (howmucftenglisapbdvr), and 20/26 ≃ 0.77.
Challenge
For an input string, return the percentage of letters of the English alphabet present in the string.

The answer can be in percentage or in decimal form.

The input string can have upper and lower case, as well as punctuation. However you can assume they have no diacritics or accentuated characters.

Test cases
Input
"Did you put your name in the Goblet of Fire, Harry?" he asked calmly.

Some valid outputs
77%, 76.9, 0.7692

Input:
The quick brown fox jumps over the lazy dog

All valid outputs:
100%, 100, 1

The expected output for "@#$%^&*?!" and "" is 0.

Python 3, 42 bytes

lambda s:len({*s.upper()}-{*s.lower()})/26

Try it online!

We filter all the non-alphabetic characters out of the string by taking the (set) difference of the uppercase and lowercase representations. Then, we take the length and divide by 26.

Python 3, 46 bytes

lambda s:sum(map(str.isalpha,{*s.lower()}))/26

Try it online!

Count the unique alphabetic (lowercase) characters, and divide by 26. In Python 2 it would require 3 more characters; two for changing {*...} to set(...), and one for making 26 a float: 26., to avoid floor division.

Python 3, 46 bytes

lambda s:sum('`'<c<'{'for c in{*s.lower()})/26

Try it online!

Same length, essentially the same as the previous one, but without "built-in" string method.


Is there a face in this image? Help, I've been diagnosed with prosopagnosia! This means I'm no longer able to recognise faces.... :(
Can you help me?
The challenge
You will be given an image as a matrix of regular ASCII characters separated by new line characters, and your task is to determine if it contains a face. Faces will look something like the following:
o.o
.7.
___

Of course, people all look different - the only features that virtually everyone has are two eyes, a nose, and a mouth. For this challenge, eyes will be a lower-case o, a nose will be a 7, and the mouth will be a line of underscores _. For this challenge, faces must have all of these features.
To be specific, a face must have two eyes in the same row of the matrix, with a nose centred horizontally between them somewhere between the rows with the eyes and the mouth, and a mouth at the bottom of the face that is a row of underscores that extends all the way from the column of one eye to the other. Since a face must have a horizontally-centred nose, all faces must be an odd number of characters wide. Please note: The nose does not have to be centred vertically so long as it is between the rows of the eyes and mouth (exclusive). No other features of the face matter so long as the face has only two eyes, one nose, and one mouth - the "fill" of the face can be anything but the characters o, 7, or _
The output format is flexible - all you must be able to do is distinguish whether the image from the input has a face. You may use any output values to represent whether an image has a face (e.g. 1 if it does, 0 if it does not)
Examples/Test Cases
...o.....o.
......7....
..._______.

^ contains a face
...o.....o.o.o
......7.....7.
..._______.___

^ contains a face (actually contains two but your program does not need to care about any additional faces)
o.o...o..o
o.7.7._.7.
.._____7__

^ does not contain a face
o.o...o..o
o...7...7.
.._____7__

^ contains a face (notice the two differences between this case and the one above)
o...o
.7...
_____

^ does not contain a face, as the nose is not centred horizontally
..o...o
.......
.......
.......
....7..
.______

^ contains a face formed by the last five columns
,/o[]8o
o198yH3
f_3j`~9
()**&#^
*#&^79%
2______

^ contains a face (the last five columns form a face just like in the previous example, except with different filler characters that make it less human-readable)
o..o.o..o.o...o..o.o.o..o...o.o.o.o.o
......7....o7......7......7......7...
..7...............___......7....___..
____.____.___._.._____.._____._______

^ contains a face (only the 3x3 face in the fifth-last through third-last columns is a face - all the other potential faces break one or more rules)
.....
.o.o.
..7..
.....
.___.

^ contains a face
o7o
...
___

^ does not contain a face
A few extra clarifications
-Faces will never be rotated
-The .'s in the test cases could be any regular ASCII characters other than the three special characters, they are periods just for better readability
-You can assume all matrices will be smaller than 100 x 100
Scoring
This is code-golf. Shortest code wins!

JavaScript (ES6),  147 ... 140  139 bytes
Returns either false or a truthy value.
s=>(p='',g=k=>s.replace(/[^7o_]/g,0).match(`o${p}${p+=0}o${S=`.{${w=s.search`
`-k}}(0${p+p}.{${w}})*`}${p+7+p+S}__{${k}}`)||w>0&&g(k+2))(2)

Try it online!
How?
We start with \$k=2\$ and \$p\$ set to an empty string.
At each iteration, we first replace all characters in the input string \$s\$ other than "o", "7" or "_" with zeros. This includes linefeeds. So the first test case:
...o.....o.
......7....
..._______.

is turned into:
flat representation: "...o.....o.¶......7....¶..._______."
after replace()    : "000o00000o00000000700000000_______0"

We then attempt to match the 3 parts of a face of width \$k+1\$.
Eyes
An "o" followed by \$k-1\$ zeros, followed by another "o":
`o${p}${p+=0}o`

Followed by the padding string \$S\$ defined as:
`.{${w=s.search('\n')-k}}(0${p+p}.{${w}})*`
 \______________________/ \____________/ |
   right / left padding      k+1 zeros   +--> repeated any
                          + same padding      number of times

Nose
\$k/2\$ zeros, followed by a "7", followed by \$k/2\$ zeros, followed by the same padding string \$S\$ as above:
`${p+7+p+S}`

Mouth
\$k+1\$ underscores:
`__{${k}}`

In case of failure, we try again with \$k+2\$. Or we stop as soon as the variable \$w\$ used to build \$S\$ is less than \$1\$, meaning that the padding string would become inconsistent at the next iteration.
For the first test case, we successively get the following patterns:
o0o.{9}(000.{9})*070.{9}(000.{9})*__{2}
o000o.{7}(00000.{7})*00700.{7}(00000.{7})*__{4}
o00000o.{5}(0000000.{5})*0007000.{5}(0000000.{5})*__{6}

The 3rd one is a match.


Find the positive divisors! Definition
A number is positive if it is greater than zero.
A number (A) is the divisor of another number (B) if A can divide B with no remainder.
For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder.
Goal
Your task is to write a program/function that takes a positive number and then find all of its divisors.
Restriction

You may not use any built-in related to prime or factorization.
The complexity of your algorithm must not exceed O(sqrt(n)).

Freedom

The output list may contain duplicates.
The output list does not need to be sorted.

Scoring
This is code-golf. Shortest solution in bytes wins.
Testcases
input    output
1        1
2        1,2
6        1,2,3,6
9        1,3,9

PostgreSQL, 176 bytes
WITH c AS(SELECT * FROM(SELECT 6v)t,generate_series(1,sqrt(v)::int)s(r)WHERE v%r=0)
SELECT string_agg(r::text,',' ORDER BY r)
FROM(SELECT r FROM c UNION SELECT v/r FROM c)s

SqlFiddleDemo
Input:  (SELECT ...v)
How it works:

(SELECT ...v) - input
generate_series(1, sqrt(v)::int) - numbers from 1 to sqrt(n)
WHERE v%r=0 -filter divisors
wrap with common table expression to refer twice
SELECT r FROM c UNION SELECT v/r FROM c generete rest of divisors and combine
SELECT string_agg(r::text,',' ORDER BY r) produce final comma separated result

Input as table:
WITH c AS(SELECT * FROM i,generate_series(1,sqrt(v)::int)s(r)WHERE v%r=0)
SELECT v,string_agg(r::text,',' ORDER BY r)
FROM(SELECT v,r FROM c UNION SELECT v,v/r FROM c)s
GROUP BY v

SqlFiddleDemo
Output:
╔═════╦════════════════╗
║ v   ║   string_agg   ║
╠═════╬════════════════╣
║  1  ║ 1              ║
║  2  ║ 1,2            ║
║  6  ║ 1,2,3,6        ║
║  9  ║ 1,3,9          ║
║ 99  ║ 1,3,9,11,33,99 ║
╚═════╩════════════════╝


First occurrence in the Sixers sequence The Sixers sequence is a name that can be given to sequence A087409. I learned about this sequence in a Numberphile video, and it can be constructed as follows:
First, take the multiples of 6, written in base 10:
6, 12, 18, 24, 30, 36, ...
Next, concatenate the numbers into a stream of digits:
61218243036...
Finally, regroup the stream into pairs and interpret each as an integer:
61, 21, 82, 43, 3, ...
As we're grouping the numbers into pairs, the maximum number in the sequence will be 99, and it turns out that all non-negative integers less than 100 are represented in the sequence. This challenge is to find the index of the first instance of a number in the Sixers sequence.
Input
An integer in the range [0-99]. You do not need to account for numbers outside this range, and your solution can have any behaviour if such an input is given.
Output
The index of the first occurrence of the input number in the Sixers sequence. This may be 0- or 1-indexed; please say which you are using in your answer.
Rules

The procedure to generate the sequence noted in the introduction is for illustrative purposes only, you can use any method you like as long as the results are the same.
You can submit full programs or functions.
Any sensible methods of input and output are allowed.
Standard loopholes are disallowed.
Links to test your code online are recommended!
This is code-golf, so shortest answer in each language wins!

Test cases
Here is a list of all input and outputs, in the format input, 0-indexed output, 1-indexed output.
0   241 242
1   21  22
2   16  17
3   4   5
4   96  97
5   126 127
6   9   10
7   171 172
8   201 202
9   14  15
10  17  18
11  277 278
12  20  21
13  23  24
14  19  20
15  29  30
16  32  33
17  297 298
18  35  36
19  38  39
20  41  42
21  1   2
22  46  47
23  69  70
24  6   7
25  53  54
26  22  23
27  11  12
28  62  63
29  219 220
30  65  66
31  68  69
32  71  72
33  74  75
34  49  50
35  357 358
36  80  81
37  83  84
38  25  26
39  89  90
40  92  93
41  27  28
42  42  43
43  3   4
44  101 102
45  104 105
46  8   9
47  177 178
48  110 111
49  13  14
50  28  29
51  119 120
52  122 123
53  417 418
54  79  80
55  128 129
56  131 132
57  134 135
58  55  56
59  437 438
60  140 141
61  0   1
62  31  32
63  75  76
64  5   6
65  120 121
66  82  83
67  10  11
68  161 162
69  164 165
70  58  59
71  477 478
72  170 171
73  173 174
74  34  35
75  179 180
76  182 183
77  497 498
78  85  86
79  188 189
80  191 192
81  18  19
82  2   3
83  78  79
84  93  94
85  7   8
86  37  38
87  168 169
88  12  13
89  228 229
90  88  89
91  218 219
92  221 222
93  224 225
94  64  65
95  557 558
96  230 231
97  233 234
98  40  41
99  239 240

JavaScript (ES6),  71 65  55 bytes

Output is 0-indexed.

n=>(g=([a,b,...c])=>b?a+b-n&&1+g(c):g([a]+6*++i))(i='')

Try it online!

How?

Using a recursive function, we either 'consume' the first 2 characters of the string of concatenated multiples of \$6\$, or append new characters if we have less than 2 of them.

Example for \$n=3\$:

 string | operation                          | result
--------+------------------------------------+--------
 ''     | not enough characters: append '6'  |   0
 '6'    | not enough characters: append '12' |   0
 '612'  | consume '61', increment the result |   1
 '2'    | not enough characters: append '18' |   1
 '218'  | consume '21', increment the result |   2
 '8'    | not enough characters: append '24' |   2
 '824'  | consume '82', increment the result |   3
 '4'    | not enough characters: append '30' |   3
 '430'  | consume '43', increment the result |   4
 '0'    | not enough characters: append '36' |   4
 '036'  | consume '03': success              |   4

Commented

n => (             // n = input
  g = (            // g is a recursive function taking either a string or an array of
                   // characters split into:
    [a, b,         //   a = 1st character, b = 2nd character,
           ...c]   //   c[] = array of all remaining characters
  ) =>             //
    b ?            // if b is defined:
      a + b - n && //   if n subtracted from the concatenation of a and b is not zero:
        1 + g(c)   //     add 1 to the final result and do a recursive call with c[]
                   //   (otherwise: yield 0 and stop recursion)
    :              // else:
      g(           //   do a recursive call with:
        [a] +      //     the concatenation of a (forced to an empty string if undefined)
        6 * ++i    //     and 6 * i, with i pre-incremented
      )            //   end of recursive call
)(i = '')          // initial call to g with an empty string,
                   // and i set to empty string as well (zero'ish)


Count characters, turn them into a cipher Problem:

You must make a program that does the following:

takes a large string of lowercase text, and counts all the occurrences of each letter.
then you put the letters in order from greatest to least occurences.
then you take that list and turns it into an encoder/decoder for the text.
then encodes the text with that cipher.

Hard to understand? See this example:

Example:

Input text:

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum.

Convert to lowercase.

Char count (per letter. spaces and punctuation ignored):

  [('a', 49), ('b', 11), ('c', 34), ('d', 22), ('e', 93), ('f', 9), ('g', 10), ('h', 3), ('i', 89), ('j', 1), ('k', 0), ('l', 61), ('m', 31), ('n', 56), ('o', 37), ('p', 20), ('q', 12), ('r', 47), ('s', 71), ('t', 59), ('u', 65), ('v', 15), ('w', 0), ('x', 0), ('y', 0), ('z', 0)]

Ordered char count:

  [('e', 93), ('i', 89), ('s', 71), ('u', 65), ('l', 61), ('t', 59), ('n', 56), ('a', 49), ('r', 47), ('o', 37), ('c', 34), ('m', 31), ('d', 22), ('p', 20), ('v', 15), ('q', 12), ('b', 11), ('g', 10), ('f', 9), ('h', 3), ('j', 1), ('k', 0), ('w', 0), ('x', 0), ('y', 0), ('z', 0)]

Then create a lookup table using the original and sorted lists:

abcdefghijklmnopqrstuvwxyz
||||||||||||||||||||||||||
eisultnarocmdpvqbgfhjkwxyz

Python dictionary:

{'o': 'v', 'n': 'p', 'm': 'd', 'l': 'm', 'k': 'c', 'j': 'o', 'i': 'r', 'h': 'a', 'g': 'n', 'f': 't', 'e': 'l', 'd': 'u', 'c': 's', 'b': 'i', 'a': 'e', 'z': 'z', 'y': 'y', 'x': 'x', 'w': 'w', 'v': 'k', 'u': 'j', 't': 'h', 's': 'f', 'r': 'g', 'q': 'b', 'p': 'q'}

And now encode the original text with this lookup table:

  'Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl klm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl krklgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp klmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl klm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, klm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, krklgge kegrjf plbjl dehhrf rp. Iphlnlg qvghe klfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph klm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl klm ephl qjmkrpeg dvmmrf lj rp rqfjd.'

I love python!

Rules:

Your program will accept a string and output one.
Convert all input to lowercase before doing anything
I don't care how you do the list sorting, but only count lowercase letters
Bonus points (-30) for making a decryptor (no copying the decryption list, do it from scratch
This is code-golf, so the shortest code wins!
Have fun!

Bash/coreutils, 91 chars
tr a-z `echo {a..z} $1|fold -w1|grep '[a-z]'|sort|uniq -c|sort -rn|awk '{printf $2}'`<<<$1

Save as cipher.sh, chmod +x it and run:
$ ./cipher.sh "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum."
Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl jlm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl jrjlgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp jlmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl jlm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, jlm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, jrjlgge jegrjf plbjl dehhrf rp. Iphlnlg qvghe jlfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph jlm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl jlm ephl qjmjrpeg dvmmrf lj rp rqfjd.
$


Binary Run-Length Encoding Overview

  Run-length encoding — sequences in which the same data value occurs in many consecutive data elements are stored as a single data value and count

When using run-length encoding:

Input:  ABBBCCACB
Output: 1A3B2C1A1C1B

This sample has an output that is larger than the input.

Instead, it can be simplified for binary inputs by removing the data value in the result,

Input:  10001110101
Output: 1331111

which is significantly smaller. This works because, logically, if the there is a "next subset" then it must be of a different data value than the current subset. Since there are only two possible values (1 and 0), you always know the "next" data value subset.

Challenge

Implement binary run-length encoding demonstrated above.

Take input through STDIN or suitable alternative.
Output to STDOUT or suitable alternative.

Examples

In:  101011101011000011
Out: 11113111242

In:  01001010001
Out: 11211131

In:  000000000
Out: 9

You may assume that no subsets will be longer than 9 characters (there won't be 10 adjacent zeroes).


Case Matching Find Replace Take three inputs, a string of text, T; a string of characters to replace, F; and a string of characters to replace them with, R. For each substring of T with the same (case insensitive) characters as F, replace them with the characters in R. However, keep the same case as the original text.

If there are more characters in R than F, the extra characters should be the same case as they are in R. If there are numbers or symbols in F, then the corresponding characters in R should keep the case they have in R. F will not necessarily appear in T.

You can assume all text will be in the printable ASCII range.

Examples

"Text input", "text", "test" -> "Test input"

"tHiS Is a PiEcE oF tExT", "is", "abcde" -> "tHaBcde Abcde a PiEcE oF tExT"

"The birch canoe slid on the smooth planks", "o", " OH MY " -> "The birch can OH MY e slid  OH MY n the sm OH MY  OH MY th planks"

"The score was 10 to 5", "10", "tEn" -> "The score was tEn to 5"

"I wrote my code in Brain$#@!", "$#@!", "Friend" -> "I wrote my code in BrainFriend"

"This challenge was created by Andrew Piliser", "Andrew Piliser", "Martin Ender" -> "This challenge was created by Martin Ender"

// Has a match, but does not match case
"John does not know", "John Doe", "Jane Doe" -> "Jane does not know"

// No match
"Glue the sheet to the dark blue background", "Glue the sheet to the dark-blue background", "foo" -> "Glue the sheet to the dark blue background"

// Only take full matches
"aaa", "aa", "b" -> "ba"

// Apply matching once across the string as a whole, do not iterate on replaced text
"aaaa", "aa", "a" -> "aa"

"TeXT input", "text", "test" -> "TeST input"

Sandbox link

APL (Dyalog), 75 73 72 bytes

Prompts for T, R, and F in that order. R must b given in Dyalog transformation format and F must be given in PCRE format.

⍞⎕R(⍞∘{(⊣⌿d)l¨⍨(1∘⌷≠(⊢⌿d∊⎕A,l⎕A)∧≠⌿)d≠(l←819⌶)d←↑⍺⍵.Match↑¨⍨≢⍺})⍠1⊢⍞

Try it online!

⍞ prompt for T

⊢ yield that (separates 1 and T)

⍞⎕R(…)⍠1 prompt for F and Replace matches with the result of the following function:

 ⍞∘{…} derive a monadic function by tying the prompted-for R as left argument to:

  ≢⍺ count the number of letters in R

  ⍺⍵.Match↑¨⍨ take that many letters from each of R and the match
   ⍺ is the left argument, which we tied R as.
   ⍵ is a namespace in which Match contains the currently found string.

  ↑ mix those two into a two-row matrix

  d← store as d

  (…)  apply the following tacit function to that:

   819⌶ lowercase (mnemonic: 819 looks like Big)

   l← store that function as as l

  d≠ Boolean where d differs (i.e. gives 0/1 for each lowercase/uppercase letter)

  (…) apply the following tacit function to that:

   ≠⌿ vertical XOR

   (…)∧ Boolean AND with the following array:

    l⎕A lowercased Alphabet

    ⎕A, prepend uppercase Alphabet

    d∊ Boolean for each letter in d whether a member of that (i.e. whether a letter)

    ⊢⌿ last row i.e. for character of the match whether it is a letter

   1∘⌷≠ XOR with the first row, i.e. whether each character of R is uppercase

  (…)l¨⍨ use that to lowercase (if 0) or uppercase (if 1) each letter of:

   ⊣⌿ the first row, i.e. R

* Byte count for Dyalog Classic using ⎕OPT  instead of ⍠.


99 Varieties of Dosa 99 Varieties of Dosa is a popular chain of roadside dosa stalls across South India. This is inspired by a combination of this chain and the classic CodeGolf challenge "99 Bottles of Beer".

Recreate the variant of the menu of the popular '99 Varieties of Dosa' listed below.

(Note: Despite the name, the list contains 103 varieties and not exactly 99)

The desired output is the following list (in any order):

Sada Dosa
Cheese Sada Dosa
Paneer Sada Dosa
Paneer Cheese Sada Dosa
Schezwan Sada Dosa
Cheese Schezwan Sada Dosa
Paneer Schezwan Sada Dosa
Paneer Cheese Schezwan Sada Dosa
Onion Sada Dosa
Cheese Onion Sada Dosa
Paneer Onion Sada Dosa
Paneer Cheese Onion Sada Dosa
Chutney Dosa
Cheese Chutney Dosa
Paneer Chutney Dosa
Paneer Cheese Chutney Dosa
Tomato Onion Dosa
Cheese Tomato Onion Dosa
Paneer Tomato Onion Dosa
Paneer Cheese Tomato Onion Dosa
Schezwan Onion Dosa
Cheese Schezwan Onion Dosa
Paneer Schezwan Onion Dosa
Paneer Cheese Schezwan Onion Dosa
Jain Dosa
Jain Cheese Dosa
Jain Paneer Dosa
Jain Paneer Cheese Dosa
Masala Dosa
Cheese Masala Dosa
Paneer Masala Dosa
Paneer Cheese Masala Dosa
Onion Masala Dosa
Onion Paneer Masala Dosa
Cheese Onion Masala Dosa
Paneer Cheese Onion Masala Dosa
Schezwan Masala Dosa
Cheese Schezwan Masala Dosa
Paneer Schezwan Masala Dosa
Paneer Cheese Schezwan Masala Dosa
Mysore Masala Dosa
Paneer Mysore Masala Dosa
Cheese Mysore Masala Dosa
Paneer Cheese Mysore Masala Dosa
Paneer Cheese Schezwan Mysore Masala Dosa
Kerala Dosa
Kerala Cheese Dosa
Paneer Kerala Dosa
Paneer Cheese Kerala Dosa
Pav Bhaji Dosa
Pav Bhaji Cheese Dosa
Pav Bhaji Paneer Dosa
Pav Bhaji Cheese Paneer Dosa
Spring Vegetable Dosa
Spring Paneer Vegetable Dosa
Spring Cheese Vegetable Dosa
Spring Paneer Cheese Vegetable Dosa
Sweet Corn Dosa
Sweet Corn Cheese Dosa
Sweet Corn Paneer Dosa
Sweet Corn Paneer Cheese Dosa
Sweet Corn Schezwan Dosa
Sweet Corn Schezwan Paneer Dosa
Sweet Corn Schezwan Cheese Dosa
Sweet Corn Schezwan Paneer Cheese Dosa
Sweet Corn Mushroom Dosa
Sweet Corn Mushroom Paneer Dosa
Sweet Corn Mushroom Cheese Dosa
Sweet Corn Mushroom Paneer Cheese Dosa
Mushroom Dosa
Mushroom Cheese Dosa
Mushroom Paneer Dosa
Mushroom Paneer Cheese Dosa
Schezwan Mushroom Dosa
Schezwan Mushroom Paneer Dosa
Schezwan Mushroom Cheese Dosa
Schezwan Corn Mushroom Paneer Cheese Dosa
Paneer Chilli Dosa
Paneer Chilli Cheese Dosa
Mushroom Chilli Dosa
Mushroom Chilli Cheese Dosa
Mushroom Chilli Paneer Dosa
Mushroom Chilli Paneer Cheese Dosa
Sada Uttappam Dosa
Sada Uttappam Cheese Dosa
Sada Uttappam Paneer Dosa
Sada Uttappam Paneer Cheese Dosa
Onion Uttappam Dosa
Onion Uttappam Cheese Dosa
Onion Uttappam Paneer Dosa
Onion Uttappam Paneer Cheese Dosa
Masala Uttappam Dosa
Masala Uttappam Cheese Dosa
Masala Uttappam Paneer Dosa
Masala Uttappam Paneer Cheese Dosa
Mysore Uttappam Dosa
Mysore Uttappam Cheese Dosa
Mysore Uttappam Paneer Dosa
Mysore Uttappam Paneer Cheese Dosa
Mixed Uttappam Dosa
Mixed Uttappam Cheese Dosa
Mixed Uttappam Paneer Dosa
Mixed Uttappam Paneer Cheese Dosa

Python 2, 503 496 487 485 479 476 bytes

for l in[a+'86'[i<2:1+i%2][::2*('v'in a)-1]+b for i in(0,1,2,3)for a,b in[l.split('~')for l in('~11~'[i<2::2]+'0|Spring ~Vegetable |73~|13~|03~|:3~|Mixed 3~|~7|~27|~17|;4~|;42~|;45~|~Tomato 1|~21|~Chutney |2'+'45~|~20|~:0|~0|Jain ~|Pav Bhaji ~|5~|59~|'[i<3:]+'<~~<'[i%2::2]).split('|')]]+['682:0','69','698']:
 for i in range(13):l=l.replace(chr(48+i),'Masala Onion Schezwan Uttappam Corn Mushroom Paneer Sada Cheese Chilli Mysore Sweet Kerala'.split()[i]+' ')
 print l+'Dosa'

Try it online!

Every dosa is of the form a [Paneer, Cheese] b Dosa

Each dosa is then encoded in a list of tuples of (a,b). There are many dosa where a or b is empty.

For each of these tuples, every combination of Paneerand Cheese is added in between them.

.. '86'[i<2:1+i%2] .. for i in(0,1,2,3) ..

The few special cases which are slightly different are:

Kerala Dosa, Kerala Cheese Dosa vs Paneer Kerala Dosa, Paneer Cheese Kerala Dosa

Kerala is moved from a to b if we have Paneer
.. '<~~<'[i%2::2] .. which gives ['Kerala',''] or ['','Kerala']

Schezwan Corn Mushroom Paneer Cheese Dosa

Corn is inserted if we have Paneer Cheese
.. '4..'[i<3:] ..

Onion Masala Dosa, Onion Paneer Masala Dosa vs Cheese Onion Masala Dosa, Paneer Cheese Onion Masala Dosa

Onion is moved from a to b if we have Cheese
.. '~11~'[i<2::2] .., similar to Kerala above

Pav Bhaji Cheese Paneer Dosa

Paneer and Cheese are swapped if a is Pav Bhaji
.. '86'[i<2:1+i%2][::2*('v'in a)-1] ..

Paneer Cheese Schezwan Mysore Masala,Paneer Chilli,Paneer Chilli Cheese

These are too different to account for, and are just added to the list at the end.
.. +['682:0','69','698']

At the end, the numbers are replaced with the correct words:

0123456789:;< -> Masala Onion Schezwan Uttappam Corn Mushroom Paneer Sada Cheese Chilli Mysore Sweet Kerala


Tips for golfing in Smalltalk What general tips do you have for golfing in Smalltalk? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Smalltalk (e.g. "remove comments" is not an answer).

   Smalltalk is a purely object-oriented language created by Alan Kay. The two links are GNU Smalltalk and a general Smalltalk page respectively. You do not have to pay attention on this "spoiler".

Use the ; operator to refer to the previous object

There is a convenient shorthand in Smalltalk used to refer to the previous object. Say we want to add 3 items to the set x.

x:=Set new
x add:5.x add:7.x add:'foo'

However, we can save a few bytes by using the ; operator:

x:=Set new
x add:5;add:7;add:'foo'


Chuck Norris vs Travelling Salesman Introduction

Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle which is to say the shortest path that visits each city and comes full-circle back to the start. That is not what this challenge is about. This challenge is to implement Chuck Norris' solution to the TSP:

  Chuck Norris solved the Travelling Salesman problem in O(1) time: break salesman into N pieces; kick each piece to a different city.

Challenge

In order to solve the TSP in this way, we need a sufficiently durable Salesman that won't shy away from frivolities like dismemberment; a number of cities to visit; a set of products to sell; a concrete method for dismemberment; and a calculation for scoring.

Specification

Cities

N is the number of cites our Salesman will visit

Salesman

The main program or function
Written in language X
With length mod N equal to 0

Products

The full names of the elements on the Periodic Table
This includes the newly accepted names of elements

Dismemberment

Slicing the Salesman into N continuous pieces of equal length
Each piece is should be a valid function or program in language X

Output

When executed the Salesman should output Chuck Norris and the sliced pieces should each output a distinct product
Only extra trailing white space is acceptable

Scoring

The length, L, of the Salesman in bytes divided by the number of cities, N, squared.
Score = L/(N*N)
Smallest score wins
Please include 3 significant figures when posting your decimal score

Examples

This Salesman visits 3 cities so N=3 and and it has a length of 9 so L=9. Thus the score for this answer would be S = 9 / (3 * 3) = 9/9 = 1.

Note that the Salesman and each sliced piece (of which there are 3), should all be valid programs or functions in the same language.

Program      -> Output
-------         ------
aaaBBBccc    -> Chuck Norris

aaa          -> Helium
BBB          -> Iridium
ccc          -> Tennessine

N=4 and L=20 so S=20/16=1.25

Program                 -> Output
-------                    ------
aaaaaBBBBBcccccDDDDD    -> Chuck Norris

aaaaa                   -> Hydrogen
BBBBB                   -> Cadmium
ccccc                   -> Mercury
DDDDD                   -> Iron

CJam, L = 1482, N = 114, score 0.114

'C:L"arbon"  L'h+:L;"Gold"L'u+:L;"Iron"L'c+:L;"Lead"L'k+:L;"Neon"LS+:L;"Argon"L'N+:L"ickel"L'o+:L;"Zinc""Coppe"L'r+:L"Silve"L'r+:LL'i+:L;"Tin" "Boron"      "Radon"      "Barium"     "Cerium"     "Cesium"     "Cobalt"     "Curium"     "Erbium"     "Helium"     "Indium"     "Iodine"     "Osmium"     "Oxygen"     "Radium"     "Sodium"     "Sulfur"     "Arsenic"    "Bismuth"    "Bohrium"    "Bromine"    "Cadmium"    "Calcium"    "Dubnium"    "Fermium"    "Gallium"    "Hafnium"    "Hassium"    "Holmium"    "Iridium"    "Krypton"    "Lithium"    "Mercury"    "Niobium"    "Rhenium"    "Rhodium"    "Silicon"    "Terbium"    "Thorium"    "Thulium"    "Uranium"    "Yttrium"    "Actinium"   "Aluminum"   "Antimony"   "Astatine"   "Chlorine"   "Chromium"   "Europium"   "Fluorine"   "Francium"   "Hydrogen"   "Lutetium"   "Nihonium"   "Nitrogen"   "Nobelium"   "Platinum"   "Polonium"   "Rubidium"   "Samarium"   "Scandium"   "Selenium"   "Tantalum"   "Thallium"   "Titanium"   "Tungsten"   "Vanadium"   "Americium"  "Berkelium"  "Beryllium"  "Flerovium"  "Germanium"  "Lanthanum"  "Magnesium"  "Manganese"  "Moscovium"  "Neodymium"  "Neptunium"  "Oganesson"  "Palladium"  "Plutonium"  "Potassium"  "Ruthenium"  "Strontium"  "Tellurium"  "Ytterbium"  "Zirconium"  "Dysprosium" "Gadolinium" "Lawrencium" "Meitnerium" "Molybdenum" "Phosphorus" "Promethium" "Seaborgium" "Technetium" "Tennessine" "Californium""Copernicium""Einsteinium""Livermorium""Mendelevium""Roentgenium"]L's+"Xenon"?

Try it online!

Each program is 13 bytes long. Here they are split up into individual lines:

'C:L"arbon"
L'h+:L;"Gold"
L'u+:L;"Iron"
L'c+:L;"Lead"
L'k+:L;"Neon"
LS+:L;"Argon"
L'N+:L"ickel"
L'o+:L;"Zinc"
"Coppe"L'r+:L
"Silve"L'r+:L
L'i+:L;"Tin"
"Boron"
"Radon"
"Barium"
"Cerium"
"Cesium"
"Cobalt"
"Curium"
"Erbium"
"Helium"
"Indium"
"Iodine"
"Osmium"
"Oxygen"
"Radium"
"Sodium"
"Sulfur"
"Arsenic"
"Bismuth"
"Bohrium"
"Bromine"
"Cadmium"
"Calcium"
"Dubnium"
"Fermium"
"Gallium"
"Hafnium"
"Hassium"
"Holmium"
"Iridium"
"Krypton"
"Lithium"
"Mercury"
"Niobium"
"Rhenium"
"Rhodium"
"Silicon"
"Terbium"
"Thorium"
"Thulium"
"Uranium"
"Yttrium"
"Actinium"
"Aluminum"
"Antimony"
"Astatine"
"Chlorine"
"Chromium"
"Europium"
"Fluorine"
"Francium"
"Hydrogen"
"Lutetium"
"Nihonium"
"Nitrogen"
"Nobelium"
"Platinum"
"Polonium"
"Rubidium"
"Samarium"
"Scandium"
"Selenium"
"Tantalum"
"Thallium"
"Titanium"
"Tungsten"
"Vanadium"
"Americium"
"Berkelium"
"Beryllium"
"Flerovium"
"Germanium"
"Lanthanum"
"Magnesium"
"Manganese"
"Moscovium"
"Neodymium"
"Neptunium"
"Oganesson"
"Palladium"
"Plutonium"
"Potassium"
"Ruthenium"
"Strontium"
"Tellurium"
"Ytterbium"
"Zirconium"
"Dysprosium"
"Gadolinium"
"Lawrencium"
"Meitnerium"
"Molybdenum"
"Phosphorus"
"Promethium"
"Seaborgium"
"Technetium"
"Tennessine"
"Californium"
"Copernicium"
"Einsteinium"
"Livermorium"
"Mendelevium"
"Roentgenium"
]L's+"Xenon"?

The missing elements are Darmstadtium, Praseodymium, Protactinium and Rutherfordium which are 12 or 13 characters long which means I can't print them in 13 characters each.

The idea is that the first few programs, which prints the elements with short names use their extraneous characters to build the string Chuck Norri in the variable L, which does not affect the output when used on their own. The final program then checks if anything is already on the stack, and uses it to choose between L (plus s) and Xenon.

A few additional bytes are saved by using the character we just added to L as part of the element name, specifically for Carbon, Nickel, Copper and Silver.


Take a stand against long quine lines or: Build a vertical quine

Inspired by Take a stand against long lines.

Your task is to build a vertical quine with as short a line length as possible.

Scoring

Shortest line length (excluding newlines) wins, with code-golf criteria as a tie-breaker.

Line length is determined as the longest line in your program excluding the line break character.

For example:

$_=
Q.
P

has a line length of 3 and a byte count of 8, whilst:

Q
$
_
P

Has a line length of 1 and a byte count of 7 (assuming no trailing newline).

Rules

Quines must meet the community definition of a quine.

Standard loopholes are forbidden.


N-Dimensional Cartesian Product Introduction
The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some examples: the Cartesian product of [1, 2] and [3, 4] is [(1, 3), (1, 4), (2, 3), (2, 4)]. The product of [1] and [2] is [(1, 2)]. However, no one said you could only use two lists. The product of [1, 2], [3, 4], and [5, 6] is [(1, 3, 5), (1, 4, 5), (1, 3, 6), (1, 4, 6), (2, 3, 5), (2, 4, 5), (2, 3, 6), (2, 4, 6)].
Challenge
Given a number of lists, your program must output the Cartesian product of the lists given.

You can assume that there will always be more than 1 list, and that each list will have the same length. No list will ever be empty. If your language has no method of stdin, you may take input from command line arguments or a variable.
Your program must output the Cartesian product of all the input lists. If your language has no stdout, you may store output in a variable or as a     return value. The output should be a list of lists, or any other iterable type.

Example I/O

Input: [1, 2] [3, 4]
Output: [(1, 3), (1, 4), (2, 3), (2, 4)]
Input: [1, 2] [3, 4] [5, 6]
Output: [(1, 3, 5), (1, 4, 5), (1, 3, 6), (1, 4, 6), (2, 3, 5), (2, 4, 5), (2, 3, 6), (2, 4, 6)]
Input: [1, 2, 3] [4, 5, 6]
Output: [(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6)]

Rules
This is code-golf so shortest answer in bytes wins!

J, 1 byte

Courtesy of ngn

{

Try it online!

'tis called Catalogue…


Output a Sudoku board Today's challenge is simple: Without taking any input, output any valid sudoku board.

In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like:

  The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (also called "boxes", "blocks", or "regions") contains all of the digits from 1 to 9.

Now here's the thing... There are 6,670,903,752,021,072,936,960 different valid sudoku boards. Some of them may be very difficult to compress and output in fewer bytes. Others of them may be easier. Part of this challenge is to figure out which boards will be most compressible and could be outputted in the fewest bytes.

Your submission does not necessarily have to output the same board every time. But if multiple outputs are possible, you'll have to prove that every possible output is a valid board.

You can use this script (thanks to Magic Octopus Urn) or any of these answers to verify if a particular grid is a valid solution. It will output a [1] for a valid board, and anything else for an invalid board.

I'm not too picky about what format you output your answer in, as long as it's clearly 2-dimensional. For example, you could output a 9x9 matrix, nine 3x3 matrices, a string, an array of strings, an array of 9-digit integers, or nine 9-digit numbers with a separator. Outputting 81 digits in 1 dimension would not be permitted. If you would like to know about a particular output format, feel free to ask me in the comments.

As usual, this is code-golf, so write the shortest answer you can come up with in the language(s) of your choosing!

Pyth, 22 14 12 10 bytes

.<LS9%D3 9

Saved 2 bytes thanks to Mr. Xcoder.

Try it here

.<LS9%D3 9
     %D3 9     Order the range [0, ..., 8] mod 3.
  >            For each, ...
.< S9          ... Rotate the list [1, ..., 9] that many times.


List all palindromic prime dates between 0000-01-01 and 99999-12-31 You know what a palindrome, a prime and a date are.

  Your task is to list all dates in 100 thousands of years that fulfill
  all three characteristics.

Nevermind anything but the numbers, use the following formats: YYYYMMDD and YYYYYMMDD.

Dates between 0000-01-01 and 9999-12-31 should be printed as 8 digit palindromes dates (If there is any?) and dates between 10000-01-01 and 99999-12-31 should be printed as 9 digit palindromes.

It's not mandatory to list the dates in chronological order.

Example part of valid output.

First three 9 digit prime palindromic dates:

...
100111001
100131001
100161001
...

Rules

Standard loopholes apply.

Ruby, 144 141 bytes (134+7 for the -rprime flag)

Saved 3 bytes thanks to benj2240!

('01'..'12').map{|m|('01'..'31').map{|d|(?0..?9).map{|k|q=m+d
y=q.reverse+k
r=y+q
Time.new(y,m,d).day==d.to_i&&r.to_i.prime?&&(p r)}}}

Try it online!

The algorithm:

generate all possible MMDD combinations, from "0101" to "1231"
generate all years for that date that would result in a palindrome, by reversing the MMDD string and adding in the middle, in turn, all chars in the (0..9) range
check if that is a valid date by creating a Time instance with the given y, m, d values. If the resulting time object has a #day value equal to d, then that was a valid date. Otherwise, it would shift the date (for example, Time.new 2018,2,30 returns 2018-03-02).
check if the valid palindrome date is also a prime and display it if it is.

The inner loop was initially a function that was called for each element in the (?0..?9) range, as well as for the empty string.

Since the empty string produced no results (there are no valid 8 digit prime palindromes), I decided to remove it and refactor to this version.


Golfing Chain (Robbers' Thread) This is a Cops and Robbers challenge. For the Cops' thread, go here.

The Cops have three tasks.
1) Pick a sequence from the OEIS.

2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rules.
Call this language LA and code CA.
For example, Jelly and Jelly_code.

3) Then, pick a different language (this is suggested to be a non-golflang, but doesn't have to be) and write code that takes no input and outputs code CA, again following all usual code-golf rules. (Note: this can be obfuscated code and doesn't necessarily need to be golfed, but the longer this code is the easier it will be for the robbers to crack your submission.)
Call this language LB and code CB.
For example, Python and Python_code.

The Cop's submission to this challenge is the sequence (specified whether 0- or 1-indexed), the name of the two languages LA and LB (and which one solves which part), and the byte-count of CB only. Keep the actual code of both parts, and the length of CA, secret.

The Robber's challenge is to select a Cops' entry and write code CC in the same LB language that outputs some code in the same LA language that solves the original OEIS task. The length of CC can be no longer than the length of CB as revealed by the cop (though may be shorter). Note: The code produced by CC does not have to match CA.

For our example, this means that the Robber has to write Python code that outputs Jelly code that solves the original OEIS sequence, and that Python code has to be no longer than the length revealed by the Cop.

Winning conditions

The Robber with the most cracked solutions wins.

Brain-Flak, 90 bytes by Mr. Xcoder

((((((((((()()()){}){}){({}[()])}{}())[(((()()()){})){}{}()]))){}{}()()())([][][]){})[][])

Try it online!

This outputs:

ÑÉ·<O

First 05AB1E answer!

How does it work?

Let's say we have 24 as input.

Ñ       # Divisors.
        # Stack: [1, 2, 3, 4, 6, 8, 12, 24]
 É      # Odd?
        # Stack: [1, 0, 1, 0, 0, 0, 0, 0]
  ·     # Double
        # Stack: [2, 0, 2, 0, 0, 0, 0, 0]
   <    # Decrement
        # Stack: [1, -1, 1, -1, -1, -1, -1, -1]
    O   # Sum
        # Stack: -4

The brain-flak code mostly just uses tricks to push large numbers in few bytes. It was very convenient (and unintentional) that the ASCII values are mostly increasing:

209
201
183
60
79

It's also nice that 60 * 3 ~=~ 183 so tripling it and adding a few can save a ton of bytes.

((((((

    # Push 79
    ((((()()()){}){}){({}[()])}{}())
    # Minus 19 (60)

    [(((()()()){})){}{}()])
    # Push that two extra times
    ))

    # Push that ^ (60) Plus the two extras popped (60 + 120 == 180)...
    {}{}
    # + 3 (183)
    ()()())

    # Plus stack-height * 3 * 2 == 3 * 3 * 2 == 18 (201)
    ([][][]){})

    # Plus stack-height * 2 == 4 * 2 == 8 (209)
    [][])


12 hour time conversion Challenge
Convert and print out a time in a 12-hour format. HH:MM AM/PM
Examples
Input:

'Fri Jun 30 2017 21:14:20 GMT-0700 (PDT)'
'Fri Jun 30 2017 00:10:23 GMT-0700 (PDT)'
'Fri Jun 30 2017 12:10:23 GMT-0700 (PDT)'
'Sat Jun 31 2018 8:06:20 GMT-0700 (PDT)'
'Fri Jul 01 2017 01:14:20 GMT-0700 (PDT)'
'Sat Apr 10 2020 09:06:20 GMT-0700 (PDT)'

Ouput:

9:14 PM
12:10 AM
12:10 PM
08:06 AM
1:14 AM
09:06 AM

Fine Points

A zero before a one digit number is okay, no zero is also allowed. The following examples are both allowed:

9:06 AM

09:06 AM

All tested years will be after 999 (each year will be exactly 4 digits)

Rules

This is code-golf so the shortest solution in bytes wins
Standard Loopholes Apply
You may use functions as well as programs


Hiding information in Cats You are a secret agent trying to communicate with your fatherland. Of course the information needs to be hidden so no one eaves drops your message. What would be better suited than a cat? Everyone loves funny pictures of cats [citation needed], so they won't suspect secret information hiding in there!

Inspired by the algorithm the game Monaco uses to save the level information of shared levels it is your tasks to write a program that encoded information into the least significant bit of the colors of an image.

Encoding format:

The first 24 bits determine the length of the remaining encoded byte-string in bits
The image is read from left to right and from top to bottom, obviously starting in the upper left pixel
The channels are read from red to green to blue
The least significant bit from each channel is read
Bits are saved in Big Endian order

Rules:

Your program takes a single byte-string to be encoded and a single image filename for the base image
The resulting image must be come out as a true color PNG file
You may use I/O in whatever form you like (ARGV, STDIN, STDOUT, writing / reading from a file), as long as you state how to use your program
You must choose a random image of a funny cat and encode your program into it to show that your program works
You may assume that you are only provided valid input, if the amount of bits are not sufficient, the image is not in true color format, the image does not exist or similar problems you may do what you want
You may assume that the provided image does not contain any alpha channel
Length is counted in UTF-8 bytes without BOM

You may use this PHP script to test your solution, provide the name of the PNG file as the first command line argument:

<?php
if ($argc === 1) die('Provide the filename of the PNG to read from');
$imageSize = @getimagesize($argv[1]);

if ($imageSize === false) die('Not a PNG file');
list($width, $height) = $imageSize;

$image = imagecreatefrompng($argv[1]);
$read = 0;
$bits = '';
for ($y = 0; $y < $height; $y++) {
    for ($x = 0; $x < $width; $x++) {
        $colorAt = imagecolorat($image, $x, $y);
        $red = ($colorAt >> 16) & 0xFF;
        $green = ($colorAt >> 8) & 0xFF;
        $blue = ($colorAt >> 0) & 0xFF;

        $bits .= ($red & 1).($green & 1).($blue & 1);
        $read += 3;
        if ($read == 24) {
            $length = (int) bindec($bits);
            $bits = '';
        }
        else if ($read > 24 && ($read - 24) > $length) {
            $bits = substr($bits, 0, $length);
            break 2;
        }
    }
}
if (strlen($bits) !== $length) die('Not enough bits read to fulfill the length');
$parts = str_split($bits, 8);
foreach ($parts as $part) {
    echo chr(bindec($part));
}

Mathematica, 255 234 206 bytes

I've seen so many 255s while testing this, I'm unreasonably happy about the size of the code. :) And then my ambition to golf it down even further got the best of me...

f=(j=ImageData[Import@#2,t="Byte"];k=(d=IntegerDigits)[j,2,8]~Flatten~2;n=1;(k[[n++,-1]]=#)&/@d[Length@#,2,24]~Join~#&[Join@@d[ToCharacterCode@#,2,8]];ArrayReshape[#~FromDigits~2&/@k,Dimensions@j]~Image~t)&

It's technically a function and not a "program", but then again this is pretty much how you write "programs" in Mathematica, if that concept is even valid there. Call it like

f["my secret", "fully/qualified/cat.png"]

It will return an actual image expression (because that's the most natural way to return an image in Mathematica), so if you want a file, you need to export it:

Export["output-cat.png", f["my secret", "input-cat.png"]]

Here is the required example:

I'd love to show you the decoded message here, but it doesn't fit... so run it through the OP's decoder. ;)

Btw, I could make it work with UTF-8 secrets for just 7 bytes (change ToCharacterCode@# into #~ToCharacterCode~"utf8").

Ungolfed code:

f[secret_, filename_] := (
  bits = Join @@ IntegerDigits[ToCharacterCode[secret], 2, 8];
  bits = Join[d[Length @ bits, 2, 24], bits];
  data = ImageData[Import@#2, "Byte"];
  dims = Dimensions@data;
  data = Flatten[IntegerDigits[data, 2, 8], 2];
  m = n = 1;
  While[m <= Length @ bits,
    data[[n++, -1]] = bits[[m++]]
  ];
  Image[ArrayReshape[FromDigits[#, 2] & /@ data, dims], "Byte"]
)


Every word from babab to zyzyz Your task is to write a program that will output a readable list of every five letter words with the structure:

consonant - vowel - consonant - vowel - consonant

The output should be sorted alphabetically with one word per line and no words repeated twice. It can be lowercase or uppercase but not mixed. So the list could start and end like this:

babab
babac
babad
...
zyzyw
zyzyx
zyzyz

Vowels are a-e-i-o-u-y, the other 20 English-alphabet letters are consonants.
Words don't have to be actual dictionary words.
Shortest code wins.

Note: A few years ago I stumbled upon a program on a university website that did exactly that. Turns out my first and last name fit the c-v-c-v-c constraint, and i'd been googling myself.

Mathematica, 72 65 61 bytes

Print@@@Tuples@{a=##/(b=#5#9#15#21#25#)&@@Alphabet[],b,a,b,a}

For testing, I recommend replacing Print@@@ with ""<>#&/@. Mathematica will then display a truncated form showing the first few and last few words, instead of taking forever to print 288,000 lines.

Explanation

I finally found a use for dividing strings. :)

I've been intrigued by the possibility of adding or multiplying strings for a while, but the actual use cases are fairly limited. The main point is that something like "foo"+"bar" or "foo"*"bar" (and consequently, the short form "foo""bar") is completely valid in Mathematica. However, it doesn't really know what to do with the strings in arithmetic expressions, so these things remain unevaluated. Mathematica does apply generally applicable simplifications though. In particular, the strings will be sorted into canonical order (which is fairly messed up in Mathematica, once you start sorting strings containing letters of various cases, digits and non-letters), which is often a dealbreaker, but doesn't matter here. Furthermore, "abc""abc" will be simplified to "abc"^2 (which is a problem when you have repeated strings, but we don't have that either), and something like "abc"/"abc" will actually cancel (which we'll be even making use of).

So what are we trying to golf here. We need a list of vowels and a list of consonants, so we can feed them to Tuples to generate all possible combinations. My first approach was the naive solution:

Characters@{a="bcdfghjklmnpqrstvwxz",b="aeiouy",a,b,a}

That hardcoded list of consonants does hurt a bit. Mathematica does have an Alphabet built-in which would allow me to avoid it, if I were able to remove the vowels in a cheap way. This is where it gets tricky though. The simplest way to remove elements is Complement, but that ends up being longer, using one of the following options:

{a=Complement[Alphabet[],b=Characters@"aeiouy"],b,a,b,a}
{a=Complement[x=Alphabet[],b=x[[{1,5,9,15,21,25}]]],b,a,b,a}

(Note that we don't need to apply Characters to the whole thing any more, because Alphabet[] gives a list of letters, not a string.)

So let's try that arithmetic business. If we represent the entire alphabet as a product of letters instead of a list, then we can remove letters by simple division, due to the cancelling rule. That saves a lot of bytes because we won't need Complement. Furthermore, "a""e""i""o""u""y" is actually a byte shorter than Characters@"aeiouy". So we do this with:

a=##/(b="a""e""i""o""u""y")&@@Alphabet[]

Where we're storing the consonant and vowel products in a and b, respectively. This works by writing a function which multiplies all its arguments with ## and divides them by the product of vowels. This function is applied to the alphabet list, which passes each letter in as a separate argument.

So far so good, but now we have

{a=##/(b="a""e""i""o""u""y")&@@Alphabet[],b,a,b,a}

as the argument to Tuples, and those things are still products, not lists. Normally, the shortest way to fix that is putting a List@@@ at the front, which turns the products into lists again. Unfortunately, adding those 7 bytes makes it longer than the naive approach.

However, it turns out that Tuples doesn't care about the heads of the inner lists at all. If you do

Tuples[{f[1, 2], f[3, 4]}]

(Yes, for an undefined f.) You'll get:

{{1, 3}, {1, 4}, {2, 3}, {2, 4}}

Just as if you had used a List instead of f. So we can actually pass those products straight to Tuples and still get the right result. This saves 5 bytes over the naive approach using two hardcoded strings.

Now the "a""e""i""o""u""y" is still fairly annoying. But wait, we can save a few bytes here as well! The arguments of our function are the individual letters. So if we just pick out the right arguments, we can reuse those instead of the string literals, which is shorter for three of them. We want arguments # (short for #1), #5, #9, #15, #21 and #25. If we put # at the end, then we also don't need to add any * to multiply them together, because (regex) #\d+ is a complete token that can't have any non-digit appended to it. Hence we end up with #5#9#15#21#25#, saving another 4 bytes.


Is the group cyclic? Introduction
You can skip this part if you already know what a cyclic group is.
A group is defined by a set and an associative binary operation \$\times\$ (that is, \$(a \times b) \times c = a \times (b \times c)\$. There exists exactly one element in the group \$e\$ where \$a \times e = a = e \times a\$ for all \$a\$ in the group (identity). For every element \$a\$ in the group there exists exactly one \$b\$ such that \$a \times b = e = b \times a\$ (inverse). For every two elements \$a, b\$ in the group, \$a \times b\$ is in the group (closure).
We can write \$a^n\$ in place of \$\underbrace{a\times a\times a\times ...\times a}_{n \text{ times}}\$.
The cyclic subgroup generated by any element \$a\$ in the group is \$<a> = \{e, a, a^2, a^3, a^4, ..., a^{n-1}\}\$ where \$n\$ is the order (size) of the subgroup (unless the subgroup is infinite).
A group is cyclic if it can be generated by one of its elements.
Challenge
Given the Cayley table (product table) for a finite group, determine whether or not it's cyclic.
Example
Let's take a look at the following Cayley table:
1 2 3 4 5 6
2 3 1 6 4 5
3 1 2 5 6 4
4 5 6 1 2 3
5 6 4 3 1 2
6 4 5 2 3 1

(This is the Cayley table for Dihedral Group 3, \$D_3\$).
This is 1-indexed, so if we want to find the value of \$5 \times 3\$, we look in the fifth column on the third row (note that the operator is not necessarily commutative, so \$5 \times 3\$ is not necessarily equal to \$3 \times 5\$. We see here that \$5 \times 3 = 6\$ (also that \$3 \times 5 = 4\$).
We can find \$<3>\$ by starting with \$[3]\$, and then while the list is unique, append the product of the last element and the generator (\$3\$). We get \$[3, 3 \times 3 = 2, 2 \times 3 = 1, 1 \times 3 = 3]\$. We stop here with the subgroup \$\{3, 2, 1\}\$.
If you compute \$<1>\$ through \$<6>\$ you'll see that none of the elements in the group generate the whole group. Thus, this group is not cyclic.
Test Cases
Input will be given as a matrix, output as a truthy/falsy decision value.
[[1,2,3,4,5,6],[2,3,1,6,4,5],[3,1,2,5,6,4],[4,5,6,1,2,3],[5,6,4,3,1,2],[6,4,5,2,3,1]] -> False (D_3)
[[1]] -> True ({e})
[[1,2,3,4],[2,3,4,1],[3,4,1,2],[4,1,2,3]] -> True ({1, i, -1, -i})
[[3,2,4,1],[2,4,1,3],[4,1,3,2],[1,3,2,4]] -> True ({-1, i, -i, 1})
[[1,2],[2,1]] -> True ({e, a} with a^-1=a)
[[1,2,3,4,5,6,7,8],[2,3,4,1,6,7,8,5],[3,4,1,2,7,8,5,6],[4,1,2,3,8,5,6,7],[5,8,7,6,1,4,3,2],[6,5,8,7,2,1,4,3],[7,6,5,8,3,2,1,4],[8,7,6,5,4,3,2,1]] -> False (D_4)
[[1,2,3,4,5,6],[2,1,4,3,6,5],[3,4,5,6,1,2],[4,3,6,5,2,1],[5,6,1,2,3,4],[6,5,2,1,4,3]] -> True (product of cyclic subgroups of order 2 and 3, thanks to Zgarb)
[[1,2,3,4],[2,1,4,3],[3,4,1,2],[4,3,1,2]] -> False (Abelian but not cyclic; thanks to xnor)

You will be guaranteed that the input is always a group.
You may take input as 0-indexed values.

Husk, 11 10 9 bytes

VS≡`ȯU¡!1

1-based.
Returns the index of a generator if one exists, 0 otherwise.
Try it online!

Explanation

V          Does any row r of the input satisfy this:
      ¡!    If you iterate indexing into r
   `    1   starting with 1
    ȯU      until a repetition is encountered,
 S≡         the result has the same length as r.


Whose neighbours are hostile? Introduction

For the purposes of this challenge, we will define the neighbours of an element \$E\$ in a square matrix \$A\$ (such that \$E=A_{i,j}\$) as all the entries of \$A\$  that are immediately adjacent diagonally, horizontally or vertically to \$E\$ (i.e. they "surround" \$E\$, without wrapping around).

For pedants, a formal definition of the neighbours of \$A_{i,\:j}\$ for an \$n\times n\$ matix \$A\$ is (0-indexed):
$$N_{i,\:j}=\{A_{a,\:b}\mid(a,b)\in E_{i,\:j}\:\cap\:([0,\:n)\:\cap\:\Bbb{Z})^2\}$$
where
$$E_{i,\:j}=\{i-1,\:i,\:i+1\}\times \{j-1,\:j,\:j+1\} \text{ \\ } \{i,\:j\}$$

Let's say that the element at index \$i,\:j\$ lives in hostility if it is coprime to all its neighbours (that is, \$\gcd(A_{i,\:j},\:n)=1\:\forall\:n\in N_{i,\:j}\$). Sadly, this poor entry can't borrow even a cup of sugar from its rude nearby residents...

Task

Enough stories: Given a square matrix \$M\$ of positive integers, output one of the following:

A flat list of elements (deduplicated or not) indicating all entries that occupy some indices \$i,j\$ in \$M\$ such that the neighbours \$N_{i,\:j}\$ are hostile.
A boolean matrix with \$1\$s at positions where the neighbours are hostile and \$0\$ otherwise (you can choose any other consistent values in place of \$0\$ and \$1\$).
The list of pairs of indices \$i,\:j\$ that represent hostile neighbourhoods.

Reference Implementation in Physica – supports Python syntax as well for I/O. You can take input and provide output through any standard method and in any reasonable format, while taking note that these loopholes are forbidden by default. This is code-golf, so the shortest code in bytes (in every language) wins!

Moreover, you can take the matrix size as input too and additionally can take the matrix as a flat list since it will always be square.

Example

Consider the following matrix:

$$\left(\begin{matrix}
64 & 10 & 14 \\
27 & 22 & 32 \\
53 & 58 & 36 \\
\end{matrix}\right)$$

The corresponding neighbours of each element are:

i j – E  -> Neighbours                          | All coprime to E?
                                                |
0 0 – 64 -> {10; 27; 22}                        | False
0 1 – 10 -> {64; 14; 27; 22; 32}                | False
0 2 – 14 -> {10; 22; 32}                        | False
1 0 – 27 -> {64; 10; 22; 53; 58}                | True
1 1 – 22 -> {64; 10; 14; 27; 32; 53; 58; 36}    | False
1 2 – 32 -> {10; 14; 22; 58; 36}                | False
2 0 – 53 -> {27; 22; 58}                        | True
2 1 – 58 -> {27; 22; 32; 53; 36}                | False
2 2 – 36 -> {22; 32; 58}                        | False

And thus the output must be one of the following:

{27; 53}
{{0; 0; 0}; {1; 0; 0}; {1; 0; 0}}
{(1; 0); (2; 0)}

Test cases

Input –> Version 1 | Version 2 | Version 3

[[36, 94], [24, 69]] ->
    []
    [[0, 0], [0, 0]]
    []
[[38, 77, 11], [17, 51, 32], [66, 78, 19]] –>
    [38, 19]
    [[1, 0, 0], [0, 0, 0], [0, 0, 1]]
    [(0, 0), (2, 2)]
[[64, 10, 14], [27, 22, 32], [53, 58, 36]] ->
    [27, 53]
    [[0, 0, 0], [1, 0, 0], [1, 0, 0]]
    [(1, 0), (2, 0)]
[[9, 9, 9], [9, 3, 9], [9, 9, 9]] ->
    []
    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
    []
[[1, 1, 1], [1, 1, 1], [1, 1, 1]] ->
    [1, 1, 1, 1, 1, 1, 1, 1, 1] or [1]
    [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
    [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
[[35, 85, 30, 71], [10, 54, 55, 73], [80, 78, 47, 2], [33, 68, 62, 29]] ->
    [71, 73, 47, 29]
    [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]]
    [(0, 3), (1, 3), (2, 2), (3, 3)]

APL (Dyalog), 17 bytes
1=⊢∨(×/∘,↓)⌺3 3÷⊢

Try it online! (credits to ngn for translating the test cases to APL)
Brief explanation
(×/∘,↓)⌺3 3 gets the product of each element with its neighbours.
Then I divide by the argument ÷⊢, so that each entry in the matrix has been mapped to the product of its neighbors.
Finally I take the gcd of the argument with this matrix ⊢∨, and check for equality with 1, 1=
Note, as with ngn's answer, this fails for some inputs due to a bug in the interpreter.


Uniquely removable subsequences Introduction

Consider a sequence of integers and one of its subsequences, say A = [4 2 2 4 4 6 5] and B = [2 4 5].
We want to remove the elements of B from A in order, and there are several ways of doing that:

A = 4 2 2 4 4 6 5
B =   2   4     5
 -> 4   2   4 6

A = 4 2 2 4 4 6 5
B =     2 4     5
 -> 4 2     4 6

A = 4 2 2 4 4 6 5
B =   2     4   5
 -> 4   2 4   6

A = 4 2 2 4 4 6 5
B =     2   4   5
 -> 4 2   4   6

In all cases, the remaining sequence is the same, [4 2 4 6].
If this happens, we say that B is uniquely removable from A.

The task

Your inputs are two sequences of nonnegative integers, A and B, where B is guaranteed to be a subsequence of A.
The inputs may be equal, and they may be empty.
You can take them in any order you want, in any reasonable format.

Your output shall be a truthy value if B is uniquely removable from A, and a falsy value if not.

Rules and scoring

You can write a full program or a function.
The lowest byte count wins.

Test cases

[] [] -> True
[0,3] [] -> True
[1,0,1] [1] -> False
[0,2] [0,2] -> True
[2,2,1,1,2,2,2] [2,1] -> True
[4,2,2,4,4,6,5] [4,5] -> False
[10,5,10,10,5,10] [10,5,10] -> False
[4,2,2,4,4,6,5] [2,4,5] -> True
[1,1,1,0,0,0,1,1,1,0] [1,0,1,1] -> True
[0,1,0,0,0,0,1,1,0,1] [1,0,1,1] -> False
[0,4,0,0,4,1,4,2,2] [0,0,0,1,4] -> True
[0,2,2,25,0,2,2,26,0,0,2] [2,0,0,0,2] -> True
[1,1,1,3,2,1,3,2,2,3,3,2] [1,1,2,3,2] -> False
[0,3,2,0,1,3,2,0,0,0,3,2] [0,1,2,0,3] -> False
[5,7,2,7,7,1,7,7,5,2,7,7,5,2,2,7,5] [2,7,5,7,7,2] -> False
[5,4,0,5,4,5,4,1,0,4,2,1,1,2,4,4,0,2,2,1] [4,0,1,1,2,1] -> False
[0,1,4,0,1,4,0,1,5,1,4,4,2,0,0,1,1,1,2,4] [0,1,0,0,2,0,1,4] -> True


Print the Najdorf Sicilian The Najdorf Variation of the Sicilian Defence is an opening often played at the highest level of chess. It is named after GM Miguel Najdorf and is known for being extremely sharp and theory heavy.
Your task is to write a program that, given a Boolean-like input, prints a chessboard representation of the opening from either White or Black perspective.
I/O format
Your program can take any input that has two possible values. Boolean, Integer, etc.
Your program must output a square chessboard using your language's standard output (usually the console). Each piece must have a corresponding character (your choice). Black and white pieces must be different. Black and white squares are allowed to be the same, but you are allowed to have different characters for them if you wish.
Using standard notation and uppercase for white and lowercase for black, here are the two chessboards, though you are free to represent the pieces differently:
True               False

R   B K Q B   R    r n b q k b   r
P P P     P P P      p     p p p p
          N        p     p   n
      P N
                         N P
    n   p     p        N
p p p p     p      P P P     P P P
r   b k q b n r    R   B Q K B   R

This is code-golf, so shortest program in bytes wins!

JavaScript (Node.js), 114 89 124 bytes

x=>`RNBQKB R
P  PPPP
P  P N

   np
  n
ppp  ppp
r bqkb r`.split`
`.sort(_=>x-1).map(n=>[...n].sort(_=>x-1).join``).join`
`

Try it online!
Take the grid and flip if needed.


(RGS 2/5) How many strings can you count within these character classes? Task

Given a string composed of ASCII printable characters, return how many strings could fit the given pattern with character literals and regex-like ranges.

Pattern string

The pattern string follows this grammar (the | means an option and the * means 0 or more occurrences of whatever was immediately to the left):

pattern := '' | pattern_string
pattern_string := (SAFE_CHAR | ASCII_RANGE) pattern_string*
ASCII_RANGE := '[' CHAR '-' CHAR ']'

where CHAR is any ASCII character in the range [32, 127] and SAFE_CHAR is any CHAR except the three characters [, - and ].

Examples

Examples of pattern strings would be a, [0-*]4fj, [a-z][4-9]D[d-B].

Input

The pattern string. You can assume all ranges are well-formed and that all the second characters in the ranges have their ASCII codepoints >= than the corresponding first characters in the range.

Output

The integer corresponding to the number of strings that match the given pattern string.

Test cases

"" -> 1
"a" -> 1
"[*-0]" -> 7
"[0-9][0-9]" -> 100
"[a-z]d[A-z]" -> 1508
"[<->]" -> 3
"[!-&]" -> 6
"[d-z]abf[d-z]fg" -> 529
"[[-]]" -> 3
"[a-a][b-b]cde[---]" -> 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]" -> 4096
"[--[][--]]" -> 2303
"[[-[].[]-]]" -> 1

You can check this Python reference implementation that I used to generate the test cases.

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it... And happy golfing!

This is the second challenge of the RGS Golfing Showdown. If you want to participate in the competition, you have 96 hours to submit your eligible answers. Remember there is still 400 reputation in prizes! (See 6 of the rules)

Also, as per section 4 of the rules in the linked meta post, the "restricted languages" for this second challenge are: 05AB1E, W, Jelly, Japt, Gaia, MathGolf and Stax, so submissions in these languages are not eligible for the final prize. But they can still be posted!!

Otherwise, this is still a regular code-golf challenge, so enjoy!

CP-1610 machine code (Intellivision),  23  22 DECLEs1 ≈ 28 bytes

As per the exception described in this meta answer, the exact score is 27.5 bytes (220 bits)

A routine taking a null-terminated string as an inline argument through R4 and returning the result in R1.

2B9 001     |         MVII    #1,     R1
2A0         | @@read  MVI@    R4,     R0
080         |         TSTR    R0
204 00F     |         BEQ     @@rtn
378 05B     |         CMPI    #'[',   R0
22C 007     |         BNEQ    @@read
2A0         |         MVI@    R4,     R0
00C         |         INCR    R4
320         |         SUB@    R4,     R0
020         |         NEGR    R0
008         |         INCR    R0
004 11C 1DC |         CALL    MULT
091         |         MOVR    R2,     R1
220 012     |         B       @@read
0A7         | @@rtn   JR      R4

A note about subroutine calls

The CP-1610 instruction for calling subroutines is JSR Rx, $address. This instruction saves the return address in Rx instead of pushing it on the stack as many other CPUs do.

This allows to pass a block of arguments that immediately follows the function call. This is a common practice in CP-1610 programming and that's what we use here.

        JSR     R4,     count     ; call to subroutine through R4
        STRING  "[*-0]", 0        ; argument
        ...                       ; we will return here

Obviously, the subroutine is responsible for reading the correct number of arguments and eventually jumping to the expected return address.

Full commented test code

        ROMW    10                ; use 10-bit ROM width
        ORG     $4800             ; map this program at $4800

PNUM    QEQU    $18C5             ; EXEC routine: print a number
MULT    QEQU    $1DDC             ; EXEC routine: signed multiplication

        ;; ------------------------------------------------------------- ;;
        ;;  main code                                                    ;;
        ;; ------------------------------------------------------------- ;;
main    PROC

        SDBD                      ; set up an interrupt service routine
        MVII    #isr,   R0        ; to do some minimal STIC initialization
        MVO     R0,     $100
        SWAP    R0
        MVO     R0,     $101

        EIS                       ; enable interrupts

        MVII    #$200,  R3        ; R3 = backtab pointer

        JSR     R4,     count     ; test cases
        STRING  "", 0
        CALL    print
        JSR     R4,     count
        STRING  "a", 0
        CALL    print
        JSR     R4,     count
        STRING  "[*-0]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[0-9][0-9]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[a-z]d[A-z]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[<->]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[!-&]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[d-z]abf[d-z]fg", 0
        CALL    print
        JSR     R4,     count
        STRING  "[[-]]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[a-a][b-b]cde[---]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[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
        CALL    print
        JSR     R4,     count
        STRING  "[--[][--]]", 0
        CALL    print
        JSR     R4,     count
        STRING  "[[-[].[]-]]", 0
        CALL    print

        DECR    R7                ; done: loop forever

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  prints the result of a test case                             ;;
        ;; ------------------------------------------------------------- ;;
print   PROC

        PSHR    R5                ; save the return address on the stack

        MOVR    R1,     R0        ; R0 = number to print
        MVII    #4,     R1        ; R1 = number of digits
        MOVR    R3,     R4        ; R4 = backtab pointer
        ADDI    #5,     R3        ; advance by 5 characters for the next one
        PSHR    R3                ; save R3
        CLRR    R3                ; R3 = attributes (black)
        CALL    PNUM              ; invoke the EXEC routine
        PULR    R3                ; restore R3

        PULR    R7                ; return

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  ISR                                                          ;;
        ;; ------------------------------------------------------------- ;;
isr     PROC

        MVO     R0,     $0020     ; enable display

        CLRR    R0
        MVO     R0,     $0030     ; no horizontal delay
        MVO     R0,     $0031     ; no vertical delay
        MVO     R0,     $0032     ; no border extension
        MVII    #$D,    R0
        MVO     R0,     $0028     ; light-blue background
        MVO     R0,     $002C     ; light-blue border

        JR      R5                ; return from ISR

        ENDP

        ;; ------------------------------------------------------------- ;;
        ;;  our routine                                                  ;;
        ;; ------------------------------------------------------------- ;;
count   PROC

        MVII    #1,     R1        ; initialize R1 to 1

@@read  MVI@    R4,     R0        ; R0 = current character
        TSTR    R0                ; end of string?
        BEQ     @@rtn             ; if yes, return

        CMPI    #'[',   R0        ; is this a '['?
        BNEQ    @@read            ; if not, just go on with the next character

        MVI@    R4,     R0        ; R0 = ASCII code of the starting character
        INCR    R4                ; skip the '-'
        SUB@    R4,     R0        ; subtract the ASCII code of the ending character
        NEGR    R0                ; negate
        INCR    R0                ; increment
        CALL    MULT              ; compute R2 = R0 * R1
        MOVR    R2,     R1        ; and save the result in R1

        B       @@read            ; go on with the next character

@@rtn   JR      R4                ; return

        ENDP

Output

screenshot from jzIntv

1. A CP-1610 opcode is encoded with a 10-bit value (0x000 to 0x3FF), known as a 'DECLE'.


Polynomial Long Division Implement polynomial long division, an algorithm that divides two polynomials and gets the quotient and remainder:

(12x^3 - 5x^2 + 3x - 1) / (x^2 - 5) = 12x - 5 R 63x - 26

In your programs, you will represent polynomials as an array, with the constant term on the tail. for example, x^5 - 3x^4 + 2x^2 - x + 1 will become [1, -3, 0, 2, -1, 1].

The long division function you are going to write will return two values: the quotient and the remainder. You do not need to handle numerical imprecisions and arithmetic errors. Do not use math library to do your job, however, you may make your function able to deal with symbolic values. Shortest code wins.

EXAMPLE: div([12, -5, 3, -1], [1, 0, -5]) == ([12, -5], [63, -26])

J, 94

f=:>@(0&{)
d=:0{[%~0{[:f]
D=:4 :'x((1}.([:f])-((#@]{.[)f)*d);([:>1{]),d)^:(>:((#f y)-(#x)))y'

eg.

(1 0 _5) D (12 _5 3 _1;'')
63 _26 | 12  _5

Explanation of some snippets, given that a: (12 -5 3 -1) and b: (1 0 -5)

length of a:

#a
4

make a and b same order by appending zeroes to b:

(#a) {. b
1 0 -5 0

divide higher powers (first elements) of a, b:

(0{a) % (0{b)
12

multiply b by that and subtract it from a:

a - 12*b
12 0 _60

repeat n times b = f(a,b):

a f^:n b


Running Merge Conflict When using a tool such as git to merge two files, a conflict could be detected and added to the result of the merge.

A merge of these two files:

my file:

Common line of code 1
Common line of code 2
my lines
Common line of code 3
Common line of code 4

their file:

Common line of code 1
Common line of code 2
their lines
Common line of code 3
Common line of code 4

would result in:

Common line of code 1
Common line of code 2
<<<<<<< Mine
my lines
=======
their lines
>>>>>>> Theirs
Common line of code 3
Common line of code 4

See Conflict Marker Lines

Resolving this conflict with Mine would create this file:

Common line of code 1
Common line of code 2
my lines
Common line of code 3
Common line of code 4

Resolving this conflict with Theirs would create this file:

Common line of code 1
Common line of code 2
their lines
Common line of code 3
Common line of code 4

The objective of this challenge is to write a source file that contains a conflict and still compiles/executes.

Write a source file which:

contains one valid, two-way, conflict marked by the proper patch conflict markers (<<<<<<<, =======, >>>>>>>) Mine and Theirs file descriptors after the markers are optional.
compiles/executes without errors/warnings if the markers remain a part of the source
compiles/executes without errors/warnings if the conflict is resolved by using mine
compiles/executes without errors/warnings if the conflict is resolved by using theirs
outputs "Hello Conflict" when compiling/executing the conflicted file
outputs "Hello Mine" when compiling/executing the mine version
outputs "Hello Theirs" when compiling/executing the theirs version

The markers should be located in the source file in such a way that kdiff3 recognizes the conflict.

Standard loopholes are forbidden.

The shortest code wins.

Score is the length of the conflicted source

JavaScript (ES6), 102 94 93 90 bytes

console.log('Hello',(a=`
<<<<<<<
Mine
=======
Theirs
>>>>>>>
Conflict`.split`
`)[6]||a[1])

If the conflict has been resolved, then there is no sixth line, so it prints the now first line instead. Edit: Saved 3 bytes thanks to @nderscore.


Mark a UKMT IMC Paper I did the IMC this year. Did anyone else here do it?

In a UKMT Intermediate Maths Challenge paper, there are twenty-five questions. The first fifteen questions give you five marks if you get them right. For the other ten questions, you get six marks for getting them right. In the last ten questions, you lose marks if you get them wrong! For questions sixteen to twenty, you lose one marks and for the last five questions, you lose two marks. If you leave a question blank, no marks are awarded or deducted. No marks are deducted for getting any of the first fifteen questions wrong. The paper is multiple choice; you can choose any answer out of A, B, C, D and E for each question. There is always just one right answer for each question.

Create a program/function that takes two strings and outputs a score. The first string will be your answers to the paper. If you skip a question, use a space, a null byte or an underscore. Otherwise, use the letter A, B, C, D or E for the answer. You can either have the inputs uppercase or lowercase. The second string will be the correct answers for each question in the paper. Your program/function will then output a score. Make your code short.

Test cases:

DDDDDDDDDDDDDDDDDDDDDDDDD
ABCDEABCDEABCDEABCDEABCDE
15

BDBEACCECEDDBDABBCBDAEBCD
BDBEACCECEDDBDABBCBDAEBCD
135

DBACBDCDBAEDABCDBEECACDC_
DBADBDCDBAEDABCDBEEDACDCA
117

_________________________
DABDABDABDABDABDABDABDABD
0

DBADBDCDBAEDABCD_E__A__C_
DBADBDCDBAEDABCDBEEDACDCA
99

_______________BBBBBBBBBB
AAAAAAAAAAAAAAAAAAAAAAAAA
-15


Fastest player for Dots and Boxes The challenge is to write a solver for the classic pencil and paper game Dots and Boxes .  Your code should take two integers m and n as input which specifies the size of the board.

  Starting with an empty grid of dots, players take turns, adding a
  single horizontal or vertical line between two unjoined adjacent dots.
  A player who completes the fourth side of a 1×1 box earns one point
  and takes another turn. (The points are typically recorded by placing
  in the box an identifying mark of the player, such as an initial). The
  game ends when no more lines can be placed. The winner of the game is
  the player with the most points.

You can assume that either n = m or n = m - 1 and m is at least 2.

The challenge is to solve the largest possible Dots and Boxes game in under a minute. The size of a game is simply n*m.   The output of your code should be win , draw or lose which should be the result for the first player assuming both players play optimally.

Your code must be compilable/runnable on ubuntu using easily installable and free tools.  Please report your score as the largest area you can solve on your computer in 1 minute together with the time.  I will then test the code on my computer and make a rank ordered table of entries.

In the case of a tie-break, the winner will be the fastest code on the largest size board it can solve in under a minute.

It would be better if the code outputted not just win or lose but the actual score as well. This makes for a sanity check of correctness.

C99 - 3x3 board in 0.084s
2020 edit/disclaimer: See comments section. It looks like there may have been errors in the original code. Proceed to the remainder of this answer with some skepticism until it is fixed.
Edit: I refactored my code and did some deeper analysis on the results.
Further Edits: Added pruning by symmetries. This makes 4 algorithm configurations: with or without symmetries X with or without alpha-beta pruning
Furthest Edits: Added memoization using a hash table, finally achieving the impossible: solving a 3x3 board!
Primary features:

straightforward implementation of minimax with alpha-beta pruning
very little memory management (maintains dll of valid moves; O(1) updates per branch in the tree search)
second file with pruning by symmetries. Still achieves O(1) updates per branch (technically O(S) where S is the number of symmetries. This is 7 for square boards and 3 for non-square boards)
third and fourth files add memoization. You have control over the hashtable's size (#define HASHTABLE_BITWIDTH). When this size is greater than or equal to the number of walls, it guarantees no collisions and O(1) updates. Smaller hashtables will have more collisions and be slightly slower.
compile with -DDEBUG for printouts

Potential improvements:

fix small memory leak fixed in first edit
alpha/beta pruning added in 2nd edit
prune symmetries added in 3rd edit (note that symmetries are not handled by memoization, so that remains a separate optimization.)
memoization added in 4th edit
currently memoization uses an indicator bit for each wall. A 3x4 board has 31 walls, so this method couldn't handle 4x4 boards regardless of time constraints. the improvement would be to emulate X-bit integers, where X is at least as large as the number of walls.

Code
Due to lack of organization, the number of files has grown out of hand. All code has been moved to this Github Repository. In the memoization edit, I added a makefile and testing script.
Results

Notes on Complexity
Brute-force approaches to dots and boxes blow up in complexity very quickly.
Consider a board with R rows and C columns. There are R*C squares, R*(C+1) vertical walls, and C*(R+1) horizontal walls. That is a total of W = 2*R*C + R + C.
Because Lembik asked us to solve the game with minimax, we need to traverse to the leaves of the game tree. Let's ignore pruning for now, because what matters is orders of magnitude.
There are W options for the first move. For each of those, the next player can play any of the W-1 remaining walls, etc.. That gives us a search-space of SS = W * (W-1) * (W-2) * ... * 1, or SS = W!. Factorials are huge, but that's only the beginning. SS is the number of leaf nodes in the search space. More relevant to our analysis is the total number of decisions which had to be made (i.e. the number of branches B in the tree). The first layer of branches has W options. For each of those, the next level has W-1, etc.
B = W + W*(W-1) + W*(W-1)*(W-2) + ... + W!

B = SUM W!/(W-k)!
  k=0..W-1

Let's look at some small table sizes:
Board Size  Walls  Leaves (SS)      Branches (B)
---------------------------------------------------
1x1         04     24               64
1x2         07     5040             13699
2x2         12     479001600        1302061344
2x3         17     355687428096000  966858672404689

These numbers are getting ridiculous. At least they explain why the brute-force code seems to hang forever on a 2x3 board. The search-space of a 2x3 board is 742560 times larger than 2x2. If 2x2 takes 20 seconds to complete, a conservative extrapolation predicts over 100 days of execution time for 2x3. Clearly we need to prune.
Pruning Analysis
I started by adding very simple pruning using the alpha-beta algorithm. Basically, it stops searching if an ideal opponent would never give it its current opportunities. "Hey look - I win by a lot if my opponent lets me get every square!", thought no AI, ever.
edit I have also added pruning based on symmetrical boards. I don't use a memoization approach, just in case someday I add memoization and want to keep that analysis separate. Instead, it works like this: most lines have a "symmetric pair" somewhere else on the grid. There are up to 7 symmetries (horizontal, vertical, 180 rotation, 90 rotation, 270 rotation, diagonal, and the other diagonal). All 7 apply to square boards, but the last 4 don't apply to non-square boards. Each wall has a pointer to it's "pair" for each of these symmetries. If, going into a turn, the board is horizontally symmetric, then only one of each horizontal pair needs to be played.
edit edit Memoization! Each wall gets a unique id, which I conveniently set to be an indicator bit; the nth wall has the id 1 << n. The hash of a board, then, is just the OR of all walls played. This is updated at each branch in O(1) time. The size of the hashtable is set in a #define. All tests were run with size 2^12, because why not? When there are more walls than bits indexing the hashtable (12 bits in this case), the least significant 12 are masked and used as the index. Collisions are handled with a linked list at each hashtable index. The following chart is my quick-and-dirty analysis of how hashtable size affects performance. On a computer with infinite RAM, we would always set the table's size to the number of walls. A 3x4 board would have a hashtable 2^31 long. Alas we don't have that luxury.

Ok, back to pruning.. By stopping the search high in the tree, we can save a lot of time by not going down to leaves. The 'Pruning Factor' is the fraction of all-possible-branches which we had to visit. Brute-force has a pruning factor of 1. The smaller it is, the better.


How to recover from DDOS'ed internet The internet has failed.  DDoS attacks are now rampant and widespread.  It is up to you to take control and repair the internet.
Each bot will control 20 nodes in this network.  Every node is either active or safe, has an owner, and has a strength, which starts at 2. Every active node is connected to all other active nodes.
Each turn, you will receive a list of all active nodes with their strength.  For each of the active nodes that you own, you either:

Designate an active node you want to transfer your entire strength to, or
Save and increase its strength

Then the following happens in order:

A Node choosing to save its strength will increase its strength by 1.
All nodes choosing to transfer their strength will simultaneously transfer their entire strength to the new node.
If a node was transferred strength from an enemy node, an attack will ensue.  If an enemy owner collectively transfers more strength than the original owner (and all other attackers), then that enemy becomes the new owner.  The strength of that node then becomes the strength of the attacker.  If there is a tie for strength, then the owner will be chosen randomly.
All nodes left without any strength will be considered safe, and gives 1 point to the owner.

After 100 games of 100 turns, the owner with the most safe nodes across all games wins. EDIT: I changed it from 2000 to 100 turns, as it ended up that the last 1900 turns were useless
IO
You will be passed the list of active nodes (via command line args) like the following:
F20 F4 E7 E2 E20 F2

F designates that the node is a friendly node, and E designates that the node is an enemy.
For each of your friendly nodes, you should return an action (via STDOUT) like the following:
0,0 1,3 5,0

The above would mean that you want to increase your strength of the first node, use your second node to attack the fourth node, and your last node will transfer its strength the first node (and if nobody attacks it, it will become a safe node).
After returning, your program should quit.
Scoreboard

accumulator got 3240 points
classy got 2370 points
dumbot got 2262 points
random_bot got 1603 points
smarter_random_bot got 1319 points
steady_bot got 1097 points

The controller can be found here: https://github.com/nathanmerrill/NetAttack

Accumulator, Python

Let's get this party started! My submission should work both on Python 2 and Python 3.

import sys

inputs = [(i, x[0], int(x[1:])) for (i, x) in enumerate(sys.argv[1].split())]

own_nodes = sorted([(s,i) for (i,o,s) in inputs if o == 'F'])
targets = sorted([(s,i) for (i,o,s) in inputs if o == 'E'])

if targets:
    t_copy = targets[:]
    out = ""
    total_str = 0
    attackers = []
    for (s,i) in own_nodes:
        attackers += [i]
        if t_copy:
            total_str += s
            if t_copy[0][0] < total_str - 1:
                j = max([j for j in range(len(t_copy)) if t_copy[j][0] < total_str - 1])
                out += " ".join([str(k) + "," + str(t_copy[j][1]) for k in attackers]) + " "
                attackers = []
                total_str = 0
                t_copy = t_copy[:j] + t_copy[j+1:]
    if attackers:
        if t_copy:
            out += " ".join([str(k) + "," + str(t_copy[0][1]) for k in attackers])
        else:
            out += " ".join([str(k) + "," + str(attackers[0]) for k in attackers])
else:
    out = " ".join([str(i) + "," + str(own_nodes[0][1]) for (s,i) in own_nodes])

print(out.rstrip())
sys.stdout.flush()

The idea is really simple.
I start enumerating my nodes in ascending order of strength, keeping a running sum of the strengths.
When the sum exceeds the strength of the weakest enemy node (+1 for a possible increase), I attack that node and remove it from the pool, reset the sum, and continue.
At the end, if the strongest nodes can't find anyone to attack, they'll collect more strength.

EDIT: Accumulator is now a bit smarter.
Instead of always attacking the weakest enemy node, it accumulates the strength until it could do so, and then attacks the strongest free node it can with that strength.
Also, if there are still enemies left at the end, any unassigned nodes will attack the weakest remaining enemy, just in case it decides to transfer its strength away.


Josephus problem with three inputs There's a question on this site that is similar to this question, but I have added a twist.

You have three inputs, the number of people in the circle n, the k-th person counted out at each step, and the q-th person that survives. The people in the circle are numbered 1 to n.

For example, in a circle of 20 people, the 20th person to survive is the very first person removed, the 19th survivor is the second person removed and so on. Normally, the Josephus problem is to determine the last person removed, here called the first survivor.

Write the shortest program or function that, with those three inputs, returns the number of the q-th person to survive.

If there are any issues with clarity, please let me know.

Some examples:

>>> josephus(20, 3, 9)
4
>>> josephus(4, 3, 1)
1
>>> josephus(100, 9, 12)
46

Edit: Assume all inputs are valid. That is no one will ask for 0 or any negative numbers and no one will ask for the 20th survivor in a circle of 5 people (that is, 1 ≤ q ≤ n)

Edit: I'll accept an answer at midnight UTC+7 at the start of December 2.

Piet, 280 273 codels

Edit: I have golfed this down some more, and I think I can golf it down even further, but that is still to come. For now, I'm just glad it works, and that I had room to sign it in the bottom left-hand corner. Two ideas I have to save more codels are a) to change the end instructions be pop, push 1, add, out num (pop n, output r+1) and b) to duplicate again at the bottom left corner to save codels in stack manipulation later on in the loop.

The picture above is my code at 8 pixels per codel. In general, it's the same algorithm as my Python answer, but with the inputs in the order of k, q, n. In practice, there is a also a great deal of stack manipulation. You can try it here by opening the image there and running the code with it.

Explanation

This is a step-by-step ungolfing of the solution.

in num    get k
dup       Stack: k k
push 1
subtract  Stack: k k-1
in num    get q
dup       Stack: k k-1 q q
dup       Stack: k k-1 q q q
push 4
push 2
roll      Stack: k q q k-1 q
mod       Stack: k q q r
in num    get n
# note: the loop will return to the following codel
dup       Stack: k q q r n n
push 4
push 3
roll      Stack: k q r n n q
greater   1 or 0
pointer   Here the loop begins. If q>n, the pointer moves clockwise.
          Else, it points straight ahead

LOOP:     Stack: k i r n (i=q at the start of the loop)
push 4
push 2
roll      Stack: r n k i
push 1
add       Stack: r n k i=i+1
push 2
push 1
roll      Stack: r n i k
dup       Stack: r n i k k
push 5
push 4
roll      Stack: n i k k r
add       Stack: n i k m=r+k
push 3
push 2
roll      Stack: n k m i
dup       Stack: n k m i i
push 3
# here it turns the corner
push 1
roll      Stack: n k i m i
mod       Stack: n k i r=m%i
push 4
# here it turns the corner and avoids the black codels
push 1
roll      Stack: r n k i
dup       Stack: r n k i i
push 5
push 3
roll      Stack: k i i r n
dup       Stack: k i i r n n
# and we meet up with the dark green codel once more
push 4
push 3
roll      Stack: k i r n n i
greater   Stack: k i r n (0 or 1)
pointer   if else again

# else    Stack: k i r n
push 2
push 1
roll      Stack: k i n r
# and turn the corner
push 1
add       Stack: k i n r+1
out num   print r+1
# turn the corner into the end pattern (the shape with the black edges)
END