Random number generation, without built-in random number generation libraries Task:

Make a random number generator. The catch is that you can't use any built-in randomness functions. Your random numbers must be anything between 0 and 100, though they do not have to be floating point.

Rules:

It must produce a pseudorandom number.
Randomness defined: If you run it x times, then x times again, the two sequences will be unlikely to be identical. Where 2 < x < 10.
It is not required that your random number generator passes any specific test about the quality of the generated numbers, as long as the previous rule is respected.
Any language is accepted, except Golfscript, see here.
This is code-golf, so the shortest answer in bytes wins.
You may not hard-code the output numbers or read them from a file.
Post 5 numbers generated by your program.
Good luck!

C (46)

The stack pointer is sort of a random number

main(x){printf("%d",((unsigned char)&x)%100);}

Numbers I got:

20
40
4
52
36


Integer Interpretator The Challenge
Given a finite list of integers, split it into the fewest partitions possible such that no partition contains a number more than once.
Rules
Input can be in any format and any order.
Output can be in any format, as long as it's clear that each group is separate.
This is code-golf, so lowest score wins!
Example I/O
Input: [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2]
Output: [[1,2],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]]

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

Input: [5,9,12,5,2,71,23,4,7,2,6,8,2,4,8,9,0,65,4,5,3,2]
Output: [[5,9,12,2,71,23,4,7,6,8,0,65,3],[5,4,8,9,2],[4,5,2],[2]]

Python 2, 50 bytes

l=input()
while l:s=set(l);print s;map(l.remove,s)

Try it online!

Repeatedly prints the unique of elements of the list, then removes one of each such element. A rare imperative use of map.


Hidden Power Calculator One of the reasons I've always loved Pokemon is because for such a simple-seeming game, it has so many layers of complexity. Let's consider the move Hidden Power. In game, the type and power (at least before Generation VI) of Hidden Power is different for every Pokemon that uses it! That's pretty cool, right? Now, would you be surprised if I told you that the type and power of Hidden Power isn't generated randomly?

In all Pokemon games, all Pokemon (not just ones in your party, ALL POKEMON) have six internally-stored integers (one for the HP stat, one for the attack stat, one for the defense stat, one for the special attack stat, one for the special defense stat and one for the speed stat) called their individual values, or IVs. These values range between 0 and 31, and they essentially are one of a few factors that influence a Pokemon's overall stats. HOWEVER, they also determine the type and power of Hidden Power!

In Generation III to V (the generations whose algorithm we'll be implementing), the type of Hidden Power is determined by the following formula (note the floor brackets, that means you need to round down the result):

where a, b, c, d, e and f are the least significant bits of  the HP, Attack, Defense, Speed, Sp. Attack, and Sp. Defense IVs respectively. (Least significant bit is IV mod 2.) The number produced here then can be converted to the actual type using this chart:

0 Fighting
1 Flying
2 Poison
3 Ground
4 Rock
5 Bug
6 Ghost
7 Steel
8 Fire
9 Water
10 Grass
11 Electric
12 Psychic
13 Ice
14 Dragon
15 Dark

For power, a similar formula is used:

Here, however, u, v, w, x, y and z represent the second least significant bit of the HP, Attack, Defense, Speed, Sp. Attack and Sp. Defense IVs (in that order again). (Second least significant bit is more complicated then least significant bit. If IV mod 4 is 2 or 3, then the bit is 1, otherwise it is 0. If your language has some sort of built-in or at least a more clever way to do this, you should probably use it.)

So, as you probably figured out already, the challenge here is to write a program that takes in six integers separated by spaces via STDIN that represent the HP, Attack, Defense, Speed, Sp. Attack and Sp. Defense IVs of a Pokemon (in that order) and output the type and power of that Pokemon's Hidden Power.

Sample input:

30 31 31 31 30 31

Sample output:

Grass 70

Sample input:

16 18 25 13 30 22

Sample output:

Poison 61

This is code-golf, so shortest code wins. Good luck!

(And before people ask, I used the Generation V algorithm here because Generation VI gets rid of the power randomization and makes it always 60. Not only do I think this is incredibly lame, I think it makes the challenge a LOT LESS INTERESTING. So for the purposes of the challenge, we're running a Gen V game.)

Ruby, 210

a=$*.map.with_index{|a,i|[a.to_i%2<<i,a.to_i[1]<<i]}.transpose.map{|a|a.inject &:+}
$><<"#{%w(Fighting
Flying
Poison
Ground
Rock
Bug
Ghost
Steel
Fire
Water
Grass
Electric
Psychic
Ice
Dragon
Dark)[a[0]*15/63]} #{a[1]*40/63+30}"

First time golfing, so I guess this is pretty obvious solution.


Cracking in progress Remember those brute-force programs to crack password that show every combination they are trying? More precisely, at one point, the n first characters are fixed (they have been guessed successfully), and every possible character for the remaining ones is being tested. You've probably seen some in movies, or in some software written by people that like fancy interfaces.
Sorry to disappoint, but we won't write a program to crack password, only one to reproduce the nice output.

Challenge

Given a string containing printable ascii characters but no newlines (ascii code 32 to 126 or matching the regex ^[ -~]{2,}$), print an output following this rules:

At time t=n seconds, the n first characters printed are the n first characters of the input string.
After the n fixed characters, you should append a string formed random character (chosen uniformly pseudo-randomly from the unicode range    to ~ (code 32 to 126)) to form a string of the length of the initial one.
You should output at least (more on that later) 20 lines every second: every one of them will have the same n first characters, but a different random end.

It's probably not very clear yet what you are supposed to do, so lets go through an example:

Example

I'll print only 5 different lines for every seconds instead of the 20 minimum just to make it more readable.

Consider the input abcde.
During the first second, a valid output can be something like (completely random):

dGuT4
S!jkN
"gQ>[
TU3!
*fAjV

Then, t=1, the first character of every following string will be a (the first character of the input):

a);jD
aHv^p
aqw5*
a|.?:
a{gbK

Now, t=2, the first two characters will be ab:

abTJ"
ab\ e
ab3T#
abYWS
ab"#<

Now, t=3, the first three characters will be abc :

abcvW
abc3G
abc(g
abc{@
abc@4

Now, t=4, the first four characters will be abcd :

abcdD
abcdv
abcdj
abcd$
abcd6

Finally, t=5, we print the input (only once):

abcde

A few precisions

You shouldn't bother too much with your language precision toward the seconds (ie. If your algorithm is correct but your system/language lacks precision then it's fine).
The first second can be shorter than one second (That is, if you launch you program during a second, the first second can be just the remaining time until the end of the current second). Or put differently, you don't have to wait for the start of a new second to start printing the outputs.
At least 20 lines per second: The more natural way would be an infinite loop with a special behaviour one every second (or a timeout, or whatever), so that will result in probably a few thousand lines per second (and that's perfectly fine!). But if you have another idea, feel free to use it as long as you print at least 20 lines per second.
The input will always be more than 2 characters long.
You can consider that the input won't be more that 30 characters long if it helps. (But if it works for longer ones, it's for the best)
The input format should be the most natural representation of a string in your language.
You are allowed to print a trailing newline.

Code example

If you still don't understand exactly what you have to do, you can run the following code in a linux terminal to see:

perl -F -aplE 'map{$t=time;print$s,map{chr 32+rand 94}@F until$t-time;$s.=shift@F}@F' <<< "Cracking in progress\!"

Winning criterion

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

Thanks to Laikoni and Flp.Tkc for their suggestions and improvement in the sandbox.

HTML/JavaScript, 170 168 167 bytes

setInterval('o.textContent=i.value.replace(/./g,(c,i)=>new Date-d>++i*1e3?c:String.fromCharCode(Math.random()*95+32))',d=50)
<input id=i oninput=d=Date.now()><pre id=o>

Edit: Saved 2 bytes thanks to @ETHproductions. Saved 1 byte thanks to @jrich.


Golomb's sequence to 1000000 This used to be an old Computer Olympiad Question, not sure what the actual source was.

Assume function f:

f(1) = 1
This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order.
Number n has been repeated f(n) times

Here is the sequence up to the fifteenth number:

n :     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
f(n) :  1 2 2 3 3 4 4 4 5  5  5  6  6  6  6

for example number 4 has been repeated f(4) = 3 times.

So what you should do is to print out the sequence till f(1000000). There are no inputs.

Also you can run out of memory, not an issue! Code with less bytes wins.

So this is how to output will look like:
1 2 2 3 3 4 4 4 5 ...

CJam (22 bytes)

1{_~$(~$-)~$)}A6#(/]S*

Online demo for only 15 terms

This relies on one of the formulae given in the entry for OEIS A001462, and the use of ~$ to index the stack from the bottom.


The von Koch conjecture You may know the mathematician von Koch by his famous snowflake. However he has more interesting computer science problems up his sleeves.
Indeed, let's take a look at this conjecture:

Given a tree with n nodes (thus n-1 edges). Find a way to enumerate the nodes from 1 to n and, accordingly, the edges from 1 to n-1 in such a way, that for each edge k the difference of its node numbers equals to k. The conjecture is that this is always possible.

Here's an example to make it perfectly clear :

YOUR TASK

Your code will take as input a tree, you can take the format you want but for the test cases I will provide the tree by their arcs and the list of their nodes.

For example this is the input for the tree in the picture :

[a,b,c,d,e,f,g]
d -> a
a -> b
a -> g
b -> c
b -> e
e -> f

Your code must return the tree with nodes and edges numbered.
You can return a more graphical output but I will provide this kind of output for the test cases :

[a7,b3,c6,d1,e5,f4,g2]
d -> a 6
a -> b 4
a -> g 5
b -> c 3
b -> e 2
e -> f 1

TEST CASES

[a,b,c,d,e,f,g]             [a7,b3,c6,d1,e5,f4,g2]
d -> a                      d -> a 6
a -> b                      a -> b 4
a -> g             =>       a -> g 5
b -> c                      b -> c 3
b -> e                      b -> e 2
e -> f                      e -> f 1

[a,b,c,d]                   [a4,b1,c3,d2]
a -> b                      a -> b 3
b -> c            =>        b -> c 2
b -> d                      b -> d 1

[a,b,c,d,e]                [a2,b3,c1,d4,e5]
a -> b                      a -> b 1
b -> c                      b -> c 2
c -> d             =>       c -> d 3
c -> e                      c -> e 4

This is code-golf this the shortest answer in bytes win!

Note : This is stronger than the Ringel-Kotzig conjecture, which states every tree has a graceful labeling. Since in the Koch conjecture it is not possible to skip integers for the labeling contrary to the graceful labeling in the Ringel-Kotzig conjecture.  Graceful labeling has been asked before here.

Jelly, 30 bytes

JŒ!³,$€
Çµy⁴VIAµ€Q⁼$€TðḢịø³JŒ!

Try it online! (Use GṄ³çG as footer to make output prettier. )

Inputs similar to example, e.g. abcdef and [d,a],[a,b],[a,g],[b,c],[b,e],[e,f]

Outputs the list e.g. a,b,c,d,e,f in order.

Note: My program produces different values than the test cases as there are several possibilities which are all valid.

Explanation

JŒ!³,$€                - helper function, generates all possible numberings, input is e.g. 'abcd'
J                      - range(len(input)). e.g. [1,2,3,4]
 Œ!                    - all permutations of the range.
   ³,$                 - pair the input with ...
      €                - each permutation. Sample element e.g. ['abcd',[3,1,2,4]]

Çµy⁴VIAµ€Q⁼$€TðḢịø³JŒ! - main dyadic link, input is e.g. 'abcd' and '[a,b],[b,c],[b,d]'
 µy                    - use a numbering as an element-wise mapping e.g. 'abcd'->[3,1,2,4]
   ⁴                   - apply this to the list of edges. e.g. '[3,1],[1,2],[1,4]'
    V                  - turn this into an internal list.
     IAµ€              - find absolute difference on each edge
         Q⁼            - Is this invariant under deduplication? Returns 1 if the numbering is valid; 0 otherwise.
Ç          $€          - apply this to all possible numberings
             Tð        - return the indices of all valid numberings
               Ḣ       - choose the first one and
                ị      - get the element corresponding to its index in
                 ø³JŒ! - all possible numberings

Save 1 byte by showing all possible solutions:

JŒ!³,$€
Çµy⁴VIAµ€Q⁼$€Tðịø³JŒ!

Try it online! (Use GṄ³çG⁷³G as a footer to make output prettier)

Use converter to copy-paste test case into an input list.


Linear combination of two vectors Executive summary
Given input representing two vectors and their respective "weights", produce output that also represents the weighted sum of those vectors.
Challenge
The input will consist of one or more lines of the following characters:

exactly one occurrence of the digit 0, which represents the origin in a two-dimensional plane;
exactly two other digits (1-9; may or may not be the same digit), whose positions relative to the origin represent vectors, and whose values represent the weights attached to thse vectors;
some number of "background characters". The solver may choose a specific background character; for example, I will choose "." (mostly for human readability). Alternately, the background characters can be anything that look like blank space.

(The solver can choose whether the input is a single multi-line string or an array of one-line strings.)
For example, the input
....2
.0...
...3.

represents a vector at coordinates (3,1) with weight 2, and a vector at coordinates (2,-1) with weight 3.
The output should be almost the same as the input, with the following changes:

a "result character", chosen by the solver, to be added at the position specified by weighted sum of the input vectors (equivalently, at the position that is the appropriate linear combination of the input vectors);
as many background characters as are needed to fit the origin, the two input vectors, and the output vector in the same picture. Extra background characters can be included if desired; the only constraint is that, if the background character is a visible character, then the entire output must be rectangular in shape and every character not representing a vector must be the background character. (If blank space is used as background characters, then these constraints don't need to be enforced.)

(In general, if we have one vector (v,w) with weight a and second vector (x,y) with weight b, their weighted sum is a(v,w)+b(x,y) = (av+bx,aw+by).)
In the previous example, the appropriate linear combination is 2*(3,1) + 3*(2,-1) = (12,-1). If we use "X" as the result character, then the output could look like
....2.........
.0............
...3.........X

or
................
...2............
0...............
..3.........X...
................
................

Usual code-golf scoring: the shortest answer, in bytes, wins.
Example input and output
If blank space is used, the above input would look like
    2
 0
   3

and the output would look like
    2
 0
   3         X

Leading/trailing whitespace characters/lines are irrelevant; if they're invisible to the reader, it's fine. (That being said, for the rest of the examples I'll go back to using "." for the background character, to make it easier to read.)
If both vectors have weight 1, then the result will look like a parallelogram: the input
.1.
...
1.0

leads to the output
X.1.
....
.1.0

Note this parallelogram can be degenerate if the input vectors are collinear: the input
0.1..1

leads to the output
0.1..1.X

It is possible for the result vector to equal one of the input vectors or the origin; in this case, it simply overwrites the input character. For example, the input
..2.0.1...

yields the output
..X.0.1...

(where in input and/or output, the leading and trailing periods could be deleted). The input
.....3
......
...0..
......
......
2.....

yields the output
.....3
......
...X..
......
......
2.....

Finally, the input
90
.8

yields the output
........90
.........8
..........
..........
..........
..........
..........
..........
X.........

MATL, 48 bytes
tZyyX:UX>*Yat48-tt0>*3#fbbhb~2#fh-*s7M+'X'wZ}4$(

The background character is space. Input is a 2D char array with rows separated by semicolons. So the tests cases have respective inputs:
['    2'; ' 0   '; '   3 ']
[' 1 '; '   '; '1 0']
['0 1  1']
['  2 0 1   ']
['     3'; '      '; '   0  '; '      '; '      '; '2     ']
['90'; ' 8']

The output includes a significant amount of padding whitespace.
Try it online!


Squeezy sequence, sideways sedimentation Challenge

Premise

I've got multiple pretty numbers all in a row. Each is a decimal digit.

0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values are closer to the middle and the lower values closer to the sides.

Specifically, this happens:

1) Find all instances of digits having the highest value. If there's an even number \$2p\$ of them, go to step 2a. If there's an odd number \$2q+1\$ of them, go to step 2b.

2a) Consider the \$p\$ instances on the left and the \$p\$ instances on the right. Continue to step 3.

2b) Consider the \$q\$ instances on the left of the middle instance, and the \$q\$ instances on its right. Continue to step 3.

3) Each member of the former subset will move right by swapping places with the digit directly on its right as long as this other digit is smaller, and members of the latter subset will move left in a similar fashion. All such swaps happen simultaneously. If exactly one lower-value digit is enclosed by two high-value digits (one on each side), always move this lower-value digit to the right instead.

4) Repeat step 3 until all digits of this value are directly side-by-side.

5) Repeat steps 1 to 4 for smaller and smaller values until the values are exhausted.

Here's a detailed example.

2101210121012 | begin
1201120211021 | four 2s; the two on the left move right, the two on the right move left
1021122011201 | conflict, resulting in change from 202 to 220 (see step 3); meanwhile,
                 the two other 2s move inwards
1012122012101 | no remarks
1011222021101 | no remarks
1011222201101 | 2s are done
0111222210110 | six 1s, but exactly one on the left of the chain of 2s moves right, and
                 exactly two on the right move left. observe 1s can never pass through 2s
                 because 2 is not smaller than 1 (see step 3)
0111222211010 | no remarks
0111222211100 | end; 1s and 0s are done at the same time

Let's find the end state with the power of automation!

Task

Input: an integer sequence where each element is between 0 and 9 inclusive. The sequence is of length \$3\leq n\leq10000\$.

Output: in any format, the end state that would be reached by following the instructions in the section 'Premise'. Shortcut algorithms that give you the correct answer are allowed.

Examples

Input -> output
0 -> 0
40304 -> 04430
3141592654 -> 1134596542
2101210121012 -> 0111222211100
23811463271786968331343738852531058695870911824015 -> 01111122233333333445556666777888888999887554211100

Remarks

This is code-golf, so fewest bytes wins.
Standard rules, I/O rules and loophole rules apply.
If possible, link an online demo of your code.
Please explain your code.

JavaScript (ES8), 186 bytes
A direct transformation of the input.

s=>(g=s=>s.join``)([...b=g((a=s.split(n=Math.max(...s)))[S='slice'](0,(k=a[L='length'])/2))+(m=a[k>>1])[S](0,k&1&&m[L]/2)].sort())+''.padEnd(k-1,n)+g([...g(a)[S](b[L])].sort((a,b)=>b-a))

Try it online!


Parse a raw IRC message In the IRC protocol, raw messages look similar to this:

command arg1 arg2 :arg3 with spaces :arg4 with spaces :arg5

In a shell environment (e.g. bash), that would be equivalent to:

command arg1 arg2 "arg3 with spaces" "arg4 with spaces" arg5

The format specification is as follows:

Raw messages will only contain printable ASCII characters (ordinals 32-126).
Raw messages will start with a command, which will not contain any spaces.
Any number of arguments may follow a command. Arguments are delimited by one or more spaces followed by a colon (<space>: and <space><space>: are both valid delimiters).

Any arguments that do not contain spaces may omit the colon from the delimiter so long as all previous arguments (if any) have omitted the colon.

Colons will not appear within arguments or commands.
Arguments will not begin with a space.

For example, these are all valid raw messages:

join #foo #bar #baz
msg person hi
msg #channel :hello world
help :how do I use IRC
foo bar :baz bip :abc def :ghi

These are all invalid raw messages:

error :n:o colons within arguments
error ::need spaces between colons
:error no colons in commands
error non-ASCII character Ω

Given a valid raw IRC message as input, output a list containing the command and the arguments, properly parsed.

Test Cases

"join #foo #bar #baz" -> ["join", "#foo", "#bar", "#baz"]
"msg person hi" -> ["msg", "person", "hi"]
"msg #channel :hello world" -> ["msg", "#channel", "hello world"]
"help :how do I use IRC" -> ["help", "how do I use IRC"]
foo bar :baz bip :abc def :ghi :xyz -> ["foo", "bar", "baz bip", "abc def", "ghi", "xyz"]

PHP, 87 bytes
$a=($s=preg_split)("# +:#",$argv[1]);array_splice($a,0,1,$s("# +#",$a[0]));print_r($a);

The first regex splits the argument by one or more spaces followed by a colon.
The second regex splits the first element by one or more spaces with no colon.
array_splice replaces the first element with the result of the second preg_split.
print_r prints the resulting array.
function version for testing
$cases=[
    "join #foo #bar #baz" => ["join", "#foo", "#bar", "#baz"],
    "msg person hi" => ["msg", "person", "hi"],
    "msg #channel :hello world" => ["msg", "#channel", "hello world"],
    "help :how do I use IRC" => ["help", "how do I use IRC"],
    "foo bar :baz bip :abc def :ghi :xyz" => ["foo", "bar", "baz bip", "abc def", "ghi", "xyz"],
];
function i($argv_1_){$a=($s=preg_split)("# +:#",$argv_1_);array_splice($a,0,1,$s("# +#",$a[0]));return $a;}
foreach($cases as$x=>$e)
{
    $y=i($x);
    echo "case '$x': ['",join("','",$y),'"]: ',($y<>$e?"FAIL. Expected: ['". join("','",$e)."']":OK),"\n";
}


Count Maximal Fence Arrangements Background

I want to build a fence.
For that, I have collected a bunch of poles, and stuck them to the ground.
I have also collected lots of boards that I'll nail to the poles to make the actual fence.
I tend to get carried away when building stuff, and most likely I'll just keep nailing the boards to the poles until there's no more place to put them.
I want you to enumerate the possible fences that I can end up with.

Input

Your input is a list of two-dimensional integer coordinates representing the positions of the poles, in any convenient format.
You can assume that it contains no duplicates, but you cannot assume anything about its order.

The boards are represented by straight lines between the poles, and for simplicity, we only consider horizontal and vertical boards.
Two poles can be joined by a board if there are no other poles or boards between them, meaning that the boards cannot cross each other.
An arrangement of poles and boards is maximal if no new boards can be added to it (equivalently, there is either a pole or a board between any two horizontally or vertically aligned poles).

Output

Your output is the number of maximal arrangements that can be constructed using the poles.

Example

Consider the input list

[(3,0),(1,1),(0,2),(-1,1),(-2,0),(-1,-1),(0,-2),(1,-1)]

Viewed from the top, the corresponding arrangement of poles looks something like this:

  o
 o o
o    o
 o o
  o

There are exactly three maximal arrangements that can be constructed using these poles:

  o        o        o
 o-o      o|o      o-o
o----o   o||| o   o| | o
 o-o      o|o      o-o
  o        o        o

Thus the correct output is 3.

Rules

You can write either a function or a full program.
The lowest byte count wins, and standard loopholes are disallowed.

Test Cases

[] -> 1
[(0,0),(1,1),(2,2)] -> 1
[(0,0),(1,0),(2,0)] -> 1
[(0,0),(0,1),(1,0),(1,1)] -> 1
[(1,0),(0,1),(-1,0),(0,-1)] -> 2
[(3,0),(1,1),(0,2),(-1,1),(-2,0),(-1,-1),(0,-2),(1,-1)] -> 3
[(0,0),(4,0),(1,1),(1,-2),(3,1),(3,-2),(2,-1),(4,-1)] -> 3
[(0,0),(4,0),(1,1),(1,-2),(3,1),(3,-2),(2,-1),(4,-1),(0,-1)] -> 4
[(0,0),(4,0),(1,1),(1,-2),(3,1),(3,-2),(2,-1),(0,-1),(2,2)] -> 5
[(0,0),(4,0),(1,1),(1,-2),(3,1),(3,-2),(2,-1),(4,-1),(0,-1),(2,2)] -> 8

Mathematica, 301 bytes

(t~SetAttributes~Orderless;u=Subsets;c=Complement;l=Select;f=FreeQ;Count[s=List@@@l[t@@@u[Sort@l[Sort/@#~u~{2},!f[#-#2&@@#,0]&]//.{a___,{x_,y_},{x_,z_},b___,{y_,z_},c___}:>{a,{x,y},b,{y,z},c}],f[#,t[{{a_,b_},{a_,c_}},{{d_,e_},{f_,e_}},___]/;d<a<f&&b<e<c]&],l_/;f[s,k_List/;k~c~l!={}&&l~c~k=={},{1}]])&

This is an unnamed function which takes the coordinates as a nested List and returns an integer. That is, you can either give it a name and call it, or just append

@ {{3, 0}, {1, 1}, {0, 2}, {-1, 1}, {-2, 0}, {-1, -1}, {0, -2}, {1, -1}}

With indentation:

(
  t~SetAttributes~Orderless;
  u = Subsets;
  c = Complement;
  l = Select;
  f = FreeQ;
  Count[
    s = List @@@ l[
      t @@@ u[
        Sort @ l[
          Sort /@ #~u~{2},
          !f[# - #2 & @@ #, 0] &
        ] //. {a___, {x_, y_}, {x_, z_}, b___, {y_, z_}, c___} :>
              {a, {x, y}, b, {y, z}, c}
      ],
      f[
        #,
        t[{{a_, b_}, {a_, c_}}, {{d_, e_}, {f_, e_}}, ___]
          /; d < a < f && b < e < c
      ] &
    ],
    l_ /; f[
      s,
      k_List /; k~c~l != {} && l~c~k == {},
      {1}
    ]
  ]
) &

I can't even begin to express how naive this implementation is... it definitely couldn't be more brute force...

Get all (unordered) pairs of poles.
Sort each pair and all pairs into a canonical order.
Discard pairs which don't share one coordinate (i.e. which aren't connectible by an orthogonal line).
Discard pairs can be formed from two shorter pairs (so that o--o--o yields only two fences instead of three).
Get all subsets of those pairs - i.e. all possible combinations of fences.
Filter out combinations which have fences crossing each other.
Count the number of resulting fence sets for which no strict superset can be found in the list.

Surprisingly it does solve all the test cases virtually immediately.

A really neat trick I discovered for this is the use of Orderless to cut down on the number of patterns I have to match. Essentially, when I want to ditch fence sets with crossing fences, I need to find a pair of vertical and horizontal fence and check the condition on them. But I don't know what order they'll appear in. Since list patterns are normally order dependent, this would result in two really long patterns. So instead I replace with surrounding list with a function t with t @@@ - which isn't defined so it is held as it is. But that function is Orderless, so I can just check a single order in the pattern, and Mathematica will check it against all permutations. Afterwards, I put the lists back in place with List @@@.

I wish there was a built-in that is a) Orderless, b) not Listable and c) not defined for 0 arguments or list arguments. Then I could replace t by that. But there doesn't seem to be such an operator.


Flattened Spiral Permutation Index Context

Consider square matrices with n columns and rows containing the first n^2 (i.e. n squared) positive integers, where n is odd. The elements of the matrices are arranged such that the integers 1 through n^2 are placed sequentially in a counterclockwise spiral starting at the center and initially moving to the left. Call these matrices M(n)

For n=1 this simply gives the one element matrix M(1)=[[1]].

M(3) is the matrix

9 8 7
2 1 6
3 4 5

M(5) is the matrix

25 24 23 22 21
10  9  8  7 20
11  2  1  6 19
12  3  4  5 18
13 14 15 16 17

and M(7) is the matrix

49 48 47 46 45 44 43
26 25 24 23 22 21 42
27 10  9  8  7 20 41
28 11  2  1  6 19 40
29 12  3  4  5 18 39
30 13 14 15 16 17 38
31 32 33 34 35 36 37

Now consider flattening this matrix into a list/array by concatenating its rows starting from the top and moving down. Call these lists L(n). L(3), L(5) and L(7) are represented below, with their elements delimited by spaces.

9 8 7 2 1 6 3 4 5     (n=3)
25 24 23 22 21 10 9 8 7 20 11 2 1 6 19 12 3 4 5 18 13 14 15 16 17    (n=5)
49 48 47 46 45 44 43 26 25 24 23 22 21 42 27 10 9 8 7 20 41 28 11 2 1 6 19 40 29 12 3 4 5 18 39 30 13 14 15 16 17 38 31 32 33 34 35 36 37    (n=7)

We can find the index i(n) of L(n) in a lexicographically sorted list of permutations of L(n). In Jelly, the Œ¿ atom gives this index for the list it acts on.

Challenge

Your challenge is to take an positive odd integer n as input and output the index i(n).

The first few values are

n  i(n)
-------
1  1
3  362299
5  15511208759089364438087641
7  608281864033718930841258106553056047013696596030153750700912081

Note that i(n) ~= (n^2)!. This is not on OEIS.

This is code golf per language, so achieve this in the fewest bytes possible.

Sandbox post.

Jelly, 21 19 bytes

-;,N$ṁx"RFḣNṙ-+\ỤŒ¿

Try it online!

Based on the method from a J article on volutes.

Explanation

-;,N$ṁx"RFḣNṙ-+\ỤŒ¿  Main link. Input: integer n
-;                   Prepend -1. [-1, n]
  ,N$                Pair with its negated value. [[-1, n], [1, -n]]
     ṁ               Mold it to length n.
        R            Range. [1, 2, ..., n]
      x"             Vectorized copy each value that many times.
         F           Flatten
           N         Negate n
          ḣ          Head. Select all but the last n values.
            ṙ-       Rotate left by -1 (right by 1).
              +\     Cumulative sum.
                Ụ    Grade up.
                 Œ¿  Permutation index.


The Death Of Low-Resolution Pixel Art (Or, Draw That Death) This is an Irregular Webcomic! themed task.*

Death is a rather extensive orginization, and, although Head Death has had no trouble telling his employees apart, certain other entities connected to the orginization have had trouble keeping track of them all.

Thus, your task here is to, given the title of one of the various Deaths, generate the corresponding 32x32 pixel image of that Death.

Furthermore, as Head Death is rather bureaucratic (and a little bit stingy), the shortest program (after a few bonuses have been taken into account) will be the one chosen for official use.

Input must be case-insensitive. Additionally, the prefixes Death Of, Death By, and The Death Of should be treated as equivalent.

The output image may be saved to a file (in any lossless bitmap image format) or displayed on the screen.

The following are the EXACT RGB values to be used:

White 255 255 255
Black 0 0 0
Dark Gray 125 125 125
Bone Gray 170 170 170
Purple 60 0 140
Brown 120 40 0
Blue 0 80 200
Green 0 100 0
Neon Green 100 255 0
Red 0 255 0

(Note that no one Death uses all of those colors, and the only color which is common to all of them is bone gray)

Each output image shown here is shown first at actual size and then at 3x close-up.

You are required to support the following Deaths:

The Death of Insanely Overpowered Fireballs

The Death of Choking On A Giant Frog

Head Death

The Death of Being Wrestled To Death By Steve

The Death of Inhaling Hatmaking Chemicals

Charon

(Note that Charon's exact role in the organization is unknown)

You are not required to support the following Deaths, but may do so for various bonuses

Death by Having Your Pelvis Crushed (-8% bonus)

The Death of Being Ground By A Mars Rover Rock Abrasion Tool (-10% bonus)

The Death of Drowning in a Reactor Pool (-10% bonus)

The Death of Being Impaled By A Javelin (-8% bonus)

The Death of Being Stabbed By A Cutlass (-9% bonus)

The Death of Bad Pizza Deliveries (-7% bonus)

(Probably the only Death not to wear a cape. Don't ask me why.)

If you add include all of them, the final multiplier is 0.92*0.9*0.9*0.92*0.91*0.93≈0.58.

Additional Bonus

If you use an RGBA format and replace the white background with transparency, save an extra 12%.

  * Irregular Webcomic! is ©2002-Present David Morgan-Mar. CC BY-NC-SA.


Find the Missing Letter Guidelines
Task
Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array (lists in some languages).

Rules

This is code golf so the shortest answer in bytes wins!
You will always get a valid array
There will always be exactly one letter missing
The length of the array will always be at least 2.
The array will always contain letters in only one case (uppercase or lowercase)
You must output in the same case (uppercase or lowercase) that the input is
The array will always only go one letter a time (skipping the missing letter)
The array length will be between 2 and 25
The first or last element of the array will never be missing

Examples
['a','b','c','d','f'] -> 'e'
['O','Q','R','S'] -> 'P'
['x','z'] -> 'y'
['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z'] -> 'v'

C# (.NET Core), 48 47 46 bytes, input as char array

s=>{for(int i=0;s[++i]==++s[0];);return s[0];}

Try it online!

Explanation: the first element in the array is incremented as well as a pointer iterating the following elements. When both the first element and the current element are different, it returns the first element.

C# (.NET Core), 58 56 50 bytes, input as string

s=>{var c=s[0];while(s.IndexOf(++c)>=0);return c;}

Try it online!

Previous 58-byte solution (referenced in the first comment):

s=>{for(int i=1;;i++)if(s[i]-s[0]>i)return(char)(s[i]-1);}

Algorithms using System.Linq

The following algorithms must add using System.Linq; (18 bytes) to the byte count and therefore are longer.

I quite liked this one (52+18 bytes):

s=>{int i=0;return(char)(s.First(c=>c-s[0]>i++)-1);}

And you also have a one-liner (45+18)-byte solution:

s=>(char)(s.Where((c,i)=>c-s[0]>i).First()-1)

And a very clever (37+18)-byte solution, courtesy of Ed'ka:

s=>s.Select(e=>++e).Except(s).First()


Rearrangement Inequality Background

The Rearrangement Inequality is an inequality that is based on rearranging numbers. If I have two lists of numbers of the same length, x0, x1, x2...xn-1 and y0, y1, y2...yn-1 of the same length, where I am allowed to rearrange the numbers in the list, a way to maximize the sum x0y0+x1y1+x2y2+...+xn-1yn-1 is to sort the 2 lists in non-decreasing order.

Read the Wikipedia article here.

Task

You would write a program that takes input from STDIN or a function that accepts 2 arrays (or related containers) of numbers (which are of the same length).

Assuming you write a function which accepts 2 arrays (a and b), you are going to find the number of ways you can rearrange the numbers in the second array (b) to maximize:

a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+...+a[n-1]*b[n-1]

In this case, if the array b is [10, 21, 22, 33, 34] (indices for clarity),

[10, 21, 22, 33, 34],

[10, 21, 22, 34, 33], (swap the two 3's)

[10, 22, 21, 33, 34] (swap the two 2's)

[10, 22, 21, 34, 33] (swap the two 3's and swap the two 2's)

are considered different arrangements. The original array, itself, also counts as a possible rearrangement if it also maximizes the sum.

For STDIN input, you may assume that the length of the arrays is provided before the arrays (please state so that you use it), or that the arrays are provided on different lines (also please state).

Here are the 4 possible inputs (for convenience):

5 1 1 2 2 2 1 2 2 3 3 (length before arrays)

1 1 2 2 2 1 2 2 3 3 (the 2 arrays, concatenated)

1 1 2 2 2
1 2 2 3 3 (the 2 arrays on different lines)

5
1 1 2 2 2
1 2 2 3 3 (length before arrays and the 2 arrays on different lines)

For output, you are allowed to return the answer (if you write a function) or print the answer to STDOUT. You may choose to output the answer mod 109+7 (from 0 to 109+6) if it is more convenient.

Test Cases (and explanation):

[1 1 2 2 2] [1 2 2 3 3] => 24

The first 2 entries have to be 1 and 2. The last 3 entries are 2, 3 and 3. There are 2 ways to arrange the 2's between the first 2 entries and the last 2 entries. Among the first 2 entries, there are 2 ways to rearrange them. Among the last 2 entries, there are 6 ways to rearrange them.

[1 2 3 4 5] [6 7 8 9 10] => 1

There is only 1 way, which is the arrangement given in the arrays.

[1 1 ... 1 1] [1 1 ... 1 1] (10000 numbers) => 10000! or 531950728

Every possible permutation of the second array is valid.

Dennis' Testcase: Pastebin => 583159312 (mod 1000000007)

Scoring:

This is code-golf, so shortest answer wins.

In case of tie, ties will be broken by time of submission, favouring the earlier submission.

Take note:

The containers may be unsorted.

The integers in the containers may be zero or negative.

The program has to run fast enough (at most an hour) for modestly sized arrays (around 10000 in length).

Inspired by this question on Mathematics Stack Exchange.

Pyth, 29 28 bytes

M/*FPJm*F.!MhMrd8aFCB,SGSHeJ

Try it online in the Pyth Compiler.

Algorithm

The result does not depend on the order of A, so we can assume it to be sorted. This means that B must also be sorted to attain the maximal dot product.

Now, if r1, … rn are the length of the runs of the sorted A, there are ∏rk! different rearrangements of the elements of A that still result in ascending order.

Likewise, if s1, … sn are the length of the runs of the sorted B, there are ∏sk! different rearrangements of the elements of B that still result in ascending order.

However, this counts all pairings multiple times. If we take the pairs of of the corresponding elements of sorted A and sorted B and define t1, … tn as the length of the runs of the resulting array, ∏tk! is the aforementioned multiplier.

Thus, the desired result is (∏rk!) × (∏sk!) ÷ (∏tk!).

Code

M/*FPJm*F.!MhMrd8aFCB,SGSHeJ

M                             Define g(G,H):
                      SGSH      Sort G and H.
                     ,          For the pair of the results.
                   CB           Bifurcated zip (C).
                                This returns [[SG, SH], zip([SG, SH])].
                 aF             Reduce by appending.
                                This returns [SG, SH, zip([SG, SH])].
      m                         Map; for each d in the resulting array:
              rd8                 Perform run-length encoding on d.
            hM                    Mapped "head". This returns the lengths.
         .!M                      Mapped factorial.
       *F                         Reduce by multiplication.
     J                          Save the result in J.
    P                           Discard the last element.
  *F                            Reduce by multiplication.
 /
                          eJ    Divide the product by the last element of J.
                                Return the result of the division.

Verification

I've pseudo-randomly generated 100 test cases of length 6, which I've solved with the above code and this brute-force approach:

Ml.Ms*VGZ.pH

M             Define g(G,H) (or n(G,H) on second use):
         .pH    Compute all permutations of H.
  .M            Filter .pH on the maximal value of the following;
                 for each Z in .pH:
     *VGZ         Compute the vectorized product of G and Z.
    s             Add the products.
                  This computes the dot product of G and Z.
 l              Return the length of the resulting array.

These were the results:

$ cat test.in
6,9,4,6,8,4,5,6,5,0,8,2
0,7,7,6,1,6,1,7,3,3,8,0
3,6,0,0,6,3,8,2,8,3,1,1
2,3,0,4,0,6,3,4,5,8,2,4
9,1,1,2,2,8,8,1,7,4,9,8
8,3,1,1,9,0,2,8,3,4,9,5
2,0,0,7,7,8,9,2,0,6,7,7
0,7,4,2,2,8,6,5,0,5,4,9
2,7,7,5,5,6,8,8,0,5,6,3
1,7,2,7,7,9,9,2,9,2,9,8
7,2,8,9,9,0,7,4,6,2,5,3
0,1,9,2,9,2,9,5,7,4,5,6
8,4,2,8,8,8,9,2,5,4,6,7
5,2,8,1,9,7,4,4,3,3,0,0
9,3,6,2,5,5,2,4,6,8,9,3
4,2,0,6,2,3,5,3,6,3,1,4
4,8,5,2,5,0,5,1,2,5,9,5
6,8,4,4,9,5,9,5,4,2,8,7
8,9,8,1,2,2,9,0,5,6,4,9
4,7,6,8,0,3,7,7,3,9,8,6
7,5,5,6,3,9,3,8,8,4,8,0
3,8,1,8,5,6,6,7,2,8,5,3
0,9,8,0,8,3,0,3,5,9,5,6
4,2,7,7,5,8,4,2,6,4,9,4
3,5,0,8,2,5,8,7,3,4,5,5
7,7,7,0,8,0,9,8,1,4,8,6
3,9,7,7,4,9,2,5,9,7,9,4
4,5,5,5,0,7,3,4,0,1,8,2
7,4,4,2,5,1,7,4,7,1,9,1
0,6,2,5,4,5,1,8,0,8,9,9
3,8,5,3,2,1,1,2,2,2,8,4
6,1,9,1,8,7,5,6,9,2,8,8
6,2,6,6,6,0,2,7,8,6,8,2
0,7,1,4,5,5,3,4,4,0,0,2
6,0,1,5,5,4,8,5,5,2,1,6
2,6,3,0,7,4,3,6,0,5,4,9
1,4,8,0,5,1,3,2,9,2,6,5
2,7,9,9,5,0,1,5,6,8,4,6
4,0,1,3,4,3,6,9,1,2,7,1
6,5,4,7,8,8,6,2,3,4,1,2
0,3,6,3,4,0,1,4,5,5,5,7
5,4,7,0,1,3,3,0,2,1,0,8
8,6,6,1,6,6,2,2,8,3,2,2
7,1,3,9,7,4,6,6,3,1,5,8
4,8,3,3,9,1,3,4,1,3,0,6
1,4,0,7,4,9,8,4,2,1,0,3
0,4,1,6,4,4,4,7,5,1,4,2
0,0,4,4,9,6,7,2,7,7,5,4
9,0,5,5,0,8,8,9,5,9,5,5
5,7,0,4,2,7,6,1,1,1,9,1
3,1,7,5,0,3,1,4,0,9,0,3
4,4,5,7,9,5,0,3,7,4,7,5
7,9,7,3,0,8,4,0,0,3,1,0
2,4,4,3,1,2,5,2,9,0,8,5
4,8,7,3,0,0,9,3,7,3,0,6
8,9,1,0,7,7,6,0,3,1,8,9
8,3,1,7,3,3,6,1,1,7,6,5
6,5,6,3,3,0,0,5,5,0,6,7
2,4,3,9,7,6,7,6,5,6,2,0
4,8,5,1,8,4,4,3,4,5,2,5
7,5,0,4,6,9,5,0,5,7,5,5
4,8,9,5,5,2,3,1,9,7,7,4
1,5,3,0,3,7,3,8,5,5,3,3
7,7,2,6,1,6,6,1,3,5,4,9
9,7,6,0,1,4,0,4,4,1,4,0
3,5,1,4,4,0,7,1,8,9,9,1
1,9,8,7,4,9,5,2,2,1,2,9
8,1,2,2,7,7,6,8,2,3,9,7
3,5,2,1,3,5,2,2,4,7,0,7
9,6,8,8,3,5,2,9,8,7,4,7
8,8,4,5,5,1,5,6,5,1,3,3
2,6,3,5,0,5,0,3,4,4,0,5
2,2,7,6,3,7,1,4,0,3,8,3
4,8,4,2,6,8,5,6,2,5,0,1
7,2,4,3,8,4,4,6,5,3,9,4
4,6,1,0,6,0,2,6,7,4,9,5
6,3,3,4,6,1,0,8,6,1,7,5
8,3,4,2,8,3,0,1,8,9,1,5
9,6,1,9,1,1,8,8,8,9,1,4
3,6,1,6,1,4,5,1,0,1,9,1
6,4,3,9,3,0,5,0,5,3,2,4
5,2,4,6,1,2,6,0,1,8,4,0
3,5,7,6,3,6,4,5,2,8,1,5
6,3,6,8,4,2,7,1,5,3,0,6
9,1,5,9,9,1,1,4,5,7,3,0
1,6,7,3,5,8,6,5,5,2,6,0
2,8,8,6,5,5,2,3,8,1,9,8
0,4,5,3,7,6,2,5,4,3,2,5
5,1,2,3,0,3,4,9,4,9,4,9
5,8,2,2,0,2,4,1,1,7,0,3
0,6,0,0,3,6,3,6,2,2,2,9
2,4,8,1,9,4,0,8,8,0,4,7
3,9,1,0,5,6,8,8,2,5,2,6
5,3,8,9,1,6,5,9,7,7,6,1
8,6,9,6,1,1,6,7,7,3,2,2
7,2,1,9,8,8,5,3,6,3,3,6
9,9,4,8,7,9,8,6,6,0,3,1
8,3,0,9,1,7,4,8,0,1,6,2
8,2,6,2,4,0,2,8,9,6,3,7
1,0,8,5,3,2,3,7,1,7,8,2
$ while read; do
> pyth -c 'M/*FPJm*F.!MhMrd8aFCB,SGSHeJMl.Ms*VGZ.pHAc2Q,gGHnGH' <<< "$REPLY"
> done < test.in
[4, 4]
[4, 4]
[8, 8]
[4, 4]
[8, 8]
[2, 2]
[4, 4]
[4, 4]
[4, 4]
[36, 36]
[2, 2]
[8, 8]
[24, 24]
[8, 8]
[2, 2]
[2, 2]
[6, 6]
[2, 2]
[8, 8]
[2, 2]
[12, 12]
[2, 2]
[8, 8]
[12, 12]
[4, 4]
[12, 12]
[4, 4]
[6, 6]
[8, 8]
[8, 8]
[6, 6]
[4, 4]
[48, 48]
[8, 8]
[4, 4]
[1, 1]
[4, 4]
[4, 4]
[8, 8]
[4, 4]
[12, 12]
[2, 2]
[96, 96]
[2, 2]
[4, 4]
[2, 2]
[6, 6]
[24, 24]
[24, 24]
[48, 48]
[4, 4]
[8, 8]
[12, 12]
[8, 8]
[4, 4]
[2, 2]
[24, 24]
[16, 16]
[2, 2]
[8, 8]
[24, 24]
[4, 4]
[24, 24]
[4, 4]
[12, 12]
[8, 8]
[12, 12]
[4, 4]
[8, 8]
[4, 4]
[16, 16]
[4, 4]
[8, 8]
[8, 8]
[4, 4]
[4, 4]
[4, 4]
[4, 4]
[72, 72]
[24, 24]
[4, 4]
[4, 4]
[4, 4]
[2, 2]
[12, 12]
[4, 4]
[8, 8]
[4, 4]
[36, 36]
[6, 6]
[12, 12]
[8, 8]
[4, 4]
[2, 2]
[8, 8]
[24, 24]
[6, 6]
[1, 1]
[2, 2]
[2, 2]

To verify my submission satisfies the speed requirement, I've ran it with this test case.

$ time pyth -c 'M/*FPJm*F.!MhMrd8aFCB,SGSHeJAc2QgGH' < test-large.in | md5sum
5801bbf8ed0f4e43284f7ec2206fd3ff  -

real    0m0.233s
user    0m0.215s
sys     0m0.019s


Move arrows along a contour Sandboxed

Given a set of closed non-overlapping 2d contours (separated by at least one space even on diagonals) with arrows oriented consistently in the same clockwise or counter-clockwise direction (each contour has its own direction) and a positive number n, move the arrows n steps along the contours in the respective direction.
The arrows are represented by > v < ^ respectively for right, down, left and up directions. There the other characters are - (horizontal), | (vertical) and + (corner).
When an arrow is on a corner, it keeps its current direction and changes it only after the turn is taken.

There will always be a straight segment (or a space) between any two corners (like +-+ for the horizontal and similar for the vertical) - in other words the sharp U turns are forbidden. The segments between the corners are either vertical or horizontal and the bend at a corner is always 90 degree.

Input:

a positive integer - n - number of steps
an ASCII representation of the contours - it can be a multiline string, a list of strings, a list of characters and so on.

Output:

The same contours with all arrows shifted n steps in each contour's overall direction.

Test cases:

1.

Input:

n = 1

 +----->->
 |       |
 |       v---+
 |           |
 +---<-------+

Output:

 +------>+
 |       v
 |       +>--+
 |           |
 +--<--------+

2.

Input:

n = 2

 +-----+ +---+
 |     | |   |
 +-->--+ |   v
         |   |
 +--->---+   |
 |           |
 +------<<---+

Output:

 +-----+ +---+
 |     | |   |
 +---->+ |   |
         |   |
 +----->-+   v
 |           |
 +----<<-----+

3.

Input:

n = 3

 +---+   +---+   +-------+
 |   |   |   v   |       |
 ^   |   |   |   +-<-+   |
 |   |   ^   |       |   v
 |   +---+   +-->----+   |
 |                       |
 |   +-------+   +---+   |
 |   |       |   v   |   |
 +---+       +---+   +---+

Output:

 +>--+   ^---+   +-------+
 |   |   |   |   ^       |
 |   |   |   |   +---+   |
 |   |   |   |       |   |
 |   +---+   v----->-+   |
 |                       |
 |   +-------+   +---+   v
 |   |       |   |   |   |
 +---+       +-<-+   +---+

4.

Input:

n = 1

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

Output:

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

5.

Input

n = 4

^>>>>
^   v
^   v>>>>
^       v
<<<<<<<<v

Output:

^>>>>
^   v
^   v>>>>
^       v
<<<<<<<<v

6.

Input:

n = 1

^->
^ v
<<v

Output:

^>+
^ v
<<v

Write a function or a program solving the above task. The shortest code in bytes in every language wins. Don't be discouraged by the golfing languages. Explanation of the algorithm and the code is highly appreciated.

JavaScript (ES6),  210 ... 182  180 bytes

Takes input as (m)(n), where \$m\$ is a list of lists of characters. Returns the result in the same format.

m=>g=n=>n?g(n-1,m=m.map((r,y)=>r.map((c,x)=>(i=0,h=$=>~$?(m[Y=y+($-2)%2]||0)[X=x+~-$%2]>h?"-|+"[n+=`;m[${Y}][${X}]=S[${$}]`,i?2:$&1]:h($^++i):c)((S="<^>v").indexOf(c)))),eval(n)):m

Try it online!

How?

You can follow this link to see a formatted version of the source.

Wrapper

The recursive function \$g\$ is just used as a wrapper that invokes the main code to move all arrows by 1 step and keeps calling itself with \$n-1\$ until \$n=0\$.

Update method

We can't safely move each arrow one at a time because we would run the risk of overwriting non-updated arrows with updated ones. Instead, we first remove all arrows and compute their new positions. We apply the new positions in a second time.

This is done by re-using \$n\$ as a string to store the position updates as JS code.

For instance, in the first test case, \$n\$ is set to:

"1;m[0][7]=S[2];m[1][8]=S[3];m[2][9]=S[2];m[4][3]=S[0]"

(Note that the leading number -- which is the original value of \$n\$ -- is harmless.)

The new positions are applied by just doing eval(n).

Directions

Each arrow is converted into a direction \$d\$ (named $ in the code), using the following compass:

$$\begin{matrix}
&1\\
0&+&2\\
&3
\end{matrix}$$

The corresponding values of \$dx\$ and \$dy\$ are computed this way:

 d | dx = (d - 1) % 2 | dy = (d - 2) % 2
---+------------------+------------------
 0 |        -1        |         0
 1 |         0        |        -1
 2 |        +1        |         0
 3 |         0        |        +1

Corners

If the next character in the identified direction is a space or is out of bounds, it means that we're located on a corner and we need to take a 90° or 270° turn. This is why the helper function \$h\$ is testing up to 3 distinct directions: \$d\$, \$d\operatorname{xor}1\$ and \$d\operatorname{xor}3\$.

If we're located on a corner, we overwrite the cell with +. Otherwise, we overwrite it with either - or |, depending on the parity of \$d\$.

Note: The parameter of \$h\$ is not named $ just because it looks uber l33t but also because it allows us to compare a given character with \$h\$ (implicitly coerced to a string) to know if it's a space (below "$"), a contour character (above "$") or another arrow (also above "$").

Animated version

f=
m=>g=n=>n?g(n-1,m=m.map((r,y)=>r.map((c,x)=>(i=0,h=$=>~$?(m[Y=y+($-2)%2]||0)[X=x+~-$%2]>h?"-|+"[n+=`;m[${Y}][${X}]=S[${$}]`,i?2:$&1]:h($^++i):c)((S="<^>v").indexOf(c)))),eval(n)):m

m = [
  [..."+---+   +---+   +-------+"],
  [..."|   |   |   v   |       |"],
  [..."^   |   |   |   +-<-+   |"],
  [..."|   |   ^   |       |   v"],
  [..."|   +---+   +-->----+   |"],
  [..."|                       |"],
  [..."|   +-------+   +---+   |"],
  [..."|   |       |   v   |   |"],
  [..."+---+       +---+   +---+"]
];

(F = _ => (o.innerHTML = m.map(r => r.join('')).join('\n'), m = f(m)(1), window.setTimeout(F, 100)))()


Computationally Calculate Core Count Almost all operating systems allow you to run multiple programs at the same time. If your system does not have enough processors to run all the programs you want to run, it starts to give each program just a tiny slice of time on the processor it runs on. This is normally not noticeable but can lead to strange artefacts that you might not expect.

Your task is to write a program that tries to find out how many cores your computer has without asking the operating system. This is a popularity contest, the most upvoted solution wins. Here are the constraints:

While you cannot expect that your submission is the only thing that runs, you may expect that all other programs on the system are idling and wake up only sporadically.
You may not ask the operating system how many cores your computer has. Neither may you look up this number from any configuration file or similar. You may also not invoke a utility that provides you with that information.
For the sake of this challenge, the number of cores your computer has is the number of processes your computer can run at the same time. For instance, if you have an Intel processor with 2 cores and hyper threading, that would count as 4 cores.
Your solution needs not to be precise. It should not be terribly wrong all the time though.

C++11
Simply compares single core performance with threaded performance until there is not a linear speedup anymore. It's important that you do not have any other CPU intensive process running at the same time.
Compile with -O2 -m64 -march=native -std=c++11. You might have to pass -lpthread.
#include <chrono>
#include <cstdint>
#include <future>
#include <iostream>
#include <vector>

double f() {
    double cnt = 0;
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::system_clock::now();

    while (true) {
        end = std::chrono::system_clock::now();
        std::chrono::duration<double> elapsed = end - start;
        if (elapsed.count() > 1.) break;
        cnt++;
    }

    return cnt;
}

int main(int argc, char** argv) {
    double one_core = f();

    int n = 1;
    while (true) {
        std::vector<std::future<double>> futures;
        for (int i = 0; i < n; ++i) {
            futures.push_back(std::async(std::launch::async, f));
        }

        double tot = 0;
        for (int i = 0; i < n; ++i) tot += futures[i].get();
        if (int(tot / one_core + 0.5) != n) {
            std::cout << n - 1 << " core(s)\n";
            return 0;
        }

        ++n;
    }
}


First-n Fibonacci sequence elements There is a well known question here that asks for a short (least characters) fibonacci sequence generator.

I would like to know if someone can generate the first N elements only, of the fibonacci sequence, in very short space.   I am trying to do it in python, but I'm interested in any short answer, in any language.  Function F(N) generates the first N elements of the sequence, either returns them as the return of the function or prints them.

Interestingly it seems that the code-golf answers start with 1 1 2, instead of 0 1 1 2. Is that a convention in code-golf or programming-in-general?  (Wikipedia says the fibonacci sequence starts with zero.).

Python Sample (First 5 Elements):

def f(i,j,n):
    if n>0:
        print i;
        f(j,i+j,n-1)
f(1,1,5)

C

Didn't bother counting, but here's a fun example:

f(n){return n<4?1:f(--n)+f(--n);}
main(a,b){for(scanf("%d",&b);a++<=b;printf("%d ",f(a)));}

Proof it works.

I'm quite proud of this: I got bored, so I rearranged my code (with a few small additions) to make it where each line represents a value in the Fibonacci sequence.

                         #                                // 1
                         f                                // 1
                         //                               // 2
                        (n)                               // 3
                       {/**/                              // 5
                      return n                            // 8
                    <2 ? 1:f(--n)                         // 13
                +f(--n); } main(a, b)                     // 21
          {a = 0, b = 0;scanf("%d",&b); for(              // 34
;a < b; a+=1) { int res = f(a); printf("%d ", res); } }   // 55

Proof it works.


Find the numbers coprime to their decimal digits Two numbers are coprime if their greatest common divisor is 1.
Given a positive integer N, your task is to compute the first N terms of OEIS A061116, which is the sequence of positive integers higher than 1 that are coprime to all their decimal digits.
Here are the first few terms of the sequence:
11, 13, 17, 19, 21, 23, 27, 29, 31, 37, 41, 43, 47, 49, 51, 53, 57, 59, 61, 67, 71

You can assume that N < 200.

Test Cases

Input -> Output

1 -> 11
3 -> 11, 13, 17
6 -> 11, 13, 17, 19, 21, 23
25 -> 11, 13, 17, 19, 21, 23, 27, 29, 31, 37, 41, 43, 47, 49, 51, 53, 57, 59, 61, 67, 71, 73, 79, 81, 83

You may output in any decent form (as a list, with a separator or whatever else). You can take input as the String representation of N or as an integer. Standard I/O rules apply.

Default Loopholes apply. This is code-golf, so the shortest code in bytes wins!

Plain English 853 787 738 594 550 538 532 bytes

Removed 66 bytes of white space.  Removed 49 bytes by using a more generic output type.  Removed 144 bytes by abbreviating variable names, and reusing the quotient and the remainder.  Removed 44 bytes by abbreviating an interface.  Shortened Destroy the number things. to Destroy the L.  Removed 6 bytes by changing "some" to "a", and "number" to "count".

Golfed code:

To create a L number things given a c count:
Put 0 in a i count.
Loop.
Add 1 to a n count.
If the i is at least the c, exit.
If the n is g,
append the n to the L;
add 1 to the i.
Repeat.
To decide if a n count is g:
If the n is at most 10, say no.
Put 1 in a m count.
Loop.
If the m is greater than the n, say yes.
Divide the n by the m giving a q quotient and a r remainder.
Divide the q by 10 giving the q and the r.
Get a gcd given the n and the r.
If the gcd is at least 2, say no.
Multiply the m by 10.
Repeat.

Ungolfed code:

Some special numbers are some number things.

To create some special numbers given a count:
  Put 0 in another count.
  Loop.
    Add 1 to a number.
    If the other count is at least the count, exit.
    If the number is coprime with its digits,
      Append the number to the special numbers;
      Add 1 to the other count.
  Repeat.

To decide if a number is coprime with its digits:
  If the number is at most 10, say no.
  Put 1 in another number.
  Loop.
    If the other number is greater than the number, say yes.
    Divide the number by the other number giving a quotient and a remainder.
    Divide the quotient by 10 giving another quotient and another remainder.
    Get a gcd given the number and the other remainder.
    If the gcd is greater than 1, say no.
    Multiply the other number by 10.
  Repeat.

"Some number things" are a doubly-linked list of numbers.
The calling code has the responsibility to Destroy the special numbers., so I have added the corresponding bytes.

The Plain English IDE is available at github.com/Folds/english.  The IDE runs on Windows.  It compiles to 32-bit x86 code.


Create an ASCII-to-hex table for Mark Watney Inspired by this SciFi.SE question.

Background (with minor spoiler):

 In the movie The Martian, protagonist Mark Watney uses an ASCII table to look up hexadecimal values of ASCII characters so he can attempt to communicate back to Earth.*

Challenge
With no input, output the following ASCII table exactly like this:
Dec Hex    Dec Hex    Dec Hex  Dec Hex  Dec Hex  Dec Hex   Dec Hex   Dec Hex
  0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60 `  112 70 p
  1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q
  2 02 STX  18 12 DC2  34 22 "  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r
  3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s
  4 04 EOT  20 14 DC4  36 24 $  52 34 4  68 44 D  84 54 T  100 64 d  116 74 t
  5 05 ENQ  21 15 NAK  37 25 %  53 35 5  69 45 E  85 55 U  101 65 e  117 75 u
  6 06 ACK  22 16 SYN  38 26 &  54 36 6  70 46 F  86 56 V  102 66 f  118 76 v
  7 07 BEL  23 17 ETB  39 27 '  55 37 7  71 47 G  87 57 W  103 67 g  119 77 w
  8 08 BS   24 18 CAN  40 28 (  56 38 8  72 48 H  88 58 X  104 68 h  120 78 x
  9 09 HT   25 19 EM   41 29 )  57 39 9  73 49 I  89 59 Y  105 69 i  121 79 y
 10 0A LF   26 1A SUB  42 2A *  58 3A :  74 4A J  90 5A Z  106 6A j  122 7A z
 11 0B VT   27 1B ESC  43 2B +  59 3B ;  75 4B K  91 5B [  107 6B k  123 7B {
 12 0C FF   28 1C FS   44 2C ,  60 3C <  76 4C L  92 5C \  108 6C l  124 7C |
 13 0D CR   29 1D GS   45 2D -  61 3D =  77 4D M  93 5D ]  109 6D m  125 7D }
 14 0E SO   30 1E RS   46 2E .  62 3E >  78 4E N  94 5E ^  110 6E n  126 7E ~
 15 0F SI   31 1F US   47 2F /  63 3F ?  79 4F O  95 5F _  111 6F o  127 7F DEL

The final newline is optional.  With the newline, the md5 of the output is 58824a1dd7264c0410eb4d727aec54e1.  Without, it is 41b6ecde6a3a1324be4836871d8354fe.
In case it helps, this is the output from the ascii Linux command with the usage info at the top chopped off.  You can recreate this on Ubuntu as follows:
sudo apt-get install ascii
ascii | tail -n+7

You may not use the ascii utility (or similar) in your answers.
Because ASCII characters are small Enough with this silly meme already!

I am aware this is similar to Print the ASCII table, but I believe the formatting of the output in this question is significantly more complex and warrants a different question.

*Note, I have not yet seen this movie.

JavaScript (ES6), 323 332 353

Edit I managed to shorten this a bit
Step 1, believe it or not, using an array of 16 chars is shorter than toString + toUpperCase
Step 2, fiddling around to use .map instead of for, so that I can transform it all to a single expression function, avoding console.log and/or return.

Edit 2 Moved DEL at place 0, idea borrowed from Cole Cameron

H=x=>(x=[...'0123456789ABCDEF']).map((d,r)=>x[S='slice'](0,8).map(c=>(o+=`   ${w=c*16+r} ${c+d} `[S](-z)+("DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".substr((w+1&127)*3,3)||String.fromCharCode(w)),z=c<5?8:9,'Dec Hex   '[S](0,c<2?z+2:z)),o+=`
`,z=7).join` `,o='')[0]+o

MD5: 41B6ECDE6A3A1324BE4836871D8354FE

Pixel perfect, I'd say

LESS GOLFED

H=x=>(
  x=[...'0123456789ABCDEF'],
  a="DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ",
  o='', // the string o will contain the body (16 rows)
  x.map((d,r)=> ( // main loop, r is thr row number, d is the second hex digit to print
    o+=`\n`, z=7,
    x.slice(0,8).map(c=> // loop on 8 columns, c is both column number and digit to print
      (
        // append the column to o
        o += `   ${w=c*16+r} ${c+d} `.slice(-z) + (a.substr((w+1&127)*3,3)||String.fromCharCode(w)),
        z=c<5?8:9, // adjust the column size
        'Dec Hex   '.slice(0,c<2?z+2:z) // column head, right size
      ) // the .map result is the 8 columns heading
    ).join` ` // join the heading in a single string
  ))[0] // any element of the result map is the heading
  + o // concatenate the body
)

Test

H=x=>(x=[...'0123456789ABCDEF']).map((d,r)=>x[S='slice'](0,8).map(c=>(o+=`   ${w=c*16+r} ${c+d} `[S](-z)+("DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".substr((w+1&127)*3,3)||String.fromCharCode(w)),z=c<5?8:9,'Dec Hex   '[S](0,c<2?z+2:z)),o+=`
`,z=7).join` `,o='')[0]+o

/* TEST */
console.log=x=>O.textContent=x

console.log(H())


Generate random LTL Formulae An LTL Formula l is defined by the following grammar (where <x> describes the non-terminal symbol x):

<l> ::= <b> | F <l> | G <l> | X <l> | (<l> U <l>) | (<l> W <l>) | (<l> R <l>)
            | (<l> & <l>) | (<l> \| <l>) | !<l>
<b> ::= BVar | True | False | (<i> < <i>) | (<i> <= <i>) | (<i> > <i>) | (<i> >= <i>)
             | (<i> = <i>) | (<i> != <i>)
<i> ::= IVar | -128 | -127 | ... | 127 | (<i> + <i>) | (<i> - <i>)
             | (<i> * <i>) | (<i> / <i>)

(I escaped a pipe to denote boolean or. You should not print that backslash in your output)

BVar and IVar represent variables of boolean and integral types respectively. Each must be one of four possible single character variable names, and there may by no overlap between BVar and IVar. For instance, you may choose a,b,c,d for BVar and w,x,y,z for IVar

Note that all binary operators must have parentheses around them and that no other parentheses are allowed.

Your task is to write a function that takes one input encoding the maximal nesting depth of an LTL formula and prints a random formula limited by that depth (but not necessarily exactly that depth). The distribution does not have to be uniformly random, but each possible formula has to have a non-zero chance of being generated.

You may use ≤, ≥, and ≠ instead of <=, >=, and !=.

You may add or remove whitespace as you see fit. Even no whitespace at all is allowed.

Examples:

f(0) -> True
f(0) -> d
f(1) -> (a&b)
f(1) -> Fd
f(1) -> (x<y)
f(3) -> (G(x!=y)|Fb)
f(3) -> (x<(w+(y+z)))

Standard loopholes are forbidden.

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


Convert Numbers to Letters, and vice-versa in a string Based on a list of numbers and their equivalent letters, take a string input, replace the characters of that string with the equivalent number/letter and output the result.
List

1 = a
2 = b
3 = c
4 = d
5 = e
6 = f
7 = g
8 = h
9 = i
0 = j

Input

thisisastring1124

Output

t89s9s1str9n7aabd

Rules

Numbers are equivalent to lowercase letters only.
Any character outside the list will be left as is.
Input string must not contain spaces.
Either full program or function is permitted.
Since it's code-golf, fewest bytes wins.

bash, 18 bytes

tr 1-90a-j a-j1-90

Try it online!


Hard code golf: Regex for divisibility by 7 Matthias Goergens has a 25,604-character (down from the original 63,993-character) regex to match numbers divisible by 7, but that includes a lot of fluff: redundant parentheses, distribution (xx|xy|yx|yy rather than [xy]{2}) and other issues, though I'm sure a fresh start would be helpful in saving space.  How small can this be made?

Any reasonable variety of regular expressions are allowed, but no executable code in the regex.

The regular expression should match all strings containing the decimal representation of a number divisible by 7 and no others.  Extra credit for a regex that does not allow initial 0s.


Make true and false global! We all know true and false, but what do speakers around the globe say?

+----------------------+------------+------------+
| Language             | True       | False      |
+----------------------+------------+------------+
| Arabic               | sahih      | zaif       |
| Armenian             | irakan     | kelc       |
| Assamese             | asol       | misa       |
| Breton               | gwir       | gaou       |
| Bulgarian            | veren      | neveren    |
| Catalan              | veritable  | fals       |
| Cornish              | gwir       | gaw        |
| Czech                | pravdivy   | nepravdivy |
| Danish               | sand       | falsk      |
| Dutch                | waar       | onwaar     |
| English              | true       | false      |
| Esperanto            | vera       | malvera    |
| Finnish              | tosi       | epatosi    |
| French               | vrai       | faux       |
| Galician, Portuguese | verdadeiro | falso      |
| Georgian             | namdvili   | cru        |
| German               | wahr       | falsch     |
| Greek                | alithis    | psevdis    |
| Hebrew               | hiyuvi     | shikri     |
| Hindi, Urdu          | thik       | jhutha     |
| Hungarian            | igaz       | hamis      |
| Icelandic            | sannur     | rangur     |
| Indonesian, Malay    | benar      | salah      |
| Irish                | fior       | breagach   |
| Italian              | vero       | falso      |
| Japanese             | shin       | nise       |
| Korean               | cham       | geojit     |
| Latin                | verus      | falsus     |
| Latvian              | patiess    | nepareizs  |
| Mandarin Chinese     | zhen       | jia        |
| Maori                | pono       | pate       |
| Persian              | dorost     | galat      |
| Polish               | prawdziwy  | falszywy   |
| Romanian             | adevarat   | fals       |
| Russian              | vernyj     | falsivyj   |
| Sardinian            | beru       | falsu      |
| Scottish Gaelic      | fior       | breugach   |
| Spanish              | verdadero  | falso      |
| Swedish              | sann       | falskt     |
| Sylheti              | hasa       | misa       |
| Turkish              | dogru      | yanlis     |
| Volapuk              | veratik    | dobik      |
| Welsh                | gwir       | anwir      |
+----------------------+------------+------------+

All words ASCIIfied from Wiktionary: true, false. Preference given to first entry under 'A state in Boolean logic that indicates an affirmative or positive result'/'state in Boolean logic that indicates a negative result', then first entry under 'concurring with a given set of facts'/'untrue, not factual, wrong'. I apologise if your favourite language is not included or the word choice for your language is not optimal - go edit Wiktionary!

Write a program or function that takes one word from the table above as input and outputs a consistent truthy value if the word means 'true' and a consistent falsy value otherwise. Your code must produce the correct output for all 79 possible inputs. Shortest code (in bytes) in each language wins.

Sorted list of unique words meaning 'true':

adevarat,alithis,asol,benar,beru,cham,dogru,dorost,fior,gwir,hasa,hiyuvi,igaz,irakan,namdvili,patiess,pono,pravdivy,prawdziwy,sahih,sand,sann,sannur,shin,thik,tosi,true,vera,veratik,verdadeiro,verdadero,veren,veritable,vernyj,vero,verus,vrai,waar,wahr,zhen

Sorted list of unique words meaning 'false':

anwir,breagach,breugach,cru,dobik,epatosi,fals,falsch,false,falsivyj,falsk,falskt,falso,falsu,falsus,falszywy,faux,galat,gaou,gaw,geojit,hamis,jhutha,jia,kelc,malvera,misa,nepareizs,nepravdivy,neveren,nise,onwaar,pate,psevdis,rangur,salah,shikri,yanlis,zaif

Python 2, 56 48 bytes

thanks to dingledooper for -8 bytes!

lambda s:0x420AF14A5F8266>>hash(s)%3317%890%57&1

Try it online!

All these answers do the same thing:

Convert the string into an unique integer.
Makes these integers smaller by repeated modulo operations.
These operations are bruteforced to make the numbers as small as possible while not mixing up the two classes.
Index into a binary lookup table.

Python 3, 59 58 bytes

lambda s:0x48A2D06199310566F06>>int(s[:4],36)%542%400%78&1

Try it online!

lambda s:0x453CCA1066840810431C1>>int(s,36)%2387%1770%86&1

Try it online!

lambda s:0x42744262AEA01A914800A12C>>int(s,36)%155687%95&1

Try it online!

05AB1E, 30 29 28 bytes

4öŽ3¹%Ƶ™%84%o•1±87÷Ðˆù³Í:•&Ā

Try it online!

6öŽ9{%521%76%o•B&¦¿³ʒв F6•&Ā

Try it online!


Evaluate Conway chained arrow notation Background

Conway chained arrow notation is a notation to express very large numbers. It consists of zero or more positive integers separated by right arrows, e.g. \$2 \to 3 \to 4 \to 5 \to 6 \$.

Assuming \$p, q, a_1, \dots, a_n\$ are positive integers and \$X\$ is an abbreviation for a nonempty chain \$a_1 \to a_2 \to \dots \to a_n\$, the rules for evaluating such a notation are as follows:

$$
\begin{align}
(\text{empty chain}) &= 1 \\
(p) &= p \\
p \to q &= p^q \\
X \to 1 &= X \\
X \to 1 \to p &= X \\
X \to (p+1)\to (q+1) &= X \to (X \to p\to (q+1))\to q
\end{align}
$$

A length-3 chain has an equivalent up-arrow notation: \$ p \to q \to r = p \uparrow^r q\$.

Note that the arrow notation cannot be treated as some kind of binary operator:

$$
\begin{align}
2 \to 3 \to 2 &= 16 \\
2 \to (3 \to 2) &= 512 \\
(2 \to 3) \to 2 &= 64
\end{align}
$$

More examples can be found on the Wikipedia page linked above.

Task

Given a (possibly empty) list of positive integers, interpret it as Conway chained arrow notation and evaluate it into a single number.

It is OK if your program gives wrong answers for large values due to the limits (bounds and/or precision) of your language's number type, as long as the underlying algorithm is correct.

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

Test cases

Input => Output
[] => 1
[1] => 1
[99999999] => 99999999
[5, 5] => 3125
[4, 8] => 65536
[1, 2, 4] => 1
[2, 2, 4] => 4
[2, 3, 2] => 16
[2, 4, 2] => 65536
[4, 3, 2] => 4^256 = 1.34e154
[2, 2, 3, 2] => 4

Haskell, 75 68 63 bytes

f(q:p:x)|p^q>p,x>[]=f$q-1:f(q:p-1:x):x|1<2=f$p^q:x
f[x]=x
f _=1

Try it online!

Takes input as a list in reversed order, since in Haskell it's easier to deal with the beginning of a list than with the end of it.

Now shorter and uglier!

Rules 3,4,5,6 are combined in the first line. The most important trick is realizing that p^q==p iff p==1||q==1 (where ^ is exponentiation and we're dealing with strictly positive numbers). We check the conditions to apply rule 6 (p and q greater than 1, at least three elements in the input) and if they are valid we do so recursively. If these conditions fail we know that either there is a 1 in the first two elements or there are just two elements in total: for both of this cases f(p^q:x) can solve the task.

The last two lines deal with inputs with less than two elements. They could be rewritten as a single line f x=last$1:x but the score would not change.

Below the original solution, no golfing tricks, just beautiful Haskell code:

f[]=1
f[p]=p
f[q,p]=p^q
f(1:x)=f x
f(_:1:x)=f x
f(q:p:x)=f$q-1:f(q:p-1:x):x

Try it online!


Fill up to duplicate ranges Let \$L\$ be a list of positive integers with no particular ordering, and which can contain duplicates. Write a program or function which outputs a list of positive integers \$M\$ (whose ordering is unimportant) such that merging \$L\$ and \$M\$ results into the smallest list which can entirely split into identical ranges of integers \$[1..i]\$, where \$i\$ is the biggest element in \$L\$

Example

Let L = [5,3,3,2,7]. The maximum element of L is 7. The most times a specific integer occurs is 2 (3 appears 2 times). Therefore, we need to output the list M that will allow to complete L so that we can construct 2 ranges of integers from 1 to 7.

Therefore, we need to output M = [1,1,2,4,4,5,6,6,7], so that each integer from 1 to 7 appears 2 times.

Inputs and outputs

Use anything in your language that is similar to lists. The data structure used for the input and the output must be the same.
The input list will contain only positive integers.
The input list will not be empty.
You cannot assume the input list is sorted.
The ordering in the output list is unimportant.

Test cases

Input                  Output
[1]                    []
[7]                    [1, 2, 3, 4, 5, 6]
[1, 1, 1]              []
[1, 8]                 [2, 3, 4, 5, 6, 7]
[3, 3, 3, 3]           [1, 1, 1, 1, 2, 2, 2, 2]
[5, 2, 4, 5, 2]        [1, 1, 3, 3, 4]
[5, 2, 4, 5, 5]        [1, 1, 1, 2, 2, 3, 3, 3, 4, 4]
[5, 3, 3, 2, 7]        [1, 1, 2, 4, 4, 5, 6, 6, 7]

Scoring

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

Perl 6, 37 33 bytes

-4 bytes thanks to nwellnhof!

{^.keys.max+1 xx.values.max∖$_}

Try it online!

Anonymous code block that takes a Bag and returns a Bag of values.

Explanation:

{                             } # Anonymous code block
 ^.keys.max+1  # Create a range from 1 to the maximum value of the list
              xx  # Multiply the list by:
                .values.max      # The amount of the most common element
                           ∖$_   # Subtract the original Bag


Unique magic triplets Description

Your input is a list of integers \$[a_1, \dots, a_n]\$.

A magic triplet is a triplet \$(a_i, a_j, a_k)\$ of values from this list, such that

the indices \$\{i, j, k\}\$ are all distinct,
the values are in ascending order (\$a_i \leq a_j \leq a_k\$), and
the sum of two of the values equals the third.

Your task is to output all unique magic triplets, in any order.

Rules

Each number in the input list is guaranteed to be in the range \$-2^{32} \leq a < 2^{32}\$.
The input list's length is guaranteed to be at most 1000.
The input list's length may be less than 3 (even 0). In this case, there are no magic triplets, and your program should produce an empty result.
The shortest answer in bytes wins.

Test cases

[1,2,3,2,4] -> [[1,2,3], [1,3,4], [2,2,4]]
[0,0,0,0] -> [[0,0,0]]
[1,0,-1] -> [[-1,0,1]]
[1,2] -> []
[1,2,4,8,99] -> []
[33,90,7,24,60,32,80,43,15,40,36,90,65,12,91,33,88,1,96,33,40] -> [[7,33,40], [32,33,65], [1,32,33], [1,90,91], [7,36,43], [24,36,60], [12,24,36], [36,60,96], [15,65,80], [40,40,80]]

Notes

In the second test case, [[0,0,0], [0,0,0]] is not a valid answer. No triplet may be listed twice in the output.
Remember that your program may order the triplets differently. For example, [[2,2,4], [1,2,3], [1,3,4]] is also a valid output for the first test case.
Nonetheless, [[4,2,2], …] is invalid: each triplet itself must be in ascending order.

Ruby, 46 51 58 bytes

->l{l.permutation(3).select{|a,b,c|a+b==c}.map(&:sort)|[]}

Try it online!

Ok, not so straightforward, but now seems to work.


Program a 2048 AI using an existing Framework EDIT : Recently, my question has been proposed as a duplicate of 2048 Bot Challenge. I would like to stress that this question is different from that question, and will require answers to be thought of differently than that question. 2048 Bot Challenge asked the user to create a bot, and it would be run for an hour, with the highest score being the user's score. Additionally, it had a limit of 555 bytes. My challenge runs the code much less frequently, only 3 times. Your score is calculated by using the average score of those three times and dividing by the character length of your golfed code. My question encourages entries to be "smarter," and not try and get the highest score by brute force.

-

  EDIT: The get method was changed to getTile, to avoid confliction with the JS keyword get. Additionally, a high score section was added.

Recently, I created a site that allows the popular game 2048 to be controlled using JavaScript. My site is linked here:

http://thatcoolidea.com/2048

How:

An Ace Editor is located above the board. You place code in it, which is run once every 250 ms, or 4 times per second. This is called a cycle.

Use the following methods to control the board. You can't use the arrow keys.

up();            //move up
down();          //move down
left();          //move left
right();         //move right

move(integer);   //integer is a direction. 0:up,1:right,2:down,3:left

getTile(y,x);        //gets the value of the tile in position y,x on the board. See diagram

The following variables are defined for your convenience:

eother        //boolean, alternates every cycle
frozen        //integer, counts how many cycles the board has remained stationary
lastDir       //integer, indicates the last direction that was tried to move in
              //uses same format as the move method above.
startup       //boolean, will always be true when the game first starts
              //you can change it as you wish
a
b             //a b and c are all persistant variables, they do not change each cycle
c             //any other variables defined in the cycle will be reset every time

Rules:

No Randomness, you must use logic. (Yes, I know the example code uses random.)
No hooking into the game functions or cheating in other ways
Generally, try to only call one move method per cycle. It is OK if you use more, but it screws with the animation
The board must start in a random state, no modification of pre-game state
You must provide both the uncompressed and golfed version of the code in your post.
You must provide a link to the site that already loads the uncompressed version of your code, served via PasteBin (For example, ...thatcoolidea.com/2048?i=pH18GWtu loads the example code.)

Scoring:

Your code will be scored by me.
Part A of your score is an average of 3 runs of the code, rounded down.
Part B of your score is the character length of your golfed code.
Your final score is Part A divided by Part B

The winner will have their code immortalized as the example code on the site, if they choose, and acknowledged in a comment in the code.

Good luck! Hope you enjoy the challenge.

Current High Score
225.22 - Freezer - user3217109

Sinker/Shaker, 65 bytes

Here's mine. It's as blind and simple as they come.

if(startup){startup=false;a=0}b=(a++)%4;move(frozen>2?0:b==0?2:b)

Uncompressed(ish)...

if(startup){startup=false;a=0;}
b=(a++)%4;
move(frozen>2?0:b==0?2:b)

All it does is repeats down, right, down, left, etc. and hits up once if it gets stuck. It doesn't always do very well, but it'll occasionally get 512s. My high score during testing was 7520.


Write a program that is valid after circular character shift Potentially very difficult, but I've seen some amazing things come out of this site.

The goal is to write a program, in any language, that does whatever you want. The catch is that the program must be valid after any circular shift of the characters.

A circular character shift is very similar to a Circular Shift. Some examples my clear things up.

For the program int main() { return 0; }

shifting to the left by 6 characters yields: in() { return 0; }int ma

shifting to the left by 1 character yields: nt main() { return 0; }i

shifting to the right by 10 character yields: eturn 0; }int main() { r

However, this program obviously doesn't comply with the rules.

Rules

Any language
Winner is decided by up-vote count
Solutions which do the same thing, or completely different things for each rotation, will receive 100 virtual up-votes to their score.

UPDATE I think this has gone on long enough. The winner, with the most votes (virtual votes included) is Mark Byers. Well done!

Use the right language for the task. In this case, that's Befunge.

This language naturally allows rotations because:

All commands are a single character.
The control wraps around when it reaches the end of the program, starting again from the beginning.

This Befunge program prints the exact same output ("Hello") regardless of how many "circular character shifts" you use:

86*01p75*1-02p447**1-03p439**04p439**05p455**1+06p662**07p75*1-08p645**2-09p69*4+019+p57*029+p59*1-039+p555**1-049+p88*059+p86*01p75*1-02p447**1-03p439**04p439**05p455**1+06p662**07p75*1-08p645**2-09p69*4+019+p57*029+p59*1-039+p555**1-049+p88*059+p645**2-00p645**2-00p

It runs on Befungee. It requires that the board is increased (not the 80 character default). It can be run like this:

python befungee.py -w400 hello.bef

It works by first dynamically generating and storing a program that prints "Hello" and then overwriting the first byte to redirect the control into the newly written program. The program is written twice so that if a byte is not written correctly the first time, it will be corrected the second time.

The idea could be extended to produce any program of arbitrary complexity.


Sort these James Bond ratings Introduction
My grandpa is a fan of James Bond, but he is always unsure on how to rank his favourite actors. As such, he is always making lists, which is a lot of work. He asked me to produce a program that will make his life easier, but I do not have time for that, I have to work! So I will count on you guys.
Challenge
The challenge is simple. The input will consist of a list, in the following format:
<number> <space> <actor's name> <newline>
Your task is to sort them based on the number at the beginning of the line, starting from the last, and ending with the first. All numbers should be removed.
However, my grandpa sometimes makes mistakes. As such, you will need to validate the data. If one of the names on the list doesn't refer to one of the actors who played Bond, you need to discard it. In case of repetitions, repeats should be removed, and the name should maintain the lowest weight it was associated with (example #3).
There is no limit to how many lines there may be.
The output only needs to be a list of some sort, whether it is an array, a comma separated string, just values separated by spaces, or something else entirely, i.e.
Pierce Brosnan, Sean Connery, David Niven
A trailing newline or space is allowed.
Example Input and Output
Input:

1 Sean Connery
2 Emma Watson
5 Timothy Dalton
4 Roger Moore
3 Daniel Craig

Output:

Timothy Dalton, Roger Moore, Daniel Craig, Sean Connery

Input:

2 Timothy Dalton
4 George Lazenby
5 George Lazenby
3 Bob Simmons

Output:

George Lazenby, Bob Simmons, Timothy Dalton

Input:

3 Sean Connery
2 Pierce Brosnan
1 Sean Connery

Output:

Pierce Brosnan, Sean Connery

As this is a code golf, shortest code (in bytes) wins!
Appendix
List of actors who played the role of Bond:

Barry Nelson
Bob Simmons
Sean Connery
Roger Moore
David Niven
George Lazenby
Timothy Dalton
Pierce Brosnan
Daniel Craig

Retina, 201 197 191

\d+
$0$*1
G`^1+ (Barry Nelson|Bob Simmons|Sean Connery|Roger Moore|David Niven|George Lazenby|Timothy Dalton|Pierce Brosnan|Daniel Craig)$
+`\b((1+)\D*)¶(\2.+)
$3¶$1
+s`1+(\D+)¶(.*\1)
$2
1+

Try it online!

6 bytes saved thanks to Martin!

Whee, bubble sort with regex. Note that ten bytes are spent doing decimal to unary conversion at the beginning, if unary input is OK then that isn't needed. Also, if numbers can't be in people's names, then a couple more bytes can be saved by moving the line that removes non-Bond actors to the end and removing the 1+ (untested with \D version).

Explanation:

A Retina program is made up of several stages, so I will explain each stage separately.

Stage 1:

\d+
$0$*1

Replaces the numbers in the input with unary. This uses Retina's special replacement token: $* which repeats the character after a number of times equal to the preceding token's base 10 value.

Stage 2:

G`^1+ (Barry Nelson|Bob Simmons|Sean Connery|Roger Moore|David Niven|George Lazenby|Timothy Dalton|Pierce Brosnan|Daniel Craig)$

The stuff before a ` in a stage changes the mode being used. This turns on grep mode, which means that each line that doesn't match the regex is discarded. The anchors are necessary to prevent near matches from slipping by.

Stage 3:

+`\b((1+)\D*)¶(\2.+)
$3¶$1

This is the sorting stage. The + in the mode signifies that this stage should be repeated until the replacement makes no change when applied (i.e. we reach a fixed point). The regex finds a word boundry, followed by some number of 1s and then all the rest of the line up to the newline. Then, if the next line has more 1s than it, the regex will match and we swap the lines.

Stage 4:

+s`1+(\D+)¶(.*\1)
$2

This stage uses the + mode again, but also uses s to make the . meta-character also match newlines. This removes duplicate lines, by matching for exact duplicates after the 1s and capturing the stuff after the first duplicate to replace the whole match with it. This will work without needing to consider the order of tie breaking, because the names are already sorted appropriately, with the larger numbers above, therefore we will always keep the smaller values.

Stage 5:

1+

Really simple one here, everything is in order, except we have a bunch of 1s in front of our Bonds, so we replace them and the space after them with nothing.


Is a statement of propositional logic always true? The challenge is to golf a program that checks if a statement of propositional calculus/logic is a logical tautology (i.e. it is true for all possible values of the variables).
Input
Input formulas will use P, P', P'' ect. as variables. They can either be true or false.
(P and P') means both P and P' are true.
(P or P') means at least one of P and P' is true.
(P implies P') means that if P is true, than P' must be true.
(not P) means that P is false.
These forms can be nested.
Example input: (P implies ((P' or P'') and P'''))
Output
Output will be a truthy value if the input is a tautology, and a falsy value if it is not.
(i.e True/False 1/0)
Test Cases
P: False
(P implies P): True
((P implies P') implies ((P' implies P'') implies (P implies P''))): True
(P implies (P or P')): True
(P implies (P and P')): False
(P or (not P)): True
and, or, not, and implies are the ONLY operators.
This is code-golf. Shortest program in bytes wins.
Clarification
The type of logic used here is Classical logic.

Retina 0.8.2, 136 124 121 bytes
{T`()`<>
.*P.*
<$& ¶ $&>
(?=(P'*))(?=.*\1[^P']*(¶|$))\1
$.2
¶
a
<not 1>|<0 or 0>|<1 [ai]\w* 0>|<0 a\w* .>|(<[^P<>]*>)
$#1

Try it online! Link includes test cases. Explanation: Works by considering each variable in turn, replacing the string f(p) with the string <f(1) and f(0)> for each variable p. The resulting string is then evaluated according to Boolean arithmetic.
{`

Repeat the entire program until the buffer stops changing.
T`()`<>

Change the ()s to something that doesn't need to be quoted.
.*P.*
<$& ¶ $&>

If the line still contains a variable, then duplicate it, and wrap the whole buffer in <>, however the two copies are still separated by a newline for now.
(?=(P'*))(?=.*\1[^P']*(¶|$))\1
$.2

Replace all copies of the last variable in the line with 1 or 0 depending on whether this is the original or duplicate line.
¶
a

Replace the newline with an a so that the two lines are joined together by an < and > operation.
<not 1>|<0 or 0>|<1 [ai]\w* 0>|<0 a\w* .>|(<[^P<>]*>)
$#1

Simplify any expressions that only contain constants. The expressions <not 1>, <0 or 0>, <1 implies 0>, <1 and 0>, <0 and 0>, <0 and 1> and <0 and P> (edge case) all evaluate to 0, while any other expression that contains no sub-expressions or variables evaluates to 1. (The original version of the code was buggy in this respect and needed a byte to fix it which I have included in the revised byte count in the header.)


Code Golf: 6174 - Kaprekar's mythical constant Why is the number 6174 so interesting? As defined by Wikipedia

  Take any four-digit number, using at
  least two different digits. (Leading
  zeros are allowed.)
  Arrange the digits in ascending and
  then in descending order to get two
  four-digit numbers, adding leading
  zeros if necessary.
  Subtract the smaller number from the
  bigger number.
  Go back to step 2.

  The above process, known as Kaprekar's
  routine, will always reach 6174 in at
  most 7 iterations. Once 6174 is
  reached, the process will continue
  yielding it.

Write a program which runs the Kaprekar's routine against a given four-digit number (see definition above) printing out each step of the routine.

Rules:

Submissions must be complete
programs.
Input must be read from standard
input. Piping from echo is OK.
Input should be in numeric form.
Printing out leading zeros is
required. (See examples below.)
Last line should say how many
iterations were needed. Punctuation is required.

Examples:

> 2607
7620 - 0267 = 7353
7533 - 3357 = 4176
7641 - 1467 = 6174
Iterations: 3.

> 1211
2111 - 1112 = 0999
9990 - 0999 = 8991
9981 - 1899 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
Iterations: 5.

> 6174
7641 - 1467 = 6174
Iterations: 1.

Any programming language is welcome. Extra points for esoteric ones + a small bounty.

Update 1: There is already a similar question.

Update 2: Added example for 6174 as input. Thanks to Peter Taylor for the notice.

Ruby 1.9, 122 characters
puts"Iterations: #{(1..7).find{s=$_.chars.sort*"";puts [r=s.reverse,?-,s,?=,$_="%04d"%(r.to_i-s.to_i)]*" ";~/6174/}}."

Example invocation:
$ echo 1211 | ruby -ln kaprekar.rb

I've counted the -ln flag as 4 characters (difference between the normal invocation ruby kaprekar.rb and ruby -ln kaprekar.rb).


Make me an alphabet tree Intro

In most fonts all of the uppercase alphabet characters besides BDO have single lines approximately touching some of the four corners of the character's bounding rectangle: ACEFGHIJKLMNPQRSTUVWXYZ.

For example, the two legs of an A "touch" the bottom left and bottom right corners of the character. Likewise, C touches its top and bottom right corners (it is a bit curved but it's close enough). L only touches it's top left and bottom right corners with single lines. The bottom left corner of L is a vertex, not the end of a single line.

Here is a table of what characters touch which corners according to the Stack Exchange font I (and hopefully you) see. 1 is for upper left, 2 is for upper right, 3 lower left, 4 lower right.

A: 3 4
C: 2 4
E: 2 4
F: 2 3
G: 2
H: 1 2 3 4
I: 1 2 3 4
J: 1 3
K: 1 2 3 4
L: 1 4
M: 3 4
N: 2 3
P: 3
Q: 4
R: 3 4
S: 2 3
T: 1 2
U: 1 2
V: 1 2
W: 1 2
X: 1 2 3 4
Y: 1 2
Z: 1 4

Setup

Pretend like these corner touching lines extend in the direction of the corner that they touch so that arrangements of these characters on a grid can be "connected".

For example, all the characters in

 A
C X

are connected because the bottom left of A and top right of C connect, and the bottom right of A and top left of X connect.

However,

CAX

has no connections because connections only occur diagonally from one character to the next.

Challenge

Write the shortest program possible (in bytes) that outputs all of the characters in ACEFGHIJKLMNPQRSTUVWXYZ in one big fully connected tree, according to the rules above. Each character must appear exactly once. Use spaces for empty space.

Example

Everything in this 23-letter tree can be reached from anything else via the diagonal connections defined above:

  Q
 A J   R
C U   S Y
 I M N
E H X
 F L T
G   Z K P
     V W

Notes

You may hardcode your solution.
Your output should only contain ACEFGHIJKLMNPQRSTUVWXYZ, spaces, and newlines. BDO will not be used.
Leading/trailing spaces are fine as long as all the connections are properly positioned.
The output grid should not be larger than 30 by 30 characters (including newlines and spaces).
Only corner connections are considered. The bottom of Y does not connect to anything. You must use the corner connections from the table above.
Not all connectable corners need to connect to something. Connectable and non-connectable corners may border each other.
Output to stdout. There is no input.
Including a connectivity graph made with slashes as Peter Taylor has done is a helpful touch but not required.

Update:
githubhagocyte has made an alphabet tree validity checker over on Github.

GolfScript (41 chars)

'QZENRPMALHIFKSXJTUVWYGC'8/{' '*n' '+:n}/

Online demo

Connectivity graph:

Q   Z   E   N   R   P   M   A
 \   \   \ /   / \ /   / \ / \
  L   H   I   F   K   S   X   J
   \ / \ / \ /   / \ /   /   /
    T   U   V   W   Y   G   C


ASCII Art of the Day #4 - Zodiac Signs We all love horoscopes, don't we? But I have a serious problem in this Horoscope App installed on my Smart Phone that it only displays the icon of the Zodiac Sign for each day's horoscope. Now, I do remember my horoscope, but its hard to remember others' whose horoscope I am interested in.

Challenge

So here is your challenge for an another addition to the ASCII Art of the Day series. Given a date and month input, output the corresponding Zodiac sign in ASCII format as shown below. Each Zodiac Sign is followed after the name and date range (DD MM format) for the zodiac sign.

Aries - 21 03 - 20 04
 .-.   .-.
(_  \ /  _)
     |
     |
Taurus - 21 04 - 20 05
 .     .
 '.___.'
 .'   '.
:       :
:       :
 '.___.'
Gemini - 21 05 - 20 06
._____.
  | |
  | |
 _|_|_
'     '
Cancer - 21 06 - 20 07
   .--.
  /   _'.
 (_) ( )
'.    /
  '--'
Leo - 21 07 - 20 08
  .--.
 (    )
(_)  /
    (_.
Virgo - 21 08 - 20 09
 _
' ':--.--.
   |  |  |_
   |  |  | )
   |  |  |/
        (J
Libra - 21 09 - 20 10
     __
___.'  '.___
____________
Scorpio - 21 10 - 20 11
 _
' ':--.--.
   |  |  |
   |  |  |
   |  |  |  ...
         '---':
Sagittarius - 21 11 - 20 12
      ...
      .':
    .'
'..'
.''.
Capricorn - 21 12 - 20 01
        _
\      /_)
 \    /'.
  \  /   :
   \/ __.'
Aquarius - 21 01 - 20 02
.-"-._.-"-._.-
.-"-._.-"-._.-
Pisces - 21 02 - 20 03
'-.    .-'
   :  :
 --:--:--
   :  :
.-'    '-.

Input

You would be provided two integers corresponding to the date of month and
month of year (in that order) of the birthday.
The date and month will be 1 indexed like in normal calendars.
You can take input form STDIN/ARGV/function arguments or the closest equivalent

Output

Based on what date range the input date falls in, output to STDOUT, the corresponding Zodiac Sign.
You can have upto 4 trailing spaces in each line but no leading spaces that are not part of the output.
You can either write a full program or a named function.

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

Leaderboard

The first post of the series generates a leaderboard.

To make sure that your answers show up, please start every answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

CJam, 296 284 272 265 264 bytes

"03½åÙªWË#å¥ÜZ2ò'ýðDc}¦Ð£RÞ5ä<Üå§ÖÞYÏuäOe¤¶è2²|ZëßB«ô¬cm"257b2bSf*Qa/"®=&ðS¢Òpût£Ð`ç«^º,[öÄ©3¸YÝæ[%$>\D£(´õÓÆeUØRHáÄ¡ããîùK½ÊÆÇ:UBÍm¥·fèäBÓEwWOkQq×tÌVfè£g8·¨    q©ñäp-ÁgUÚ´Éõ'>r    Ê#"256bDb"
.\"'()-/:\_|J"f=.+sSN+/l~\K>+=

Try it online in the CJam interpreter.

Idea

We start by joining all twelve signs using the string <SP><LF> as separator. We opt for the zodiac signs not to contain trailing spaces, so this allows to separate them easily.

The joined string is 542 bytes long. 236 of these bytes are spaces, which is almost half of them. We build an array that contains a 1 for every space and a 0 for every non-space. This way, encoding a space will only cost 1 bit.

Removing all spaces from the joined string, we are left with the characters <LF>."'()-/:J\_|. Assigning each of them a value (e.g., the index in this string) between 0 and 12

Finally, we decode the above base 2 and base 13 arrays as byte arrays.

In the final program, for a given input DD MM, we compute (int(MM) + (int(DD) > 20)) % 12, reverse the above process to obtain the array of all zodiac signs and select the proper one.

Code

"03½åÙªWË#å¥ÜZ2ò'ýðDc}¦Ð£RÞ5ä<Üå§ÖÞYÏuäOe¤¶è2²|ZëßB«ô¬cm"

        e# Push the encoded space positions.

257b2b  e# Convert from base 257 to base 2.
Sf*     e# Replace 1's with spaces and 0's with empty strings.
Qa/     e# Split at empty strings.

"®=&ðS¢Òpût£Ð`ç«^º,[öÄ©3¸YÝæ[%$>\D£(´õÓÆeUØRHáÄ¡ããîùK½ÊÆÇ:UBÍm¥·fèäBÓEwWOkQq×tÌVfè£g8·¨ q©ñäp-ÁgUÚ´Éõ'>r    Ê#"

        e# Push the encoded non-space characters.

256bDb  e# Convert from base 256 to base 13.

"
.\"'()-/:\_|J"f=

        e# Replace each digit in base 13 by the corresponding character.

.+s     e# Interleave both arrays to create a string.
SN+/    e# Split at trailing spaces.
l~      e# Evaluate the input from STDIN.
\K>+    e# Add 1 to the month if the day is larger than 20.
=       e# Retrieve the corresponding element from the array.


Tangent Polygon Extensions Draw something that looks like this:

In more precise terms, draw a circle of radius r, with n evenly-spaces tangent lines of length l. Connect the ends of these lines to form a new n-sided regular polygon.

Rules

r = circle radius
n = number of tangent lines - must be evenly spaced around circle (n>=3)
l = side length of tangent lines

Create a program that accepts the arguments { r, n, l } and draws the required output.

Units are in pixels.

There is no restrictions to the location of the drawing, as long as all of it is visible.

The picture is pretty self-explanatory.

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

Python, 133 bytes
The only answer so far to comply with the "Units are in pixels" rule...
from turtle import*
c=circle
r,n,l=input()
lt(90)
exec'c(r,360/n);fd(l);bk(l);'*n
fd(l)
lt(towards(-r,0)-180)
c(distance(-r,0),360,n)

Add exitonclick() to the end if you don't want the window to close immediately.
Output:
python tangentpoly.py <<< "20, 6, 30":

python tangentpoly.py <<< "100, 8, 200":


Acronyms can really obviously narrow your message sensors Because of this, you need a better way of working out if a phrase is an acronym of a word. You also think it would be worthwhile to see if the phrase and word in question are recursive acronyms.
Your task:
Given a word and then a phrase separated by a line, output if the phrase is an acronym and then if it is a recursive acronym. (The phrase contains what it stands for)

The input will compose of alphabetical characters as well as spaces.
Your program shouldn't be case sensitive.

Example Input/Output:
Case 1:
Input:
Acronyms
Acronyms can really obviously narrow your message sensors

Output:
True
True

Case 2:
Input:
FAQ
frequently asked questions

Output:
True
False

Case 3:
Input:
foo
bar baz

Output:
False
False

Case 4:
Input:
GNU
GNU is not Unix

Output:
False
False

Case 5:
Input:
Aha
A huge Aha

Output:
True
True

Python 3, 89

Saved a bunch of bytes thanks to SOPython.

a=input().lower()
d=input().lower().split()
h=tuple(a)==next(zip(*d))
print(h,h&(a in d))

The most complicated part of this solution is h=tuple(a)==next(zip(*d)).
This unpacks the list d into zip and then calls next to return a tuple of the first element of each iterable passed into zip which is then compared against a tuple of each letter in a (tuple(a)).