Linear interpolation of the Fibonacci sequence Your task is to find the nth Fibonacci number, but n is not necessarily an integer.

The Fibonacci sequence, 0-indexed, goes as follows:

0, 1, 2, 3, 4, 5,  6,  7, ...

1, 1, 2, 3, 5, 8, 13, 21, ...

However, what happens if we want the 2.4th number?

The 2.4th number is 0.4 times the difference between the 3rd and 2nd Fibonacci numbers plus the 2nd Fibonacci number. So, the 2.4th Fibonacci number is 2 + 0.4 * (3 – 2) = 2.4.

Similarly, the 6.35th Fibonacci number is 13 + 0.35 * (21 – 13) = 15.8.

Your task is to find the nth Fibonacci number, such that n is greater than or equal to 0.

You may do this zero- or one-indexed, just please say which one you are using.

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

Some more examples:

0        1
4.5    6.5
0.7      1
7       21

Jelly, 5 bytes
_Ḟ1+¡

This is an iterative solution without built-ins. It uses the same indexing as the challenge spec.
Try it online!
Background
Let f be the function defined in the challenge spec and F the Fibonacci function defined as usual (i.e., with F(0) = 0). For a non-negative integer n, we have f(n) = F(n + 1). When 0 ≤ x < 1, the challenge spec defines f(n + x) as f(n) + (f(n + 1) - f(n))x.
Clearly, this just affects the base cases, but not the recursive formula, i.e., f(n) = f(n - 1) + f(n - 2) holds as it would for F. This means we can simplify the definition for non-integer arguments to the easier f(n) = f(n) + f(n - 1)x.
As others have noted in their answers, the recursive relationship also holds for non-integer arguments. This is easily verifiable, as

Since f(0) = f(1) = 1, f in constant in the interval [0, 1] and f(0 + x) = 1 for all x. Furthermore, f(-1) = F(0) = 0, so f(-1 + x) = f(-1) + (f(0) - f(-1))x = 0 + 1x = x. These base cases cover in [-1, 1), so together with the recursive formula, they complete the definition of f.
How it works
As before, let n + x be the only argument of our monadic program.
¡ is a quick, meaning that it consumes some links to its left and turns them into a quicklink. ¡ in particular consumes either one or two links.

<F:monad|dyad><N:any> calls the link N, returning r, and executes F a total of r times.

<nilad|missing><F:monad|dyad> sets r to the last command-line argument (or an input from STDIN in their absence) and executes F a total of r times.

Since 1 is a nilad (a link without arguments), the second case applies, and +¡ will execute + n times (a non-integer argument is rounded down). After each call to +, the left argument of the quicklink is replaced with the return value, and the right argument with the previous value of the left argument.
As for the entire program, Ḟ floors the input, yielding n; then _ subtract the result from the input, yielding **x, which becomes the return value.
1+¡ then calls +¡ – as described before – with left argument 1 = f(0 + x) and right argument x = f(-1 + x), which computes the desired output.


Permutations with Indistinguishable Items Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each group of indistinguishable numbers has length n_i, this is n! / (n_1! * n_2! * ...)
Rules

Input will be some form of list as arguments to a function or the program with 1 to 12 non-negative integers.

Output will be printing or returning the number of permutations as described above.

No standard loopholes or built-in functions (generating permutations, combinations, etc.). Factorials are allowed.

Test Cases
Inputs:
1, 3000, 2, 2, 8
1, 1, 1
2, 4, 3, 2, 3, 4, 4, 4, 4, 4, 1, 1

Outputs:
60
1
83160

Python, 48 bytes
f=lambda l:l==[]or len(l)*f(l[1:])/l.count(l[0])

A recursive implementation.
In the formula, n! / (n_1! * n_2! * ...), if we remove the first element (say it's 1), the number of permutation for the remaining n-1 elements is
(n-1)! / ((n_1-1)! * n_2! * ...) ==
n! / n / (n_1! / n_1! * n_2! * ...) ==
n/n_1 * (n! / (n_1! * n_2! * ...)`)

So, we get the answer by multiplying by n/n1, the reciprocal-fraction of elements that equal the first one, by the recursive result for the rest of the list. The empty list gives the base case of 1.


Find how many ordered pairs of integers share only one digit Task

Your task is to make the smallest function/program that can, when gives an number N, return/print:

the number of possible choices a, b such that \$1 \leq a < b < N\$ and a and b have exactly one common digit in base 10 (there exists a digit, and only one digit, which appears both in a and b, for example 12 and 23, where 2 appears both in 23 and in 12)

note - 1 and 11 count as having exactly one common digit, as 1 is a digit which appears in both of them, and it's the only one that appears in both of them.

You function/program should work for all n from 1 to 1000.

Test Cases

20 -> 63
40 -> 267
60 -> 575
80 -> 987
100 -> 1503
1000 -> 235431

Rules

This is a code golf so the lowest score in bytes wins. Good luck!

APL (Dyalog Extended or 18.0), 24 22 bytesSBCS

Full program.

≢⍸∘.(<∧1=∘≢∘∪∩⍥⍕)⍨1↓⍳⎕

Try it online!

⎕ prompt for N from the console

⍳ first N integers

1↓ drop the first one (0)

 ⍨ apply the following function using those integers as both left and right argument:

  ∘.(…) apply the following function between all combinations of left and right elements:

   ⍥⍕ stringify (make into character list) both arguments, then:

    ∩ find the intersection between the character lists

   ∪ find the Unique elements of that

   ∘ then:

    ≢ count that

   ∘ then:

    1= check if that is equal to 1

   ∧ and

   < the left argument is less than the right argument

⍸ find the ɩndices of the trues

≢ count them


Tesco's Burger Relish Best Before End date number Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit Burger Relish Best Before End date number.

The format is simply the last two digits of the year, followed immediately by three digits representing the day of that year, between 000 and 365.

Cookies if you can do this using only numeric operations and comparisons. You may put such code separately from your golfed code, if it isn't also the shortest code you have.

Test cases

[year,month,day] → BRBBED:

[2010,1,1] → 10000

[2019,7,5] → 19185

[2020,5,20] → 20140

[2096,12,31] → 96365

[2099,12,31] → 99364

PowerShell, 74 70 67 bytes

param($y,$m,$d)-join"$y 00$((date "$m/$d/$y"|% d*r)-1)"[2,3+-3..-1]

Try it online!

Exactly what it says on the tin (but formatted weirdly). Takes in $year, $month, $day, plucks out the last two digits of the $year, gets a .NET datetime object of the specified day, then gets the dayofyear (with |% d*r) thereof. Subtracts one to make it zero-indexed, then uses string formatting and slicing to make it three-padded (e.g., 000 instead of 0), and then -joins it all together into a single string with implicit output.

Note this is culture dependent due to the datetime formatting. This works in en-us, which is what TIO also uses.

-3 bytes thanks to mazzy


Split a number in every way possible way within a threshold Task
Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold.
Examples

Input: 15008
Threshold: 400

Valid Output:
[[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]]
Invalid outputs:

[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500, 8] ... (500 is above threshold)

[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 5008] ...  (5008 is above threshold)

[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 5, 00, 8] ...  (double zeroes not allowed)

[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 5, 0, 08] ...  (leading zero not allowed)

[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 5, 008] ...  (leading zeroes not allowed)

Input: 15008
Threshold: 17

Valid Output:
[[1, 5, 0, 0, 8], [15, 0, 0, 8]]
Invalid output: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150,0,0,8]... (150 is above threshold)
Rules

Valid threshold values are between 10 and 999.
Double zeroes are not allowed on output.
Leading zeroes are not allowed on output.
Duplicates must be removed.
Output order is not relevant

Scoring

Shortest answer in bytes wins

Jelly, 11 bytes
ŒṖḌfV⁼³ʋƇḶ}

Try it online!
-1 byte thanks to Jonathan Allan
-1 more byte thanks to Jonathan Allan
How it works
ŒṖḌfV⁼³ʋƇḶ} - Main link. Takes n on the left and t on the right
ŒṖ          - All partitions of the digits of n
  Ḍ         - Convert the lists of digits to a list of numbers
          } - To t:
         Ḷ  -   Yield [0, 1, 2, ..., t-1]
        Ƈ   - Filter the partitions p, keeping those for which the following is true...
       ʋ      ...with each partition p on the left and the lowered range on the right:
   f        -   Keep the numbers in the lowered range (i.e. less than t)
    V       -   Concatenate the numbers into a single number
     ⁼³     -   Is that equal to n?


Brainf*** subprograms with unique outputs You should write a 100-byte long brainfuck (BF) program.

One character will removed from it in every possible way the resulting 100 new (99-byte long) programs.  E.g. for the program ++.>. the 5 subprograms are +.>., +.>., ++>., ++.. and ++.> .

Your score will be the number of unique outputs the 100 programs generate. Higher score is better.

Details

Your programs will be terminated after outputting the first character.
Invalid or non-terminating programs and programs generating empty outputs are not counted towards the score.
The BF cells are 8 bit wrapping ones. (255+1=0, 0-1=255)
Your program is given no input. If you use , in the code it set's the current cell to 0.
There are no cells on the left side of the starting position. E.g. <. is invalid but .< is valid as the execution is terminated at .. The tape is unbounded in the other direction.
Programs with unbalanced brackets ([ and ]) are invalid.
Your original program can be shorter than 100 bytes as it's easy to extend it to 100 bytes without changing the score.
Your original program doesn't have to be valid BF code.

You can use this python3 program (ideone link) to determine the score of your answer. (For long-running programs you may need to modify the maxstep variable.)

Example

(For simplicity this program is shorter than 100 bytes.)

Solution: ++,+[-]+><.-,-.

Score: 3

Explanation:

Subprogram     => Output

+,+[-]+><.-,-. => 1
+,+[-]+><.-,-. => 1
+++[-]+><.-,-. => 1
++,[-]+><.-,-. => 1
++,+-]+><.-,-. => None
++,+[]+><.-,-. => None
++,+[-+><.-,-. => None
++,+[-]><.-,-. => 0
++,+[-]+<.-,-. => None
++,+[-]+>.-,-. => 0
++,+[-]+><-,-. => 255
++,+[-]+><.,-. => 1
++,+[-]+><.--. => 1
++,+[-]+><.-,. => 1
++,+[-]+><.-,- => 1

Unique outputs are [0, 1, 255]
Score is 3 for ++,+[-]+><.-,-. (length = 15)

In case of a tie the winner is the one with the shorter code. (Your program can be shorter than 100 bytes as stated in the Details section.) If the codes are equal length the winner is the earlier poster.

Bonus puzzle: without the bolded restriction can you find a program with score 100?

Score: 35 41 69 78 79 83
(Remove the newline.)
-->+>->+>->+>->+>->+>->+>->+>->+>->+>->+>->+>->+>-
>+>->+>->+>->+>->+>->+>->+>->+>++[>[-<+++>]<<++]>.

Try it online!
I'm not sure exactly why it works...
Score: 79
X->>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>
+>+>+>+>+>+>+>+>+>+>+>+[>[-<+>>+<]+>[-<+>]<<<+]>>.

Try it online!
It was supposed to sum 2*mem[i]*i and add the number of cells (+const) where the addresses are counted from the right to the left. The multiplier 2 and number of cells can make removing + and > having different parity.
It indeed worked like that in the 69 points version. But the latest version broke that and got something else by coincidence. It calculates sum(mem[i]*i+i+1) and removing + and > does almost the same, except for the sum(i) which has a difference of the number of cells, which is also the number of different output for either removing + and >.
For the bonus:

 +.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.


Hexcellent Minesweeping Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.)  Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph).  The one that is most difficult is the {X} and -X- rules.

The {X} rule tells us that a cell borders X mines and that all of these mines border each other in a continuous path.  For example if we had the board:

  ?   ?

?  {3}  ?

  ?   ?

The 6 possibilities for mine placement would be

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

*  {3}  .   *  {3}  .   .  {3}  *   .  {3}  *   .  {3}  *   *  {3}  .

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

Your goal is to implement the rule {3} in generalized Minesweeper.

Specifics

Generalized Minesweeper is Minesweeper played on an arbitrary graph.  The graph has two types of vertex, an "indicator" or a "value".  A value can be either on or off (a mine or a dud) however its state is unknown to the player. An indicator tells the player how many adjacent vertices are on (mines) and does not count as a mine itself.

For example the following board for Generalized Minesweeper tells us that cells A and B are either both mines or neither of them are mines.

(In the diagram indicators are marked in gray while values are white)

Unlike in normal minesweeper where you click values that are off to reveal indicators, there is no such mechanic in Generalized Minesweeper.  A player simply determines for what states of the graph can satisfy its indicator.

Your goal is to build a structure in Generalized Minesweeper such that there are 6 specific cells that can only have states that fulfill as if they were connected with the Hexcells rule {3}.  When you write your solution you should not have specific values in mind for value cells. (In answer to H.PWiz's question it is allowed that some value cells might be deducible from the state, but you can always improve your score by removing such cells)

Scoring

You answers will be scored by the number of vertices in the final graph minus 6 (for the 6 inputs) with a lower score being better.  If two answers tie in this metric the tie breaker will be the number of edges.

Solvability

This problem is solvable, I have a solution to this problem and I will post it once this challenge is a week old.

7 5 vertices, 14 10 edges

(Graph made with this online tool and paint.)

A-F are our six nodes, and J is a helper node. The three 1-nodes enforce that opposite nodes are different, while the 2-node makes sure that A, C and E can neither be all mines, nor all empty.

Edit: -2 vertices thanks to  CalculatorFeline and H.PWiz!


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

For example,

k = 2
n = 4
A = 1 2 3 4

The subsets of size 2 and their products are

1 2 = 2
1 3 = 3
1 4 = 4
2 3 = 6
2 4 = 8
3 4 = 12

which sum together to 35.

Some test cases:

Input

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

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

Output

499369377

87409828

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

Constraints

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

The shortest solution is the winner.

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

For example,

Mathematica (31)

Times@@#&/@A~Subsets~{k}//Total

R - 20

Since the OP said:

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

sum(combn(A,k,prod))


Can I exit the maze with this many bombs? Inspired by this Puzzling challenge, and easier version of my previous challenge.
Challenge
A 2D rectangular grid is given, where each cell is either an empty space or a wall. You start at the top left cell, and you need to exit through the bottom right cell. You can move to one of four adjacent cells in one step.
You have some bombs, so that using one bomb will let you break exactly one cell-sized wall and go through it. Can you exit the maze using just what you have?
Input and output
The input is the maze and the initial number of bombs. The maze can be taken as a matrix (or any equivalent) containing two distinct values to represent empty spaces and walls. The top left and bottom right cells are guaranteed to be empty. The number of bombs n is always a non-negative integer.
The output should be truthy if you can exit the maze using n or fewer bombs, falsy otherwise. You can output truthy/falsy using your language's convention (swapping is allowed), or use two distinct values to represent true or false respectively.
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
Uses .# for spaces and walls.
Input maze
..#..#..
Output: false (for 0 or 1 bomb), true (≥2 bombs)

Input maze
.....
####.
.....
.####
.....
Output: true (for any bombs)

Input maze
.
Output: true (for any bombs)

Input maze
.#.#.
##.##
.###.
Output: false (for ≤2 bombs), true (≥3 bombs)

Input maze
.####
#####
##.##
#####
####.
Output: false (for ≤5 bombs), true (≥6 bombs)

JavaScript (ES7),  126 125  119 bytes
Expects (matrix)(bombs), where the matrix is filled with -1 for an empty cell and -2 for a wall.
Returns false if we can exit the maze, or true if we can't.

m=>g=(b,X=0,Y=0)=>m.every((r,y)=>m[Y+1]||r[X+1]?r.every((v,x)=>r[x]*=v>0|(X-x)**2+(Y-y)**2!=1||g(b-~v,x,y,r[x]=1)):b<0)

Try it online!
Commented
m =>                        // m[] = matrix
g = (                       // g is a recursive function taking:
  b,                        //   b = number of bombs
  X = 0, Y = 0              //   (X, Y) = current position, starting at (0, 0)
) =>                        //
  m.every((r, y) =>         // for each row r[] at position y in m[]:
    m[Y + 1] ||             //   if there's a row below the current cell
    r[X + 1] ?              //   or there's a column on the right:
      r.every((v, x) =>     //     for each value v at position x in r[]:
        r[x] *=             //       restore r[x] if any of these tests is true:
          v > 0 |           //         - v is greater than 0 (this cell was visited)
          (X - x) ** 2 +    //         - the squared distance between
          (Y - y) ** 2 != 1 //           (x, y) and (X, Y) is not equal to 1
          ||                //
          g(                //         - this recursive call is truthy:
            b - ~v,         //             decrement b if v = -2
            x, y,           //             use the new position (x, y)
            r[x] = 1        //             mark r[x] as visited by setting it to 1
          )                 //           end of recursive call
      )                     //     end of inner every()
    :                       //   else (bottom-right cell):
      b < 0                 //     return true if we've used too many bombs
  )                         // end of outer every()


Visualize a large int Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc.  The result shall be groups of three digits, interspersed by the prefixes (e. g. 1G234M567k890), so that it is easy to glance the order of magnitude of the number without counting the digits.

It shall work for numbers of all digit counts up to 15.  Only non-negative numbers are allowed as input.

More test cases:

0 → 0
123 → 123
1234 → 1k234
1000 → 1k000
1000000000 → 1G000M000k000

JavaScript (ES6), 64 bytes

Takes input as a string.

f=(n,i=0,[d,t]=n.split(/(...)$/))=>t?f(d,i+1)+['kMGT'[d&&i]]+t:d

Try it online!

How?

The regular expression /(...)/$ matches the last three digits of the integer, or nothing at all if there are less than 3 digits remaining.

Because there's a capturing group, these digits -- if present -- are included in the output of the .split() method.

Examples:

'123456789'.split(/(...)$/) // --> [ '123456', '789' '' ]
'123'.split(/(...)$/))      // --> [ '', '123' ]
'12'.split(/(...)$/))       // --> [ '12' ]
''.split(/(...)$/))         // --> [ '' ]

Commented

f = (                 // f is a recursive function taking:
  n,                  //   n = input
  i = 0,              //   i = index of next prefix
  [d, t] =            //   d = either the leading digits without the last 3 ones,
                      //       or all remaining digits if there are less than 3
    n.split(/(...)$/) //   t = last three digits (or undefined)
) =>                  //
  t ?                 // if t is defined:
    f(d, i + 1) +     //   append the result of a recursive call with d and i + 1
    ['kMGT'[d && i]]  //   append the prefix if d is defined, or an empty string otherwise
    + t               //   append the last 3 digits
  :                   // else:
    d                 //   stop recursion and return the remaining digits


Generate Hamming codes Given a stream of bits, output the shortest possible Hamming code that encodes it.

The steps to generate the Hamming code are as follows, although your submission does not necessarily have to conform to them as long as it produces identical output. The input 110100101 will be used as an example.

Pad the input with trailing zeroes until its length is 2m - m - 1 for some integer m.

110100101        becomes
11010010100

Insert spaces at every position with an index of 2i (note that all indexing is 1-based for the purposes of this algorithm). This will insert m spaces for parity bits, resulting in 2m - 1 bits total.

11010010100      becomes
__1_101_0010100

Fill in the parity bits. A parity bit at index i is calculated by taking the sum modulo 2 of all bits whose index j satisfies i & j ≠ 0 (where & is bitwise AND). Note that this never includes other parity bits.

__1_101_0010100  becomes
111110100010100

Input may be taken as a list (or a string) of any two distinct elements, which do not necessarily have to be 0 and 1. Output must be in an identical format. (Input or output as an integer with the corresponding binary representation is disallowed, as this format cannot express leading 0s.)

The input will always have a length of at least 1.

Test cases (of the form input output):

0 000
1 111
01 1001100
1011 0110011
10101 001101011000000
110100101 111110100010100
00101111011 110001001111011
10100001001010001101 0011010100010010010001101000000

JavaScript (ES6), 116 bytes

f=(a,p=i=0)=>1/a[p]?f(a,p+p+1,a.splice(p,0,0)):[...Array(p)].map(_=>i&++i?~~a[i-1]:a.reduce((p,e,j)=>p^=++j&i&&e,0))

If the padding is unnecessary, then for 97 bytes:

f=(a,p=i=0)=>1/a[p]?f(a,p+p+1,a.splice(p,0,0)):a.map(e=>i&++i?e:a.reduce((p,e,j)=>p^=++j&i&&e,0))


Control Your Computer's Fan Speed The objective of this question is to create a program that pushes your computer's internal fan speed to its maximum RPM.  Upon exiting the program, your fan should return to the normal operating RPM.

Rules:

You may not perform a CPU intensive task in order to modify the
fan's speed.
Exiting the program may be via user input, a timeout period, or a response to a SIGTERM or SIGEXIT signal.
Avoid the standard loopholes.

OSX + Bash + smcFanControl, 91 bytes
This relies on the third-party smcFanControl suite to do the hard work and is therefore more of a proof-of-concept than a serious answer.  Real answers could pick apart the smcFanControl source code and do this without third-party help.
smcFanControl.app is assumed to be installed in /Applications.
p=/Ap*/smcFan*/C*/R*/smc\ -k # Path to CLI utility
f()($p'FS! ' -w000$1)        # function to set fan mode
f 3                          # Set fan speeds to "forced" mode
eval $p\ F{0,1}"Tg -w5DC0;"  # Set fan 1 and 2 to 6000 RPM target speed
read                         # wait for keyboard input
f 0                          # Return fans to "auto" mode

Comments added for explanation, but not included in score.


Python 2, 58 bytes

u=-abs(200-input()%400)-4
print u/100+5>(u-8)*5/4%7>u%4/-3

Try it online!

A direct formula.


Within Fibonacci Numbers The Challenge

Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would return 26: 121393 as 12 is found within the number (121393) and it is at index 26 of the Fibonacci numbers.

Examples

Given the input:

45

Your program should output:

33: 3524578

Input:

72

Output:

54: 86267571272

Input:

0

Output:

0: 0

Input:

144

Output:

12: 144

Scoring

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

Jelly, 10 bytes

0ÆḞ©w¥1#;®

Try it online!

How it works

0ÆḞ©w¥1#;®  Main link. Argument: n

0           Set the return value to 0.
       #    Call the second link to the left with arguments k = 0, 1, 2, ... until
      1     one match has been found.
     ¥        Combine the two links to the left into a dyadich chain.
 ÆḞ             Compute the k-th Fibonacci number...
   ©              and copy it to the register.
    w           Yield 1 if n occurs inside the Fibonacci number, 0 otherwise.
         ®  Yield the value stored in the register.
        ;   Concatenate the index and the Fibonacci number.


Squarefree Palindromes Create the shortest function, program, or expression that calculates a sequence of squarefree palindromic numbers.
A squarefree number is one which is not evenly divisible by a square number (i.e. does not contain a repeated prime factor). For example, \$44 = 2^2 \times 11\$ is not squarefree, whereas \$66 = 2\times3\times11\$ is.
You can find a list of the numbers from this link. The list goes as such: 1, 2, 3, 5, 6, 7, 11, 22, 33, 55, 66, 77, 101, 111, 131, 141, 151, 161, 181, 191...

Python 2, 82 75 bytes
n=0
while 1:
 n+=1
 if`n`[::-1]==`n`*all(n%i**2for i in range(2,n)):print n

Try it Online!
If this was a decision problem (54 bytes):
lambda n:`n`[::-1]==`n`*all(n%i**2for i in range(2,n))

Explanation:
`n`[::-1]==`n`                     # If n is a palindrome. `n` is repr(n).
                                   # We check that it's the same
                                   # backwards and forwards.
              *                    # Multiplplying 2 booleans is AND
all(n%i**2for i in range(2,n))     # Check that squares of all #'s < n do not divide n


Impatiently wait for input Your task today is to implement a time limit for getting input, a task I've found rather annoying to achieve in most languages.

You will create a program function which prompts the user for input. Immediatly after the user supplies input, print the message input received and end execution/return. However, if the user waits for more than 10 seconds to provide input, output the message no input received and end execution/return.

Input must be from stdin (the console) or equivalent, not function or program arguments, however output can be either to stdout, your function's return value, or any other accepted output method.

You may ask for any amount of  input, it can be a single character, a line, a word, or whatever method is shortest in your language as long as it waits for at least one character.

You must output as soon as the input is received, not after the 10 seconds have passed.

After 10 seconds have passed, you must end, you cannot continue waiting for input after no input received has been printed.

You may assume that input is not passed in the time between 10 seconds elapsing and text being printed to the screen, as this is an extremely small window. You may also assume that your language's builtin equivalent of sleep is consistently, absolutely perfect.

This is code-golf, fewest bytes wins!

bash, 38 bytes

read -t10||a=no;echo $a input received

This uses the -t (timeout) option to bash's read, which causes it to fail and return a nonzero exit code if no input is given in the specified number of seconds.


Bitwise XOR of rational numbers Introduction

Every rational number between 0 and 1 can be represented as an eventually periodic sequence of bits.
For example, the binary representation of 11/40 is

0.010 0011 0011 0011 ...

where the 0011 part repeats indefinitely.
One way of finding this representation is the following.
Start with r = 11/40, then repeatedly double it and take the fractional part, recording when it goes above 1.
When the value of r repeats, you know you have entered a loop.

1. r = 11/40
2. 2*r = 11/20 < 1   ->  next bit is 0, r = 11/20
3. 2*r = 11/10 >= 1  ->  next bit is 1, r = 2*r - 1 = 1/10
4. 2*r = 1/5 < 1     ->  next bit is 0, r = 1/5
5. 2*r = 2/5 < 1     ->  next bit is 0, r = 2/5
6. 2*r = 4/5 < 1     ->  next bit is 0, r = 4/5
7. 2*r = 8/5 >= 1    ->  next bit is 1, r = 2*r - 1 = 3/5
8. 2*r = 6/5 >= 1    ->  next bit is 1, r = 2*r - 1 = 1/5, same as in 4.
   The loop 5. -> 6. -> 7. -> 8. now repeats.

To get from the binary string back to 11/40, you can use the formula

(int(prefix) + int(suffix)/(2^len(suffix) - 1)) / 2^len(prefix)

where prefix is the initial part 010, suffix is the repeating part 0011, and int converts a binary string to integer.

Given two such representations, we can perform the bitwise XOR operation on them.
The resulting sequence will also be periodic, so it represents a rational number.

For some rational numbers, there are two binary representations.

1/4 = 0.010000000...
    = 0.001111111...

The choice between them can affect the result of the bitwise XOR.
In these cases, we use the former representation, which has infinitely many 0s.

The task

Your inputs are two rational numbers in the half-open interval [0,1).
Your output shall be the result of the bitwise XOR operation applied to the inputs, expressed as a rational number.
Note that the output can be 1, even though neither of the inputs are.

The exact formats of input and output are flexible, but each rational number should be represented by two integers, the numerator and denominator (with the exception of 0 and 1, which can be represented as 0 and 1 if desired).
You can assume that the inputs are expressed in lowest terms.
The output must be expressed in lowest terms.
A built-in rational number type is an acceptable format, as long as it satisfies these restrictions.
You can ignore any bounds on integers imposed by your language, but your algorithm should theoretically work for all rational numbers.

The lowest byte count wins.
Standard code-golf rules apply.

Example

Consider the inputs 11/40 and 3/7.
We write their representations one above the other, delimiting the repeating parts by pipes |.
Then we extract repeating parts of equal lengths, and apply bitwise XOR to them and the parts before them.

11/40 = 0. 0 1 0|0 0 1 1|0 0 1 1|0 0 1 1|0 0 1 1|0 0 1 1|0 0 1 1|0 0 1 ...
3/7   = 0.|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|0 1 1|...
     -> 0. 0 0 1|0 1 0 1 1 1 1 0 1 0 0 0|0 1 0 1 1 1 1 0 1 0 0 0|0 1 0 ...

The resulting rational number is 89/520.

Test cases

0 0 -> 0
1/2 1/2 -> 0
1/2 1/4 -> 3/4
1/3 2/3 -> 1
1/2 3/4 -> 1/4
5/8 1/3 -> 23/24
1/3 1/5 -> 2/5
15/16 3/19 -> 257/304
15/16 257/304 -> 3/19
3/7 11/40 -> 89/520
5/32 17/24 -> 59/96
16/29 16/39 -> 621001733121535520/696556744961512799

Python 3, 193 164 bytes
def x(a,b,z=0):
 l=[]
 while(a,b)not in l:l+=[(a,b)];z=2*z|(a<.5)^(b<.5);a=a*2%1;b=b*2%1
 p=l.index((a,b));P=len(l)-p
 return((z>>P)+z%2**P*a**0/~-2**(P or 1))/2**p

Takes input as Python 3's fractions.Fraction type, and outputs it as well.
Fun fact (you can easily show this using generating functions), if you change (a<.5)^(b<.5) to ((a>=.5)and(b>=.5)) above you get the binary AND between two rational numbers. Call this nd(a, b). Then we have a + b - 2*nd(a, b) = x(a, b)!


Mean Reputation Change Challenge

Given a the ID for a PPCG user who has existed for at least a month, output the average amount of reputation they gain per month. You can do this by dividing their reputation by the time since their account was created (which you can find on the profile). This should be returned floored; that is, truncate all of the decimals. (We don't care about the small stuff).

Input

A single integer, which is the user's ID

Output

A single integer, representing the floored rep change per month.

Test Cases

input -> output
42649 -> 127 (me)
12012 -> 3475 (Dennis)
8478  -> 3015 (Martin Ender)

JS, ES6 243 235 168 166 165 164 bytes

i=>fetch(`//api.stackexchange.com/users/${i}?site=codegolf`).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3))))

Based on the Python answer.

Run this in the console:

(i=>fetch(`//api.stackexchange.com/users/${i}?site=codegolf`).then(x=>x.json()).then(x=>alert(~~((y=x.items[0]).reputation/((new Date/1e3-y.creation_date)/2592e3)))))(+prompt("Enter a userId"))

-4 thanks to @insert_name_here

Old answer:

z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert((/([\d,]+) repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0))))

Improvements welcome! Just fetches the profile page and parses it with regular expressions!

Won't work as a stack snippet, but you can paste this in your console:

(z=>fetch("//codegolf.stackexchange.com/u/"+z).then(x=>x.text()).then(x=>alert(Math.floor(/([\d,]+) repu/.exec(x)[1].replace(/,/g,"")/(((y=/Member for <.+>((\d+) years?, )?(\d+) month/.exec(x))[2]||0)*12+ +y[3]||0)))))(+prompt("Enter a userId"))


Help me carry my shopping bags It was a warm summer evening...
when my stupid car decided to break down in the middle of the road on my way back from the supermarket. I pushed it to the sideline and decided to walk home. I opened the trunk to take out the grocery and remaining stuff. It was then that I noticed the items were not evenly bagged. Some bags had more heavy items while others had few lighter stuff - some even had a mix of such items. To make it easy for me to carry, I decided to group everything in to two bags and make their weights as close to each other as possible.

Your goal
is to help me rearrange the items in to two shopping bags in such a way that the difference between both bags is close to zero as possible.
Mathematically:

WEIGHT LEFT HAND —  WEIGHT RIGHT HAND ≈ 0

Example
If I had only 2 items, Bread and Peanut butter, and the weight of bread is 250 grams and peanut butter is 150 grams, the best way is to carry them separately in two hands.

WLH - WRH = W(BREAD) - W(P.BUTTER)
250 - 150 = 100

The other possibility is :

W(BREAD, P.BUTTER) - W(empty hand) = (250 + 150) - 0 = 400

This is not better than our first case, so you should go with the first one.
Your code should

take inputs of numbers indicating weights of items in the shopping bag. Units are not important, but they should be the same (ideally kilograms or grams). Input can be done one by one or all at once. You may restrict the total count to 20 items max, if you want.
The input format/type is up to you to choose, but nothing else should be present other than the weights.
Any language is allowed, but stick to standard libraries.
Display output. Again, you're free to choose the format, but explain the format in your post. ie, how can we tell which ones are left hand items and which ones are right hand items.

Points

Shortest code wins.

Hint

The two possible algorithms that I could think of are differentiation (faster) and permutations/combinations (slower). You may use these or any other algorithm that does the job.

Pyth, 9 bytes

ehc2osNyQ

Input, output formats:

Input:
[1, 2, 3, 4, 5]
Output:
[1, 2, 4]

Demonstration.

ehc2osNyQ
             Q = eval(input())
       yQ    Take all subsets of Q.
    osN      Order those element lists by their sums.
  c2         Cut the list in half.
eh           Take the last element of the first half.

This works because y returns the subsets in such an order that each subset and its complement are equidistant fom the center. Since the sum of a subset and the sum of its complement will always be equidistant from the center, the list after osNyQ will also have this property. Thus, the center two elements of osNyQ are complements, and must have an optimal split. We extract the first of those two elements and print it.


Efficiently generate all vector partitions A vector partition is splitting a vector up a series of vectors such that their sum is the original. Here are a couple partitions:

[3, 1, 2] = [3, 1, 2]
[3, 1, 2] = [0, 0, 1] + [0, 0, 1] + [0, 1, 0] + [1, 0, 0] + [2, 0, 0]
[3, 1, 2] = [1, 1, 2] + [2, 0, 0]

Here vector addition is done element-wise. A valid partition does not contain any vectors with negative integers, or the all-zero vector.

Now the challenge is to write a program or function that generates all possible vector partitions given a target vector. This may sound relatively easy...

...but there is a twist. If the input vector has size L, and the biggest partition it generates has M elements, you may not use more than O(L*M) memory.

You may assume that an integer uses O(1) memory.
This means that you must output the partitions as you generate them. On top of that, you must only output each partition exactly once. For example, these are the same partition:

[3, 1, 2] = [3, 0, 2] + [0, 1, 0]
[3, 1, 2] = [0, 1, 0] + [3, 0, 2]

If you were to output both your answer is invalid.

All partitions for [3, 2]:

[3, 2]
[0, 1] + [3, 1]
[0, 1] + [0, 1] + [3, 0]
[0, 1] + [0, 1] + [1, 0] + [2, 0]
[0, 1] + [0, 1] + [1, 0] + [1, 0] + [1, 0]
[0, 1] + [1, 0] + [2, 1]
[0, 1] + [1, 0] + [1, 0] + [1, 1]
[0, 1] + [1, 1] + [2, 0]
[0, 2] + [3, 0]
[0, 2] + [1, 0] + [2, 0]
[0, 2] + [1, 0] + [1, 0] + [1, 0]
[1, 0] + [2, 2]
[1, 0] + [1, 0] + [1, 2]
[1, 0] + [1, 1] + [1, 1]
[1, 1] + [2, 1]
[1, 2] + [2, 0]

To test your answer, run it on [3, 2, 5, 2]. It should generate 17939 partitions, all of which sum to [3, 2, 5, 2], and that are all unique (you can test for uniqueness by first sorting each partition lexicographically).

Shortest code in bytes wins.

Python 2, 289 bytes
Simple brute force algorithm. Treats entire list as a number in base max(input)+1 (b), and checks each "number" in the range [0, b**(L*M)) to see if it:

Sums to the correct amount
Is in alphabetical order (ensures uniqueness)

If the list matches these criteria, the program outputs it with all the all-zero vectors stripped.
Memory usage
The largest data structure I use in this program is a doubly-nested list, an list length M containing liss length L to give O(L*M) memory.
For my other data structures, I have 3 global ints O(3), 1 list length L (O(L)), 1 array length M (O(M)), and a copy of the largest array when outputting (O(L*M)).
In total, this gives me a memory usage of O(2*L*M + L + M + 3) which simplifies to O(L*M), fufilling the criteria.
Time complexity
Being a brute force algorithm, this algorithm is extremely slow. For the while loop to quit, the final int in the array needs to be b-1. The loop needs to run b**(L*M) times before that happens.
In addition, each time the list runs, it needs to check both conditions, and print the list in a worst case, using L*M+L+M iterations. This simplifies to give an overall O(L*M * b**(L*M)). I tried to test my program on [3, 2, 5, 2], but gave up after 45 minutes.
Golfed program
v=input()
L=len(v)
M=sum(v)
b=max(v)
R=range
t=[L*[0]for i in R(M)]
def A(l,i):
 if i<L*M-1and~-b<l[i/L][i%L]:A(l,i+1)
 l[i/L][i%L]=-~l[i/L][i%L]%-~b
while t[-1][-1]<b:
 if v==[sum(q[i]for q in t)for i in R(L)]and all(`t[i]`>=`t[i+1]`for i in R(M-1)):print[x for x in t if[0]*L!=x]
 A(t,0)

I might be able to golf this a bit more, especially the increment part. Ungolfed code coming.


The smallest self-improving program The goal is to write a program that learns from its own mistakes, and improves itself based on it. This means, that later attempts at the problem should be either faster or more accurate, than earlier ones.

To deny trivial solutions, here is a set of rules (they are rather obvious):

you can choose the problem to be solved, but your choice will be voted upon.
the program should read input, this means the problem must have input variables, and its output should depend on that input.
later runs of the algorithm should be better (at least after a certain number of runs) than the previous ones. Better can mean faster, or more optimal, or more accurate.
the improvement must be real, and not just the disabling of purposefully introduced inhibitors like if (never_run_before()) sleep(100);
the improvement must be caused by your program, and not external factors (like the OS giving faster access to a resource, if it was already opened or more often accessed before)
the iterations can be either successive runs of the program while you save knowledge to a non-volatile storage, or you can have an interactive program which reads input again and again for successive runs of the algorithm.
there should be improvement besides the situation where the algorithm runs faster given the exact same input data. (just storing previous results and doing nothing else would be too cheap). This means, there should be some improvement even if there is no repetition in the input data, for example if the task is to solve a maze, the input maze might be different each time.
the algorithm must be part of your program, so the use of existing machine-learning tools is not allowed (otherwise it would be a too easy win for Matlab and its built-in neural network)

The score is: number of characters - 5 * score form votes. It can be negative. Smallest wins. Winner will be selected not sooner than 10 days after the first valid solution, and has to have a positive vote score.

For voters: the golfing is already an independent part of the score, so pleas don't vote based on the amount of golfing, but on the cleverness of the solution and the hardness and originality of the chosen problem (a program playing a game against the user should worth more than a program calculating the digits of pi)

GNU Octave / MATLAB, 14

f=@(n)n+sin(n)

You don't generally take a standard input with Octave programs, so this is a function which gives an improved estimate of pi after every call on its previous output. Sample run:

octave> f=@(n)n+sin(n);
octave> format 'long'
octave> n = 1;
octave> n = f(n)
n =  1.84147098480790
octave> n = f(n)
n =  2.80506170934973
octave> n = f(n)
n =  3.13527633289972
octave> n = f(n)
n =  3.14159261159065
octave> n = f(n)
n =  3.14159265358979


Detect Rectangular Text with Rectangular Code Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. Additionally, the source code for your solution must be rectangular.

A string is rectangular if it meets all of the following conditions:

The first line and the last line contain no spaces.
The first and last character of each line is not a space.
All lines have the same number of characters.

For example, the following text is rectangular:

abcd
e fg
hijk

This text, however, is not rectangular (requirement #3):

1234
567
8900

Test Cases

Truthy:

sdghajksfg

asdf
jkl;

qwerty
u i op
zxcvbn

1234
5  6
7890

abcd
e fg
hijk

Falsey:

a b c

123
456
7 9

12
345

qwerty
 uiop
zxcvnm

1234
567
8900

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

C (gcc), 127 125 124 118 bytes

Saved two bytes by golfing r*=!e&(!t|t==c); to r>>=e||t&&t-c;. (This golf was the inspiration for my recent C tips answer Inverse flag update.)
Saved a byte by golfing *(_-2) to _[~1].
Saved six bytes by golfing *_++-10||(...) to *_++<11?...:0 and utilizing the placeholder zero ...:0 (which is not used constructively) to golf the c++ increment. Those golfs allowed some further loop reshuffling.
When one can use multiple falsey values, 114 bytes could be possible.

r,e,c,t;_(char*_){for(r=1,t=c=0;*_;*_++<11?r*=(t||(t=c,!e))&*_>32&_[~1]>32&t==c,c=e=0:c++)*_-32||(e=1);r>>=e||t&&t-c;}

Try it online!

Source layout achieving a taller rectangle.

Explanation

The following explains the 124 bytes long version.

r,e,c,t;_(char*_){     // `r` is the boolean result flag, `e` a boolean flag if the current line contains
                       //  a space, `t` the first line's width, `c` the current line's current width
 for(r=1,t=c=0;*_;c++) // initialize, loop through entire string
  *_-32||              // if the current char is a space,
   (e=1),              //  the current line contains a space
  *_++-10||            // if the current char is a newline (char pointer `_` now incremented)
   (r*=(t||(t=c,!e))   // if t is not yet set, the current line is the first line; set it
                       //  to this line's length, check that no spaces where found
    &*_>32             // the next line's first char should not be a space
    &_[~1]>32          // this line's last char should not have been a space
    &t==c,c=~0,e=0);   // the line lengths should match, reset `c` and `e` to zero
                       //  (`~0 == -1`, countering the loop's increment of `c`)
 r>>=e||t&&t-c;}       // return boolean flag, check that the last line does not contain spaces,
                       //  there was either no newline or line lengths match
                       //  (here) equivalent to `r*=!e&(!t|t==c)`

Try it online!


ASCII Borromean Rings The Borromean rings are a curious set of three circles, linked such that the removal of any one of them will unlink the other two:

You can make a set for yourself with a couple rubber bands and a binder ring. With more rubber bands, it's easy to make any Brunnian link.

Write a program or function that outputs (prints or returns) this ascii-art representation of Borromean rings:

    +-----+
    |     |
+-----+   |
|   | |   |
| +-|---+ |
| | | | | |
| | +-|---+
| |   | |
+-|---+ |
  |     |
  +-----+

The lines may have trailing spaces and there may be a trailing newline.

The shortest code in bytes wins.

CJam, 53 51 50 49 bytes
Plain old base conversion...
"FÓîÞ¤ÛYËB[¢O²êÍÓ
}²|äG"299b4b"+ -|"f=B/N*

All characters are well in extended ASCII range (ASCII code 1 to 255), so number of characters == number of bytes.
Try it online here and get the original code here


Colorize a diff in unified format Introduction
git diff is a great way to export patches of the source code, and its outputs are colorized if you don't pass extra arguments to it.
However, when you want to review the exported file with colored output, it would be pretty hard. colordiff is an option, but it acts like the diff program itself, also, it is not "multiplatform" considering how many languages this community can code in.
Challenge
Write a program that takes a diff text input from the user and colorize it. On *nix, it might mean printing to standard output with ANSI escape sequences. The colored output must be clearly visible to users.
Details

Only valid diff texts will be passed. You can make it so other cases are UB.
The original file line starting with --- (e.g. ---path/to/example) should be colored red and bolded.
The new file line starting with +++ (e.g. +++path/to/example) should be colored green and bolded.
The modification lines starting with + or - (e.g. +correct and -wrong) should be colored green and red respectively, but not bolded.
You can color the hunk range information indicated by two @@s at the start of a line (e.g. @@ -22,3 +23,7 @@) however you like, but it should not be the default color, and it must be consistent throughout the program. The hunk range indicators can be bolded.
The optional section heading after the hunk range information which is after the second @@ (e.g. "This is an optional heading" in @@ -22,3 +23,7 @@ This is an optional heading) should NOT be colored.
All other lines should NOT be colored.
The program must output the exact text from the input. The only difference is the color.
You may assume that only new file lines start with +++, only original file lines start with ---, only modification lines start with + or - (but not --- or +++), and that all lines starting with @@ denote a hunk information.

Restriction
Usage of diffutils, patchutils, git tools, or any other external programs are not allowed.
Test Cases
+++ Green and Bolded
++ Green, not Bolded
+ Green
- Red
-- Red, not Bolded
--- Red and Bolded
@@ -123,1 +123,1 @@ <- that was a color different to this color
This should be a sentence that has the same color as the line above and after the second @@
This is not colored: @@ test ---+++ @@ because it doesn't start at the beginning of a line

@@ -12,3 +12,3 @@ <- that should have the same color as the last hunk

Winning Criterion
This is code-golf, so the shortest wins!


Finding approximate correlations Consider a binary string S of length n.  Indexing from 1, we can compute the Hamming distances between S[1..i+1] and S[n-i..n] for all i in order from 0 to n-1.    The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. For example,
S = 01010

gives
[0, 2, 0, 4, 0].

This is because 0 matches 0, 01 has Hamming distance two to 10, 010 matches 010, 0101 has Hamming distance four to 1010  and finally 01010 matches itself.
We are only interested in outputs where the Hamming distance is at most 1, however. So in this task we will report a Y if  the Hamming distance is at most one and an N otherwise.  So in our example above we would get
[Y, N, Y, N, Y]

Define f(n) to be the number of distinct arrays of Ys and Ns one gets when iterating over all 2^n different possible bit strings S of length n.
Task
For increasing n starting at 1, your code should output f(n).
Example answers
For n = 1..24, the correct answers are:
1, 1, 2, 4, 6, 8, 14, 18, 27, 36, 52, 65, 93, 113, 150, 188, 241, 279, 377, 427, 540, 632, 768, 870

Scoring
Your code should iterate up from n = 1 giving the answer for each n in turn. I will time the entire run, killing it after two  minutes.
Your score is the highest n you get to in that time.
In the case of a tie, the first answer wins.
Where will my code be tested?
I will run your code on my (slightly old) Windows 7 laptop under cygwin.  As a result, please give any assistance you can to help make this easy.
My laptop has 8GB of RAM and an Intel i7 5600U@2.6 GHz (Broadwell) CPU with 2 cores and 4 threads. The instruction set includes SSE4.2, AVX, AVX2, FMA3 and TSX.
Leading entries per language

n = 40 in Rust using CryptoMiniSat, by Anders Kaseorg. (In Lubuntu guest VM under Vbox.)
n = 35 in C++ using the BuDDy library, by Christian Seviers. (In Lubuntu guest VM under Vbox.)
n = 34 in Clingo by Anders Kaseorg. (In Lubuntu guest VM under Vbox.)
n = 31 in Rust by Anders Kaseorg.
n = 29 in Clojure by  NikoNyrh.
n = 29 in C by bartavelle.
n = 27 in Haskell by  bartavelle
n = 24 in Pari/gp by  alephalpha.
n = 22 in Python 2 + pypy by me.
n = 21 in Mathematica by  alephalpha. (Self reported)

Future bounties
I will now give a bounty of 200 points for any answer that gets up to n = 80 on my machine in two minutes.

Rust, n ≈ 30 or 31 or 32

On my laptop (two cores, i5-6200U), this gets through n = 1, …, 31 in 53 seconds, using about 2.5 GiB of memory, or through n = 1, …, 32 in 105 seconds, using about 5 GiB of memory.  Compile with cargo build --release and run target/release/correlations.

src/main.rs

extern crate rayon;

type S = u32;
const S_BITS: u32 = 32;

fn cat(mut a: Vec<S>, mut b: Vec<S>) -> Vec<S> {
    if a.capacity() >= b.capacity() {
        a.append(&mut b);
        a
    } else {
        b.append(&mut a);
        b
    }
}

fn search(n: u32, i: u32, ss: Vec<S>) -> u32 {
    if ss.is_empty() {
        0
    } else if 2 * i + 1 > n {
        search_end(n, i, ss)
    } else if 2 * i + 1 == n {
        search2(n, i, ss.into_iter().flat_map(|s| vec![s, s | 1 << i]))
    } else {
        search2(n,
                i,
                ss.into_iter()
                    .flat_map(|s| {
                                  vec![s,
                                       s | 1 << i,
                                       s | 1 << n - i - 1,
                                       s | 1 << i | 1 << n - i - 1]
                              }))
    }
}

fn search2<SS: Iterator<Item = S>>(n: u32, i: u32, ss: SS) -> u32 {
    let (shift, mask) = (n - i - 1, !(!(0 as S) << i + 1));
    let close = |s: S| {
        let x = (s ^ s >> shift) & mask;
        x & x.wrapping_sub(1) == 0
    };
    let (ssy, ssn) = ss.partition(|&s| close(s));
    let (cy, cn) = rayon::join(|| search(n, i + 1, ssy), || search(n, i + 1, ssn));
    cy + cn
}

fn search_end(n: u32, i: u32, ss: Vec<S>) -> u32 {
    if i >= n - 1 { 1 } else { search_end2(n, i, ss) }
}

fn search_end2(n: u32, i: u32, mut ss: Vec<S>) -> u32 {
    let (shift, mask) = (n - i - 1, !(!(0 as S) << i + 1));
    let close = |s: S| {
        let x = (s ^ s >> shift) & mask;
        x & x.wrapping_sub(1) == 0
    };
    match ss.iter().position(|&s| close(s)) {
        Some(0) => {
            match ss.iter().position(|&s| !close(s)) {
                Some(p) => {
                    let (ssy, ssn) = ss.drain(p..).partition(|&s| close(s));
                    let (cy, cn) = rayon::join(|| search_end(n, i + 1, cat(ss, ssy)),
                                               || search_end(n, i + 1, ssn));
                    cy + cn
                }
                None => search_end(n, i + 1, ss),
            }
        }
        Some(p) => {
            let (ssy, ssn) = ss.drain(p..).partition(|&s| close(s));
            let (cy, cn) = rayon::join(|| search_end(n, i + 1, ssy),
                                       || search_end(n, i + 1, cat(ss, ssn)));
            cy + cn
        }
        None => search_end(n, i + 1, ss),
    }
}

fn main() {
    for n in 1..S_BITS + 1 {
        println!("{}: {}", n, search(n, 1, vec![0, 1]));
    }
}

Cargo.toml

[package]
name = "correlations"
version = "0.1.0"
authors = ["Anders Kaseorg <andersk@mit.edu>"]

[dependencies]
rayon = "0.7.0"

Try it online!

I also have a slightly slower variant using very much less memory.


Find all number pairs that sum to 121212 This problem is quite easy to do by brute force.  In fact, it'll be reasonably fast to brute force as well.  But where's the fun in that?

The Problem

Produce a list of all unique 5 digit number pairs that sum to 121212.  However, each decimal digit must appear exactly once in either number.  So a valid pair would be (98167, 23045).  But an invalid pair would be (23456, 97756) because 7, 5, 6 are repeated more than once, and 1, 8, 0 are not used at all.  There are exactly 192 unique pairs.

Rules

Efficiency: You can brute force this.  But that's trivial to do.  So instead, the real challenge here is to find a way to efficiently produce the list of numbers.
Source Code Requirements: It cannot store the number list (or any part of it).  The number sequence must be generated on the fly.

Have Fun!

C++

#include<iostream>
using namespace std;
#include<algorithm>

int main()
{
    long long N,F,S;
    char str[11]="1023456789";
    while (1) {
        sscanf(str,"%lld",&N);
        F=N/100000;S=N%100000;
        if (F>60000)
           break;
        if (F+S==121212)
           printf("%lld %lld\n",F,S);
        next_permutation(str,str+10);
    }
}

http://www.ideone.com/Lr84g


Light up a Roguelike Given a board, write the shortest program or function to display or return which characters are in sight of the player. A character is in sight if is possible to draw a line between it and the player, without crossing any characters that block vision.

Input:

@ represents the player's position. There will only be one of these in the input.
any character that matches the regex [#A-Z] blocks vision.
any character that matches [ a-z] allows vision.
there will be no invalid characters
you are guaranteed a rectangular input

Lines are defined as follows:

define vector to be a magnitude and a direction
a direction is one of N,NE,E,SE,S,SW,W,NW
a magnitude is how many chars along that direction to count
let the initial vector be called d1; the second vector be called d2
one of d1 or d2 must have a magnitude of 1; the other may have whatever magnitude
d1's direction must be adjacent to d2's direction (e.g: N and NE)

A line is defined to be all chars along the path marked by applying d1, then d2, d1, d2 ....

Sample line (given by the .s):
d1 = (magnitude: 4, direction: E)
d2 = (magnitude: 1, direction NE)

               .....
          .....
     .....
@....

Output:

each visible character in the right position, . substitutes for space.
Space for each non-visible character.

Sample input:

@
    K
 J

    L

         o

Corresponding output:

@.........
....K.....
.J.....
..........
.. .L.....
..  . ....
... .. ...
...  .. ..
...   .  .
....  ..

Sample Input:

 B###M#  by
 #Q   # Zmpq
 # # aaa
@  m #
# ##P#
# ####
# ####
#M ###
######

Corresponding Output:

.B  #M
.# ..   Z pq
.#.#.aaa..
@..m.#
#.##P#
 .#
 .#
 M.
  #

Sample input:

  w

     O  l   gg  rT
   QQL      Ag  #b
   qqqqq         XqQ
 x     V# f@aa
   Y        aaa
   uU  E  l TaKK
  e  dd  FF d opi
   e       d

Corresponding output:

   ..........  .....
    ......... .....
     O..l...gg..rT
...QQL......Ag..#b..
...qqqqq.........XqQ
        #.f@aa......
   Y........aaa.....
...uU..E..l.TaKK....
      d..FF.d.op
     .... .d. ...


Guess my password! (Code Golf) So, like the title says, today you are going to guess my password (sort of). You need to make a big long list of every possible password I might be using on my 4 digit online vault.

Specifications:

It could contain any 26 letters of the alphabet in UPPER CASE.
It could contain any numbers 0-9.
So, basically, each digit has 36 different possibilities.
There are four digits.
Repeat characters are allowed! (Hint: Sample space is 1,679,616 or
36^4)

Program Requirements/Rules:

Program must output all possible answers to a text file or to the console, line by line. (One answer per line)
You may not make use of any premade tools for this (Idk if any exist, but just in case)
It must generate all 36^4 possible answers

Remember, this is a Code-golf. So shortest answer in bytes wins. Please use the standard title format of ##Language Name, Byte Size. Even if there is a winner, feel free to post your answer. (It's always fun to see the different solutions in different languages).

Edit: Not a duplicate of sugested, mines has different context, and different paremeters. (I require numbers, duplicate characters, and only UPPERCASE)

Pyth - 8 bytes
^+jkUTG4

Try smaller password length online here.


Find the super palindromes! Consider the number 99999999. That number is obviously a palindrome.  The largest prime factor of 99999999 is 137. If you divide 99999999 by 137, you get 729927. This number is also a palindrome.
The largest prime factor of 729927 is 101. 729927/101=7227 which again is a palindrome.
The largest prime factor of 7227 is 73. 7227/73=99 which again is a palindrome.
By further dividing by the largest prime factor, you get 9, 3 and finally 1, which, being one-digit numbers, are also palindromes. Since 1 has no prime factors, the procedure ends here.
Now generalizing this observation, I define a super-palindrome as a palindrome which is either 1, or which gives another super-palindrome if divided by its largest prime factor.

Credits: https://math.stackexchange.com/questions/200835/are-there-infinitely-many-super-palindromes
Given a number N, determine if it is a super palindrome or not, and print a truthy or falsey value accordingly.
Your program should print a truthy value for these inputs:
1
101
121
282
313
353
373
393
474
737
919
959
1331
1441
2882
6446
7887
8668
9559
9779

Your program should print a falsey value for these inputs:
323
432
555
583
585
646
642
696
777
969
989
2112
3553
4554
5242
5225
5445
8080
8118
9988

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

Jelly, 13 12 9 8 bytes

Æf×\D⁼U$

Try it online! or verify all test cases.

How it works

Æf×\D⁼U$  Main link. Argument: n

Æf        Yield all prime factors of n, with multiplicities and in ascending order.
  ×\      Take the cumulative product.
    D     Decimal; convert each product into the array of its base 10 digits.
       $  Combine the two links to the left into a monadic chain.
      U     Upend; reverse all arrays of decimal digits.
     ⁼      Test for equality.


I transpose the source code, you transpose the input! Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!

Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that if I transpose your source code², the output/result must be transposed too.

You may choose which kind of 2D data your solution can accept. For example a list of lists, a matrix, a list of strings, etc. State which one(s) it handles. You may assume that the input will always be rectangular and will have a length of 1 or more along each dimension.
For the purposes of transposing, short lines in your source code will be considered as padded with trailing spaces until it is rectangular, however, these padded trailing spaces do not contribute to your code length.

Since this is code-golf, the target is to optimize the byte count of the original source code (not the transposed version).

Examples

Let's say your solution takes a numeric matrix and your source code is

AB
DEF

and its input/argument is [[1,2],[3,4],[5,6]]. If I write

AD
BE
 F

instead and run it, the output/result must be [[1,3,5],[2,4,6]].

Let's say your solution takes a linefeed-separated string and your source code is

ABC

and its input/argument is "96\n". If I write

A
B
C

instead and run it, the output/result must be "9\n6\n".

Python 3 + numpy, 45 bytes

lambda\
a:a
ma= """
b.    "
dT"   "
a "
\ """

Try it online!

Thanks to @EriktheOutgolfer pointing out a bug of the previous version

Transposed:

lambda\
a:a.T
ma= """
b     "
d "   "
a "
\ """

Try it online!

The functions take a numpy matrix as input and output a numpy matrix. The solution does not rely on comments like many other solutions do but instead exploits multi-line strings.


Find pairs of numbers with a particular LCM and GCD I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows:

  The difference of two natural numbers is 2010 and their greatest common denominator is 2014 times smaller than their lowest common multiply. Find all the possible solutions.

We started writing the program independently of each other, and when it worked we decided to golf it up to get the least amount of bytes we could manage. We ended up with this beautiful line of code at a marvelous 89 bytes.

from fractions import*;print[i for i in range(10**6)if i*(i+2010)/gcd(i,i+2010)**2==2014]

We wanted to see if anyone manages to write a shorter piece of code, that enumerates the first 1 million i's. If you are brave enough to compete, you may use any language you like, but we would prefer Python 2 to be able to compare your code with ours.

Usual rules apply, shortest bytes win.
The standard code golf loopholes apply. Standard "loopholes" which are no longer funny

Have fun!

Mathematica, 8 bytes

{4,5092}

Proof that 4 and 5092 are the only solutions: The original problem can be rewritten as

  x (x + 2010) = 2014 GCD(x, x+2010)2

Let's write x as 2a2 3a3 5a5… and x + 2010 as 2b2 3b3 5b5… Then the equation becomes

  2a2+b2 3a3+b3 5a5+b5… = 2014 22min(a2,b2) 32min(a3,b3) 52min(a5,b5)…

Since 2014 = 2 × 19 × 53, we have

  ap + bp = 2min(ap, bp) + { 1 if p ∈ {2, 19, 53}, 0 else }

Thus

  ap = bp if p ≠ 2, 19, 53
  ap = bp±1 else

Thus

  x + 2010 = 2±1 19±1 53±1 x

There are only 8 possible choices, and we could easily check that 4 and 5092 are the only positive integer solutions.

Wait, I hear people screaming standard loophole…

Mathematica, 45 bytes

Select[Range[9^7],2014GCD[#,s=#+2010]^2==s#&]


Musical Tweet Challenge This is the audio version of the Twitter image encoding challenge.

Design an audio compression format that can represent at least one minute of music in 140 bytes or less of printable UTF-8-encoded text.

Implement it by writing a command-line program that takes the following 3 arguments (after the name of the program itself):

The string encode or decode.
The input filename.
The output filename.

(If your preferred programming language lacks the ability to use command-line arguments, you may use an alternative approach, but must explain it in your answer.)

The encode operation will convert from your chosen audio format to your compressed “tweet” format, and the decode operation will convert from your “tweet” format to the original audio format.  (Of course, you're expected to implement lossy compression, so the output file need not be identical to the input, just in the same format.)

Include in your answer:

The source code of your program, in full.  (If it's too long for this page, you may host it elsewhere and post a link to it.)
An explanation of how it works.
At least one example, with a link to the original audio file(s), the “tweet” text it compresses down to, and the audio file obtained by decoding the tweet.  (Answerer is responsible for copyright “fair use” assertions.)

Rules

I reserve the right to close any loopholes in the contest rules at any time.
[Edited April 24] For the input of your encode function (and output of your decode function), you may use any reasonable, common audio format, whether it be:

Uncompressed waveform, like WAV.
Compressed waveform, like MP3.
“Sheet music” style, like MIDI.

Your compressed “tweet” format must actually encode the sounds in the input file.  So, the following types of output do not count:

A URI or file path giving the location where the actual output is stored.
A key to a database table where the actual output is stored as a blob.
Anything similar.

Your program must be designed to compress generic music files, so don't do stuff that's too obviously tied to your specific example song.  For example, if you're demonstrating “Twinkle, Twinkle, Little Star", your compression routine shouldn't hard-code a specific symbol for the sequence do-do-so-so-la-la-so.
Your program's output should actually be able to go through Twitter and come out unscathed.  I don't have a list of the exact characters that are supported, but try to stick to letters, digits, symbols, and punctuation; and avoid control characters, combining characters, BIDI markers, or other weird stuff like that.
You may submit more than one entry.

Judging criteria

This is a popularity contest (i.e., most net upvotes wins), but voters are urged to consider the following:

Accuracy

Can you still recognize the song after it's been compressed?
Does it sound good?
Can you still recognize which instruments are being played?
Can you still recognize the lyrics?  (This is probably impossible, but it would be impressive if anyone accomplished it.)

Complexity

The choice of the example song matters here.

[Added April 24] This challenge will be easiest with MIDI or similar formats.  However, if you take the extra effort to make it work with waveform-type formats, that deserves extra credit.
What's the structure?  Sure, you can meet the one-minute requirement by simply repeating the same 4 measures an arbitrary number of times.  But more complex song structures deserve more points.
Can the format handle a lot of notes being played at one time?

The code

Keep it as short and simple as possible.  However, this is not a code golf, so readability matters more than character count.
Clever, complicated algorithms are OK too, as long as they're justified by improved quality of results.

Scala
Sure, it'd be easier to encode MIDI files, but who's got a bunch of MIDI files lying around? It's not 1997!
First things first: I've decided to interpret a "Unicode byte" as a "Unicode char" and use CJK characters, because:

It matches the image challenge
Twitter is cool with it
I really need those bits

There are a few tricks I use to squeeze every last drop of entropy from the sources:
Firstly, music is made with notes. Moreover, we generally regard the same note in a different octave as the same note (which is why a 12-string guitar sounds right), so we only have 12 possibilities to encode. (when I output B, for example, I actually output a chord, consisting solely of B in all the octaves, a bit like a 12-string guitar).
Next, I remember from high-school music class that most note transitions are small (up or down one note). Jumps are less common. This tells us that there's probably less entropy in the jump sizes than in the notes themselves.
So, our approach is to break our source into a number of blocks - I found 14 blocks per second worked well (side note, I'd always wondered why audio was encoded at 44100 Hz. It turns out that 44100 has lots of factors, so I could have chosen 1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 14, 15, 18, 20, 21, 25, 28 or 30 blocks per second, and it would have divided cleanly). We then FFT these blocks (well, technically not fast, as the library I used isn't fast for non-power-of-2 blocks. And technically I used a Hartley transform, not Fourier).
We then find the note that sounds loudest (I used A-weighting, with high and low cut-offs, mostly because it's easiest to implement), and either encode this note, or encode silence (silence detection is based on SNR - low SNR is silence).
We then translate our encoded notes into jumps, and feed them to an adaptive arithmetic coder. The process for translation to text is similar to the image compression question (but involves some abusive use of BigInteger).
So far, so good, but what if the sample has too much entropy? We use a crude psychoacoustic model to remove some. The lowest entropy jump is "no change", so we look at our FFT data to try to find blocks where the listener probably won't notice if we keep playing the previous note, by looking for blocks where the note from the previous block is almost as loud as the loudest note (where "almost" is controlled by the quality parameter).
So, we've got a target of 140 characters. We start by encoding at quality 1.0 (max quality), and see how many characters that is. If it's too many, we drop to 0.95 and repeat, until we get to 140 characters (or we give up after quality 0.05). This makes the encoder an n-pass encoder, for n <= 20 (although it's massively inefficient in other areas too, so m'eh).
The encoder/decoder expects audio in s16be mono format. This can be achieved using avconv as:
#decoding ogg to s16be, and keeping only the first 60s
avconv -i input.ogg -ac 1 -ar 44100 -f s16be -t 60s input.raw
#encoding s16be to mp3
avconv -f s16be -ac 1 -ar 44100 -i output.raw output.mp3

To run the encoder:
sbt "run-main com.stackexchange.codegolf.twelvestring.TwelveString encode input.raw encoded.txt"
sbt "run-main com.stackexchange.codegolf.twelvestring.TwelveString decode encoded.txt output.raw"

Full code at https://github.com/jamespic/twelvestring.
Pitfall to note: You'll need nayuki's Arithmetic Coding library, which doesn't currently have Maven artifacts available. Instead, you'll need to locally build and install developster's fork of it.
And here are some samples. They sound awful, but just about recognisable:

Beethoven's 5th: original, encoded - 刲檁囉罓佖镱賑皌蝩蔲恁峕逊躹呯兲搆摼蝺筶槛庬一掛獴趤笲銗娵纜喫覤粠僭嫭裵獄鱨蠰儏咍箪浝姑椻趕挍呪白鸞盙宠埘謭擆闯脲誜忘椐笸囃庣稨俖咛脔湙弻籚砌鍖裏橈镙訁鹻塿骱踠筟七趇杅峇敖窈裞瘫峦咰呹櫬茏蛏姆臸胝婁遼憀麁黦掏毈喙眝綄鴀耢椚筤菮蟞斗俼湛营筬禴籙嬧窻丄
Fur Elise: original, encoded - 訖忢擫鏝拪纒铇鯪薯鉰孝暱埛痏絘僌莻暆鴈屖鳮絒婘譮蠣託騶腀饚緂柤碠瞢碩脅歙棆敗辦冏鄔酾萖苯劺誺軩忇穤锳婁伉巠桭晘酉筟緵俅怚尵鎽蜓崁飿嘔但鈐謽酝屮呤誥俊覊鶮龔癸埙煂臙牎繬肜摲炚雗頨款驦燈菩凧咁楾媡夥俰欓焵韀冊嗥燠鱧駟髉
Twinkle Twinkle Little Star: original, encoded - 欠悺矜莳錥鷗谴裴皽鳺憝漿箔皇殤鸧蜻猻丱
A fun chiptune: original, encoded - 简詐諥尘牿扫鲑龮箫颫齰蠏騁煟靸阒萎囦鮇雝愯訖芉馄鈿鬦嶏觲沠丆贀蛑蛀漥荤侲咔麑桬鲠僵擕灼攲陇亄鹘琾業纟鵼牤棌匩碆踬葫鶙懲欃铳樯柇鋡疡衻澯伅墇搢囻荸香貱夹咽蟽籐屈锂蛉袒貊屨鈦夜镤沄鍡唦魮骬乔蚖醶矕咻喸碋利褼裊匎嶮窢幘六沧鼝瞮坡葍帷锆邵旻符琨鱴郤栱烇仾椃騋荄嘵統篏珆罽

Update
I tweaked the silence threshold in the code, and re-encoded. The encodings have been updated accordingly. Also, I added another song (technically not open source, but I doubt the original copyright holder will feel their IP is under threat), just for fun:

Imperial March: original, encoded - 岼讶湠衢嫵焅喋藭霔憣嗗颟橳蕖匵腾嗅鈪芔区顕樭眀冂常僠寝萉乹俚戂闤灈蟑拷邢音褈霈媬盒萳璥唂焰銯艉鶱縩巻痭虊窻熲紆耺哅淙苉嘏庸锺禒旇蘄籷遪刨繱蕖嬯摺祑仰軈牰杊瘷棏郖弘卄浕眮騜阖鏴鶺艂税寛柭菸採偋隆兎豅蚦紛襈洋折踜跅軩树爺奘庄玫亳攩獼匑仡葾昐炡瞱咏斎煟价藭恐鷖璌榍脅樐嬨勀茌愋

More Updates
I've tweaked the encoder a little, and it's had a surprising impact on quality (I'd forgotten that in DHT, out-of-phase signals are effectively negative, so I was ignoring out-of-phase signals).
An earlier version of the code just took the larger of these out-of-phase signals, but we now take the RMS. Also, I added a fairly conservative window function to the encoder (Tukey, alpha 0.3), to try to combat artifacting.
Everything's updated accordingly.


Tips for writing quines A quine is a program that produces output that's identical to the program's source code. On this website, we generally only care about proper quines (at the time of writing, the current definition is "some part of the output is encoded by a different part of the program").

What advice do you have for writing proper quines, or programs with quine-like properties? As usual, each tip should be in a different answer.

Take advantage of string formatting
One of the easiest ways to create a quine is to define a string, then put the string inside itself with string formatting.

s='s=%r;print s%%s';print s%s

So in this example Python quine, we declare a string with the first part equal to whatever is before the string s=, then we allow for the string to be inserted with formatting with %r, and finally we put what comes after the string to print and format it. The trailing newline is because print prints a trailing newline.
So the template is really this, in Python:
<A>'<A>%r<B>'<B>

To expand the existing quine with more code:
<more A>s='<more A>s=%r;print s%%s<more B>';print s%s<more B>


Expand compressed brain-flak This challenge was posted as part of the April 2018 LotM challenge, as well as for Brain-flak's 2nd birthday

I was thinking about what the most efficient way to encode brain-flak programs would be. The obvious thing to do, since there are only 8 valid characters, is to map each character to a 3-bit sequence. This is certainly very effective, but it's still very redundant. There are some features of brain-flak code that we could take advantage of to shorten the encoding.

The nilads, which are all represented by 2 matched brackets, really act as a single unit of information rather than 2. If we replaced each bracket with a single byte character, this would make the encodings much smaller without losing any data.
This one is less obvious, but the closing bytes of the monads are redundant too. Think you could guess what the '?' characters represent in the following snippet?

 {(({}?<>?<>?

If we assume the input is valid brain-flak code, then there is only one option for each of those question marks. This means that we can unambiguously use a close monad character to represent every closing bracket. This has the added benefit of keeping the character set small, which would greatly help if we wanted to use a huffman encoding. Since the close monad character will most likely be the most common character by a wide margin, it could be represent by a single bit, which is hugely efficient.

These two tricks will let us compress brain-flak code via the following algorithm:

Replace every closing bracket of a monad with |. Or in other words, replace every closing bracket that is not preceded by it's opening match with a bar. So...

(({})<(()()())>{})

would become

(({}|<(()()()||{}|

Replace every nilad with it's closing bracket. Therefore, matched brackets with nothing in them use the following mapping:

() --> )
{} --> }
[] --> ]
<> --> >

Now our last example becomes:

((}|<()))||}|

Remove trailing | characters. Because we know that the total number of bars should equal the total number of ({[< characters, if there are bars at the end missing, we can infer them. So an example like:

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

would become

({(}|(}[)

Your challenge for today is to reverse this process.

Given a string of compressed brain-flak containing only the characters (){}[]<>|, expand it into the original brain-flak code. You can assume that the input will always expand to valid brain-flak. This means that no prefix of the input will ever contain more | than ({[< characters.

The input will not contain trailing | characters. These must be inferred from context.

As usual, you can submit either a full program or a function, and input/output formats are permissive. And since this is a code-golf, your code will be scored by the length of the source code in bytes, the smaller the score the better.

Test cases

Here are some test cases. If you would like more, you can generate your own test cases with this python script and the Brain-Flak Wiki, which is where the majority of these test cases come from.

#Compressed code
#Original code

())))
(()()()())

([([}()||||(>||{(})|>|}{((<}|||>}|}>}
([([{}(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}

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

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


Implement Entombed's lookup table Background
Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By disassembling the game's ROM, researchers discovered that this is done with the help of a mysterious lookup table.
When a tile X is to be generated, the game first looks at the states of 5 tiles A, B, C, D, and E which are around it:
$$
\bbox[5px, border: 1px solid white]{\color{white}{\mathsf{x}}}
\bbox[6px, border: 1px solid black]{\mathtt{C}}\,
\bbox[6px, border: 1px solid black]{\mathtt{D}}\,
\bbox[6px, border: 1px solid black]{\mathtt{E}}\\
\;
\bbox[6px, border: 1px solid black]{\mathtt{A}}\,
\bbox[6px, border: 1px solid black]{\mathtt{B}}\,
\bbox[6px, border: 1px solid white]{{\mathtt{X}}}\,
\bbox[10px, border: 1px solid white]{\color{white}{\mathsf{x}}}\,
$$
These five values then index into the following 32-byte lookup table to determine what should appear at X — a wall, an empty space, or either a wall or an empty space, chosen at random:
A B C D E    X
0 0 0 0 0    1
0 0 0 0 1    1
0 0 0 1 0    1
0 0 0 1 1    R
0 0 1 0 0    0
0 0 1 0 1    0
0 0 1 1 0    R
0 0 1 1 1    R
0 1 0 0 0    1
0 1 0 0 1    1
0 1 0 1 0    1
0 1 0 1 1    1
0 1 1 0 0    R
0 1 1 0 1    0
0 1 1 1 0    0
0 1 1 1 1    0
1 0 0 0 0    1
1 0 0 0 1    1
1 0 0 1 0    1
1 0 0 1 1    R
1 0 1 0 0    0
1 0 1 0 1    0
1 0 1 1 0    0
1 0 1 1 1    0
1 1 0 0 0    R
1 1 0 0 1    0
1 1 0 1 0    1
1 1 0 1 1    R
1 1 1 0 0    R
1 1 1 0 1    0
1 1 1 1 0    0
1 1 1 1 1    0

Here R represents a value to be chosen randomly.
Task
Given values for A, B, C, D, and E as input, your program or function should output the correct value for X (either 0 or 1, depending on which row of the table the input corresponds to). However, if the input corresponds to a row in the table with an X value of R, your program should output either 0 or 1 uniformly randomly.
Rules

This is code-golf, so shortest answer in bytes wins.
Your input can be given in any reasonable format, e.g. a list of values, a string with the values in it, an integer in the range [0..31], etc.
When receiving input that corresponds to an X value of R in the table, your output has to be non-deterministic.

Jelly, 21 19 15 bytes
ị“£ṅ@kṃżF’b3¤BX

Try it online!
-4 bytes after inspiration from @Neil's Charcoal Answer (binary!).
Try all testcases listed out in a grid (each row is one input tested multiple times).
How?
ị“£ṅ@kṃżF’b3¤BX     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0,1]
                          # (2 => R; 1 => 1; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             B            # convert to binary: 2 => [0,1], 1 => [1], 0 => [0]
              X           # Pick a random element from that list

19 byte version
(I personally like this one more because it uses special properties of ị and X)
Try it online!
Try all testcases.
ị“©½B.ọṅc’b3¤Hị1,0X     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [2,2,1,0,0,1,1,2,2,2,2,1,0,0,0,2,2,2,1,0,0,0,0,1,0,2,1,1,0,0,0,2]
                          # (2 => 1; 1 => R; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             H            # Halve: [2,1,0] => [1,0.5,0]
              ị1,0        # Index into 1,0 (again 1-indexed)
                            # 1 gives 1, and 0 gives 0
                            # 0.5 gives [0,1]; since it is a fractional index, it gives both the element corresponding to floor(0.5) and ceil(0.5)
                  X       # Random; 3 different functions
                            # 0 => 0
                            # 1 => random integer from 1 to 1 => 1
                            # [0,1] => random element of [0,1]


Do you like Taekwondo? Choi Hong Hi died on the 15th June 2002 at the honorable age of 83. He founded Taekwondo.

15 years after his death, I would like to be a Taekwondo master. This is my time to shine !

Task

Given a string you should output a Taekwondo version.

Rules

You will receive a non-empty string/sentence by any valid input
You must replace each titles (case insensitive)  by the revised romanization equivalent.
You must add , *side kick* at the end of the sentence because I like to do side kicks.
You must output this changed sentence as a string.
This is code-golf you should aim to minimize the byte count of your answer

Examples

"I am a Student and I do Taekwondo twice a week"
  => "I am a Geup and I do Taekwondo twice a week, *side kick*"

"I am a Teacher willing to be a President"
  => "I am a Gyosa nim willing to be a Gwanjang nim, *side kick*"

List of titles

English             =>  Revised Romanization
============================================
President           =>  Gwanjang nim
Founder             =>  Gwanjang nim
Master instructor   =>  Sabeom nim
Teacher             =>  Gyosa nim
Black Belt          =>  Dan
Student             =>  Geup
Color Belt          =>  Geup
Master level        =>  Godanja

PHP, 241 bytes

<?=preg_replace(["#\b(President|Founder)\b#i","#\bMaster instructor\b#i","#\bTeacher\b#i","#\bBlack Belt\b#i","#\b(Studen|Color Bel)t\b#i","#\bMaster level\b#i"],[Gwanjang.$n=" nim",Sabeom.$n,Gyosa.$n,Dan,Geup,Godanja],"$argn, *side-kick*");

Try it online!


Boxed character regions Given an input string, determine the number of regions that a page will be split into.

Consider the letter P. It has one enclosed region within the letter. Assume that each letter splits the page by one or more regions (i.e. a box is drawn around the character).

Input

A string of 0 or more characters. You may assume that the string contains only characters from the following sets:

+0 regions: Spaces , tabs \t, and new lines \n
+1 region: CEFGHIJKLMNSTUVWXYZcfhijklmnrstuvwxyz12357~!^*()-_=+[]{}\'|:;",.?/<>
+2 regions:ADOPQRabdeopq469@#
+3 regions: Bg08$%&

You may take the input as a function argument, standard input, command-line argument, whatever works best for your language.

Output

An integer representing the number of regions split by the given input. Output can be a return value or standard output (but not stderr).

This is code-golf, so shortest solution in bytes win.

Test cases

(empty string or only whitespace) === 1
-1 === 3
100% === 11
Hello world! === 16
May the force be with you === 28
do {$busTickets-=2;} while ($transit != false) === 54
return @$_GET['foo'] ?? $$var % $var || $g8 << ; //# Syntax error === 80

Feel free to use the demo in my JavaScript answer (with a compatible browser of course) to run test cases.

Visual representation

Note: The visual representation for the characters g and 0 (zero) may not be entirely correct depending on the monospaced font that your computer has installed.

For the purposes of this challenge, assume that the bottom of the g has a closed loop and the 0 has a slash through it.

(function() {
  'use strict';
  [
    'CEFGHIJKLMNSTUVWXYZcfhijklmnrstuvwxyz12357~!^*()-_=+[]{}\\\'|:;"<,>.?/`',
    'ADOPQRabdeopq469@#',
    'Bg08$%&'
  ].forEach(function(set, i) {
    set.split('').sort().forEach(function(letter) {
      var p = document.querySelectorAll('section[data-letter-regions="' + (i + 1) + '"]')[0];
      console.log(p)
      var el = document.createElement('span');
      el.setAttribute('class', 'letter');
      el.textContent = letter;
      p.appendChild(el);
    });
  });

}());
h1 {
  font-family: sans-serif;
}
section + section {
  border-top: medium solid purple;
}
.letter {
  font-family: Consolas, 'Droid Sans Mono', monospace;
  font-size: 3em;
  line-height: 1;
  padding: 3px;
  margin: 3px;
  display: inline-block;
  border: thin solid darkgray;
}

1 region

2 regions

3 regions

JavaScript (ES6), 94 bytes

f=x=>[...x].reduce((p,z)=>p+!!z.trim()+2*/[Bg08$%&]/.test(z)+/[ADOPQRabdeopq469@#]/.test(z),1)

Demo

As the code is in ES6, the demo only works in ES6-compatible browsers. At time of writing, this includes Firefox, Edge, and Chrome/Opera with experimental JavaScript features enabled.

f = x => [...x].reduce((p, z) => p + !!z.trim() + 2 * /[Bg08$%&]/.test(z) + /[ADOPQRabdeopq469@#]/.test(z), 1)

// Snippet stuff
var v = function() {document.getElementById('Z').textContent = f(this.value)};
document.getElementById('I').addEventListener('keyup', v, false);
document.getElementById('I').addEventListener('change', v, false);
textarea {width: 100%}

Input: <textarea id=I></textarea>

Output: <output id=Z>1</output>


Expand Kirkman's Schoolgirl Problem For those of you who are unfamiliar, Kirkman's Schoolgirl Problem goes as follows:

  Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk twice abreast.

We could look at this like a nested 3 by 5 list (or matrix):

[[a,b,c]
 [d,e,f]
 [g,h,i]
 [j,k,l]
 [m,n,o]]

Essentially, the goal of the original problem is to figure out 7 different ways to arrange the above matrix so that two letters never share a row more than once. From MathWorld (linked above), we find this solution:

[[a,b,c]   [[a,d,h]   [[a,e,m]   [[a,f,i]   [[a,g,l]   [[a,j,n]   [[a,k,o]
 [d,e,f]    [b,e,k]    [b,h,n]    [b,l,o]    [b,d,j]    [b,i,m]    [b,f,g]
 [g,h,i]    [c,i,o]    [c,g,k]    [c,h,j]    [c,f,m]    [c,e,l]    [c,d,n]
 [j,k,l]    [f,l,n]    [d,i,l]    [d,k,m]    [e,h,o]    [d,o,g]    [e,i,j]
 [m,n,o]]   [g,j,m]]   [f,j,o]]   [e,g,n]]   [i,k,n]]   [f,h,k]]   [h,l,m]]

Now, what if there were a different number of schoolgirls? Could there be an eighth day?† This is our challenge.

†In this case no††, but not necessarily for other array dimensions
††We can easily show this, since a appears in a row with every other letter.

The Challenge:

Given an input of dimensions (rows, than columns) of an array of schoolgirls (i.e. 3 x 5, 4 x 4, or [7,6], [10,10], etc.), output the largest possible set of 'days' that fit the requirements specified above.

Input:
The dimensions for the schoolgirl array (any reasonable input form you wish).

Output:
The largest possible series of arrays fitting the above requirements (any reasonable form).

Test Cases:

Input:  [1,1]
Output: [[a]]

Input:  [1,2]
Output: [[a,b]]

Input:* [2,1]
Output: [[a]
         [b]]

Input:  [2,2]
Output: [[a,b]  [[a,c]  [[a,d]
         [c,d]]  [b,d]]  [b,c]]

Input:  [3,3]
Output: [[a,b,c]  [[a,d,g]  [[a,e,i]  [[a,f,h]
         [d,e,f]   [b,e,h]   [b,f,g]   [b,d,i]
         [g,h,i]]  [c,f,i]]  [c,d,h]]  [c,e,g]]

Input:  [5,3]
Output: [[a,b,c]   [[a,d,h]   [[a,e,m]   [[a,f,i]   [[a,g,l]   [[a,j,n]   [[a,k,o]
         [d,e,f]    [b,e,k]    [b,h,n]    [b,l,o]    [b,d,j]    [b,i,m]    [b,f,g]
         [g,h,i]    [c,i,o]    [c,g,k]    [c,h,j]    [c,f,m]    [c,e,l]    [c,d,n]
         [j,k,l]    [f,l,n]    [d,i,l]    [d,k,m]    [e,h,o]    [d,o,g]    [e,i,j]
         [m,n,o]]   [g,j,m]]   [f,j,o]]   [e,g,n]]   [i,k,n]]   [f,h,k]]   [h,l,m]]

There may be more than one correct answer.

*Thanks to @Frozenfrank for correcting test case 3: if there is only one column, there can only be one day, since row order does not matter.

This is code-golf competition - shortest answer wins.

Mathematica, 935 bytes

Inp={5,4};L=Length;T=Table;ST[t_,k_,n_]:=Binomial[n-1,t-1]/Binomial[k-1,t-1];H=ToExpression@Alphabet[];Lo=Inp[[1]]*Inp[[2]];H=H[[;;Lo]];Final={};ST[2,3,12]=4;ST[2,4,20]=5;If[Inp[[2]]==1,Column[Partition[H,{1}]],CA=Lo*Floor@ST[2,Inp[[2]],Lo];While[L@Flatten@Final!=CA,Final={};uu=0;S=Normal[Association[T[ToRules[H[[Z]]==Prime[Z]],{Z,L@H}]]];PA=Union[Sort/@Permutations[H,{Inp[[2]]}]];PT=Partition[H,Inp[[2]]];While[L@PA!=0,AppendTo[Final,PT];Test=Flatten@T[Times@@@Subsets[PT[[X]],{2}]/.S,{X, L@PT}];POK=T[Times@@@Subsets[PA[[Y]],{2}]/.S,{Y,L@PA}];Fin=Select[POK,L@Intersection[Test,#]==0&];Facfin=T[FactorInteger[Fin[[V]]],{V,L@Fin}];end=T[Union@Flatten@T[First/@#[[W]],{W,L@#}]&[Facfin[[F]]],{F,L@Facfin}]/.Map[Reverse,S];PA=end;PT=DeleteDuplicates[RandomSample@end,Intersection@##=!={}&];If[L@Flatten@PT<L@H,While[uu<1000,PT=DeleteDuplicates[RandomSample@end,Intersection@##=!={}&];If[L@Flatten@PT==L@H,Break[],uu++]]]]];Grid@Final]

this is for 26 ladies max

EDIT
I made some changes and I think it works!
The code right now is set to solve [5,4] (which is the "social golfers problem") and gets the result in a few seconds.
However [5,3] problem is tougher and you will have to wait 10-20 minutes but you will get a right combination for all days.
For easier cases it is very quick.

anyway you can try it and see the results
Try it online here
copy and paste using ctrl-v
press shift+enter to run the code
you can change the input at the begining of the code -> Inp={5,4}
run the code multiple times to get different permutations


What is the minimum set of characters with which you can write any valid python program? The proof of the set of characters is that there is a translator which takes any ascii python program as input and produces a limited character set version of the program. The limited character set program can be slower than the original program. It simply has to be possible to produce the same output as the valid python program.

For example, here is a translator that takes any ascii python program as input and writes out a version that doesn't use the character x:

import random
import string
with open('in.py') as infile:
    with open('out.py', 'w') as outfile:
        lines = infile.readlines()
        outfile.write("data = '")
        random_string = ''.join(random.choice(string.digits) for x in range(20))
        for line in lines:
            outfile.write(line.encode('string-escape').replace('x', random_string))
        outfile.write("'\n")
        outfile.write("exec data.replace('%s', chr(%s))" % (random_string, ord('x')))

note that this will fail if the program happens to have the random string in it already, but for the purposes of this question lets accept that 'any' can be slightly limited. We don't have to consider extremely low probabilities of failure due to random chance or a malicious input program.

I've come up with a 9-character translator using exec (also posted at this GitHub gist):

def convert_txt(txt):
    """Convert the text of a Python program to minimal Python"""
    s = "+".join(["chr(%s)" % "+".join(["1"] * ord(c))
                            for c in txt])
    return 'exec(%s)' % s

The only characters it needs are ()+1cehrx.


What language is this word? Your should write a program or function that determines the language of a given word.

The task is to recognize some of the 5000 most common words in 4 languages:

English
German
Italian
Hungarian

The word lists can be found in this GitHub repository.

You are allowed to make mistakes in 40% of the provided test cases. I.e. you can miscategorize 8000 of the 20000 inputs.

Details

The lists only contain words with lowercase letters a-z so e.g. won't and möchte are not included.
A few words appear in multiple languages which means your code can't always guess the expected output correctly.
For convenience you can download all the test cases as one list. In each line a number indicates the language of the word. (1 for English, 2 for German, 3 for Italian and 4 for Hungarian.)
Standard loopholes are disallowed.
Using word lists our similar data provided by your programming language is forbidden.

Input

A string containing only lowercase English letters (a-z).
Trailing newline is optional.

Output

You can categorize the words by providing a distinct and consistent (always the same) output for each language. (E.g. 1 for English, 2 for German, 3 for Italian and 4 for Hungarian.)

This is code golf so the shortest program or function wins.

Related code golf question: Is this even a word?

The word lists were taken from wiktionary.org and 101languages.net.

Retina, 51 bytes

.*[aeio]$
1
A`en$|ch|ei|au
^$
2
A`[jkz]|gy|m$
\D+
4

I came up with the regexes and @MartinBüttner did the conversion to/golfing in Retina so ... hurray for team effort?

The mapping is 1 -> Italian, 2 -> German, (empty) -> Hungarian, 4  -> English, with the amount classified in each category being 4506 + 1852 + 2092 + 3560 = 12010.

Try it online! | Modified multiline version

Explanation

First off, the equivalent Python is something like this:

import re
def f(s):
  if re.search("[aeio]$", s):
    return 1
  if re.search("en$|ch|ei|au", s):
    return 2
  if re.search("[jkz]|gy|m$", s):
    return ""
  return 4

Let me just say that o$ is an excellent indicator of Italian.

The Retina version is similar, with pairs of lines forming replacement stages. For example, the first two lines

.*[aeio]$
1

replaces matches of the first line with the contents of the second.

The next three lines do the same, but using Retina's anti-grep mode - anti-grep (specified with A`) removes the line if it matches the given regex, and the following two lines is a replacement from an empty line to the desired output.

A`en$|ch|ei|au
^$
2

The following line uses anti-grep again, but doesn't replace the empty line, giving the fixed output for Hungarian.

A`[jkz]|gy|m$

Finally, the last two lines

\D+
4

replaces a non-empty non-digit line with 4. All of the substitutions can only happen if no previous substitution activated, simulating an if/else if chain.


Find the Intersection of 2 Sets in Unioned Interval Notation Find the Intersection of 2 Sets in Unioned Interval Notation

Given two sets of real numbers described as the union of intervals, output a description of the intersection of these two sets as a union of the same type of interval.

The input sets will always consist of unions of intervals such that each interval begins and ends at a different integer (i.e. no interval has measure zero).  However, different intervals in the same set may begin or end at the same integer or overlap.

The output set must also be a union of intervals which begin and end at integers, but no interval in the output may overlap any other even at a single integer.

The input may take any form that is suitable for your language of choice, as long as it consists of two lists of pairs of integers.

For example, you may represent the set  as:

[-10,-4]u[1,5]u[19,20]

Or as:

[[-10,-4],[1,5],[19,20]]

Or as:

[-10,-4;1,5;19,20]

Your output representation must be identical to your input representation (except that it is only one list of intervals instead of two).

Examples/Test cases:

Input:

[[[-90,-4],[4,90]],[[-50,50]]]

Output:

[[-50,-4],[4,50]]

In other words, we're intersecting the set that contains all real numbers between -90 and -4 and all real numbers between 4 and 90 with the set that contains all real numbers between -50 and 50. The intersection is the set containing all real numbers between -50 and -4 and all real numbers between 4 and 50. A more visual explanation:

-90~~~~~-4  4~~~~~90   intersected with
    -50~~~~~~~~50        yields:
    -50~-4  4~~50

Input:

"[-2,0]u[2,4]u[6,8]
[-1,1]u[3,5]u[5,9]"

Output:

"[-1,0]u[3,4]u[6,8]"

Input:

[-9,-8;-8,0;-7,-6;-5,-4]
[-7,-5;-1,0;-8,-1]

Output:

[-8,0]

Invalid Output (even though it represents the same set):

[-8,0;-7,-5;-5,0]

Scoring:

This is code-golf so shortest source in bytes wins, as potentially modified by the following bonus.

Bonus:

-15% if you also support positive and negative infinity as bounds of intervals. You may choose what token(s) represent these numbers. (And yes, infinity is a number in the hyperreals ;P)

Mathematica, 41 bytes - 15% = 34.85

Mathematica has a built-in function for interval intersection.

List@@IntervalIntersection@@Interval@@@#&

Example:

In[1]:= List@@IntervalIntersection@@Interval@@@#&[{{{-90, -4}, {4, Infinity}}, {{-50,Infinity}}}]

Out[1]= {{-50, -4}, {4, Infinity}}