Is it a Proth number? A Proth number, named after François Proth, is a number that can be expressed as
$$N = k \times 2^n + 1$$
Where \$k\$ is an odd positive integer and \$n\$ is a positive integer such that \$2^n > k\$. Let's use a more concrete example. Take 3. 3 is a Proth number because it can be written as
$$ 3 = (1 \times 2^1) + 1 $$
and \$2^1 > 1\$ is satisfied. 5 Is also a Proth number because it can be written as
$$ 5 = (1 \times 2^2) + 1 $$
and \$2^2 > 1\$ is satisfied. However, 7 is not a Proth number because the only way to write it in the form \$N = k \times 2^n + 1\$ is
$$ 7 = (3 \times 2^1) + 1 $$
and \$2^1 > 3\$ is not satisfied.
Your challenge is fairly simple: you must write a program or function that, given a positive integer, determines if it is a Proth number or not. You may take input in any reasonable format, and should output a truthy value if it is a Proth number and a falsy value if it is not. If your language has any "Proth-number detecting" functions, you may use them.
Test IO
Here are the first 46 Proth numbers up to 1000. (A080075)
3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993

Every other valid input should give a falsy value.
As usual, this is code-golf, so standard loopholes apply, and the shortest answer in bytes wins!

Number theory fun-fact side-note:
The largest known prime that is not a Mersenne Prime is \$19249 \times 2^{13018586} + 1\$, which just so happens to also be a Proth number!

Jelly, 5 bytes
’&C²>

Try it online! or verify all test cases.
Let \$\newcommand{\&}[]{\text{ & }}j\$ be a strictly positive integer. \$j + 1\$ toggles all trailing set bits of \$j\$ and the adjacent unset bit. For example, \$10011_{2} + 1 = 10100_{2}\$.
Since \${\sim}j = -(j + 1) = -j - 1\$, \$-j = {\sim}j + 1\$, so \$-n\$ applies the above to the bitwise NOT of \$j\$ (which toggles all bits), thus toggling all bits before the last \$1\$.
By taking \$j \& (-j)\$ (the bitwise AND of \$j\$ and \$-j\$), all bits before and after the last set bit are nullified (since unequal in \$j\$ and \$-j\$), thus yielding the highest power of \$2\$ that divides \$j\$ evenly.
For input \$N\$, we want to apply the above to \$N - 1\$ to find \$2^{n}\$, the highest power of \$2\$ that divides \$N - 1\$. If \$m = N - 1\$, \$-m = -(N - 1) = 1 - N\$, so \$(N - 1) \& (1 - N)\$ yields \$2^{n}\$.
All that's left to test is if \$2^{n} > k\$. If \$k > 0\$, this is true if and only if \$(2^{n})^{2} > k2^{n}\$, which is true itself if and only if \$(2^{n})^{2} \ge k2^{n} + 1 = N\$.
Finally, if \$(2^{n})^{2} = N = k2^{n} + 1\$, \$2^{n}\$ must be odd (\$1\$) so the parities of both sides can match, implying that \$k = 0\$ and \$N = 1\$. In this case \$(N - 1) \& (1 - N) = 0 \& 0 = 0\$ and \$((N - 1) \& (1 - N))^{2} = 0 < 1 = N\$.
Therefore, \$((N - 1) \& (1 - N))^{2} > N\$ is true if and only if \$N\$ is a Proth number.
How it works
’&C²>  Main link. Argument: N

’      Decrement; yield N - 1.
  C    Complement; yield 1 - N.
 &     Take the bitwise AND of both results.
   ²   Square the bitwise AND.
    >  Compare the square to N.


Sort by custom alphabet The challenge is to make a program that sorts a list of words, only that the words need to be in the order of a random given alphabet.

Your program will accept a string of comma-separated words and a new alphabet.
Your program will output every word in the same way in the new sorted order.

Example:

Input:

home,oval,cat,egg,network,green bcdfghijklmnpqrstvwxzaeiouy

Output:

cat,green,home,network,egg,oval

This is a code-golf, so the winner is the person with the shortest program.

This is my first challenge so any improvements to the question/challenge are appreciated.

Bash+coreutils, 37 bytes

tr ,$2 \\na-z<<<$1|sort|tr \\na-z ,$2

Output:

$ ./alphasort.sh home,oval,cat,egg,network,green bcdfghijklmnpqrstvwxyzaeiouy
cat,green,home,network,egg,oval, $


Where are they calling from? When making phone calls internationally, phone numbers are prefixed with a code indicating what country the number is located in. These codes are prefix codes, meaning that no code is a prefix of another.
Now, earlier today you missed a call, and you're kind of curious where that call might have come from. So you want to look up the calling code. But, being a prefix code, you're not quite sure where it ends, so you decide to write a program to separate the calling code from the rest of the number.
Input
As input, you will recieve a string consisting of the digits 0-9. The first few digits will be one of the country calling codes listed below (this means the first digit will never be 0). After the country calling code, the rest of the input will contain zero or more digits in any order - it is not guaranteed to be a valid phone number. Your program must be able to handle inputs containing at least 15 digits
Output
Your program should output the unique country calling code that is a prefix of the number. The valid outputs are as follows:
1
20
211
212
213
216
218
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
260
261
262
263
264
265
266
267
268
269
27
290
291
297
298
299
30
31
32
33
34
350
351
352
353
354
355
356
357
358
359
36
370
371
372
373
374
375
376
377
378
379
380
381
382
383
385
386
387
389
39
40
41
420
421
423
43
44
45
46
47
48
49
500
501
502
503
504
505
506
507
508
509
51
52
53
54
55
56
57
58
590
591
592
593
594
595
596
597
598
5993
5994
5997
5999
60
61
62
63
64
65
66
670
672
673
674
675
676
677
678
679
680
681
682
683
685
686
687
688
689
690
691
692
7
800
808
81
82
84
850
852
853
855
856
86
870
875
876
877
878
879
880
881
882
883
886
888
90
91
92
93
94
95
960
961
962
963
964
965
966
967
968
970
971
972
973
974
975
976
977
979
98
991
992
993
994
995
996
998

This list is based on the codes listed on Wikipedia's list of country calling codes page as of revision 915410826, with a few modifications

All codes listed as unassigned or discontinued and some codes listed as reserved for future use were omitted
If a code listed on Wikipedia is a prefix of another, the latter was omitted
If a single country or territory would have more than one code, and if those codes would have a common prefix, those codes are omitted in favour of their common prefix.

This may result in independent countries being lumped together, or disputed territories being lumped in with a particular claimant. This is not intended as a political statement, and decisions about the inclusion or omission of territories and states were made based on the codes, not any beliefs I hold regarding the ownership or sovereignty of the entities using them.
If given an input that does not begin with any of these codes, your program's behaviour is undefined.
And finally:

This is code-golf, fewer bytes of code is better
Your submission may be either a function or a full program
Any of the default I/O methods are fine
The standard loopholes are forbidden

Test cases
input -> output
5292649259 -> 52
3264296721 -> 32
1550 -> 1
33121394 -> 33
7 -> 7
2542112543 -> 254
2005992972 -> 20
350 -> 350
360 -> 36
8505234469 -> 850
9795586334 -> 979
148985513598795 -> 1
222222 -> 222
5999995 -> 5999

JavaScript (ES6),  75 73  71 bytes
Saved 1 byte thanks to @Shaggy
Saved 2 bytes thanks to @Neil

s=>/1|7|(2[^07]|3[578]|42|599?|50|6[789]|8[0578]|9[679]|.)./.exec(s)[0]

Try it online!


Print the missing characters Simple challenge inspired by the popularity of my previous print invisible text and print real invisible text challenges, and the same length different string challenge.

Given a string consisting of only printable characters (0x20 to 0x7E), print every printable character not present in the string.

Input

A string, or array of characters, consisting of only printable ASCII characters

Output

Every printable ASCII character not present in the input string, in any order.

Testcases

Input:  "Hello, World!"
Output: ""#$%&'()*+-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVXYZ[\]^_`abcfghijkmnpqstuvwxyz{|}~"
========
Input:  "Hi!"
Output: " "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghjklmnopqrstuvwxyz{|}~"
========
Input:  ""
Output: " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
========
Input:  " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
Output: ""

Scoring

This is code-golf so fewest bytes in each language wins

GS2, 2 bytes

ç7

Try it online!

How it works

    (implicit) Push the sting of all characters in STDIN on the stack.
ç   Push the string of all printable ASCII characters.
 7  Perform symmetric set difference.
    (implicit) Print the result to STDOUT.


Finding the Deadlock Finding the Deadlock

When programming a multithreading application one must take good care to avoid deadlocking the various threads when accessing shared resources. A deadlock occurs when a thread attempts to access a resource that's locked in another thread at the same time that the other thread is trying to access a resource locked by the first. This is the simple case, but it can get more complex with longer resource chains.

The challenge

You should write a program or function that can detect a possible deadlock situation in a list of the resources accessed by each thread. This is code-golf, so shortest answer in bytes wins.

Every thread is started at the same time, but after that they can run at any combination of interleaving. If there are 2 threads with 4 actions each, it could be run as (where each number is an action taken by the thread with that id) 1,1,1,1,2,2,2,2, 2,2,2,2,1,1,1,1, 1,2,1,2,1,2,1,2, 1,1,2,2,2,2,1,1, or any other possible combination.

Input

You will receive, via STDIN, function parameter, or closest alternative, a list of strings. Each string will be in the format +a -b. Every one of this strings represents the locking(+)/unlocking(-) of a resource by the thread. Between every thread will be a --- separator.
It is guaranteed that a thread won't try to lock a resource it already has locked, and that all threads will explicitly unlock all the resources they have locked before exiting.
Following is an example to demonstrate:

+a    # Lock resource a
+b    # Lock resource b
-a    # Unlock resource a
-b    # Unlock resource b
---   # Thread separator
+b    # Lock resource b
-b    # Unlock resource b

Output

The output shall be falsy if the input doesn't contain any deadlock possibility, and truthy if it contains a possible deadlock situation. For example:

true
false
1
0

are all valid outputs, but anything clearly defined as truthy/falsy will be accepted.

Examples

+a
-a
---
+a
-a

Output: false

+a
+b
-b
-a
---
+b
+a
-a
-b

Output true

Deadlock when trying to acquire b,a respectively for threads 1,2

+a
+b
-a
-b
---
+a
+b
-b
-a

Output false

+a
+b
-b
-a
---
+b
+c
-c
-b
---
+c
+a
-a
-c

Output: true

Deadlock in threads 1,2,3 when trying to acquire b,c,a respectively.

http://pastebin.com/vMYRZxtW

Output false

http://pastebin.com/V5MVgNgS

Output true

Deadlock in threads 1,2,3 when trying to aquire b,d,a respectively.

Of course this could get a lot more complex, with more threads, more resources for each one, and so on, but I believe these tests cover the basics.

Bonus

Since it's very very sad when you find deadlock situations when writing a program, there is a -8 byte bonus to answers outputting :( and :) as truthy/falsy respectively.

Python - 586 539 524 501 485 bytes - 8 = 477

Indentation levels:

1: 1 space
2: 1 tab
3: 1 tab + 1 space
4: 2 tabs

--

import sys
V=set()
t=[[[]]]
for r in sys.stdin:
 r=r.strip()
 if'---'==r:t.append([[]])
 else:v=r[1:];V.add(v);l=t[-1][-1];t[-1].append(l+[v]if'+'==r[0]else filter(lambda x:x!=v,l))
s=lambda l:s(l[1:])+map(lambda x:(l[0],x),l[1:])if 1<len(l)else[]
E=reduce(set.union,map(lambda x:set(sum(map(s,x),[])),t),set())
for v in V:
 k=set();q=[v]
 while 0<len(q):
    u=q.pop(0)
    if u in k:continue
    k.add(u)
    for x,y in E:
     if u==x:
        if y in k:print':(';sys.exit()
        else:q.append(y)
print':)'


Is this a circular step sequence? Background

We define a circular step sequence of order \$n\$ as follows:

$$
a_1, a_2, \dots, a_n = \text{Permutation of } 1 \dots n \\
b_i = \min ( |a_{i+1} - a_i|, n-|a_{i+1} - a_i| ), 1 \le i < n \\
\text{Circular step sequence} \stackrel{\text{def}}{=} b_1, b_2, \dots, b_{n-1}
$$

Informally, it is the \$n-1\$ distances between \$n\$ points evenly spaced on a circle, given a permutation of those points.

For example, if we choose a permutation \$1, 3, 6, 2, 4, 5 \$ for \$n = 6\$, we get a circular step sequence of \$2, 3, 2, 2, 1\$. (Refer to the circular layout below.)

 1 2
6   3
 5 4

On the other hand, a circular step sequence of order 6 cannot have a substring of \$2, 2, 2\$. Regardless of where you start and in which direction you go first, you'll get stuck at the third 2.

Task

Given the value of \$n\$ and a sequence \$b_1, b_2, \dots, b_{n-1}\$ of positive integers, determine if the given sequence can be a circular step sequence of order \$n\$, i.e. there exists a permutation \$a_1, \dots, a_n\$ which leads to the given sequence \$b\$.

Input and output

The elements \$b_i\$ of the input sequence are guaranteed to satisfy \$ 1 \le b_i \le n/2 \$ and \$ b_i \in \mathbb{Z}^+ \$. Also, you can assume \$n \ge 1\$. If \$ n = 1 \$, the only possible \$b\$ is a zero-length sequence. You can omit the number \$n\$ from the input.

For output, you can use truthy/falsy values for your language (swapping is allowed). If such a convention is not defined, you can use two distinct values to represent true/false respectively.

Scoring and winning criterion

Standard code-golf rules apply. The shortest code measured in bytes wins.

Test cases

True

1, []              # permutation: [1]
2, [1]             # permutation: [1, 2]
3, [1, 1]          # permutation: [1, 2, 3]
4, [1, 1, 1]       # permutation: [1, 2, 3, 4]
4, [1, 2, 1]       # permutation: [1, 2, 4, 3]
4, [2, 1, 2]       # permutation: [1, 3, 2, 4]
5, [1, 2, 2, 1]    # permutation: [1, 2, 5, 3, 4]
6, [2, 3, 2, 2, 1] # permutation: [1, 3, 6, 2, 4, 5]

False

4, [2, 2, 1]
5, [2, 2, 1, 1]
6, [1, 2, 2, 2, 3]
6, [3, 2, 1, 1, 2]
7, [2, 2, 3, 1, 2, 2]

JavaScript (ES7),  99 79 74  72 bytes
Takes input as (n)(b). Returns a Boolean value.

n=>g=([d,...b],x=0,m=2**n-2)=>d?[x+d,x-d+n].some(y=>g(b,y%=n,m^1<<y)):!m

Try it online!
How?
Instead of using an array for \$a_i\$, we use a bitmask \$m\$ initialized to \$2^n-2\$ and a bit pointer \$x\$ initialized to \$0\$ (i.e. pointing to the least significant bit).
For instance: for \$n=4\$, we start with \$m=4^2-2=14=1110_2\$. Because the LSB is our starting position, it is cleared right away to mark it as visited.
The main part of the code is a recursive search in a binary tree: for each \$b_i\$, we move the bit pointer to either \$x+b_i\$ or \$x-b_i\$ (wrapping around modulo \$n\$) and toggle the bit at the new position in \$m\$.
We have \$m=0\$ on a leaf node iff all positions have been reached exactly once.


Find the Longest Palindrome in a String by Removing Characters Problem: Remove characters from strings to make the longest (character length) palindrome possible. The first line gives an integer value of the number of strings to test. Each subsequent line is a string to test.

Example Input:

3 // Number of lines to test
GGABZXVYCCDBA
ABGBAD
ABC

Example Output:

ABCCBA
ABGBA
B

Shortest code wins.

Here is my solution in Java (not exactly short hah)...

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Palindrome {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(new File("src/pal.dat"));

        int q = sc.nextInt();
        sc.nextLine();

        for (int z = 0; z < q; z++) {
            String line = sc.nextLine();

            int max = 0;
            String maxP = "";

            for (int k = 0; k < line.length(); k++) {

                String p = calc(line.substring(k));

                if (p.length() > max) {
                    max = p.length();
                    maxP = p;
                }

            }

            System.out.println("Max Palindrome: " + maxP);

        }

    }

    public static String calc(String s) {
        if (s.length() == 0)
            return "";
        if (s.length() == 1 || (s.length() == 2 && s.charAt(0) != s.charAt(1)))
            return s.charAt(0) + "";
        if (s.length() == 2)
            return s;

        char[] arr = s.toCharArray();

        boolean match = false;
        int i = 0;
        for (i = arr.length - 1; i > 0; i--) {
            if (arr[i] == arr[0]) {
                match = true;
                break;
            }
        }

        int max = 0;
        String maxPalin = "";
        for (int k = 1; k < i; k++) {
            String p = calc(s.substring(k, i));
            if (p.length() > max) {
                max = p.length();
                maxPalin = p;
            }
        }

        if (match)
            return arr[0] + maxPalin + arr[0];
        return maxPalin;

    }

}


Find the capacity of 2D printed objects In a fictional 2D world, a set of 2D printing instructions for an object can be represented by a list of integers as follows:
1 4 2 1 1 2 5 3 4

Each number represents the height of the object at that particular point. The above list translates to the following object when printed:
      #
 #    # #
 #    ###
 ##  ####
#########

We then fill it with as much water as we can, resulting in this:
      #
 #~~~~#~#
 #~~~~###
 ##~~####
#########

We define the capacity of the object to be the  units of water the object can hold when completely full; in this case, 11.
Strictly speaking, a unit of water (~) can exist at a location if and only if it is surrounded by two solid blocks (#) in the same row.
Challenge
Take a list of positive integers as input (in any format), and output the capacity of the object printed when the list is used as instructions.
You can assume the list contains at least one element and all elements are between 1 and 255.
Test Cases
+-----------------+--------+
|      Input      | Output |
+-----------------+--------+
| 1               |      0 |
| 1 3 255 1       |      0 |
| 6 2 1 1 2 6     |     18 |
| 2 1 3 1 5 1 7 1 |      7 |
| 2 1 3 1 7 1 7 1 |      9 |
| 5 2 1 3 1 2 5   |     16 |
| 80 80 67 71     |      4 |
+-----------------+--------+

Haskell, 54 bytes
f l=(sum$zipWith min(scanl1 max l)$scanr1 max l)-sum l

The expressions scanl1 max l and scanr1 max l compute the running maximum of the list reading forwards and backwards, i.e. the profile of the water plus land if water would go flow one direction.
Orig:
      #
 #    # #
 #    ###
 ##  ####
#########

Left:
      #~~
 #~~~~#~#
 #~~~~###
 ##~~####
#########

Right:
~~~~~~#
~#~~~~#~#
~#~~~~###
~##~~####
#########

Then, the profile of the overall picture is the minimum of these, which corresponds to where the water does not leak either direction.
Minimum:
      #
 #~~~~#~#
 #~~~~###
 ##~~####
#########

Finally, the amount of water is the sum of this list, which contains both water and land, minus the sum of the original list, which contains only land.


Validate Blokus Board Blokus is a board game in which players take turns placing pieces on a \$ n \times n \$ square grid. In this version of the game, there will be just one person playing. The person is given \$ 21 \$ unique polyominoes, ranging from \$ 1 \$ to \$ 5 \$ tiles each. They then proceed to place down a subset of the pieces onto the board. After the pieces have been placed, it is your job to determine whether it could be a valid Blokus board.

There are \$ 3 \$ key rules for placing down pieces, which must be followed:

\$ 1. \$ The first piece being placed must touch one of the four corners of the board
 \$ 2. \$ After the first piece, each subsequent piece must not contain a tile that is adjacent to another piece in any of the four cardinal directions (not including diagonals)
 \$ 3. \$ After the first piece, each subsequent piece must contain at least one tile that is diagonally adjacent to another piece, (that is, all pieces should form a single connected component which are connected only by corners touching)

Task

The task is to determine, given an \$ n \times n \$ square grid, whether it could be a valid Blokus board. A Blokus board is considered valid if it obeys the \$ 3 \$ rules given above.

In addition, you can assume that the board will consist only of the \$ 21 \$ valid Blokus pieces. However, you may not assume that there are no duplicates. A board which contains a duplicate is automatically considered invalid.

Very Important

You may notice that sometimes a single board can have multiple orientations of the pieces. For example,

...
.XX
XXX

might be a single P piece, but it could also be a V3 piece directly adjacent to a 2 piece, among other things. If this is ever the case, you should output a Truthy value if any of these orientations match. So in the above example, it would return true, because while it could be a V3 and a 2 piece, which breaks Rule 2, it could also be a single P piece, making it a valid board.

Clarifications

The board will be inputted as a grid of two distinct values, denoting whether a given tile is occupied by a polyomino
The input can be taken in any reasonable format (e.g. 2D array, flattened string, list of coordinates + dimensions)
The pieces can be rotated or reflected before placing on to the board
Not all the pieces are required to be placed down to be considered a valid position

Test Cases

Truthy

('X' for occupied, '.' for unoccupied)

.X.
.XX
X..

XX.X
XXX.
...X
..XX

.....
.....
.....
.....
.....

......
......
......
......
......
X.....

X....XXX.
X..XX.X..
X..XX..X.
X.....XXX
X.XX.X.X.
.X.XX....
.X..X.XXX
.X.X.X...
.X.XXX...

Falsey

('X' for occupied, '.' for unoccupied)

Invalid configuration, there is no such piece, unless two pieces are joined to
look as one (e.g. 'L4' piece is directly adjacent to '2' piece), which would
break Rule 2.
XXX
X.X
X..

Invalid, since a valid board can contain no duplicates.
X....
X....
X....
X....
.XXXX

Invalid configuration. Even though the pieces are all valid, it doesn't start in
one of the four corners, which breaks Rule 1.
.....
..X..
.XXX.
.X...
..X..

Invalid configuration. All pieces are valid and are not adjacent horizontally
or vertically, however they are disjoint (they do not form a single chain, which
breaks Rule 3).
X...XX
X.X.XX
X.X..X
..XXX.
.....X
X..XXX

Invalid configuration. The two components are disjoint.
.XX..
X....
X.X..
X..XX
X..XX

Invalid configuration. It breaks Rule 1, 2, and 3 (board may be portrayed as an
'L4' piece at the bottom, and an 'O' and a '2' piece at the top).
.....
.XXXX
...XX
.X...
.XXX.

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

Python 2, 446 422 385 384 bytes

-1 byte thanks to @ovs

l=len
A=abs
s="""def v(O,N):
 def c():
 qp:
    qp:
        if(i!=j)*any(A(t-T)==1qiqj):i+=j;p.remove(j);c();return
 p=[[a]qO];c();r=C=p[:1];i=[sum(A(b-a)*A(c-b)qPqPqP)qp];N-=1
qC:
  if l(o)>5:r=0
 qp:C+=[P]*(1-all(A(a-b)-2**0.5qoqP)-(P in C))
 print(l(p)-l(C)+l(i)-l(set(i))==0)*any(k in Oq[0,N*1j,N+N*1j,N])*r,p>[]"""
exec eval("s"+".replace('q',' for %s in ',1)"*14%tuple("ijtTaabcPoPabk"))

The output format is a bit strange: it prints more than 7 characters for truthy output, and 7 or fewer characters for falsey output (7 characters is the length of "[] True". This may be stretching it, so the p>[] can be replaced by if p!=[] else 1 for +11 characters to give more traditional truthy/falsey output.

The input is a list of coordinates given as complex numbers, along with the dimension n.

Try it online!

All testcases

The invariant may be the most interesting part. Since it must be conserved on rotations and reflections, distance between corresponding tiles is just about the only thing that stays constant. Also, I could not rely on the order that the tiles are listed in the piece. Using the product/sum of distances between every tile led to collisions, but using triples of tiles worked well.

I used for _ in fourteen times (wow), so the exec/eval saves 37 bytes.

Ungolfed:

def invariant(piece):
    inv=1
    for a in piece:
        for b in piece:
            for c in piece:
                inv+=abs((b-a)*(c-b))
    return inv

def valid(occupied,n):
    # convert list of rows into coordinates of Xs
    if not len(occupied):
        return True
    # generate list of pieces (this takes care of rule #2)
    pieces = [[a] for a in occupied]
    def consolidate():
        for i in pieces:
            for j in pieces:
                # merge two pieces if they share an edge
                if i!=j and any(abs(tile1-tile2)==1 for tile1 in i for tile2 in j):
                    i += j
                    pieces.remove(j)
                    # this repeats consolidate until no change (nothing left to combine)
                    consolidate()
                    return
    consolidate()
    # get a connected component of pieces (for rule #3)
    connected = [pieces[0]]
    for connected_piece in connected:
        # eventually every piece should be connected if the board is otherwise valid, so
        # we can check for valid-size pieces in this outer loop
        # all polyominoes with at most 5 tiles are valid
        if len(connected_piece) > 5:
            return False
        for piece in pieces:
            if any(abs(a-b)==abs(1+1j) for a in connected_piece for b in piece) and piece not in connected:
                connected += [piece]
    # check that all pieces are only used once
    ids = [invariant(piece) for piece in pieces]
    used_once = len(ids) == len(set(ids))
    nm = n-1
    rule_1_met = any(k in occupied for k in [0, nm*1j, nm+nm*1j, nm])
    return used_once and rule_1_met and len(pieces) == len(connected)


Help Gödel with his β function Gödel's β  function takes three natural numbers as arguments.

It is defined as β(x,y,z) = rem(x, 1 + (z + 1) · y) = rem(x, (z · y + y + 1) )

where rem(a, b) denotes the remainder after integer division of a by b.

The β Lemma now states that:

  For any sequence of natural numbers (k_0, k_1, … , k_n), there are natural numbers b and c such that, for every i ≤ n, β(b, c, i) = k_i.

Gödel needs help to find b and c for any given input (k_0, k_1, … , k_n), k_i ∈ ℕ.

Write a function that takes in an array of length n, filled with natural numbers, and gives a possible b,c output that fulfilles the Lemma for the array.

Do not get solutions by brute force!

(In my totally unprofessionall opinion, it is brute force when you first get a number and then do the calculation. That is guessing the number and then looking if the guess was correct. What I want to be coded here is a solution which calculates the numbers and does not have to check whether they fulfill the lemma because they were calculated to do so. )

Construct them with the equations and information given.
Shortest code wins, bonus points if you do it in Javascript because I am just getting into it :)

Example:

[5, 19, 7, 8] -> (1344595, 19)
1344505 % (1 + (0 + 1) * 19) = 5
1344505 % (1 + (1 + 1) * 19) = 19
1344505 % (1 + (2 + 1) * 19) = 7
1344505 % (1 + (3 + 1) * 19) = 8

JavaScript (ES6), 104 bytes

a=>[c=a.reduce(c=>c*++i,Math.max(...a),i=0),a.reduce(g=(x,k)=>x%m-k?g(x+n,k):(n*=m,m+=c,x),0,n=1,m=c+1)]

Returns [c, b] as an array. The solution it returns isn't minimal in c but I think it is minimal in b for the given c. For 120 bytes this returns solutions minimal in c and in b for the given c:

f=(a,c=1,b=a.reduce(g=(x,k)=>x%m-k?d--?g(x+n,k):0/0:n%m?g(x,k,n+=o):(o=n,d=m+=c,x),0,o=n=1,d=m=c+1))=>1/b?[b,c]:f(a,c+1)

Ungolfed minimal solution solver:

function godel(a) {
    for (c = 0;; c++) {
        var b = 0, n = 1, i = 0;
        for (;;) {
            var m = c * i + c + 1;
            // Increase b until β(b,c,i) = a[i]
            // Adding n won't change output for smaller i
            for (j = 0; j < m; j++) if (b % m != a[i]) b += n;
            if (j == m) break; // couldn't find a remainder, c too low
            i++;
            if (i == a.length) return [b, c]; // Result!
            // Next time we want adding n to b not to change β(b,c,i)
            for (j = 1; n * j % m != 0; j++);
            n *= j;
        }
    }
}


Golf a Custom Fibonacci Sequence The Fibonacci sequence is a fairly well known thing around here. Heck, it even has its own tag. However, for all that, we sure like to stick to our roots of 1, 1, ... (or is it 0, 1, ...? We may never know...). In this challenge, the rules are the same, but instead of getting the nth item in the Fibonacci sequence, you will get the nth item in the Fibonacci-esque sequence starting with x, y, ....

Input

Three integers, in whatever order you want. n is the index (0 or 1 indexed) of term in the sequence for your output. x and y are the first two items in your current program run's Fibonacci sequence.

Output

The nth term in the Fibonacci sequence starting with x, y.

Test Cases

(0-indexed)

n   x     y     out
5   0     0     0
6   0     1     8
6   1     1     13
2   5     5     10
10  2     2     178
3   3     10    23
13  2308  4261  1325165
0   0     1     0
1   0     1     1

(1-indexed)

n   x     y     out
6   0     0     0
7   0     1     8
7   1     1     13
3   5     5     10
11  2     2     178
4   3     10    23
14  2308  4261  1325165
1   0     1     0
2   0     1     1

Caveats

Assume 0 <= x <= y.

Please note your input order (must be constant).

Jelly, 3 bytes

+¡ạ

Takes x, y, and n (0-indexed) as separate command-line arguments, in that order.

Try it online!

How it works

+¡ạ  Main link. Left argument: x. Right argument: y. Third argument: n

  ạ  Yield abs(x - y) = y - x, the (-1)-th value of the Lucas sequence.
+¡   Add the quicklink's left and right argument (initially x and y-x), replacing
     the right argument with the left one and the left argument with the result.
     Do this n times and return the final value of the left argument.


Find the program that prints this integer sequence (Cops' thread) This is the cops' thread. The robbers' thread goes here.
The last cops-and-robbers thread was already 4 months ago.
The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.
The cop must state it if the program is intolerant towards zero.
The cop will provide at least 2 sample inputs/outputs.
For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

a(0) returns 0
a(3) returns 2

The number of examples is up to the cop's discretion.
However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(
The cop can hide as many characters as is so wished.
For example, if my program is:

function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end

Then I would hide these characters as I want:

function a(n)
    if ### then
        ########
    else
        ######################
    end
end

The robber's task

is obviously to find the original source code.
However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.
Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.
The winner will be the submission with the lowest score that hasn't been cracked in 7 days.
Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.
In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).
Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes
Output:
a(0) returns 0
a(3) returns 2

Code (# marks unrevealed characters):
function a(n)
    if ### then
        ########
    else
        ######################
    end
end

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

Vim, 36 keystrokes -- Safe!

i****<esc>:let @q="^*i****$**@***"<cr><n>@qbD

(Note: <n> is where you type your input)

Here is the code unrelated to number generation:

          :let @q="              "<cr><n>@qbD

Meaning I am revealing 5 out of 19 characters.

<n> is the input. Here are some sample outputs:

1@q:    1
2@q:    3
6@q:    18

Answer

This code prints The Lucas Numbers (A000032), which are just like The Fibonnaci Sequence, except that it starts on 2, 1 instead of 1, 1. Here are the first 15 numbers:

2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843

Here's the revealed code:

i2 1 <esc>:let @q="^diwwyw$pb@-<c-v><c-a>"<cr><n>@qbD

Explanation:

i2 1 <esc>                          "Insert the starting numbers
          :let @q="....."<cr>       "Define the macro 'Q'

Explanation of the macro:

^                      "Move to the first non-whitespace character on the line.
 diw                   "(d)elete (i)nner (w)ord. This is different then 'dw' because it doesn't grab the space.
                      "It also throws people off since 'i' is usually used for inserting text.
    wyw$               "Move to the next number, yank it then move to the end of the line
        pb             "(p)aste the yanked text and move (b)ack
          @-     <c-a> "@- is the register holding the word we deleted. Increment the current number that many times.
            <c-v>      "Since we're adding <c-a> this from the command line, we need to type it as a literal.

Now, we just need to remove the second number, since the first number is the lucas number we want. So we do

b   "move (b)ack
 D  "(D)elete to the end of the line.

Also, if I'm not mistaken, this is the first safe submission! That's kinda cool.


Primus-Orderus Primes Who are they?
Primus-Orderus Primes (POP) are primes which contain their order in the sequence of primes.
So the nth prime, in order to be POP, must contain all the digits of n in a certain way which I'll explain.
Examples
Let's get things clearer:
All digits of n must appear among the digits of POP in the same order they appear in n
The 6469th prime is 64679 which is POP because it contains all digits of 6469 in the right order .
1407647 is POP because it is the 107647th prime number
14968819 is POP (968819th prime).So this challenge is NOT OEIS (A114924)
1327 is NOT POP because it is the 217th prime (digits are not in the right order)
The Challenge
You guessed right!
Given an integer n, output the nth POP
Test Cases
input-> output
1->17
3->14723
5->57089
10->64553
29->284833
34->14968819

This is code-golf so the shortest answer in bytes wins!
All these should be 1-Indexed

Mathematica, 104 bytes

Extremely efficient

(t=i=1;While[t<#+1,If[!FreeQ[Subsets[(r=IntegerDigits)@Prime@i,{Length@r@i}],r@i],t++];i++];Prime[i-1])&

finds n=34 in under a minute


Create an omnifix calculator Inspiration. Inverse.
Evaluate a given omnifix expression.
Omnifix is like normal mathematics' infix notation, but with additional copies of each symbol surrounding the arguments. The outer symbols take the place of parentheses, and there is therefore no need for additional parentheses.
You must support addition, subtraction, multiplication, division, and positive real numbers (negative ones can be written -0-n-) within a reasonable range for your language.
Plus and minus must be + and -, but you may use * or × for times and / or ÷ for divide. Other reasonable symbols will be allowed upon request.
Brownie points for explanation and additional features (like additional operations, negative numbers, strings, etc.) Even if your answer does not have these features, feel free to show how it could.
Please provide a link to test your solution if at all possible.
Examples
For clarity, the explanations below use high minus (¯) to indicate negative numbers. You may return negative numbers using any reasonable format.
-5-2- → 3
+2+×3×2×+ → 8 (+2+×3×2×+ → +2+6+ → 8)
-14--3-1-- → 12 (-4--3-1-- → -14-2- → 12)
+2.1+×3.5×2.2×+ → 9.8 (+2.1+×3.5×2.2×+ → +2.1+7.7+ → 9.8)
×3×÷-0-6-÷2÷× → -9 (×3×÷-0-6-÷2÷× → ×3×÷¯6÷2÷× → ×3×¯3× → ¯9)
÷4÷-3-÷1÷2÷-÷ → 1.6 (÷4÷-3-÷1÷2÷-÷ → ÷4÷-3-0.5-÷ → ÷4÷2.5÷ → 1.6)

Python 3, 159 158 152 144 136 135 132 bytes

def t(i,a=1):
 while'-'<l[i]!='/':i+=1;a=0
 if a:l[i]='(';i=t(t(i+1));l[i-1]=')'
 return-~i
*l,=input()
t(0)
print(eval(''.join(l)))

Try it online!

Doesn't allow negative numbers (though -0-5- works of course) and requires python operators.


Am I a Fibonacci Number? Your Task:

Write a program or function to check if a number that is inputted is a Fibonacci number.  A Fibonacci number is a number contained in the Fibonacci sequence.

The Fibonacci Sequence is defined as:
F(n) = F(n - 1) + F(n - 2)

With the seeds being F(0) = 0 and F(1) = 1.

Input:

A non-negative integer between 0 and 1,000,000,000 that may or may not be a Fibonacci number.

Output:

A truthy/falsy value indicating whether or not the input is a Fibonacci number.

Examples:

0-->truthy
1-->truthy
2-->truthy
12-->falsy

Scoring:

This is code-golf, lowest byte count wins.

Neim, 2 bytes

f

Explanation:

f       Push an infinite fibonacci list
       Is the input in that list?

Works the same as my It's Hip to be Square answer, but uses a different infinite list: f, for fibonacci.

Try  it!


Japanese Multiplication There's a visual method for multiplication that is taught to Japanese schoolchildren [citation needed] that uses lines and crossings to get the answer.

Image Source

Your task is to implement this in ASCII art. You will be given two numbers to multiply. The output should be the corresponding ASCII art made up of \, /, and X, padded with ASCII spaces.

The first number of the multiplication will use backslashes, starting from left to right. The second number will use forward slashes, once again from leftmost digit to rightmost. The output is made up of distinct diagonal line groupings. The number of lines within a grouping should be equal to the value of the digit. There should be at least one diagonal space between each grouping and there should be no spaces within the grouping.

Suppose 43 is the first number. Before extending lines and creating crossings, it will start like this:

       \
      \
     \

   \
  \
 \
\

If the second number is 61, it will look like this before extending and crossing:

/
 /
  /
   /
    /
     /

       /

Conceptually "extend" the lines, using X's for intersection points, to get the result:

       \ /
      \ X /
     \ X X /
      X X X /
   \ / X X X /
  \ X / X X X /
 \ X X / X X X
\ X X X / X X \ /
 X X X X / X \ X
/ X X X X / \ X \
 / X X X X   X \
  / X X X \ / \
   / X X \ X
    / X \ X \
     / \ X \
        X \
       / \

Example Test Cases

5 * 9

    \ /
   \ X /
  \ X X /
 \ X X X /
\ X X X X /
 X X X X X /
/ X X X X X /
 / X X X X X /
  / X X X X X /
   / X X X X X
    / X X X X \
     / X X X \
      / X X \
       / X \
        / \

16 * 27

       \ /
      \ X /
     \ X X
    \ X X \ /
   \ X X \ X /
  \ X X \ X X /
   X X \ X X X /
\ / X \ X X X X /
 X / \ X X X X X /
/ X   X X X X X X /
 / \ / X X X X X X
    X / X X X X X \
   / X / X X X X \
    / X / X X X \
     / X / X X \
      / X / X \
       / X / \
        / X
         / \

7 * 24

      \ /
     \ X /
    \ X X
   \ X X \ /
  \ X X \ X /
 \ X X \ X X /
\ X X \ X X X /
 X X \ X X X X
/ X \ X X X X \
 / \ X X X X \
    X X X X \
   / X X X \
    / X X \
     / X \
      / \

123 * 543

       \ /
      \ X /
     \ X X /
      X X X /
   \ / X X X /
  \ X / X X X
   X X / X X \ /
\ / X X / X \ X /
 X / X X / \ X X /
/ X / X X   X X X /
 / X / X \ / X X X
  / X / \ X / X X \ /
   / X   X X / X \ X /
    / \ / X X / \ X X /
       X / X X   X X X
      / X / X \ / X X \
       / X / \ X / X \
        / X   X X / \
         / \ / X X
            X / X \
           / X / \
            / X
             / \

735 * 21

                \ /
               \ X /
              \ X X
             \ X X \ /
            \ X X \ X
             X X \ X \
          \ / X \ X \
         \ X / \ X \
        \ X X   X \
         X X \ / \
      \ / X \ X
     \ X / \ X \
    \ X X   X \
   \ X X \ / \
  \ X X \ X
 \ X X \ X \
\ X X \ X \
 X X \ X \
/ X \ X \
 / \ X \
    X \
   / \

Rules

There should be at least one (diagonal) space between each set of lines. For the purposes of this challenge, it doesn't have to line up in any sort of pretty visual way.
Border crossings should jut out by exactly one slash.
Any amount of padding to the left or the right is allowed as long as all the crossings line up correctly.
Single-width ASCII spaces must be used as padding.
You do not need to calculate the actual result of the multiplication.
You may assume the number is in base 10 and and is at most three digits long with no zeros.
Order matters for the purposes of the output. The first number is always in the \ direction and the second number is always in the / direction.
Input and output may be in any convenient format.
Standard loopholes are banned.

Happy Golfing!

Canvas, 41 bytes

（Ａ┬｛［１｝０｝┐）
⁷Ｌ├Ｘ⁷ｌＹø；｛³×？³ｙ³－╵ｘ＼╋
⁸⤢↔╶╶⁸ｎ

Try it here!


Left Hand vs. Right Hand — Typists Challenge Your task is to pit each side of the keyboard against each other and build two programs, in the same language, one using only keys on the left-hand side of a standard keyboard that outputs Pollinium milk; plump pumpkin; lollipop?, and one using the keys on the right that outputs Weatherheaded sweetheart haberdasheress!.

Rules

The exact keys allowed for the left-hand program are:

123456!@#$%^QWERTYqwertyasdfghASDFGH`zxcvb~ZXCVB

and for the right-hand program:

7890-=&*()_+uiop[]UIOP{}jkl;'\JKL:"|nm,./NM<>?

There are four free keys Esc (\x1b), Tab (\x09), Space (\x20) and Enter(\x0a and/or \x0d) which can be used in either, neither, or both solutions.

Your score will be the total byte count for both programs. Whilst I've used the term program, your submissions can either be full programs, or functions as usual, and both can be different types (eg. one full program, and one function).

Your result must include the desired text, any amount of leading and trailing whitespace is fine, as long as the exact text appears within it.

Standard loopholes are forbidden.

The shortest solutions in each language win.

Perl 5, 261 = 88 + 173 bytes

This is an example where "language options don't count" is a problem. The rigt side solution uses -p, the left side doesn't. So does it count as the same language or not? And should the options come from the left/right character set ?

Left 88

use -M5.10.0 (or -E from the commandline) to activate say Again arguable if this option should count as code and should come from the left side or if it falls under "options to set language version don't count"

say eYYYYZYEYWYYYYYWQYEYQWQEYQYYZYWYYYYYQYQW^q%565504004w4052bw!504!w!04!204bw56550!6!h%

Try it online!

Right 173

Run with the -p option (which also consists of right characters)

}{*_=\(uuuuuuuuuuuuuiuuuuuuuuuuiuuuuuuuuuuuuuui&Uiipjipjiijij0puiipjiipp0jijipjipjipipp7|Ouiujujjuiuuu0kouuujuiju0jijujuikjujukk7&"7oulio7iouloli77ooliou7liiu7o7lu7io7o77i")

This can almost certainly be improved, but for now it was hard enough to get something working. Not having access to print, say, $_ and sub{} makes output tricky

Try it online!


Is this even a word? Your should write a program or function that takes a 4-character string as input and outputs a value indicating if the string is an English word or not. You are allowed to make mistakes in 15% of the provided testcases.

Input details:

Input is a 4-character string containing only the lowercase English letters (a-z).

Output details:

If the input is an English word you should output a boolean true or an integer 1.

If the input isn't an English word you should output a boolean false or an integer 0.

Word lists

list of 4-letter English words (2236 words)

list of 4-letter non-word strings (2236 strings)

The non-word list contains uniformly randomly generated letter sequences with the real words removed from them.

Testing

Your program or function should make no more than 15% mistakes on the given word lists together. That means you can give wrong output for 670 of the 4472 provided inputs.

You should post the testing program or function too so others could check your answer. The length of your testing program doesn't count into your submissions score.

Standard loopholes are disallowed.

Your program shouldn't use any external sources e.g. accessing web or reading from file.

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

Ruby, 29 bytes
->s{!s[/[^aeiou]{3}|[jqxz]/]}

Hopefully I've got this right - it's my first time programming in Ruby. I actually did all my testing in Python, but import re was far too long for me.
This is an anonymous function which takes in a string and outputs true/false accordingly. It uses a regex which looks for one of the following two things:

Three consonants in a row
Contains one of jqxz

If either of these are present, we classify the input as not a word.
The function matches 2030 words (incorrectly failing on 206) and fails on 1782 non-words (incorrectly matching 454), for a total of 660 misclassifications. Tested on ideone.
Thanks to @MartinBüttner for the Ruby help. Martin also points out that a full program takes the same number of bytes:
p !gets[/[^aeiou]{3}|[jqxz]/]

Also thanks to user20150203 for simplifying the regex.

Ruby, 1586 1488 1349 1288 1203 bytes
For a bonus, here's a function with a much longer regex:
->s{!s[/[^aeiouyhs]{3}|[^aeiouy]{4}|q[^u]|^x|^[bdf][^aeioulry]|^[cgkprtwy][mfdsbktjgxpc]|^a[aoz]|^e[hf]|^i[ea]|^o[ecy]|^u[^ltnspgr]|[bdgktyz][cgmpw]$|[fhpvx][^aieoflnrsty]$|eh$|i[iyh]|[wkybp]z|[dghz]t|[fjzsv]y.|h[ns].|ae.|y.?[yifj]|[ejo]..[iuw]|[inv]..[gpuvz]|[eu].[jqwx]|[vyz][^t][fhmpqy]|i[^ae][fjqrv]|[ospen].?j|[ceg][iuy][ghkoux]|[bcpx]f|[hnuy]w|[ghnw]b|[txz]n|[jk]r|.[fjuyz]u|[hnt]ia|lsy|.p.o|.l.l|.tas|zal|f.p|eeb|wei|.sc.|.pl|yat|hov|hab|aug|v.re|aba|ohu|ned|s.dd|uc$|nux|oo$|dgo|lix|wua|v.o|vo$|ryo|wue|dk|oic|yol|.tr|yrb|oba|ruh|c.ls|idd|chn|doy|ekh|tk|lke|asl|cir|eez|asc|uil|iou|m..p|awt|irp|zaa|td|swk|ors|phe|aro|yps|q.e|ati|ibt|e.mo|we.y|p.de|ley|eq|tui|e..g|sps|akh|dny|swr|iul|.t.t|.tao|rcy|.p.y|idi|j.o|.kl|oms|ogi|jat|.lis|mye|uza|rsi|.ala|ibo|ipi|yaa|eun|ruy|wog|mm$|oex|koi|uyn|.hid|osc|ofe|w.op|auc|uzy|yme|aab|slm|oza|.fi|bys|z.e|nse|faf|l.h|f.va|nay|hag|opo|lal|seck|z.b|kt|agl|epo|roch|ix.|pys|oez|h.zi|nan|jor|c.ey|dui|ry.d|.sn|sek|w.no|iaz|ieb|irb|tz.|ilz|oib|cd|bye|ded|f.b|if$|mig|kue|ki.w|yew|dab|kh.|grs|no.t|cs.|.n.m|iea|y.na|vev|eag|el[uz]|eo[dkr]|e[hlsu]e|e[dho]l|eov|e[adp]y|r[grt]u|yn[klo]|.[^ilv].v|s[bdgqrz]|m[dfghrz]|[vpcwx]{2}|^[hjlmnvz][^aeiouy]|^[drw]l|l[hnr]/]}

I wanted to show that regex can still beat compression, so this one classifies every given case correctly. The regex itself is a bit like exponential decay — the first bits match a lot of non-words, then every bit after matches fewer and fewer until I gave up and just concatenated the rest (about 200 or so) at the end. Some of the ones that were left looked surprisingly like real words (such as chia which is a word).
I threw the regex at my regex golf cleaner which I wrote for another challenge — it golfed about 300 bytes before I had to try shuffling things around manually. There's still a fair bit to be golfed though.


Borders of overlapping circles Given the coordinates of several points on a plane, and the radius of a circle surrounding each point, draw polygons representing the circles and the edges where the circles meet. Straight edges will always fall along circle-circle intersection lines, but might not follow the full length of these lines.

Per mbomb007's suggestion, imagine the behavior of 2D soap bubbles. That's technically wrong, because soap bubbles would always meet at 120° angles to minimize energy, while these circles may meet at any angle.

This is a Voronoi diagram, minus a defined area plane. Thanks Andreas. This is actually a generalization of a Voronoi diagram called a power diagram.

Examples

For example, given two points and two radii, the output might look like this:

Add another point and radius and the output might look like this:

Input

You can structure the input however you wish. Please post results with the following inputs.

Test 1

x: 10, y: 10, r: 10
x: 25, y: 12, r: 8

Test 2

x: 8, y: 10, r: 6
x: 20, y: 8, r: 4
x: 18, y: 20, r: 12

Output

Output should be graphical and should include polygon borders, but nothing else is required. Points and intersections do not need to be represented like they are in the examples.

Constraints

No point will exist within the radius of another circle.
Standard codegolf rules.
No answers with loopholes will be accepted, but feel free to have fun with it.


This question has its ups and downs Input will consist of the following characters:

^: Go up one
v: Go down one
▲ or k: Go up two
▼ or j: Go down two

For example, the following input:

^^▲^v▼▲^^v

would produce the following output:

        ^
   ^   ^ v
  ▲ v ▲

 ^   ▼
^

Escape sequences that move the cursor such as \e[B are not allowed. You must produce the output using spaces and newlines.

Here are a few more test cases.

▲v^v^v^v^v^v^v^v▲

                ▲
▲ ^ ^ ^ ^ ^ ^ ^
 v v v v v v v v

^^^^^^^▲▲▲▼▼▼vvvvvv

         ▲

        ▲ ▼

       ▲   ▼

      ^     ▼
     ^       v
    ^         v
   ^           v
  ^             v
 ^               v
^                 v

v^^vv^^vvv^v^v^^^vvvv^^v^^vv

  ^   ^         ^
 ^ v ^ v       ^ v       ^
v   v   v ^ ^ ^   v   ^ ^ v
         v v v     v ^ v   v
                    v


Stripping off extra spaces from a string You are given a string. Output the string with one space per words.

Challenge

Input will be a string (not null or empty), surrounded with quotes(") sent via the stdin. Remove leading and trailing spaces from it. Also, if there are more than one space between two words (or symbols or whatever), trim it to just one space. Output the modified string with the quotes.

Rules

The string will not be longer than 100 characters and will only contain ASCII characters in range (space) to ~(tilde) (character codes 0x20 to 0x7E, inclusive) except ",i.e, the string will not contain quotes(") and other characters outside the range specified above. See ASCII table for reference.
You must take input from the stdin( or closest alternative ).
The output must contain quotes(").
You can write a full program, or a function which takes input (from stdin), and outputs the final string

Test Cases

"this  is  a    string   "         --> "this is a string"

"  blah blah    blah "             --> "blah blah blah"

"abcdefg"                          --> "abcdefg"

"           "                      --> ""

"12 34  ~5 6   (7, 8) - 9 -  "     --> "12 34 ~5 6 (7, 8) - 9 -"

Scoring

This is code golf, so the shortest submission (in bytes) wins.

CJam, 7 bytes
q~S%S*p

Code Explanation
CJam has reserved all capital letters as inbuilt variables. So S has a value of a space here.
q~          e# Read the input (using q) and evaluate (~) to get the string
  S%        e# Split on running lengths (%) of space
    S*      e# Join (*) the splitted parts by single space
      p     e# Print the stringified form (p) of the string.

This removes the trailing and leading spaces as well
Try it online here


More efficient US state codes Abbreviate that US state! was fun, but we learnt that efficiently abbreviating US state names is hard with the current system. Let's come up with an alternative state code scheme for efficient golfing.
Your task:

Write a function (or program) which, given a valid US state name (only the 50 normal states required), returns a unique two-letter code in uppercase identifying it. The code must meet these requirements:

The first letter must be the same as the first letter of the state.
The second letter must be one of the other letters of the state (not a space).
It must always give the same output for the same input, and must never give the same output for two different valid inputs.

For instance, given "Alabama", your function could return "AL", "AA", "AB" or "AM" - as long as it doesn't return that value for any of Alaska, Arkansas, etc. ("AA" is only possible because "A" appears more than once in the state name.)
Standard loopholes forbidden. Standard input/output are ok. This is code golf, so shortest solution, in bytes, wins.
The complete list of possible inputs is here:
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
New Hampshire
New Jersey
New Mexico
New York
North Carolina
North Dakota
Ohio
Oklahoma
Oregon
Pennsylvania
Rhode Island
South Carolina
South Dakota
Tennessee
Texas
Utah
Vermont
Virginia
Washington
West Virginia
Wisconsin
Wyoming

Jelly,  13  12 bytes

907ị;⁸Qḣ2ṢŒu

A monadic link taking and returning lists of characters.

Try it online! or see a test suite

How?

907ị;⁸Qḣ2ṢŒu - Monadic link: list of characters, state    e.g. Alabama   or   Kansas
907          - literal 907
   ị         - index into state                                b              K
     ⁸       - link's left argument, state
    ;        - concatenate                                     bAlabama       KKansas
      Q      - de-duplicate (unique by 1st appearance)         bAlam          Kans
       ḣ2    - head to index 2                                 bA             Ka
         Ṣ   - sort                                            Ab             Ka
          Œu - convert to uppercase                            AB             KA

Indexing in Jelly is 1-indexed and modular, so the 907th index of something of length L is the (907-modulo-L)th item. For example for "Alabama" the length is 7 so the item at index 907 is the (907-modulo-7)th, and 907-modulo-7 is 4 (907 = 129 * 7 + 4), so the item at index 907 is 'b'.

907 is the first positive index at which the state abbreviations using index 1 and that index over all of the 50 states become unique.

State names, including their spaces, are of length 4 through 14 inclusive, and 907-modulo-6 is 1 (whereas for all other lengths the value is not 1). This means that if we were to use the 1st and 907th characters for the abbreviations that Alaska, Hawaii, Kansas, Nevada, and Oregon would be AA, HH, KK, NN, and OO respectively - this is not acceptable for Hawaii, Kansas, or Nevada; so an adjustment needs to be made; this is the reason for the concatenation, de-duplication, head to index 2 and sort, this makes Alaska, Hawaii, Kansas, Nevada, and Oregon become AL, HA, KA, NA and OR respectively and does not collide with existing state abbreviations.


The most common substring The purpose of this task is to write a program or function to find the most common substring within a given string, of the specified length.
Inputs

A string, s, of any length and characters that are valid as inputs for your language.
A number, n, indicating the length of substring to find. Guaranteed to be equal to or less than the length of the string.

Output
The most common (case-sensitive) substring of s of length n. In the case of a tie, any of the options may be output.
Win Criteria
This is code-golf, so lowest bytes wins; usual exceptions etc. apply.
Examples
Hello, World!, 1 > l (appears 3 times)
Hello! Cheerio!, 2 > o! (appears twice)
The Cat sat on the mat, 2 > at (appears three times)
The Cat sat on the mat, 3 > at  or he  (both with trailing spaces. Both appear twice - note case-sensitivity so The and the are different substrings)
Mississippi, 4 > issi (appears twice, note that the two occurrences overlap each other)
Some more examples, all using the same input string*
Bb:maj/2
F:maj/5
Bb:maj/2
G:9/3
Bb:maj7
F:maj/3
G:min7
C:sus4(b7,9)
C:sus4(b7,9)
C:sus4(b7,9)
F:maj
F:maj

(note the trailing newline)
1 > \r\n(appears 12 times, counting \r\n as a single character - my choice, your code may differ on this - otherwise either \r or \n appear the same number of times). : also appears 12 times
2 > :m (appears 8 times)
3 > :ma or maj (appears 7 times)
4 > :maj (appears 7 times)
5 > F:maj or \r\nF:ma or :maj/ (appears 4 times)
14 > \r\nC:sus4(b7,9)\r\n (appears 3 times)
(* input is taken from How predictable is popular music?. The result of this task might be used, for example, to find the most efficient way to apply a substitution in order to compress the string)

Python 3.8, 75 68 97 63 bytes

lambda s,n:max(l:=[s[j:j+n]for j in range(len(s))],key=l.count)

You can try it online! Increased byte count because, as @xnor kindly pointed out, Python's str.count doesn't count overlapping substrings... But then @xnor's reformulation of what I was doing allowed to slice a third of the bytes!

How:

l:=[s[j:j+n]for j in range(len(s))]

This creates a list of all the substrings in s of size n, plus the suffixes of size n-1, n-2, ..., 1. Then we find the max on that list, with the numerical value being used to sort given by

l.count

That means that if a and b are from l, a > b if a shows up more times in l than b. This means the shorter suffixes are never the result of the max because they only show up once, and even if the correct-sized substrings only show up once, they are first in l so they come out instead of the short suffixes. This allows me to save some bytes in the range used, given that I don't have to prevent i+n from being larger than len(s).

# Python, 83 64 bytes

lambda s,n:max((s[i:i+n]for i in range(len(s)-n+1)),key=s.count)

Thanks to @mypetlion I saved a LOT of bytes :D

You can try it online with my very own incredible test case!


Transmit Pi... precisely Following on from Monte Carlo estimator of Pi this challenge is to produce the shortest  code for the constant Pi. Except here your code must output consecutive digits of pi forever.

This is code golf, so the shortest submission (in bytes) wins except that it must output the first 10,000 digits in less than 10 seconds on a reasonable PC and it must never terminate.

You can't use any built-in for Pi or trig functions.

Removed the hard limit on code size.

Python, 138 bytes
q,r,t,i=1,180,60,2
while 1:u,y=27*i*(i+1)+6,(q*(27*i-12)+5*r)//(5*t);print(y,end="");q,r,t,i=10*q*i*(2*i-1),10*u*(q*(5*i-2)+r-y*t),t*u,i+1

Implementation of http://www.cs.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf.


Creating a Crossed Square Creating a Crossed Square

You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.

The general idea is for the output to be a hollow square that has a diagonal cross through it.:

Input: 7
Output:
*******
*#   #*
* # # *
*  #  *
* # # *
*#   #*
*******

In the above example the '*'s represent the outer box and the '#'s represent the diagonal cross.

Note that the above example uses two different characters so that it is easier to see what the output looks like, your program should use one character only.

Input

An integer of 1 or more, it is guaranteed to be odd.

Output

A square that is made up of a character of your choice with a cross through the middle.

The cross must be diagonal
The square may be output via the function or written to output
Trailing newlines are okay
Can output as a graphic, diagram or image if you wish too

Examples

Input: 1
Output:
*

Input: 3
Output:
***
***
***

Input: 5
Output:
*****
** **
* * *
** **
*****

Input: 7
Output:
*******
**   **
* * * *
*  *  *
* * * *
**   **
*******

Specs

Functions or full programs are allowed
You can get input by your preferred means
Standard loopholes are disallowed
Programs must work without any additional statements i.e. usings in C#, they must be included in the entry
You can output from a function or print the result

This is code golf so the shortest solution wins.

VBA Excel, 168 bytes
Instruction:
I find Excel with the help of VBA is an effective and a sufficient tool for this challenge. Set the worksheet of Excel like following

Yes, we use the small, classic square-shaped pixels like the old times by using the cells in a worksheet as the pixels. Ha-ha...
Here I use cell A1 as the input and I change its font color to red. Why red? Because red is three-letter-color so it fits for golfing. Write and run the following code in the Immediate Window:
N=[A1]:Range("A1",Cells(N,N)).Interior.Color=vbRed:Range("B2",Cells(N-1,N-1)).Clear:For i=1To N:Cells(i,i).Interior.Color=vbRed:Cells(i,N+1-i).Interior.Color=vbRed:Next

Ungolfed the code:
Sub A()
    N = [A1]
    Range("A1", Cells(N, N)).Interior.Color = vbRed
    Range("B2", Cells(N - 1, N - 1)).Clear

    For i = 1 To N
        Cells(i, i).Interior.Color = vbRed
        Cells(i, N + 1 - i).Interior.Color = vbRed
    Next
End Sub

Step-by-step Explanation:
N = [A1]: Range("A1", Cells(N, N)).Interior.Color = vbRed

Range("B2", Cells(N - 1, N - 1)).Clear

Looping through the diagonal of range cells: Cells(i, i).Interior.Color = vbRed

Final step and output: Cells(i, N + 1 - i).Interior.Color = vbRed


Visualize long addition with ASCII art Totally not inspired by Visualize long division with ASCII art ;)

Your job is to show long hand addition with ASCII art. You solve longhand addition by adding up the columns right to left, placing the value of the ones place in the result, and carrying the tens place over to the top of the next column.

Input

Input can come basically in any format you want, just as long as you take from 2 to 9 numbers as input.

Output

The formatting here likely matches how you learned it in school:

carry row
 number1
 number2
     ...
+   numX
--------
  result

You can have just about any amount of trailing whitespace you want here ;)

Examples

50, 50

1
 50
+50
---
100

1651, 9879

1111
 1651
+9879
-----
11530

6489789, 9874, 287

   1122
 6489789
    9874
+    287
--------
 6499950

Pyth, 59 58 bytes

L.[dJhl`eSQ`b:jk_.u/+NsYT.t_MjRTQ00\0djbyMPQXyeQ0\+*J\-ysQ

Try it online. Test suite.

Way too long. Should golf more.

Explanation

L                  helper function y = lambda b:
        eSQ          largest number in input
      l`             length as string
     h               increment
    J                save to J
 .[d       `b        pad argument with spaces to that length

                             carry row:
                jRTQ           each input to base 10
              _M               reverse each result
            .t      0          transpose, padding with zeroes
    .u               0         cumulative reduce from 0:
         sY                      sum digits of column
       +N                        add previous carry
      /    T                     floor-divide by 10
   _                           reverse
 jk                            join by ""
:                     \0d      replace 0 by space

          number rows:
    PQ      all input numbers but last one
  yM        pad to correct length
jb          print on separate lines

           last number row:
  eQ         last input number
 y           pad to correct length
X   0\+      change first char to +

        separator row:
 J        width of input (saved in helper)
* \-      that many dashes

       result row:
 sQ      sum of inputs
y        pad to correct length


Walk home one step at a time You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of:

Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing.
Rotate 90 degrees left, staying in place.
Rotate 90 degrees right, staying in place.

Your goal is to write code that will eventually get you home to \$(0,0)\$ if called repeatedly, each time with your current position and facing. Your code must always give the same output for a given input, which precludes using randomness or past state.

Input:

Two integers \$(x,y)\$ and a facing direction. The 4 possible facing directions are given as numbers 0 through 3, or alternatively 1 through 4, matched as you choose. The position can also be taken as a vector or point or complex number.

You won't be given \$(0,0)\$ where you're already home. Don't worry about overflows caused by huge inputs.

Output:

One of three distinct consistent outputs corresponding to the possible actions of walking straight, turning left, and turning right.

Haskell, 21 bytes

(!!).([(<0),(>0)]<*>)

Try it online!

Outputs a boolean with True being move forward and False being turn right.

Haskell, 28 bytes

Here's a version that is easy to understand / translate into any language.

f(x,y)d=[x<0,y<0,x>0,y>0]!!d

Try it online!

Explanation

The idea here is two-fold

We notice that we only ever need to turn in one direction.  A turn left is just 3 turns right.  So we will limit ourselves to only right turns.
Now we notice that given a direction there is a simple condition that can check if we ought to move forward.  Namely the sign of one of the two variables.

With this information we construct out solution, by making a list of the conditions and indexing the list with the direction.  True means the condition was passed and we can move forward (so we do), False means the condition was failed and we should not move forward, so we rotate.

Now the specification allows us to just output these values as is, since they are distinct and we have no intention of turning left.


Enumerate rhyme schemes A "rhyme scheme" is a string of letters a to z, such that the first occurrences of the characters are in ascending order (without gaps), starting from a. For example (with first occurrences marked):

abccdbebdcfa
^^^ ^ ^   ^

The number of rhyme schemes of length N is given by the Bell numbers B(N). (OEIS A000110)

The Challenge

Your task is to implement an enumeration of these rhyme schemes, i.e. a bijective mapping from integers to rhyme schemes. You're given a positive integer N <= 26, as well as a non-negative integer 0 <= i < B(N). Alternatively, you can use the range 1 <= i <= B(N). You should output a rhyme scheme of length N, such that every i yields a different string.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

You may use either lower or upper case letters (consistently).

Your code must be able to handle any valid input in reasonable amount of time (e.g. not more than a few hours for N = 26, worst case i). This should allow solutions that scale exponentially with N (for small bases), even in slow languages but prohibit solutions that scale linearly with i (i.e. B(N)). In particular, that means you cannot just iterate through all valid rhyme schemes of length N until you've discard i schemes.

Standard code-golf rules apply.

Examples

The exact assignment of the i to schemes (i.e. the order of the schemes for a given N) is up to you. But say you chose lexicographical ordering, your solution should correspond to the following table (with - denoting invalid input):

N\i 1    2    3    4    5    6    7    8    9    10   11   12   13   14   15
1   a    -    -    -    -    -    -    -    -    -    -    -    -    -    -
2   aa   ab   -    -    -    -    -    -    -    -    -    -    -    -    -
3   aaa  aab  aba  abb  abc  -    -    -    -    -    -    -    -    -    -
4   aaaa aaab aaba aabb aabc abaa abab abac abba abbb abbc abca abcb abcc abcd

Here is a short CJam script which generates all valid rhyme schemes for any given length (but don't try more than 10 or you'll wait a while).

Related Challenges

Translate a Glypho program
Check if words are isomorphs

Python 2, 153

u=[1]*999;i=60;exec"u[i]=i%30*u[i-30]+u[i-29];i+=1;"*900
def x(l,n,a=0):m=u[30*l+a];c=n>=a*m;return'.'*l and chr(65+min(n/m,a))+x(l-1,[n%m,n-m*a][c],a+c)

It uses alphabetical order and 0-based indexing.
Let l denote the length of a suffix of the letters and a denote the number of distinct letters that were used in the preceding part. Then a function p(l,a) that calculates the number of ways to select the remaining letters could be 40 bytes:
p=lambda l,a:l<1or a*p(l-1,a)+p(l-1,a+1)

However, this is too slow for the challenge, so instead the necessary values are precalculated and stored in the u array. At each stage of the calculation, if the next letter is the one of the a already used, the n = k * p(l - 1, a) + n' where k is the 0-indexed letter of the alphabet and n' is the value of n for the next function call, which contains the information about the remaining letters. If a new letter is used, then n = a * p(l - 1, a) + n'.


Magic number of a given length Your program must take an input (n for the purpose of description) and output all permutations of a number that is n digits long with no repeating digits, where each of the digits preceding and including its index are divisible by the place in the number that it falls.

You can read about magic numbers here.

Rules:

1 <= n <= 10
No digits may be repeated
The leading 0 must be present (if applicable)
The 1st through xth digit of the number (starting with the first character as 1) must be divisible by x, i.e. in 30685, 3 is divisible by 1, 30 is divisible by 2, 306 is divisible by 3, 3068 is divisible by 4, and 30685 is divislbe by 5.
The program must take an integer as input (through the command line, as a function argument, etc.) and print all permutations that satisfy the rules.
Output must be separated by 1 or more white space character
Permutations may start and with zero (so they're not technically magic numbers).
The order of output does not matter
You do not need to handle unexpected input
Least characters in bytes wins

Examples

Given 1:

0
1
2
3
4
5
6
7
8
9

Given 2:

02
04
06
08
10
12
14
16
18
20
24
26
28
30
32
34
36
38
40
42
46
48
50
52
54
56
58
60
62
64
68
70
72
74
76
78
80
82
84
86
90
92
94
96
98

Given 10:

3816547290

Credit to Pizza Hut & John H. Conway for the original puzzle (Option A).
Thanks to @Mego and @sp3000 for their links.

JavaScript (Firefox 30-57), 77 bytes

f=n=>n?[for(s of f(n-1))for(c of"0123456789")if(s.search(c)+(s+c)%n<0)s+c]:[""]

Edit: Saved 1 byte thanks to @edc65.


Model a probability table using 15-bit fixed probabilities A histogram is an array of integers that counts the number of times a symbol occurs. For example, for the string "aaabbbabbdebabbbebebdbaaabbabaaaaeebeaabaaba" a histogram is a: 18, b: 18, c: 0, d: 2, e: 6, or [18, 18, 0, 2, 6] in short.

If we were to pick a random character out of this string, what would the chance be that it is a particular character? We can calculate a probability table using the histogram. Simply divide every number by the sum of the histogram. So we have a 18/44 chance to get a.

Probability tables are used in compression algorithms. But compression algorithms have to be fast and always do the same computation on every machine. We can't use ratios, as they're slow and get big (1248148/13468235) and we can't use floating point as rounding errors differ from machine to machine. So we use... fixed point probability!

A 15-bit fixed point probability is a 15-bit integer representing a probability. If n is the integer, then it represents the real probability n / 0x7fff. So 0 is never, 0x7fff is always, and 0x3fff is (nearly) 50%.

So, the challenge is to compute a 15-bit fixed point probability table, given a histogram. But there are a few assumptions that the output must fulfill:

Every symbol in the histogram has a respective 15-bit fixed point probability in the probability table.
A symbol with count 0 in the histogram must have zero probability.
A symbol with count > 0 in the histogram may not have zero probability.
The cumulative probability must be 1: the probability table must sum to 0x7fff.

Your score for a certain histogram will be the sum of squared differences between the real probabilities and the 15-bit fixed point approximations.

The score for your answer will be the sum of scores you get on the set of histograms generated by the following Python (2 or 3) program:

import random
random.seed(0)
for _ in range(100):
    l = 1 + min(int(random.expovariate(1/100.)), 1000)
    print([int(random.expovariate(1/10.)) for _ in range(l)])

Alternatively, you can view the test set here. I may change the test set in the future, do not optimize for this particular one.

If you write your probability tables in a Python list format, one per line, the following Python program can score your answer in one fell swoop using python score.py hist.txt prob.txt:

from __future__ import division
import sys
scores = []
with open(sys.argv[1]) as hist, open(sys.argv[2]) as prob:
    skip_empty_lines = lambda it: filter(lambda s: s.strip(), it)
    for hist_l, prob_l in zip(skip_empty_lines(hist), skip_empty_lines(prob)):
        hist, prob = eval(hist_l), eval(prob_l)
        scores.append(sum((p/0x7fff - h/sum(hist))**2 for h, p in zip(hist, prob)))
print(sum(scores))

Lowest score wins, ties broken by asymptotic complexity before first answer.

Python, score 8.682671033510566e-07, O(n * log(n))
#!/usr/bin/env python
from __future__ import division
from ast import literal_eval
from fractions import Fraction
from operator import itemgetter
from sys import argv
import fileinput

def model(hist):
    TOTAL_FINAL = 0x7fff
    TOTAL_INIT = sum(hist)
    SCALE = Fraction(TOTAL_FINAL, TOTAL_INIT)
    hist_probs = [Fraction(x, TOTAL_INIT) for x in hist]
    res = [max(int(x*SCALE),1) if x > 0 else 0 for x in hist]

    adjust = TOTAL_FINAL - sum(res)
    res_probs = [Fraction(x,TOTAL_FINAL) for x in res]
    diffs = [(x-y)**2 for x,y in zip(hist_probs, res_probs)]
    d2 = [(x-y) for x,y in zip(hist_probs, res_probs)]
    if adjust > 0:
        idx, vals = zip(*list(filter(lambda x:x[1]>0, sorted(((i,x) for (i,x) in enumerate(d2) if hist[i]), key=itemgetter(1), reverse=True))))
        i = 0
        while i < adjust:
            res[idx[i%len(idx)]] += 1
            i += 1
    else:
        idx, vals = zip(*list(filter(lambda x:x[1]<0,sorted(((i,x) for (i,x) in enumerate(d2) if hist[i]), key=itemgetter(1)))))
        i = 0
        while i < adjust:
            res[idx[i%len(idx)]] -= 1
            i += 1

    return res

if __name__ == '__main__':
    for line in fileinput.input():
        print(model(literal_eval(line)))

This takes input as a file (or sequence of files) with one Python-list-format histogram per line, with the filename(s) provided on the command line (like python prog.py hist.txt).
The general strategy here is to make a (decent) initial guess at the best probability representation, by doing integer scaling of the input histogram to 15 bits. This almost always gets the resultant list just shy of 32767 total. To adjust the probabilities, the items with the largest squared differences from the input histogram get incremented. If the result is too high initially, the largest value in the array is decreased by the excess, instead.
Time Complexity
O(n * log(n)), based on the sorting, which is the most time-consuming operation for each histogram.


Strobogrammatic Numbers Strobogrammatic Numbers

Definition
A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,

(source: w3resource.com)
Task
Given a number as the input, determine if it's strobogrammatic or not.
Examples

Truthy

1
8
0
69
96
69169
1001
666999
888888
101010101

Falsey

2
3
4
5
7
666
969
1000
88881888
969696969

Rules

The number is guaranteed to be less than a billion.
We are considering 1 in it's roman numeral format for the sake of the challenge.
Input can be taken as number, or an array of chars, or as string.
Output would be a truthy/falsey value. However, you are allowed to flip the output values.
This is a code-golf, so fewest bytes will win!

Sandbox link

Node.js 11.6.0,  34  33 bytes
Expects an array of digits. Returns false for strobogrammatic, or true otherwise.

n=>n.some(c=>n.pop()-c**66%79%63)

Try it online!
How?
Taking the precision errors on large integers into account1, we look for a function:
$$f(x)=(x^p\bmod m_0)\bmod m_1$$
such that:
$$f(0)=0,\:f(1)=1,\:f(6)=9,\:f(8)=8,\:f(9)=6$$
and:
$$f(x)>9\text{ for }x\in\{2,3,4,5,7\}$$
1: These errors actually depend on the JS engine. This is guaranteed to work with Node 11.6.0.

JavaScript (ES6), 38 bytes
Expects an array of digits. Returns false for strobogrammatic, or true otherwise.

n=>n.some(c=>n.pop()!="01----9-86"[c])

Try it online!


Shortest program that continuously allocates memory Write a program which runs forever and allocates more and more memory on the heap the longer it runs, at least until you reach the limit of the operating system on the amount of memory that can be allocated.

Many kernels won't actually reserve memory you allocate until you use it for something, so if your program is in C or some other low level language you'll have to make sure you write something to each page. If you're using an interpreted language, you're probably not going to have to worry about this.

Shortest code wins.

Funge-98 (cfunge), 1 byte
9

I would have posted this earlier, but decided to test it, and it took a while to get my computer back to a usable state. cfunge stores the Funge stack on the operating system's heap (which is easily verifiable by running the program with a small memory limit, something that I should have done earlier!), so an infinitely growing stack (as with this program, which just pushes 9 repeatedly; Funge programs wrap from the end of a line back to the start by default) will allocate memory forever. This program likely also works in some Befunge-93 implementations.
More interesting:
"NULL #(4

This was my first idea, and is an infinite allocation that doesn't rely on the Funge stack (although it blows up the Funge stack too). To start with, the " command pushes a copy of the rest of the program to the stack (it's a string, and the program wraps round, so the close quote also serves as the open quote). Then the N reflects (it has no meaning by default), causing the program to run backwards. The " runs again, and pushes the program to the stack – the other way round this time, with the N at the top of the stack – then the program wraps around, loading a library with a 4-letter name (4(; the NULL library is part of cfunge's standard library). NULL defines all uppercase letters to do reflect, so the L reflects, the # skips the library load on the way back, the 4 pushes junk we don't care about to the stack and the whole program repeats from the start. Given that loading a library multiple times has an effect, and requires the library's command list to be stored once for each copy of the library (this is implied by Funge-98's semantics), it leaks memory via non-stack storage (which is an alternative method of defining "heap", relative to the language rather than the OS).


Regex (.NET flavour), 23 22 bytes

.+?(?=(.*$)(?<=^\1.*))

This will match the required period as a substring.

Test it here.

How does it work?

# The regex will always find a match, so there's no need to anchor it to
# the beginning of the string - the match will start there anyway.
.+?        # Try matching periods from shortest to longest
(?=        # Lookahead to ensure that what we've matched is actually
           # a period. By using a lookahead, we ensure that this is
           # not part of the match.
  (.*$)    # Match and capture the remainder of the input in group 1.
  (?<=     # Use a lookahead to ensure that this remainder is the same
           # as the beginning of the input. .NET lookaheads are best
           # read from right to left (because that's how they are matched)
           # so you might want to read the next three lines from the
           # bottom up.
    ^      # Make sure we can reach the beginning of the string.
    \1     # Match group 1.
    .*     # Skip some characters, because the capture won't cover the
           # entire string.
  )
)


American Gothic in the palette of Mona Lisa: Rearrange the pixels You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of pixels.

Your task is to create an algorithm that makes the most accurate looking copy of the Source by only using the pixels in the Palette. Each pixel in the Palette must be used exactly once in a unique position in this copy. The copy must have the same dimensions as the Source.

This Python script can be used ensure these constraints are met:

from PIL import Image
def check(palette, copy):
    palette = sorted(Image.open(palette).convert('RGB').getdata())
    copy = sorted(Image.open(copy).convert('RGB').getdata())
    print 'Success' if copy == palette else 'Failed'

check('palette.png', 'copy.png')

Here are several pictures for testing. They all have the same area. Your algorithm should work for any two images with equal areas, not just American Gothic and the Mona Lisa. You should of course show your output.

Thanks to Wikipedia for the images of famous paintings.

Scoring

This is a popularity contest so the highest voted answer wins. But I'm sure there's lots of ways to be creative with this!

Animation

millinon had the idea that it would be cool to see the pixels rearrange themselves. I thought so too so I wrote this Python script that takes two images made of the same colors and draws the intermediate images between them. Update: I just revised it so each pixel moves the minimum amount it has to. It is no longer random.

First is the Mona Lisa turning into aditsu's American Gothic. Next is bitpwner's American Gothic (from Mona Lisa) turning into aditsu's. It's amazing that the two versions share the exact same color palette.

The results are really quite astounding. Here is aditsu's rainbow Mona Lisa (slowed to show detail).

This last animation is not necessarily related to the contest. It shows what happens when my script is used to rotate an image 90 degrees.

Java - GUI with progressive randomized transformation
I tried a LOT of things, some of them very complicated, then I finally came back to this relatively-simple code:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;

@SuppressWarnings("serial")
public class CopyColors extends JFrame {
    private static final String SOURCE = "spheres";
    private static final String PALETTE = "mona";
    private static final int COUNT = 10000;
    private static final int DELAY = 20;
    private static final int LUM_WEIGHT = 10;

    private static final double[] F = {0.114, 0.587, 0.299};
    private final BufferedImage source;
    protected final BufferedImage dest;
    private final int sw;
    private final int sh;
    private final int n;
    private final Random r = new Random();
    private final JLabel l;

    public CopyColors(final String sourceName, final String paletteName) throws IOException {
        super("CopyColors by aditsu");
        source = ImageIO.read(new File(sourceName + ".png"));
        final BufferedImage palette = ImageIO.read(new File(paletteName + ".png"));
        sw = source.getWidth();
        sh = source.getHeight();
        final int pw = palette.getWidth();
        final int ph = palette.getHeight();
        n = sw * sh;
        if (n != pw * ph) {
            throw new RuntimeException();
        }
        dest = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_RGB);
        for (int i = 0; i < sh; ++i) {
            for (int j = 0; j < sw; ++j) {
                final int x = i * sw + j;
                dest.setRGB(j, i, palette.getRGB(x % pw, x / pw));
            }
        }
        l = new JLabel(new ImageIcon(dest));
        add(l);
        final JButton b = new JButton("Save");
        add(b, BorderLayout.SOUTH);
        b.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                try {
                    ImageIO.write(dest, "png", new File(sourceName + "-" + paletteName + ".png"));
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        });
    }

    protected double dist(final int x, final int y) {
        double t = 0;
        double lx = 0;
        double ly = 0;
        for (int i = 0; i < 3; ++i) {
            final double xi = ((x >> (i * 8)) & 255) * F[i];
            final double yi = ((y >> (i * 8)) & 255) * F[i];
            final double d = xi - yi;
            t += d * d;
            lx += xi;
            ly += yi;
        }
        double l = lx - ly;
        return t + l * l * LUM_WEIGHT;
    }

    public void improve() {
        final int x = r.nextInt(n);
        final int y = r.nextInt(n);
        final int sx = source.getRGB(x % sw, x / sw);
        final int sy = source.getRGB(y % sw, y / sw);
        final int dx = dest.getRGB(x % sw, x / sw);
        final int dy = dest.getRGB(y % sw, y / sw);
        if (dist(sx, dx) + dist(sy, dy) > dist(sx, dy) + dist(sy, dx)) {
            dest.setRGB(x % sw, x / sw, dy);
            dest.setRGB(y % sw, y / sw, dx);
        }
    }

    public void update() {
        l.repaint();
    }

    public static void main(final String... args) throws IOException {
        final CopyColors x = new CopyColors(SOURCE, PALETTE);
        x.setSize(800, 600);
        x.setLocationRelativeTo(null);
        x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        x.setVisible(true);
        new Timer(DELAY, new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                for (int i = 0; i < COUNT; ++i) {
                    x.improve();
                }
                x.update();
            }
        }).start();
    }
}

All the relevant parameters are defined as constants at the beginning of the class.
The program first copies the palette image into the source dimensions, then repeatedly chooses 2 random pixels and swaps them if that would get them closer to the source image. "Closer" is defined using a color distance function that calculates the difference between the r, g, b components (luma-weighted) together with the total luma difference, with a greater weight for luma.
It takes just a few seconds for the shapes to form, but a while longer for the colors to come together. You can save the current image at any time. I usually waited about 1-3 minutes before saving.
Results:
Unlike some other answers, these images were all generated using the exact same parameters (other than the file names).
American Gothic palette

Mona Lisa palette

Starry Night palette

The Scream palette

Spheres palette
I think this is the toughest test and everybody should post their results with this palette:

Sorry, I didn't find the river image very interesting so I haven't included it.
I also added a video at https://www.youtube.com/watch?v=_-w3cKL5teM , it shows what the program does (not exactly in real-time but similar) then it shows the gradual pixel movement using Calvin's python script. Unfortunately the video quality is significantly damaged by youtube's encoding/compression.


How many votes does a state get? Given a list of the populations of each state, output, from greatest to least, the number of votes that state gets in the electoral college.

Input: The first number represents the total number of votes to distribute; it is followed by a list of and populations. In this example, abbreviations for states are used, but any name containing uppercase and lowercase letters could be used. You can take this in any format you like, as long as the only information contained is the state's abbreviation and its population.

Input may be taken as arguments to a function, or any way you want.

Example (possible) input: 538 [[CA 38000000], [NH 1300000] etc.]

Output: Output, in some format, the number of votes each state gets. Order the states from greatest to least. If two states have the same number of votes, order by whichever name would come first in a dictionary (which comes first alphabetically).

Before finding the number of votes, first check if there is a state named DC in the list of inputs, and if there is, give the state 3 votes, regardless of its population. Then, remove it from the list and assign the rest of the votes as though DC didn't exist.

The number of votes in the electoral college is defined to be the sum of the number of senators and representatives. Every state gets two senators, so subtract twice the number of states from the total (538, in the example input) to get the number of representatives. Assign every state one representative to start. Then, perform the following process:

Assign each state a number, A, defined to be P/sqrt(2) where P is the population.
Sort the states according to their values of A.
Assign the first state (the one with the largest A) one more representative.
Reassign values of A, as A = P/(sqrt(n)*sqrt(n + 1)), where n is the current number of representatives assigned to the state.
Go back to step 2. Repeat until all representatives have run out.

Example (possible) output: {CA: 518, NH: 20}. The output doesn't have to be in this format, but must contain the same information.

Note that if it is not possible to assign votes legally because there are less than 3*(# of states) votes, print whatever you want. You can crash, throw an error, etc.

Test cases:

538 [['CA' 38000000], ['NH' 1300000]] --> CA: 518, NH: 20
538 [['NH' 1300000], ['CA' 38000000]] --> CA: 518, NH: 20 (must be in order from greatest to least!)
538 [['DC' 1000000], ['RH' 1]] --> RH: 535, DC: 3
100 [['A', 12], ['B', 8], ['C', 3]] --> A: 51, B: 35, C: 14
100 [['A', 12], ['B', 8], ['C', 3], ['D', 0]]: --> [49, 34, 14, 3] (yes, even states with no population get votes)
2 [['A', 1]] --> aasdfksjd;gjhkasldfj2fkdhgas (possible output)
12 [['A', 1], ['B', 2], ['C', 3], ['D', 4]] --> A: 3, B: 3, C: 3, D: 3
42 [['K', 123], ['L', 456], ['M', 789]] --> M: 23, L: 14, K: 5
420 [['K', 123], ['L', 456], ['M', 789]] --> M: 241, L: 140, K: 39
135 [['C', 236841], ['D', 55540], ['G', 70835], ['K', 68705], ['M', 278514], ['Ms', 475327], ['Nh', 141822], ['Nj', 179570], ['Ny', 331589], ['Nc', 353523], ['P', 432879], ['R', 68446], ['Sc', 206236], ['Ve', 85533], ['Vi', 630560]] --> Vi: 20, Ms: 16, P: 14, Nc: 12, Ny: 12, M: 10, C: 9, Sc: 8, Nj: 7, Nh: 6, Ve: 5, D: 4, G: 4, K: 4, R: 4

Clean, 263 244 222 bytes

v n s=sortBy(\(a,b)(c,d).b>d)([(t,3.0)\\t<-s|fst t=="DC"]++w(n-3*(length s))[(t,1.0)\\t<-s|fst t<>"DC"])
w 0s=w 0 s=[(p,r+2.0)\\(p,r)<-s]
w n s#s=sortBy(\a b.A a>A b)s
#(p,r)=hd s
=w(n-1)[(p,r+1.0):tl s]
A((_,p),r)=p/sqrt(r*r+r)

Call like

Start = v 538 [("DC", 1000000.0), ("RH", 1.0)]

Ungolfed version, full program (census.icl):

module census

import StdEnv

Start = votes 538 [("DC", 1000000.0), ("RH", 1.0)]

votes n states
# dc = filter (((==)"DC")o fst) states
= sortBy (\(a,b)(c,d).b>d) ([(t,3.0) \\ t <- dc] ++ votes` (n-3*length states) [(t,1.0)\\t<-removeMembers states dc])
where
    votes` 0 states = map (\(p,r).(p,r+2.0)) states
    votes` n states
    # states = sortBy (\a b.A a > A b) states
    # (p,r) = hd states
    = votes` (n-1) [(p,r+1.0):tl states]

    A ((_,p),r) = p / sqrt(r*r+r)


Turing-Complete polyglot Write a polyglot (code that works in two or more languages) that has a "mid-section" that can be modified to do any computational task. This question is similar to https://stackoverflow.com/questions/1053931/code-golf-shortest-turing-complete-interpreter.

Rules:

The program must be able to preform a computation and print the results. Pseudorandom number capability is a plus but not necessary. The results must be the same in all languages, minor string-formatting differences are OK.

There is a section in the program that can be modified (in a straight-forward way) to do any computation (Turing complete). This is like the "comments section" in http://ideology.com.au/polyglot/polyglot.txt for which any comment can be inserted.

You must use at least 2 languages (this rule is here so you don't sue me).

Edit: Ideally you only need to write the "computation" part once. It is less interesting to use comment blocks, etc to knock out A so you have a block from B and then knockout B to write code from A. However, the one block solution is very difficult unless the languages have enough "overlap".

Also, using very similar languages (like C# and Java) isn't as interesting. It is still allowed but will probably earn less votes.

Grading

The winning is a popularity contest (Mar 1st).

C, Python, and Brainfuck

The Brainfuck program on the line starting with pgm= can be changed into any valid Brainfuck program (so it is Turing-complete). The program will then run in C, Python, and Brainfuck. The given program prints Hello World!.

The interpreters in both C and Python have the following characteristics:

8-bit cells
Infinite tape in both directions
-1 (255) on EOF

It runs like this:

$ gcc poly_bf.c; ./a.out
Hello World!
$ python poly_bf.c
Hello World!
$ bf poly_bf.c
Hello World!

And here's the program:

#define AA [
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BB ]
#define PGM char*\
pgm="++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
#define ZZ \
""" [-][";
struct cell { char val; struct cell *prev; struct cell *next; };
struct cell *prv(struct cell *c) {
    if (!c->prev) {
        struct cell *z = malloc(sizeof(struct cell));
        z->next = c;
        z->prev = 0;
        z->val = 0;
        c->prev = z;
    }
    return c->prev;
}
struct cell *nxt(struct cell *c) {
    if (!c->next) {
        struct cell *z = malloc(sizeof(struct cell));
        z->prev = c;
        z->next = 0;
        z->val = 0;
        c->next = z;
    }
    return c->next;
}
int main() {
    PGM
    int ip=0, t=0;
    struct cell *c = malloc(sizeof(struct cell));
    memset(c, 0, sizeof(struct cell));
    while (pgm[ip]) {
       switch(pgm[ip]) {
           case '+': c->val++;break;
           case '-': c->val--;break;
           case '>': c=nxt(c);break;
           case '<': c=prv(c);break;
           case '.': putchar(c->val);break;
           case ',': c->val=getchar();break;
           case '[':
               if (c->val) break;
               ip++;
               t=1;
               while (t) {
                  t += pgm[ip] == '[';
                  t -= pgm[ip] == ']';
                  ip++;
               }
               ip--;
               break;
           case ']':
               if (!c->val) break;
               ip--;
               t=1;
               while (t) {
                  t -= pgm[ip] == '[';
                  t += pgm[ip] == ']';
                  ip--;
               }
               ip++;
               break;
       }
       ip++;
    }
    return 0;
}
#define YY \
" """;
#define XX /*
import sys;
ip=t=0
class Cell:
  pv=None
  nx=None
  val=0

  def prev(self):
     if not self.pv:
        self.pv = Cell()
        self.pv.nx = self
     return self.pv
  def next(self):
     if not self.nx:
        self.nx = Cell()
        self.nx.pv = self
     return self.nx

cell=Cell()
while ip<len(pgm):
  if pgm[ip]=='+': cell.val+=1;cell.val%=256
  elif pgm[ip]=='-': cell.val-=1;cell.val%=256
  elif pgm[ip]=='>': cell=cell.next()
  elif pgm[ip]=='<': cell=cell.prev()
  elif pgm[ip]=='.': sys.stdout.write(chr(cell.val))
  elif pgm[ip]==',':
      ch=sys.stdin.read(1)
      if ch:cell.val=ord(ch)
      else:cell.val=255
  elif pgm[ip]=='[' and not cell.val:
      t=1
      ip+=1
      while t:
        t += pgm[ip] == '['
        t -= pgm[ip] == ']'
        ip+=1
      ip-=1
  elif pgm[ip]==']' and cell.val:
      t=1
      ip-=1
      while t:
        t -= pgm[ip] == '['
        t += pgm[ip] == ']'
        ip-=1
      ip+=1
  ip+=1
#]*/


Unicorn "Miner" CodeGolf This is a pretty cool CodeGolf challenge in the sense that you're only going to have a limited amount of time to do it. You need to build a program that "mines" StackOverflow unicoins. In order to do this, you need to perform just two HTTP requests. I'm not going to say how, to add to the fun.

The first person to do this gets a -10 on their score. Good luck! Also, if your doing this in JavaScript or similar, you don't need to account for the target browser's XSS, etc. prevention.

Javascript, 104 (114 chars - 10 bonus)
All due credit here.  Simply posting this to get the "first answer" -10 bonus ;-).
p='$.post("/unicoin/'
setInterval(p+'rock",function(o){'+p+'mine?rock="+o.rock,StackExchange.options.user)})',2e4)

setInterval accepts both functions and strings of code. After susbtituting the variable p, the following gets executed every 20 seconds:
$.post("/unicoin/rock", function(o) {
    $.post("/unicoin/mine?rock=" + o.rock, StackExchange.options.user)
}

Edits are welcome.  I don't know javascript well enough to really competitively golf this.