When is my piversary? Since I want to celebrate this definitely not nerdy event, your job is to calculate the piversary (pi-anniversary) of a given date.
Input
Your code has to have a possibilty to input a date in the format DD/MM/YYYY. You can expect, that the input is valid and the year is 0000<YYYY<9996.
Output
You have to release two dates, the date in Pi months and the date in Pi years.
Rules

If your language hasn't a build in Pi, you have to make a variable which will be exact enough to calculate the dates, but it is not allowed to calculate the days separately and use fix numbers.
You have to take care, that the months have different amount of days, but you don't have to care about leap years (only if you want).
If you calculate the date, you have to add the three years/months first and then the left part in rounded days.
Your code has to accept any valid date and should be able to handle edge cases like 30/12/2000

Example:
Input: 12/04/2010

Calculate monthly piversary:
date +  3 months = 12/07/2010
date + (31*(Pi-3)) = date + 4.39 = date + 4 = 16/07/2010 //31 because July has 31 days

Calculate yearly piversary:
date + 3 years = 12/04/2013
date + (365*(Pi-3)) = date + 52 = 03/06/2013

Output:
16/07/2010,03/06/2013

May the shortest code win.

Mathematica, 152 134 bytes

f[i_]:=DateList@{i,{d="Day",m="Month",y="Year"}}~DatePlus~{{3,#},{Round[#2*(Pi-3.)],d}}~DateString~{d,"/",m,"/",y}&@@@{{m,31},{y,365}}

Ungolfed

f[i_] :=
 DateString[
    DatePlus[
     DateList@{i,{d="Day",m="Month",y="Year"}},
     {{3, #}, {Round[#2*(Pi - 3.)], d}}
    ],
    {d, "/", m, "/", y}
 ] & @@@ {{m, 31}, {y, 365}}

This does handle leap years. It's also horribly long.


This challenge is about recursion (Cops' thread) Cops' thread

In this thread, your task is to make a recursion-based program/function to generate any integer series. Robbers will try and find a shorter non-recursive solution over in the Robbers' thread.

Challenge synopsis

In many languages, recursive functions can significantly simplify a programming task. However, the syntax overhead for a proper recursion may limits its usability in code-golf.

The cops will create a program or function taking a single integer n, which will generate the first n entries of an integer series, using only recursion1. They should also make sure there is a shorter nonrecursive way to generate the sequence in order to mark their entry as safe.

The robbers will try to find a shorter program or function in the same language, generating the same integer series, using no recursion2.

If the cops' submission is not cracked within ten days (240 hours), the cop will prove it was in fact possible to have a shorter non-recursive approach by revealing their own solution. They may then mark their submission as safe.

The winner of the cops challenge will be the shortest (according to code-golf) recursion-based submission marked safe.

The winner of the robbers challenge will be the robber who cracked the most solutions.

1: It only needs to be recursive in syntax; you don't need to worry about for example tail call optimization.

2: Again, non-recursive in syntax; so you can't post a recursive solution and claim its compiled to a loop thanks to tail call optimization.

Submission requirements

Each submission will take a single integer n (zero- or one-based). The submission will then output or return the first n entries of an integer series of choice. (note that this integer series must not depend on n). The input and output method may differ between the recursive and non-recursive approach. The integer series may be any deterministic series with a length of at least 5. The series should be explained properly.

Your submission does not have to work for arbitrary large n, but should work for at least n=5. The non-recursive approach must be able to work up to at least the same n as the recursive approach, or up to n=2^15-1, whichever is smaller.

Recursion

For the sake of this challenge, recursion is defined as creating the desired sequence using a function (or function-like construct) that calls itself (or calls a sequence of functions that ends up calling itself; this includes constructs like the Y combinator). The recursion depth should go to infinity as n goes to infinity. The non-recursive approach is anything that is not recursive.

Python 3, 65 bytes (Safe)

f=lambda n,a=3,b=0,c=6,d=6:n*[1]and[a+b]+f(n-1,c,d,2*c+d,2*a+3*b)

Try it online!

Another try in Python.

The sequence is "the number of ways to fill a 2-by-n board with dominoes in three colors, so that no two same-colored dominoes touch each other". Not on OEIS.

Let's say n=6. The board looks like:

######
######

and these are valid domino tilings in three colors (1-3 represent a color each):

123123 122331 212332 212121 113311
123123 133221 212112 212121 331133

but these are not (two same-colored dominoes are touching each other):

112323 332333 211113
112323 112311 233223

The sequence counts all possible domino tilings that satisfy the rules for each n.

Intended solution, 58 bytes

n=int(input());a=3;b=12
for _ in[0]*n:print(a);a,b=b,a*4+b

Try it online!

Unfortunately it looks like no one bothered to simplify the recurrence relation, which was clearly shown in the recursive code. Making a program with the given double recurrence as-is doesn't work since it's Python 3.


Simulate any 1D cellular automaton The Challenge

You are to write a complete program that takes seven numbers from STDIN, and prints the two dimensional history of the cellular automaton (CA) to STDOUT. This is code golf.

Input Formatting
The input will be seven integers/strings separated by commas. The first number is the number of the rule according to Wolfram code (the standard name for each rule). The second is the initial starting configuration. The third and fourth describe what pattern and how many times it should be appended to the left of the starting config. as padding. The fifth and sixth do the same for the right side. The last number is the number of generations to run the simulation.

So, an example of input is 90,11,0,4,0,4,5. This should tell your program that you are running rule 90. It should also tell the program that you want the initial configuration to be 11 with the string 0 appended 4 times to both ends, so the actual starting pattern is 0000110000. It also tells your program to run this simulation for 5 generations.

Output Your program should print the entire array of cells each generation (separated by newlines), so that the output is the space-time diagram of the CA. For each generation, the state of each cell is determined by its state and the states of the cells to the immediate left and right, in accordance to the rule provided as input. The simulation should wrap around the edges. The first thing printed should be the starting array as gen. 0.

The input 90,11,0,4,0,4,5 should result in the following output as exactly as possible.

0000110000
0001111000
0011001100
0111111110
1100000011
0110000110

Notice that the starting state is not included in the five generations. Also notice that the simulation wraps around the edges.

More Examples

input:

184,1100,01,2,01,1,4

output:

0101110001
1011101000
0111010100
0110101010
0101010101

input:

0,1011,1,0,0,1,2

output:

10110
00000
00000

More information on how 1D CA's work and how they are numbered


Print last inputted byte Challenge
You have one string of input bytes, output the last byte in it.
Rules
Your submission may be a program or function outputting the last byte in the input which

is either a string, stdin or command-line arguments, and
is non-empty.

I was trying to solve this with brainfuck, however all languages are allowed to participate. This is code-golf.
Examples
"?" -> "?"
"29845812674" -> "4"

Attache, 4 bytes

Last

Try it online! (If the input could be a list of characters, &/S could work.)

Alternatives

5 bytes: `@&-1

8 bytes: &/S@List

10 bytes: `@«_,-1»

10 bytes: Fold!Right

10 bytes: `@<~_,-1~>

10 bytes: `^^&:Right

10 bytes: {Right^^_}

11 bytes: Get«_,-1»

11 bytes: Get<~_,-1~>

12 bytes: `@«_,#_-1»

12 bytes: `@<~_,#_-1~>

13 bytes: Get«_,#_-1»

13 bytes: Get<~_,#_-1~>


Help me with my polyrhythms I'm a musician, and I need more polyrhythms in my life!

A polyrhythm occurs in music (and in nature) when two events (claps, notes, fireflies flashing etc.) are occurring at two different regular intervals. The two kinds of event happen a different number of times in the same interval.

If I tap with my left hand twice, and with my right hand 3 times, in the same space of time, it looks a little bit like this:

  ------
R . . .
L .  .

The hyphens at the top denote the length of the polyrthmic pattern, which is the lowest common multiple or 2 and 3. This can be understood as the point at which the pattern repeats.

There's also a 'metarhythm', which is the pattern produced when either hand is tapping:

  ------
R . . .
L .  .
M . ...

This is a simple, and very common polyrhythm, with a ratio of 3:2.

Let's just say I don't want to do a simple polyrhythm that I can work out in my head, so I need something to work it out for me. I could do it long-form on paper, or...

Rules:

Write some code to generate and display a polyrhythm diagram, as described above.
Any old language, try for the fewest bytes.
Your code takes two arguments:

Number of taps with the Left hand (positive integer)
Number of taps with the right hand (positive integer)

It will work out the length, which is the lowest common multiple for the two arguments.
The top line will consist of two whitespace characters followed by hyphens displaying the length (length * '-')
The second and third lines will show the pattern for the right and left hands:

It will start with an R or L, do denote which hand it is, followed by a space.
The interval for that hand is the length divided by it's argument.
The taps will start at the third character, denoted by any character you choose. From then on it will display the same character 'interval' characters apart.
It will not be longer than the length line.

The fourth line is the metarhythm:

It will start with an upper case M, followed by a space.
From the third character onwards, it will show a character (any character you choose) in every position where there's a tap on either the right or the left hand.

Trailing whitespace is irrelevant.

Test cases:

r = 3, l = 2

  ------
R . . .
L .  .
M . ...

r = 4, l = 3

  ------------
R .  .  .  .
L .   .   .
M .  .. . ..

r = 4, l = 5

  --------------------
R .    .    .    .
L .   .   .   .   .
M .   ..  . . .  ..

r = 4, l = 7

  ----------------------------
R .      .      .      .
L .   .   .   .   .   .   .
M .   .  ..   . . .   ..  .

r = 4, l = 8

  --------
R . . . .
L ........
M ........

Happy golfing!

JavaScript (ES6), 131 bytes

Outputs 0 as the tap character.

r=>l=>`  ${g=n=>n?s.replace(/./g,(_,x)=>[,a=x%(k/r),x%=k/l,a*x][n]&&' '):++k%l|k%r?'-'+g():`-
`,s=g(k=0)}R ${g(1)}L ${g(2)}M `+g(3)

Try it online!

How?

We use the same helper function \$g()\$ for two different purposes.

When \$g()\$ is called with no argument or an argument equal to \$0\$, it recursively builds the hyphen string of length \$k=\operatorname{lcm}(l,r)\$ with a trailing linefeed:

g = _ => ++k % l | k % r ? '-' + g() : `-\n`

This string is saved in \$s\$.

When \$g()\$ is called with \$1 \le n \le 3\$, it generates a tap string by replacing each hyphen at position \$x\$ in \$s\$ with either a space or \$0\$:

g = n => s.replace(/./g, (_, x) => [, a = x % (k / r), x %= k / l, a * x][n] && ' ')


Electron Configurations Electron Configurations

Your mission is to accept an element's atomic number as input, and output its electron configuration (e.g. 2,8,8,2 for calcium).

Input

An atomic number from 1 to 118. You may assume valid input. The atom is not charged (it has as many electrons as protons). You may not expect the input to be stored in a variable, and you must write a complete program.

Output

The number of electrons in each non-empty electron shell. I will be quite lenient with the output format; all of the following are acceptable, i.e. you may use any punctuation or whitespace to separate the numbers, and brackets of any sort are permitted. Please specify which is used.

2,8,8,2
2.8.8.2
2, 8, 8, 2,
[2,8,8,2]
2 8 8 2
([2 [8]] [8] 2)

How Electrons Work

In atoms, electrons are ordered into "shells", which are energy levels. Each shell has a certain capacity, the maximum number of electrons that it is capable of holding. The shells are filled from the inside out, but not evenly. Your task is to determine, given an atomic number, how many electrons there are in each shell, according to this source.

Up to and including calcium (atomic number 20), the shells fill evenly and in order; the inner shell is first filled to its capacity of 2, the second to 8, then the third to 8 and the last to 2. The electron configuration of calcium is 2,8,8,2.

After calcium, things get complicated; further electrons go into the third shell, not the last one. To make things worse, vanadium (23) is 2,8,11,2, while chromium (24) is 2,8,13,1 and manganese (25) is 2,8,13,2.

There are some consistent patterns, however: a noble gas and the seven elements before it will always have the number of electrons in the outer shell increase from 1 to 8. For example:

gold (79): 2,8,18,32,18,1
mercury (80): 2,8,18,32,18,2
...
astatine (85): 2,8,18,32,18,7
radon (86): 2,8,18,32,18,8

Rules

Standard loopholes are forbidden.
Libraries which existed prior to this challenge are permitted.
Any built-in or library features which specifically deal with atoms, molecules or chemistry are banned.
Lowest code length in bytes wins.
In the linked source, configurations of elements 103-118 are marked with (?), as they are predicted, and the elements are too unstable for this to be checked. For this challenge, assume them to be correct.
You may hardcode part or all of your data.
[NEW RULE] Please provide a base64 or an xxd dump of your files if you use control characters in them (as many answers seem to be doing)

WINNER: Dennis's CJam answer at 80 bytes!

CJam, 87 83 82 80 bytes

0"hTHøìð¼Ä¿håêÛ¾ªÔ¼"256b6b5a/4a8**li<{[33:B_B*65_B*1]=\_B%8=B\#*+}/Bb0-`

The above code contains unprintable characters.

Try it online in the CJam interpreter. If the link doesn't work for you, copy from this paste.

Background

To obtain the electron configuration of the Nth atom, we start with an atom without electrons and apply N transformations to it.

To reduce the byte count of the implementation, we represent the electron configuration of an atom as an integer. Each digit of that integer in base 33 corresponds to the number of electrons in a certain shells; the least significant digit represents the outer shell.

For example, the electron configuration of Molybdenum (42) is [2 8 18 13 1]. This corresponds to the integer 2 × 334 + 8 × 333 + 18 × 332 + 13 × 33 + 1 = 26,79,370.

Palladium (48) is a special case, which we treat as [2 8 18 18 0] instead of [2 8 18 18].

This convenient representation reduces the aforementioned transformations to simple arithmetic:

R += 1 (add an electron to the outer shell)
R += 33 (add an electron to the second outer shell)
R += 65 (add two electrons to the second outer shell; remove one from the first)
R += 1089 (add an electron to the third outer shell)
R += 2145 (add two electrons to the third outer shell; remove one from the second)
R *= 33, R += 1 (add a new shell containing a single electron)

All that's left is to somehow encode which transformation has to be applied to pass from a particular atom to the next. The differences of the integer representations of two consecutive atoms are as follows:

[1 1 65 1 1 1 1 1 1 1 2369 1 1 1 1 1 1 1 78401 1 33 33 33 65 1 33 33 33 65 1 1 1 1 1 1 1 2598017 1 33 33 65 33 1 65 33 65 1 1 1 1 1 1 1 1 85745345 1 33 1089 2145 1089 1089 1089 1089 33 2145 1089 1089 1089 1089 1089 33 33 33 33 33 33 33 65 33 1 1 1 1 1 1 1 2830095041 1 33 33 2145 1089 1089 2145 1089 33 2145 1089 1089 1089 1089 1089 65 1 33 33 33 33 33 33 65 1 1 1 1 1 1 1]

The unique differences in this array are the following:

[1 33 65 1089 2145 2369 78401 2598017 85745345 2830095041]

All but the first 5 correspond to instances when a new shell is added; these can be omitted since multiplying by 33 and adding 1 yields the same result as adding the difference.

Since we have to add a new shell if and only if the current atom has exactly eight electrons in its outer shell (with the exception of He (2) ↦ Li (3), which can be encoded as add 65), we can encode those transformations as add 1 and determine the need for multiplication on the fly.

Thus, if we define

X := 0
I := 0
L := [33 1089 65 2145 1]
T := [1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 3 1 0 0 0 3 1 1 1 1 1 1 1 1 1 0 0 3 0 1 3 0 3 1 1 1 1 1 1 1 1 1 1 0 2 4 2 2 2 2 0 4 2 2 2 2 2 0 0 0 0 0 0 0 3 0 1 1 1 1 1 1 1 1 1 0 0 4 2 2 4 2 0 4 2 2 2 2 2 3 1 0 0 0 0 0 0 3 1 1 1 1 1 1 1]

the electron configuration of the Nth atom can be computed as follows:

while(X < N):
    R *= (33 ** (R % 33 == 8))
    R += L[T[X]]
    X += 1

How it works

" Push 0, the initial value of R; convert the following array into an integer by
  considering it a base 256 number, then back to the array of its digits in base 6.       ";

0"hTHøìð¼Ä¿håêÛ¾ªÔ¼"256b6b

" Replace each 5 in the resulting array by [4 4 4 4 4 4 4 4]. This yields the array T
  from the above section.                                                                 ";

5a/4a8**

" Read an integer N from STDIN and discard all but the first N elements of T.             ";

li<

" For each element Y of the remainder of T, do the following:                             ";

{
    [33:B_B*65_B*1]=\   " Define B := 33, push L, retrieve L[Y] and swap it with R.       ";

    _B%8=B\#*           " Execute R *= 33 ** (R % 33 == 8).                               ";

    +                   " Execute R += L[Y].                                              ";
}/

" Convert R into the array of its digits in base 33, remove eventual zeros (Palladium)
  and replace the resulting array with its string representation.                         ";

Bb0-`

Example run

$ base64 -d > electrons.cjam <<< MCJoVEgM+OzwErzEGL9o5erbvqrUB4YZhrwRIjI1NmI2YjVhLzRhOCoqbGk8e1szMzpCX0IqNjVfQioxXT1cX0IlOD1CXCMqK30vQmIwLWA=
$ cksum electrons.cjam
3709391992 80 electrons.cjam
$ for i in {1..118}; do LANG=en_US cjam electrons.cjam <<< $i; echo; done
[1]
[2]
[2 1]
[2 2]
[2 3]
[2 4]
[2 5]
[2 6]
[2 7]
[2 8]
[2 8 1]
[2 8 2]
[2 8 3]
[2 8 4]
[2 8 5]
[2 8 6]
[2 8 7]
[2 8 8]
[2 8 8 1]
[2 8 8 2]
[2 8 9 2]
[2 8 10 2]
[2 8 11 2]
[2 8 13 1]
[2 8 13 2]
[2 8 14 2]
[2 8 15 2]
[2 8 16 2]
[2 8 18 1]
[2 8 18 2]
[2 8 18 3]
[2 8 18 4]
[2 8 18 5]
[2 8 18 6]
[2 8 18 7]
[2 8 18 8]
[2 8 18 8 1]
[2 8 18 8 2]
[2 8 18 9 2]
[2 8 18 10 2]
[2 8 18 12 1]
[2 8 18 13 1]
[2 8 18 13 2]
[2 8 18 15 1]
[2 8 18 16 1]
[2 8 18 18]
[2 8 18 18 1]
[2 8 18 18 2]
[2 8 18 18 3]
[2 8 18 18 4]
[2 8 18 18 5]
[2 8 18 18 6]
[2 8 18 18 7]
[2 8 18 18 8]
[2 8 18 18 8 1]
[2 8 18 18 8 2]
[2 8 18 18 9 2]
[2 8 18 19 9 2]
[2 8 18 21 8 2]
[2 8 18 22 8 2]
[2 8 18 23 8 2]
[2 8 18 24 8 2]
[2 8 18 25 8 2]
[2 8 18 25 9 2]
[2 8 18 27 8 2]
[2 8 18 28 8 2]
[2 8 18 29 8 2]
[2 8 18 30 8 2]
[2 8 18 31 8 2]
[2 8 18 32 8 2]
[2 8 18 32 9 2]
[2 8 18 32 10 2]
[2 8 18 32 11 2]
[2 8 18 32 12 2]
[2 8 18 32 13 2]
[2 8 18 32 14 2]
[2 8 18 32 15 2]
[2 8 18 32 17 1]
[2 8 18 32 18 1]
[2 8 18 32 18 2]
[2 8 18 32 18 3]
[2 8 18 32 18 4]
[2 8 18 32 18 5]
[2 8 18 32 18 6]
[2 8 18 32 18 7]
[2 8 18 32 18 8]
[2 8 18 32 18 8 1]
[2 8 18 32 18 8 2]
[2 8 18 32 18 9 2]
[2 8 18 32 18 10 2]
[2 8 18 32 20 9 2]
[2 8 18 32 21 9 2]
[2 8 18 32 22 9 2]
[2 8 18 32 24 8 2]
[2 8 18 32 25 8 2]
[2 8 18 32 25 9 2]
[2 8 18 32 27 8 2]
[2 8 18 32 28 8 2]
[2 8 18 32 29 8 2]
[2 8 18 32 30 8 2]
[2 8 18 32 31 8 2]
[2 8 18 32 32 8 2]
[2 8 18 32 32 10 1]
[2 8 18 32 32 10 2]
[2 8 18 32 32 11 2]
[2 8 18 32 32 12 2]
[2 8 18 32 32 13 2]
[2 8 18 32 32 14 2]
[2 8 18 32 32 15 2]
[2 8 18 32 32 16 2]
[2 8 18 32 32 18 1]
[2 8 18 32 32 18 2]
[2 8 18 32 32 18 3]
[2 8 18 32 32 18 4]
[2 8 18 32 32 18 5]
[2 8 18 32 32 18 6]
[2 8 18 32 32 18 7]
[2 8 18 32 32 18 8]


What is the missing number (divisibility by 9) Challenge

Given a whole number divisible by 9 and one missing digit, find the missing digit.

The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.

If the missing digit could be 0 or 9, output something to signify so.

Assume the user is intelligent enough to put only one missing digit and one number etc.

Test Cases

In the test cases the missing digit is represented by a question mark

123? -> 3
?999 -> 0 or 9
?0023 -> 4
000?1 -> 8

Python, 21 bytes

lambda s:-int(s,19)%9

Try it online!

I used I to represent a missing digit.


Golfscript Diagonal Array Is there a way in Golfscript to bring all of the diagonals of an array into a single array?

For example, for the array

[[1 2 3][4 5 6][7 8 9]]

return

[[7][4 8][1 5 9][2 6][3]]

(not necessarily in that order) and for

["ABCD""EFGH""IJKL"]

return

["I""EJ""AFK""BGL""CH""D"]

(not necessarily in that order). Assume the lengths of the arrays are the same.

I am struggling with figuring it out. I tried doing something with = and iterating through the (length+1)th character of the strings, but that didn't work. Can someone help me?

I'd like the shortest way to do this, if possible.

Consider

[
    "ABCD"
    "EFGH"
    "IJKL"
]

To obtain the main diagonal and the diagonals above it, we can shift out the first char of the second row and the first two of the third:

[
    "ABCD"
    "FGH"
    "KL"
]

Note that all columns correspond to a diagonal, so "zipping" the array (i.e., transposing rows and columns) will yield an array containing the aforementioned four diagonals:

[
    "AFK"
    "BGL"
    "CH"
    "D"
]

We're still missing the diagonals below the main diagonal.

If we zip A itself and repeat the above process, we'll obtain an array containing the main diagonal and all diagonals below it. All that's left it to compute the set union of both arrays.

Putting it all together:

[.zip]{:A,,{.A=>}%zip}/|

[.zip]{              }/  # For the original array and it's transpose, do the following:
       :A                # Store the array in A.
         ,,{    }%       # For each I in [ 0 1 ... len(A) ], do the following:
            .A=>         # Push A[I] and shift out its first I characters.
                  zip    # Transpose the resulting array.
                       | # Perform set union.

Try it online.

Finally, if we only need the diagonals because we're searching for a string inside them (like in the Word Search Puzzle, which I assume inspired this question), a "less clean" approach might also be suitable.

You can use

..,n**\.0=,\,+)/zip

to obtain all diagonals, plus some unnecessary linefeed characters.

I've explained the process in detail in this answer.

Try it online.


Generate the Stack Overflow logo The challenge is to generate an image similar to the StackOverflow logo:

The output must contain:

Image size 64*64 or greater
A gray |__| shaped base
A curved segmented stack coming up from the base. The segments will fade from gray to orange, and make a ~90 degree right turn. The number of segments should be between 5 and 7, with 6 being preferred.

Note: For ascii displays that lack color, use a '0' character to represent gray, and '9' for orange. '1' to '8' would represent the shades in-between.

Restrictions:

You must generate the image. Loading images or storing them in the code/binary is not allowed.

Additional rules/information:

The image is not required to be identical to the logo, however it must be recognizable as it.
The method of display is up to you. Saving it to an image file or displaying on the screen are both acceptable.

Judging/winning criteria:

Accuracy of the image is the primary condition
Elegance of generation is the secondary condition

Mathematica
Graphics[{
   Gray, Rectangle[{0, 0}, {78, 50}],
   White, Rectangle[{9, 9}, {69, 50}]}
  ~Join~
  Table[{
    Blend[{Gray, Orange}, x/5],
    Rotate[
     Translate[
      Rectangle[{16, 16}, {61, 25}],
      {0.25x^3 + 0.6x^2 - 0.4x, -0.53x^3 + 3.26x^2 + 12x}],
     -0.05x^2 - 0.04x]},
   {x, 0, 5}]]

I decided to prettify my answer after realizing this isn't code golf. Whoops!
Screenshot:

In related news, I also created what I think the Stack Overflow logo might look like in... THE FUTURE:

Here's the code if anyone wants to play around with it (sorry for the mess):
Graphics3D[{EdgeForm[],
   Opacity[1],
   RGBColor[0.2, 0.2, 0.2], Cuboid[{0, 0, 0}, {78, 4, 50}],
   Cuboid[{0, 4, 0}, {4, 45, 50}],
    Cuboid[{74, 4, 0}, {78, 45, 50}],
   Opacity[1]}
  ~Join~
  Fold[Join, {},
   Table[{Hue[0.15 - i/5/12, i/3, 1],
     Translate[
      Rotate[
       Scale[Cuboid[{16, 16, 16}, {61, 25, 25}], {1, .3, .3}],
       (-.05 ((i*2 - 1.5)*1.25)^2 - .04 ((i*2)*1.2)), {0.3,
        0.8, -1}, {(16 + 61)/2, (16 + 25)/2, (16 + 25)/2}],
      {-((i*2)^2 - (i*2)*4)/2, (i*2)^2*3/2, 0}]},
    {i, 0, 4.5, 0.05}]], Lighting -> "Neutral", Axes -> False,
 Background -> White, Boxed -> False]


how to find n'th number in the decimal expansion of a proper fraction? Given three integers N,D,R write a program to output Rth digit after the decimal point in the decimal expansion for a given proper fraction N/D.

GolfScript 17

10\?@abs*\abs/10%

GolfScript can't handle real numbers well, but multiplying by powers of 10 is equivalent.

Here's an explanation and walkthrough with sample input, for any of you who are new to GolfScript, since I think this is a nice simple introduction:

59 -17 5
10\ #Place 10 on the stack and then switch the top 2 elements
-> 59 -17 10 5
? #Exponentiate
-> 59 -17 100000
@ #Rotate top 3 elements
-> -17 100000 59
abs #Take absolute value of top element
-> -17 100000 59
* #Multiply the top 2 elements
-> -17 5900000
\ #Switch top 2 elements
-> 5900000 -17
abs #Take absolute value of top element
-> 5900000 17
/ #Do integer division
-> 347058
10% #Place 10 on the stack and then take modulo
-> 8


Shift characters in a string In this challenge, you are required to shift characters in an inputted string n number of times and output the shifted string

Input

Input will first contain a string. In the next line, an integer, which denotes n will be present.

Output

If n is positive, shift the characters in the string to the right n times.
If n is negative, shift the characters in the string to the left n times.
If n is zero, don't shift the characters in the string.

After shifting (except when n is zero), print the shifted string.

Notes

The string will not be empty or null.
The string will not be longer than 100 characters and will only contain ASCII characters in range (space) to ~(tilde) (character codes 0x20 to 0x7E, inclusive). See ASCII table for reference.
The shift is cyclic.
The number n may be positive, negative, or zero.
n will always be greater than or equal to -1000 and lesser than or equal to 1000
You may take input via stdin or from command line arguments
The shifted string must be outputted in the stdout (or closest equivalent)
You may write a full program or a function which takes input and outputs the string in stdout or closest equivalent

Test Cases

1)

Hello world!
5             -->orld!Hello w

2)

Testing...
-3            -->ting...Tes

3)

~~~
1000          -->~~~

4)

12345
0             -->12345

5)

ABA
17            -->BAA

Scoring

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

Pyth, 4 bytes
.>zQ

This is almost similar to my CJam 5 byte version, except that Pyth as a auto-eval input operator Q.
.>              # Cyclic right shift of
  z             # Input first line as string
   Q            # Rest of the input as evaluated integer

Try it online here


Generalization of abbreviations Given an input of a list of words and their abbreviations, output the pattern
by which the abbreviations can be formed.

Let us take the example input of

potato ptao
puzzle pzze

as an example (that is, the abbreviation for potato is ptao, and the
abbreviation for puzzle is pzze).

Consider all possible ways to obtain ptao from potato. One possible way is
to take the first, third, fourth, and sixth letters, which we will refer to as
1346. But since t and o appear multiple times in the word, there are
multiple other possible ways to generate ptao from potato: 1546, 1342,
and 1542.

Similarly, note that pzze can be generated from puzzle with any of 1336,
1346, 1436, 1446. The only pattern that these two abbreviations have in
common is 1346; therefore, that must be the output for this input. If
multiple possible patterns are possible, you may output any, some, or all of
them (at least one).

You may assume that:

Input words and abbreviations contain only lowercase letter.
There is at least one word/abbreviation pair in the input.
It is possible for every abbreviation to be formed from its corresponding
word.
There will always be at least one pattern that forms every abbreviation.
The maximum length of each word is 9 characters.

Input may be taken as any of the following:

2-dimensional array/list/array of tuples/etc. [[word, abbr], [word, abbr],
...]
flat 1-dimensional array/list [word, abbr, word, abbr, ...]
single string, delimited by any single character that is not a lowercase
letter "word abbr word abbr"
hash/associative array/etc. {word => abbr, word => abbr, ...}

In any of these input options, you are also permitted to swap the order of word/abbr (please fully describe the input format in your post).

Output may be given as a single number, a string delimited by non-digits, or an array/list/tuple/etc. of numbers.

Since this is code-golf, the shortest code in bytes will win.

Test cases (remember that you only need to output ≥1 results if multiple
patterns work):

In                                Out
--------------------------------------------------------
potato ptao puzzle pzze         | 1346
aabbcc abc fddeef def           | 246
prgrmming prgmg puzzles pzzlz   | 14353
aaaaa a bbbb b ccc c dd d e e   | 1
aaaaa a bbbb b ccc c            | 1, 2, 3
abcxyz zbcyax                   | 623514
abcxyz acbbacbcbacbbac          | 132213232132213
potato ptao                     | 1346, 1546, 1342, 1542
a aaaaa                         | 11111

MATL, 29 bytes
!"@Y:!=2#fX:wX:h]N$v1XQtv4#X>

Input is a 2D array in the following format:
{'potato' 'ptao'; 'puzzle' 'pzze'}

Try it online! (the linked code includes some modifications owing to changes in the language since this answer was posted)
!       % take input. Transpose
"       % for each column
  @Y:   %   push column. Unpack the two strings and push them onto the stack
  !     %   transpose second string
  =     %   matrix with all pairwise matchings of characters in word and abbreviation
  2#f   %   find row and col indices of those matchings
  X:    %   transform into column vector
  wX:   %   swap, transform into column vector
  h     %   concat into a two-col matrix
]       % end for
N$v     % concatenate all matrices containing the indices
1       % push 1
XQ      % build matrix adding 1 for each (row,col) index
tv      % concat vertically with itself, so that it has at least two rows.
        % This forces the following function to work on each col.
4#X>    % arg max of each col: position that produces a match in all pairs.
        % If there are several maximizers in each col this gives the first

The code required some involved (and lengthy!) tricks to

Prevent the orientation of vectors produced by find (f) from changing depending on input shape. These are statements X:wX:: force both outputs to be column vectors.
Counteract the "work along first non-singleton dimension" default behaviour of the min (X>) function. These are statements tv: concat a copy of itself to assure at least two rows);


Finding sum-free partitions Executive summary

Given input k, find a partition of integers 1 to n into k sum-free subsets for the largest n you can within 10 minutes.

Background: Schur numbers

A set A is sum-free if its self-sum A + A = { x + y | x, y in A} has no elements in common with it.

For every positive integer k there is a largest integer S(k) such that the set {1, 2, ..., S(k)} can be partitioned into k sum-free subsets. This number is called the kth Schur number (OEIS A045652).

For example, S(2) = 4. We can partition {1, 2, 3, 4} as {1, 4}, {2, 3}, and that is the unique partition into two sum-free subsets, but we can't now add a 5 to either part.

Challenge

Write a deterministic program which does the following:

Take a positive integer k as input
Write the current Unix timestamp to stdout
Outputs a sequence of partitions of 1 to n into k sum-free subsets for increasing n, following each sequence with the current Unix timestamp.

The winner will be the program which prints a partition for the largest n within 10 minutes on my computer when given input 5. Ties will be broken by the quickest time to find a partition for the largest n, averaged over three runs: that's why the output should include timestamps.

Important details:

I have Ubuntu Precise, so if your language is not supported I will be unable to score it.
I have an Intel Core2 Quad CPU, so if you want to use multithreading there's no point using more than 4 threads.
If you want me to use any particular compiler flags or implementation, document that clearly in your answer.
You shall not special-case your code to handle the input 5.
You are not required to output every improvement you find. E.g. for input 2 you could output only the partition for n = 4. However, if you don't output anything in the first 10 minutes then I will score that as n = 0.

Python 3, sort by greatest number, n = 92 121
Thanks to Martin Büttner for a suggestion that unexpectedly improved the maximum n reached.
Last output:
[2, 3, 11, 12, 29, 30, 38, 39, 83, 84, 92, 93, 110, 111, 119, 120]
[1, 4, 10, 13, 28, 31, 37, 40, 82, 85, 91, 94, 109, 112, 118, 121]
[5, 6, 7, 8, 9, 32, 33, 34, 35, 36, 86, 87, 88, 89, 90, 113, 114, 115, 116, 117]
[14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108]
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81]

The algorithm is the same as my previous answer, quoted below:

There are k bins that have both the numbers in it so far and the numbers that can't go in it anymore. At each depth in the iteration (it's basically a depth-first search), the bin ordering is shuffled and the next number (nextN) is (sequentially) put into the bins that can take it and then goes one step deeper. If there are none, it returns, backing up one step.

...with one exception: the bin ordering is not shuffled. Instead, it is sorted in such a way that the bins with the greatest number come first. This reached n = 121 in 8 seconds!
Code:
from copy import deepcopy
from random import shuffle, seed
from time import clock, time
global maxN
maxN = 0
clock()

def search(k,nextN=1,sets=None):
    global maxN
    if clock() > 600: return

    if nextN == 1: #first iteration
        sets = []
        for i in range(k):
            sets.append([[],[]])

    sets.sort(key=lambda x:max(x[0]or[0]), reverse=True)
    for i in range(k):
        if clock() > 600: return
        if nextN not in sets[i][1]:
            sets2 = deepcopy(sets)
            sets2[i][0].append(nextN)
            sets2[i][1].extend([nextN+j for j in sets2[i][0]])
            nextN2 = nextN + 1

            if nextN > maxN:
                maxN = nextN
                print("New maximum!",maxN)
                for s in sets2: print(s[0])
                print(time())
                print()

            search(k, nextN2, sets2)

search(5)


Determine whether strings are anagrams Challenge

Given two strings, work out if they both have exactly the same characters in them.

Example

Input

  word, wrdo

This returns true because they are the same but just scrambled.

Input

  word, wwro

This returns false.

Input

  boat, toba

This returns true

Rules

Here are the rules!

Assume input will be at least 1 char long, and no longer than 8 chars.
No special characters, only a–z
All inputs can be assumed to be lowercase

Test Cases

boat, boat = true
toab, boat = true
oabt, toab = true
a, aa = false
zzz, zzzzzzzz = false
zyyyzzzz, yyzzzzzy = true
sleepy, pyels = false
p,p = true

Python, 32 bytes

f=lambda a,b,S=sorted:S(a)==S(b)


Align a list of numbers Perhaps something like this is here already, but I couldn't find it.
It is not the same as Aligning Lines!.
Example:
Input:
98.6
$2,750.17
-$23
-86
3,120,487.19

Output:
       98.6
   $2,750.17
     -$23
      -86
3,120,487.19

Note that .6 isn't right-padded to .60 or .6 .
Input:

A list/array of strings (or lines from stdin), each one containing a number, without leading or trailing whitespace
Some may begin with begin with a negative sign (-), and/or a currency symbol ($), in that order
Some may contain a decimal mark (.)
Digits before the decimal mark will sometimes be grouped into threes and separated by commas

Output:

A list/array (or stdout)
Each entry is left padded with spaces so that the actual or implied decimal marks align
No trailing whitespace

This is code-golf, so shortest code wins.

Update:
This first attempt has turned into a valuable learning experience: always use the sandbox.

My first version was overly complicated, and I trimmed it down a lot before actually posting.
I simplified it again in response to the quite valid comments that soon arrived.
Unfortunately, the resulting question ended up too simple (effectively a duplicate of the question that I said wasn't), with most of the description of the input becoming irrelevant.
Somewhere in there I managed to lose the original intent, which was to process only what are valid numbers while leaving other strings
alone.
(The idea came from a function in an existing program that does just that, its purpose being to turn all strings into something that will look good if everything is printed left-justified.)

When posing a problem, take more time to think it through, and as I said: always use the sandbox.

05AB1E, 19 18 15 10 bytes
Code:
'.©«®δkZαú

Try it online! Explanation:
'.©«             # append . to each element
    ®δk          # Find index of . for all elements
       Z         # Get the largest
        α        # Get the absolute difference between the indices
         ú       # Pad by that much


Sort an Integer List The Challenge

It's quite simple really, sort a list of numbers.

Details

You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. list.sort() in Python).

Input/output can be done in any method you choose, as long as it is human readable.

Standard loopholes are disallowed as always.

Shortest code in bytes wins.

You must explain/list what sort method you used (Bubble, Insertion, Selection, etc.)

Input will not contain duplicates.

Sample Input/Output

Input: 99,-2,53,4,67,55,23,43,88,-22,36,45

Output: -22,-2,4,23,36,43,45,53,55,67,88,99

Note: A near direct opposite of Sort a List of Numbers

05AB1E, 2 bytes
Code:
œß

Same algorithm as the Jelly answer. Computes all permutations of the input and pops out the smallest one.
Try it online!

A more efficient method is:
E[ß,Ž

Performs selection sort. Uses CP-1252 encoding.
Try it online!


A newly discovered number: bleen! "The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7."  --George Carlin

In this challenge, you will print all Integers, inclusive, within the given input range.  Print numbers ascending or descending according to their input order.  That is, for input [n1, n2], print ascending if n1 < n2, descending if n1 > n2.

Since bleen is now an Integer number it may be used as input.  It must also be included in the output, between 6 and 7 where applicable.  Also note that -bleen exists between -7 and -6.

Input

Two Integers [n1, n2] in the range [-10, 10], inclusive, via your programming language's input of choice.

(Input may also contain bleen and -bleen!)

Output

Print all Integers starting at n1 and ending with n2, including the newly discovered bleen between 6 and 7.  Output can be a range of character separated numbers in some form your language supports - that is, comma or space separated.  One trailing space of output is okay.

Examples

Input:  1 10
Output: 1 2 3 4 5 6 bleen 7 8 9 10

Input:  -9 -4
Output: -9 -8 -7 -bleen -6 -5 -4

Input:  -8 bleen
Output: -8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen

Input:  9 1
Output: 9 8 7 bleen 6 5 4 3 2 1

Input:  2 -bleen
Output: 2 1 0 -1 -2 -3 -4 -5 -6 -bleen

Input:  -bleen 0
Output: -bleen -6 -5 -4 -3 -2 -1 0

Input:  bleen bleen
Output: bleen

Input:  2 2
Output: 2

Additional notes

You may write a program or function and use any standard method of receiving input and providing output.

You may use any programming language, but standard loopholes are not allowed.

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

Python 3, 132 130 bytes

r=round
bleen=6.1
m=1.08
a,b=eval(input())
d=1-2*(a>b)
print(*[[r(i/m),"-bleen"[i>0:]][i*i==49]for i in range(r(m*a),d+r(m*b),d)])

Takes input in the following example format:

-8, bleen


Disappearing Elements Given a string S and a list of indices X, modify S by removing the element at each index of S while using that result as the new value of S.

For example, given S = 'codegolf' and X = [1, 4, 4, 0, 2],

0 1 2 3 4 5 6 7  |
c o d e g o l f  |  Remove 1
c d e g o l f    |  Remove 4
c d e g l f      |  Remove 4
c d e g f        |  Remove 0
d e g f          |  Remove 2
d e f

Your task is to perform this process, collect the values of S after each operation, and display each on a newline in order. The final answer would be

S = 'codegolf'
X = [1, 4, 4, 0, 2]

Answer:

codegolf
cdegolf
cdeglf
cdegf
degf
def

This is code-golf so make your code as short as possible.
You may assume that the values in X are always valid indices for S, and you may use either 0-based or 1-based indexing.
The string will only contain [A-Za-z0-9]
Either S or x may by empty. If S is empty, it follows that x must also be empty.
You may also take S as a list of characters instead of a string.
You may either print the output or return a list of strings. Leading and trailing whitespace is acceptable. Any form of output is fine as long as it is easily readable.

Test Cases

S = 'abc', x = [0]
'abc'
'bc'

S = 'abc', x = []
'abc'

S = 'abc', x = [2, 0, 0]
'abc'
'ab'
'b'
''

S = '', x = []
''

S = 'codegolfing', x = [10, 9, 8, 3, 2, 1, 0]
'codegolfing'
'codegolfin'
'codegolfi'
'codegolf'
'codgolf'
'cogolf'
'cgolf'
'golf'

JavaScript (ES6), 57 50 48 45 42 bytes
Takes the string as an array of individual characters, outputs an array containing a comma separated string of the original followed by a subarray of comma separated strings for each step.
s=>a=>[s+"",a.map(x=>s.splice(x,1)&&s+"")]

3 bytes saved thanks to Arnauld
suggesting I abuse the loose output spec more than I already was, which led me to abusing it even more for another 3 byte saving.

Test it

o.innerText=JSON.stringify((f=

s=>a=>[s+"",a.map(x=>s.splice(x,1)&&s+"")]

)([...i.value="codegolf"])(j.value=[1,4,4,0,2]));oninput=_=>o.innerText=JSON.stringify(f([...i.value])(j.value.split`,`))
label,input{font-family:sans-serif;font-size:14px;height:20px;line-height:20px;vertical-align:middle}input{margin:0 5px 0 0;width:100px;}
<label for=i>String: </label><input id=i><label for=j>Indices: </label><input id=j><pre id=o>

Explanation
We take the two inputs via parameters s (the string array) and a (the integer array) in currying syntax, meaning we call the function with f(s)(a).
We build a new array and start it off with the original s. However, as the splice method we'll be using later on modifies an array, we need to make a copy of it, which we can do by converting it to a string (simply append an empty string).
To generate the subarray, we map over the integer array a (where x is the current integer) and, for each element, we splice 1 element from s, beginning at index x. We return the modified s, again making a copy of it by converting it to a string.


Basic Typescript Types Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types:

string
number
boolean
undefined
null

And two "meta" types:

any
never

The type any annotates that any type is valid:
const a: any = "foo";
const b: any = 42;
const c: any = true;
const d: any = undefined;

Whereas never annotates that no type is valid:
const e: never = <no valid literal assignment possible>;

We'll also consider two compositions of types: unions and intersections, annotated as | and & respectively.
A union type expects either one or the other type:
const f: string | number = "foo";
const g: string | number = 42;

While an intersection creates a combination of both types:
const h: string & any = "foo";
const i: string & any = 42;
const j: string & number = <no valid literal assignment possible>;

The order of operands within unions and intersections doesn't matter, string | number is equal to number | string.
The challenge
Given one of the above type declarations, return the resulting resolved type. The input will be one of the following:

a basic type as listed above or;
a meta type as listed above or;
a union of two basic and/or meta types or;
an intersection of two basic and/or meta types.

Examples
// All basic and meta types simply map to themselves
string → string
number → number
any → any
never → never

// Unions between basic types create unions except with themselves
string | number → string | number
string | undefined → string | undefined
string | string → string

// Intersections between basic types create never except with themselves
string & number → never
string & undefined → never
string & string → string

// Unions with any create any
any | string → any
any | never → any

// Intersections with any result in any except with never
any & string → any
any & number → any
any & never → never

// Unions with never yield the other half
never | string → string
never | any → any
never | never → never

// Intersections with never return never
never & string → never
never & any → never
never & never → never

A good way to get a feel for the types is to try out the Typescript playground.
Any reasonable and consistent input-output format, standard loop holes, code-golf.

Python 3, 261 bytes

lambda x,o="&",y="":("any"in x+y)*(o<"|")*-~-("never"in x+y)*"any"or(lambda r:r==31and"any"or"|".join("ubsnnnotuudormleliblfene iagr nn   e    d"[i::5]for i in range(5)if r&2**i)or"never")(eval(o.join(str(min(31,2**"dormlyv".find(k[2])%64))for k in[x,y or x])))

Try it online!
-1 byet thanks to ovs


Wargame Tank Simulation Some of you may have heard of the Wargame series of computer based real time strategy game.  These games pit teams of players with primarily cold war era units to see how a hot cold war would have played out.  The goal of this challenge is to simulate a tank battle in these games.

Input

Two "tanks" (one red and one blue) will be entered into your program or function.  Each tank is classified by a rate of fire, accuracy, armor value, and attack power value.

Challenge

From the inputs above, simulate the two tanks fighting.  You will do this by having each tank fire according to its rate of fire.  If it hits (randomly determined by accuracy), a tank will do damage according to the armor value of its target and its own attack power.  The formula for damage is floor[(attackpower - armor)/2].  Therefore a tank with 10 attack power against a tank with 5 armor would do 2 damage.

Tank crews also have morale, which follows the following rule

There are four possible morale values; calm, worried, scared, and panicked. Tanks always start calm.  These names do not need to be in your code, in the sample below I've used calm = 1, worried = 2, etc.
Each morale value reduces the accuracy as follows: Calm -> 100% (no change), worried -> 75%, scared -> 50%, panicked -> 25%.   Therefore a panicked tank which normally has 60% accuracy now has 0.25 * 0.6 = 15% accuracy
Each hit by the opposing tank degrades morale by one level, each miss upgrades the morale by one level.

For example:

morale: calm  |  worried  |  calm  |  worried  |  scared
hit:         hit         miss     hit         hit

Rules:

Input should be two parameters to repesent each tank (I've used two tuples in the example below). Inputs may be provided in any order, just be sure to state which one is which. Input may be provided by user input via STDIN, read from a file, or parameters passed to a function call.
Each tank starts with 10 health.
Rate of fire will either be 8.5, 7.5, 6.5, 6, 5, or 3 seconds between shots.
Tanks start loaded, so each fires at time = 0.  Because Communists are sneaky, red fires first.
Accuracy must be randomly rolled.
Ineffective hits (hits which do no damage) have an effect on morale! (because it probably sounds terrifying)
Naturally since we want to see the action, output will be an update after each shot.  The update will contain the time of the shot, whom it was made by (red or blue), health of both tanks, and the morale of both tank crews.  Output maybe be presented in any format so long as it contains all of the required information in a human readable fashion (items must be delimited in some way).  Similar to input, please describe your output format in the answer.
Engagements are limited to 100 seconds. If you play the game you know this is because a plane has swooped in by then.  For our purposes if both tanks are alive at this point, it is a draw.
After one tank reaches 0 health (or after 100 seconds), print which tank is victorious ("Red" or "Blue") or "Draw" if appropriate.  I don't care about  trailing whitespace or newlines.
Printing output may be printing to STDOUT or writing to a file
Shortest answer in bytes wins

Sample Python Implementation

This is a little sample I worked up to demonstrate some of the methodology.  It takes the two tanks as tuples to the main() function, then outputs a nice little table.  Your output does not need to be so fancy.  For the curious, it's 1,930 bytes.  You can do better.

Sample Tanks:

Some tanks to use for you, the numbers are ROF, accuracy, armor, and power.

T-72A: 8.5, 45%, 12, 16
T-72BU: 8.5, 55%, 22, 23
T-80: 7.5, 40%, 14, 16
T-80U: 7.5, 60%, 20, 23
M1 Abrams: 7.5, 55%, 16, 18
M1A2 Abrams: 7.5, 60%, 22, 24
Leclerc: 6, 65%, 20, 20
STRV-103D: 5, 60%, 18, 16
Zhalo (I know, not a tank): 3, 60%, 2, 18

Python 3, 465
Saved 8 bytes thanks to wnnmaw.
Saved 34 bytes thanks to DSM.
Expects tanks as lists as follows, [Rate of Fire, Accuracy, Armor, Attack]
from random import*
def f(r,b):
 r+=10,1;b+=10,1
 for x in range(200):
  if r[4]<1:return"Blue"
  if b[4]<1:return"Red"
  if x%int(r[0]*2)<1:
   if random()>=(r[1]*r[5]):b[4]-=(r[3]-b[2])//2;b[5]-=(b[5]!=0.25)/4
   else:b[5]+=(b[5]<1)/4
   print('r,%f,%d,%f,%d,%f'%(x/2,*r[4:],*b[4:]))
  if x%int(b[0]*2)<1:
   if random()>=(b[1]*b[5]):r[4]-=(b[3]-r[2])//2;r[5]-=(r[5]!=0.25)/4
   else:r[5]+=(r[5]<1)/4
   print('b,%f,%d,%f,%d,%f'%(x/2,*r[4:],*b[4:]))
 return"Draw"

Prints the output as Attacker,TimeOfShot,RedHealth,RedMorale,BlueHealth,BlueMorale. Morale is represented as a float.


Knights and Knaves and Codes In this challenge, your bot has landed on an island with the stereotypical knights and knaves. Knights always tell the truth, and knaves always lie. The objective is to find the correct 32 digit hexadecimal string before anyone else, by asking knights and knaves and trying to trick other bots into giving you answers or accepting fake ones.
Knights and Knaves
Every bot will be given an array of 48 people, who are the same for all bots. The bots do not know whether any one person is a knight or knave. Each person is assigned two characters of the 32 digit string. Exactly half of all people are knights, and half are knaves: a knight will always give you the correct characters and their indexes within the result string; a knave, however, will give an incorrect character each time along with the correct index. These incorrect characters will always be the same for any one bot, so a knave is indistinguishable from a knight without outside help or some deductive skills. Every character of the string is known by exactly three people, and no person has the same character twice.
Interacting
In order to find knaves, bots can interact with one another. One bot will request help from another for a specific character of the string, and the second bot can return any character. It is up to the first bot to decide if this character is real or fake, likely by asking for more help and comparing the results.
In order to prevent help-vampire bots, no bot can have more outgoing help requests than twice the number of incoming requests it has answered, plus four.
Bots
Every bot is assigned a random Unique ID (UID) number each round. This number is used to communicate with other bots, and ranges from 0 to one less than the number of bots. It can request help from another bot using the function sendRequest(uid, index), and read from responses with readResponses(), which is formatted as an array/list of objects containing uid, index, and char properties.
Additionally, a bot can view the requests sent to it using viewRequests(). Each request is an object containing two properties: index, and uid. To reply to a request, use the function replyRequest(uid, index, char). There must be a request in viewRequests() from that UID asking about the index specified in order for this to work, and char must be a hexadecimal character.
Both sendRequest and replyRequest will output false if something is invalid (UID for sendRequest, and no request to reply to for replyRequest), and true otherwise.
The bot will receive three arguments as input to its function. The first is an array/list of each knight/knave, with each one represented as an array/list of two objects (index and char are their properties).
The second argument is the number of bots. UIDs range from zero to one less than this number. Finally, the third argument is an empty object, which the bot can use to store any information it needs.
Rules

The bot can be programmed in JavaScript (heavily recommended), Python, or any language with functions, strings, numbers, arrays/lists, and objects/dictionaries/hash maps
All bots will be converted to JavaScript to be run in the controller
A bot may not read or modify any variables outside of its function arguments and local/function scoped variables it creates
A bot may not execute any functions declared outside its scope, aside from the four interaction functions (sendRequest, readResponses, viewRequest, and replyRequest)
Your bot's guess is submitted by return value. If it does not know, it can return null/false/undefined, or a random guess. Each bot has a win count. If multiple bots guess correctly in the same turn, this increments by 1/correctGuesses
Standard Loopholes are prohibited, per the usual
Controller, Chatroom
By the way, this is not a dupe. The other questions based around knights and knaves have a very different objective, they are just similar in their topic

Zero Information Bot
function ZeroInformationBot(people, bots, data) {
    if (!data) {
        data = {
            botData: [],
            knaves: [],
            guess: "",
            newKnaves: false,
            attestations: Array(36).fill(0),
            threshold: -5,
        };
    }
    let newResponses = [];
    readResponses().forEach(res => {
        if (!data.botData[res.uid][res.index]){
            newResponses.push(res);
            data.botData[res.uid][res.index] = res.char;
        }
    });
    newResponses.forEach(res => {
        if (people.find(p => (p[0].index == res.index && p[0].char == res.char) || (p[1].index == res.index && p[1].char == res.char))){
            people.forEach((p, i) => {
                if ((p[0].index == res.index && p[0].char == res.char) || (p[1].index == res.index && p[1].char == res.char)) data.attestations[i] += 2;
                if ((p[0].index == res.index && p[0].char != res.char) || (p[1].index == res.index && p[1].char != res.char)) data.attestations[i] -= 1;
                if (data.attestations[i] < -1 && !data.knaves.find(i)) {
                    data.knaves.push(i);
                    data.newKnaves = true;
                }
            });
        }
    });
    viewRequests().forEach(req => {
        if (!data.botData[req.uid]){
            data.botData[req.uid] = Array(36).fill([]);
        } else if (!data.botData[req.uid][req.index]) {
            sendRequest(req.uid, req.index);
            data.botData[req.index] = "-"
        } else if (data.botData[req.uid][req.index] != "-") {
            replyRequest(req.uid, req.index, data.botData[req.uid][req.index]);
        }
    });
    if (!data.newKnaves && data.guess) return data.guess;
    data.newKnaves = false;
    let detected = true;
    let loop = false;
    let possibilities;
    while (detected){
        detected = false;
        possibilities = Array(36).fill(new Set());
        let examined = [], chargroups = [];
        people.forEach((p, i) => {
            if (data.knaves.find(i)) return;
            possibilities[p[0].index].add(p[0].char);
            possibilities[p[1].index].add(p[1].char);
            let first = examined.find(e => e.index == p[0].index && e.char == p[0].char);
            let second = examined.find(e => e.index == p[1].index && e.char == p[1].char);
            if (first && !second){
                chargroups[first.group].push(p[1]);
                examined.push({index: p[1].index, char: p[1].char, group: first.group});
            } else if (!first && second){
                chargroups[second.group].push(p[0]);
                examined.push({index: p[0].index, char: p[0].char, group: second.group});
            } else if (!first && !second){
                examined.push({index: p[0].index, char: p[0].char, group: chargroups.length});
                examined.push({index: p[1].index, char: p[1].char, group: chargroups.length});
                chargroups.push(p);
            } else if (first && second && first.group != second.group){
                chargroups[first.group].push(...chargroups[second.group]);
                examined = examined.map(e => {
                    if (e.group == second.group) e.group = first.group;
                    return e;
                });
                chargroups.splice(second.group, 1);
            }
        });
        possibilities.forEach((p, i) => {
            if (p.size == 1) {
                let char = Array.from(p)[0];
                chargroups.forEach(c => {
                    if (c.find(ch => ch.index == i && ch.char != char)) {
                        people.forEach((person, j) => {
                            if (data.knaves.find(j)) return;
                            // We don't need to check both characters; if one's in the group they both are.
                            if (c.find(ch => ch.index == person[0].index && ch.char == person[0].char)) {
                                data.knaves.push(j);
                                detected = true;
                            }
                        });
                    }
                });
            } else if (p.size == 0) {
                // Uh oh... need to reset.
                data.knaves = [];
                data.attestations.forEach((a, i) => {
                    if (a <= data.threshold) data.knaves.push(i);
                });
                detected = true;
                // Don't get stuck in a loop.
                if (loop) data.threshold--;
                loop = true;
            }
        });
    }
    data.guess = possibilities.map(p => Array.from(p)[0]).join("");
    return data.guess;
}

This bot lets out exactly zero information.  Whenever it's asked about something, it responds by first asking what that bot thinks, and then it replies with that data.
It counts up the number of times that other bots have given it one of the values of one of the people, and uses that to give a rough confidence score to each person, tentatively marking someone as a knave if they hit -2.  If it hits a paradox, it resets who it's considering as a knave, but only automatically re-marks someone as a knave if they have a score of -5 or worse.
Because this bot doesn't aggressively attempt to solve, it's quite possible it'll get stuck on one or two people for a long time; I'm interested in how well it will do.  I haven't tested it yet, as it seems the controller is still (slightly) in flux.


Chess960 position generator Context

  Chess960 (or Fischer Random Chess) is a variant of chess invented and advocated by former World Chess Champion Bobby Fischer, publicly announced on June 19, 1996 in Buenos Aires, Argentina. It employs the same board and pieces as standard chess; however, the starting position of the pieces on the players' home ranks is randomized

Rules

  White pawns are placed on the second rank as in standard chess
  All remaining white pieces are placed randomly on the first rank
  The bishops must be placed on opposite-color squares
  The king must be placed on a square between the rooks.
  Black's pieces are placed equal-and-opposite to White's pieces.

From: http://en.wikipedia.org/wiki/Chess960

For all the people that would like to post answers...

you have to make a Chess960 positions generator, capable of randomly generate one of the 960 positions following the rules described above (it has to be capable of outputting any of the 960, hardcoding one position is not accepted!), and you only need to output the white rank one pieces.

Example output:

rkrbnnbq

where:

k king
q queen
b bishop
n knight
r rook

This will be code golf, and the tie breaker will be the upvotes.

Ruby 1.9, 67 65 characters
Ah, the old "keep randomizing until you generate something valid" technique...
$_=%w(r r n n b b q k).shuffle*''until/r.*k.*r/&&/b(..)*b/
$><<$_

(In Ruby 2.0, %w(r r n n b b q k) could be 'rrnnbbqk'.chars)


Generate all 4-perfect numbers Your program or function should output all the 36 4-perfect numbers in increasing order  separated by newlines.
An n positive integer is a k-perfect number (multiply perfect number) if the sum of its divisors including itself (i.e. the sigma function of n) equals k*n.
For example 120 is a 3-perfect number because 1 + 2 + 3 + 4 + 5 + 6 + 8 + 10 + 12 + 15 + 20 + 24 + 30 + 40 + 60 + 120 = 360 = 3*120.
Details

Your entry should actually produce the output and terminate on your machine before you submit your answer. (i.e. the program should terminate in a reasonable time)
Hardcoding is allowed.
Built-in functions or data closely related to the problem (e.g. sigma function) are disallowed.
This is code-golf but as the task is non-trivial without major
hardcoding non-golfed entries are welcomed too.

(This is a great detailed page about the history of all multiply perfect numbers.)

Prime factorization (Ruby ,570 542 bytes)

Rev 0

Below is a table of the prime factorizations of the 36 required numbers (copied from Wolfram, hopefully with no errors.) Only 31 prime factors are involved if I have counted correctly, and some of these always occur together, for example 137*547*1093 and 683*2731*8191.

It should be possible to condense the information in the table, or perhaps even employ a search strategy. This should beat simply compressing the numbers.

Unfortunately the numbers are too big even for a 128-bit integer, which means I can't use C. Ruby and Python do support arbitrary precision integers. I have put the table in valid Ruby syntax, which makes it my first ever Ruby program!

puts 2**5  *3**3  *5    *7
puts 2**3  *3**2  *5    *7           *13
puts 2**2  *3**2  *5    *7**2        *13      *19
puts 2**9  *3**3  *5          *11                         *31
puts 2**7  *3**3  *5**2                  *17              *31
puts 2**9  *3**2        *7    *11    *13                  *31
puts 2**8  *3     *5    *7                    *19             *37       *73
puts 2**10 *3**3  *5**2                               *23 *31                 *89
puts 2**13 *3**3  *5          *11                                 *43                 *127
puts 2**14 *3     *5    *7                    *19         *31                                   *151
puts 2**13 *3**2        *7    *11    *13                          *43                 *127
puts 2**5  *3**4        *7**2 *11**2          *19**2                                  *127
puts 2**8  *3**2        *7**2        *13      *19**2          *37       *73           *127
puts 2**7  *3**10 *5                     *17          *23                        *107                                               *3851
puts 2**7  *3**6  *5                     *17          *23                                  *137           *547           *1093
puts 2**14 *3**2        *7**2        *13      *19**2      *31                         *127      *151
puts 2**5  *3**4        *7**2 *11**2          *19**4                                            *151                *911
puts 2**9  *3**4        *7    *11**3                      *31**2     *61    *83                      *331
puts 2**8  *3**2        *7**2        *13      *19**4            *37     *73                     *151                *911
puts 2**25 *3**3  *5**2                       *19         *31                                                  *683            *2731       *8191
puts 2**17 *3**10       *7                    *19**2  *23       *37     *73      *107 *127                                           *3851
puts 2**17 *3**6        *7                    *19**2  *23       *37     *73           *127 *137           *547           *1093
puts 2**25 *3**4        *7    *11**2          *19**2                                  *127                     *683            *2731       *8191
puts 2**25 *3**5        *7**2        *13      *19**2                                  *127                     *683            *2731       *8191
puts 2**17 *3**10       *7                    *19**4  *23       *37     *73      *107           *151                *911             *3851
puts 2**25 *3**10 *5                          *19     *23                        *107                          *683            *2731 *3851 *8191
puts 2**17 *3**6        *7                    *19**4  *23       *37     *73                *137 *151      *547      *911 *1093
puts 2**25 *3**6  *5                          *19     *23                                  *137           *547 *683      *1093 *2731       *8191
puts 2**25 *3**4        *7    *11**2          *19**4                                            *151           *683 *911       *2731       *8191
puts 2**25 *3**5        *7**2        *13      *19**4                                            *151           *683 *911       *2731       *8191
puts 2**33 *3**4        *7    *11**3                      *31        *61    *83                      *331                                        *43691 *131071
puts 2**33 *3**10       *7    *11                     *23                   *83  *107                *331                      *3851             *43691 *131071
puts 2**33 *3**6        *7    *11                     *23                   *83            *137      *331 *547           *1093                   *43691 *131071
puts 2**37 *3**4        *7    *11**3                      *31        *61    *83                      *331                                        *43691        *174763*524287
puts 2**37 *3**10       *7    *11                     *23                   *83  *107                *331                      *3851             *43691        *174763*524287
puts 2**37 *3**6        *7    *11                     *23                   *83            *137      *331 *547           *1093                   *43691        *174763*524287

Rev 1
Just starting to gather some terms.

#683*2731*8191=15278451143, 137*547*1093=81908327, 107*3851=412057, 174763*524287=91625968981, 19**2*151*911=49659521, 83*331=27473, 11**3*31*61=2516921,37*73=2701,19*19=361

puts 2**5  *3**3  *5       *7
puts 2**3  *3**2  *5       *7           *13
puts 2**2  *3**2  *5       *7**2        *13      *19
puts 2**9  *3**3  *5             *11                         *31
puts 2**7  *3**3  *5**2                     *17              *31
puts 2**9  *3**2           *7    *11    *13                  *31
puts 2**8  *3     *5       *7                    *19                *2701
puts 2**10 *3**3  *5**2                                  *23 *31                 *89
puts 2**13 *3**3  *5             *11                                 *43                 *127
puts 2**14 *3     *5       *7                    *19         *31                               *151
puts 2**13 *3**2           *7    *11    *13                          *43                 *127
puts 2**5  *3**4           *7**2 *11**2          *19**2                                  *127
puts 2**8  *3**2           *7**2        *13      *19**2            *2701                 *127
puts 2**7  *3**10 *5                        *17          *23                                                                           *412057
puts 2**7  *3**6  *5                        *17          *23                                                                *81908327
puts 2**14 *3**2           *7**2        *13      *19**2      *31                         *127  *151
puts 2**5  *3**4           *7**2 *11**2          *19**2                                            *49659521
puts 2**9  *3**4           *7                                *31    *2516921  *27473
puts 2**8  *3**2           *7**2        *13      *19**2            *2701                           *49659521
puts 2**25 *3**3  *5**2                          *19         *31                                                            *15278451143
puts 2**17 *3**10          *7                    *19**2  *23       *2701                 *127                                           *412057
puts 2**17 *3**6           *7                    *19**2  *23       *2701                 *127                               *81908327
puts 2**25 *3**4           *7    *11**2          *19**2                                  *127                                                   *15278451143
puts 2**25 *3**5           *7**2        *13      *19**2                                  *127                                                   *15278451143
puts 2**17 *3**10          *7                    *19**2  *23       *2701                           *49659521                            *412057
puts 2**25 *3**10 *5                             *19     *23                                                                            *412057 *15278451143
puts 2**17 *3**6           *7                    *19**2  *23       *2701                           *49659521                *81908327
puts 2**25 *3**6  *5                             *19     *23                                                                *81908327           *15278451143
puts 2**25 *3**4           *7    *11**2          *19**2                                            *49659521                                    *15278451143
puts 2**25 *3**5           *7**2        *13      *19**2                                            *49659521                                    *15278451143
puts 2**33 *3**4           *7                                       *2516921   *27473                                                               *43691 *131071
puts 2**33 *3**10          *7    *11                     *23                   *27473                                             *412057           *43691 *131071
puts 2**33 *3**6           *7    *11                     *23                   *27473                                       *81908327               *43691 *131071
puts 2**37 *3**4           *7                                       *2516921   *27473                                                               *43691        *91625968981
puts 2**37 *3**10          *7    *11                     *23                   *27473                                             *412057           *43691        *91625968981
puts 2**37 *3**6           *7    *11                     *23                   *27473                                       *81908327               *43691        *91625968981

Rev 2, 570  542 bytes (thanks to Martin for the improvement)

As this is my first Ruby program, I just stuck with the simple approach of continuing to gather terms. Compression of the numbers would be great if anyone knows how to do that.

I could save a few more bytes by evaluating some of the literal-only expressions in the variable assignment part, but I decided to leave them for clarity.

e=361
f=e*e*137561
g=27473
h=2516921
j=2701
k=81908327*729
m=412057*59049
n=15278451143*2**25
p=g*43691*2**33*7
q=131071
r=91625968981*16
s=127
t=1024
w=250240
x=1467648
y=7439488
puts [30240,32760,2178540,23569920,45532800,142990848,510720*j,t*42833475,t*510840*s,t*149417520,t*3099096*s,15367968*e*s,x*e*j*s,w*m,w*k,t*429378768*e*s,15367968*f,8999424*g*h,x*j*f,n*397575,t*m*y*j*s,t*k*y*j*s,n*68607*e*s,n*154791*e*s,t*20608*j*f*m,2185*n*m,t*20608*j*f*k,2185*k*n,68607*f*n,154791*f*n,81*h*p*q,253*p*m*q,253*p*k*q,81*h*p*r,253*p*m*r,253*p*k*r]


f(g(x)) decreases while g(f(x)) increases For this challenge you need to implement two functions, f and g, on the integers, such that f ∘ g is a strictly decreasing function while g ∘ f is a strictly increasing function. In other words, if you take any two integers a < b, then f(g(a)) > f(g(b)) and g(f(a)) < g(f(b)). There are no restrictions on f and g individually, except that they must each map one integer to another integer.
Please include a short description of f and g and an argument for why they have the required property.
Credit: This challenge was inspired by a problem in the 2011 Romanian Master of Mathematics competition (which asks the same thing but on the real numbers, instead of integers). If you really want spoilers, you now know what to search for.
Rules

The word "function" in this challenge should be taken in the mathematical sense of mapping one integer to another: you may either write two programs or two functions and use any of the standard methods of receiving input and providing output, as usual. You may use string representations of integers instead of actual integer variables, but the types of input and output should be identical, so that the functions can be composed without manually converting types in between. Remember that conceptually, f and g still need to be functions on ℤ, so you can't cheat by using two different string representations of the same number or anything like that.

Remember that functions may be unnamed, as long as their name isn't needed by itself or another function you define. If you do name one or both of the functions, you may assume that they exist in the same program, so that they may refer to each other in their implementation (e.g def f(x): return -g(x) in Python).

The usual integer overflow rules apply: your solution must be able to work for arbitrarily large integers in a hypothetical (or perhaps real) version of your language in which all integers are unbounded by default, but if your program fails in practice due to the implementation not supporting integers that large, that doesn't invalidate the solution.

You may use any programming language, but note that these loopholes are forbidden by default.

This is code-golf, so your score is the sum of the number of bytes of both functions and the shortest valid answer wins.

Python, 68 characters
f=lambda x:(1-x%2*2)*(2*x*x+(x<0))
g=lambda x:(1-x%2*2)*(2*x*x+(x>0))

f maps negative numbers to odd numbers and positive numbers to even numbers, and even numbers to positive numbers and odd numbers to negative numbers, with the output magnitude increasing strictly with the input magnitude.
g does the same, except it maps negative numbers to even numbers and positive numbers to odd numbers.
f ∘ g maps negative → even → positive and positive → odd → negative.
g ∘ f maps negative → odd → negative and positive → even → positive.
Therefore f and g have the desired properties.


Make the biggest and smallest numbers Inspired by this post over on Puzzling. Spoilers for that puzzle are below.

Given three positive integers as input, (x, y, z), construct the inclusive range [x, y], concatenate that range together, then remove z not-necessarily-consecutive digits to produce the largest and smallest positive integers possible. Leading zeros are not permitted (i.e., the numbers must start with [1-9]). Output those two numbers in either order.

For the example from the Puzzling post, for input (1, 100, 100), the largest number possible is 99999785960616263646566676869707172737475767778798081828384858687888990919293949596979899100,
and the smallest number is 10000012340616263646566676869707172737475767778798081828384858687888990919293949596979899100,
following the below logic from jafe's answer posted there:

We can't influence the number's length (there's a fixed number of digits), so to maximize the value we take the maximal first digit, then second digit etc.
Remove the 84 first non-nines (16 digits left to remove):
999995051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
The largest number within the next 17 digits is 7, so from here, the next digit in the answer can be at most 7 (we can't remove more than 16 digits). So remove 15 non-7's... (1 digit left to remove): 999997585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
From here, the next digit can be at most 8 so remove one non-8 from the middle: 99999785960616263646566676869707172737475767778798081828384858687888990919293949596979899100
Similar logic, but reversed (i.e., we want leading 1s instead of leading 9s) for the smallest number.

Here's a smaller example: (1, 10, 5).

We construct the range 12345678910 and determine which 5 digits we can remove leaving the largest possible number. Obviously, that means we want to maximize the leading digit, since we can't influence the length of the output. So, if we remove 12345, we're left with 678910, and that's the largest we can make. Making the smallest is a little bit trickier, since we can pluck out numbers from the middle instead, leaving 123410 as the smallest possible.

For (20, 25, 11), the result is rather boring, as 5 and 1.

Finally, to rule out answers that try leading zeros, (9, 11, 3) gives 91011 which in turn yields 91 and 10 as the largest and smallest.

I/O and Rules

If it's easier/shorter, you can code two programs/functions -- one for the largest and one for the smallest -- in which case your score is the sum of both parts.
The input and output can be given by any convenient method.
The input can be assumed to fit in your language's native number type, however, neither the concatenated number nor the output can be assumed to do so.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Haskell, 162 bytes

l=length
((m,f)%n)s|n>=l s=[]|n>0,(p,c:r)<-span(/=m(f$take(n+1)s))s=c:((m,id)%(n-l p)$r)|1>0=s
(x#y)z=[p%z$show=<<[x..y]|p<-[(maximum,id),(minimum,filter(>'0'))]]

Try it online!

Uses the algorithm described by jafe. Might be shorter to use a less efficient method, but this was more fun to write :)

The % operation takes 4 arguments (actually 3, but whatever): m which is a function that selects the "optimal" member from a list (either maximum or minimum depending on what we want); f which is a "filter" function; n the number of digits left to drop; and s the string. First we check whether n is equal to the number of digits left in the string (I used >= for safety) and drop the rest of s if so. Otherwise we check if we still need to drop digits (n>0), then we use span to break our string into three pieces: p the digits to drop, c the optimal reachable digit, and r the remaining string. We do this by passing span a predicate that checks for equality against our optimal digit. To find that digit we take the first n+1 digits of the string, filter it, then pass it to our "chooser" function. Now we just yield our optimal digit and recur, subtracting the length of p (the number of digits dropped) from n. Notice that we do not pass our filtering function to the recursive call, and, instead, we replace it with id. That's because the filter is only there to avoid selecting leading 0s in the minimum case which is only relevant on the first iteration. After that we no longer need any filter.

% is really only a helper function for # which is our "real" function, taking x, y, and z. We use a list comprehension just to avoid a bit of repetition, iterating over our function tuples and passing them to % along with z and the concatenated string. That string is created using the magic monad operator (=<<) which, in this context, works like concatMap.


Pick the longest stick You are a young programming geek living with your 2 other best friends. Every week, one of you has to do all the chores of the house and you decide whose turn it is by picking a stick. The one who picks the shortest stick loses and does all the chores.

As all of you are programmers and love creating puzzles, you have modified the "Pick the shortest stick" into a computer puzzle.

Here are the rules of the puzzle.

You will be given a 2D matrix, where each column represents a stick.
In each column, 1 represents a portion of the stick and 0 is an empty space
When going from top to bottom in each column, initially you have 0's and as soon as you hit a 1, the stick has started and rest of the column will be filled with 1 only
You can write your program to pick one column. The size of the stick in that column determines the winner/loser. Size of stick == number of 1s in that column.
However, that program can only have a linear worst-case time complexity.

As all of you are programmers, you will know if someone else's program is shooting the time complexity limit.

Your job is to:

Write a program or function that accepts input in either a 2D format or array of strings.
Input can be taken from STDIN/prompt/console or a function argument.
If you are reading the input from STDIN/prompt then you can assume that the reading of input and converting it to an array takes 0 time (even though the code to do so has to be there in your answer)
Determine the column with the longest stick in it.
Output can be the function's return value or to STDOUT/console/alert.
The program/function must have linear worst-case time complexity, O(m+n) where m is the number of rows and n the number of columns.

Input can be either one of the following formats:

2D array:

[ [0, 0, 0, 0],
  [1, 0, 0, 0],
  [1, 1, 0, 1],
  [1, 1, 1, 1] ]

Array of Strings:

[ "0000", "1000", "1101", "1111" ]

The input will have following properties:

Size of the array is unknown, assume a rectangle of any size
In any column, coming top down, if you see a 1, then everything below will be a one
Empty-columns (i.e. 0-length) sticks are allowed.

This is a code-golf so shortest code wins!*

Please explain your code, or give the ungolfed version (to verify time complexity) along with which of the two input formats you expect.

UPDATE
Linear time complexity here means O(n+m) where n is column size and m is row size. (For those who were unclear)

UPDATE 2  This definitely can be done in linear time. And if you are posting an answer, feel free to delay posting the logic/algorithm by a couple of days for a fair fight :)

UPDATE 3 I'll go over all answers in couple of hours to validate time complexity and the program :)

Ruby, 83 75 68 66 63 bytes

f=->m{m[b=c=i=0].map{(c=i;b-=1)while(r=m[b-2])&&r[i]>0;i+=1};c}

Defines a function f which takes the 2D array form as input.

   I'm starting at the bottom left, keeping track of maximum stick length (actually, minus that) and the corresponding column. In each column, if there are still 1s above the previous maximum stick length, I walk up the stick to the end and remember the new maximum length and column. That means that I'm iterating once along the columns and at most once along the rows (specifically I'm iterating as far as the maximum stick length), which is precisely O(m+n).


Shortest path for a chess knight Your program should compute the number of moves it takes a chess knight to reach each square of the chess board.  The input will be two space-separated integers representing coordinates of the starting square (horizontal then vertical coordinate, 0-7 inclusive each).  Your program should output a number grid containing the minimum number of moves a chess knight needs to make to reach each square.

examples

input

0 0

output

03232345
34123434
21432345
32323434
23234345
34343454
43434545
54545456

input

3 1

output

21232123
32303232
21232123
34121432
23232323
32323234
43434343
34343434

Shortest code wins.

APL (Dyalog Classic), 55 bytes

{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8

{⍵⌊d⍴1+⌊/¨⌷∘⍵¨¨a/⍨¨Ö↓2=×/↑|∘.-⍨a←,⍳d}⍣≡0@(⊂⌽⎕)⊢9⍴⍨d←8 8
                                       0@(⊂⌽⎕)⊢9⍴⍨d←8 8 ⍝ create an 8x8 grid of 9s with a 0 at the start position
                           ∘.-⍨a←,⍳d                    ⍝ all differences between coordinates
                     2=×/↑|                             ⍝ is 2 equal to the product of the absolute values?
               a/⍨¨Ö↓                                   ⍝ filter where true (finds knight moves)
          ⌷∘⍵¨¨                                         ⍝ index into the board
     1+⌊/¨                                              ⍝ 1 plus the minimum (finds minimum distance)
   d⍴                                                   ⍝ 8x8 reshape
 ⍵⌊                                                     ⍝ the minimum of the new and old moves
{                                   }⍣≡                 ⍝ apply until converged (minimum distances found)

Try it online!


Illiteral Prime numbers Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent.

Simple? Here's the twist:

You may not use literals in your program. These include:

Literal numbers (0 through 9)
Literal strings (in quotes)

You may not use built in prime checks

EDIT: A prime check is a built in function that

Returns if a number is a prime number
Returns a prime number
Returns a list of prime numbers

You may code your own functions that do the above

Prime factorisation functions are allowed

As this is code-golf, shortest answer in bytes wins

05AB1E, 7 6 bytes
Six byte solution
Since prime factorisation is now allowed, this is my six byte solution:
LDÒ€gÏ

Explanation:
L       # Create the list [1, ..., input]
 D      # Duplicate this list
  Ò     # Get the prime factorisation of each number
   €g   # Get the length of each prime factorisation (length 1 = prime)
     Ï  # Keep the numbers for which is the index is equal to 1

Uses CP-1252 encoding. Try it online!.

Previous solution
Uses Wilson's theorem. Code:
LÐ<!n%Ï

Explanation:
L        # Generate the list [1, ..., input].
 Ð       # Triplicate the list.
  <      # Decrement the last one by one.
   !     # Take the factorial.
    n    # Square each.
     %   # Modulo the list by [1, ..., input].
      Ï  # Take the values for which the indices are equal to 1.

Visual explanation for input n = 9:
 Command - Stack

L        # [1, 2, 3, 4, 5, 6, 7, 8, 9]
 Ð       # [1, 2, 3, 4, 5, 6, 7, 8, 9] × 3
  <      # [1, 2, 3, 4, 5, 6, 7, 8, 9] × 2, [0, 1, 2, 3, 4, 5, 6, 7, 8]
   !     # [1, 2, 3, 4, 5, 6, 7, 8, 9] × 2, [1, 1, 2, 6, 24, 120, 720, 5040, 40320]
    n    # [1, 2, 3, 4, 5, 6, 7, 8, 9] × 2, [1, 1, 4, 36, 576, 14400, 518400, 25401600, 1625702400]
     %   # [1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 1, 0, 1, 0, 1, 0, 0]

Which leaves us (using Ï):
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 1, 0, 1, 0, 1, 0, 0]

    2  3     5     7

Uses CP-1252 encoding. Try it online!.


An optimization version of the Hadamard problem First, some definitions.

A Hadamard matrix is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal.  The Hadamard conjecture proposes that a Hadamard matrix of order 4k exists for every positive integer k.

A circulant matrix is a special kind of matrix where each row vector is rotated one element to the right relative to the preceding row vector. That is the matrix is defined by its first row.

It is known that, except for 4 by 4 matrices, there are no circulant Hadamard matrices.

A matrix with m rows and n >= m columns is partial circulant, if it is the first m rows of some circulant matrix.

The task

For each even integer n starting at 2, output the size of the largest partial circulant matrix with +-1 entries and n columns that has the property that all its rows are mutually orthogonal.

Score

Your score is the highest n such that for all k <= n, no one else has posted a higher correct answer than you.  Clearly if you have all optimum answers then you will get the score for the highest n you post. However, even if your answer is not the optimum, you can still get the score if no one else can beat it.

Languages and libraries

You can use any available language and libraries you like. Where feasible, it would be good to be able to run your code so please include a full explanation for how to run/compile your code in Linux if at all possible.

Leading entries

64 by Mitch Schwartz in Python


Computers will never taste a refreshing cookie Inspired by github.com/JackToaster/Reassuring-Parable-Generator, in turn inspired by xkcd.com/1263. The possible words are derived from the reassuring.cfg of that repository.

Having a look at the reassuring.cfg (use the 12th commit) is suggested to see the grammar the output matches (The output is a list of all strings matching the grammar).

Task: Your program must output all 7968 case-sensitive lines of the exact text contained in the pastebin pastebin.com/2SNAJ1VH. A copy of the pastebin is saved in the Wayback Machine

Here is a sample of 33 motivating lines from the pastebin:

Computers can't enjoy a salad.
Computers can't enjoy a cake.
Computers can't enjoy a ice cream cone.
Computers can't enjoy a meal.
Computers can't enjoy a drink.
Computers can't enjoy a steak.
Computers can't enjoy a chicken dinner.
Computers can't enjoy a piece of cake.
Computers can't enjoy a piece of pie.
Computers can't enjoy a cookie.
Computers can't enjoy a sandwich.
Computers can't taste a salad.
Computers can't taste a cake.
Computers can't taste a ice cream cone.
Computers can't taste a meal.
Computers can't taste a drink.
Computers can't taste a steak.
Computers can't taste a chicken dinner.
Computers can't taste a piece of cake.
Computers can't taste a piece of pie.
Computers can't taste a cookie.
Computers can't taste a sandwich.
Computers can't experience eating a salad.
Computers can't experience eating a cake.
Computers can't experience eating a ice cream cone.
Computers can't experience eating a meal.
Computers can't experience eating a drink.
Computers can't experience eating a steak.
Computers can't experience eating a chicken dinner.
Computers can't experience eating a piece of cake.
Computers can't experience eating a piece of pie.
Computers can't experience eating a cookie.
Computers can't experience eating a sandwich.

Challenge rules:

The lines output may be ordered in any way you want, but all 7968 of them must be included.
The output should be as a single flat string, not as a list of strings.
Your program should accept no input or an empty unused input.
Your program may not fetch data from any online source.
A single trailing newline is optional.

This is code-golf, so shortest code wins.

Zsh, 765 bytes

This may be the first thing I’ve ever written in zsh, but it has the incredibly convenient feature of being able to convert arrays to brace expansions (though it’s not as convenient as it should be…).  Run with zsh -P (counted as +1 byte), which turns on RC_EXPAND_PARAM.

a=able\ to
b=" be $a"
d=wonderful
i=ing\ a
o=omputer
n="No c$o "
r=ever
p=capable\ of
u=will
w=$u\ n$r
x=experienc
e=(\ {{{enjoy,tast,$x'ing eat'}$i,tast$i\ {delicious,fresh,tasty,refreshing,$d}}\ {salad,cake,'ice cream cone',meal,drink,steak,chicken\ dinner,'piece of '{cake,pie},cookie,sandwich},{understand$i,{enjoy,$x}$i{,\ {beautiful,$d,{inspir,amaz}ing,superb}}}\ {son{net,g},poem,story,play,'piece of music'}}.)
f=(${e:s/cing/ce/:s/sting/ste/:s/ding/d/:s/ying/y})
l=($w won\'t$b {$w,n$r\ $u}{$b,' have the ability to'})
v=($l "won't $r$b")
k=({ca,wo}n\'t $l is{"n't ",\ un}$a)
c=(C$o\s A\ c$o)
printf %s\\n $c\ $k$f C$o's '$v$f $n{can,is\ $a,$u\ $r$b,"is $r going to",{can,$u}\ $r}$f{,} $c\ {is{\ in,"n't "}$p,"cannot $x"e}$e $n{{is,$u\ be}\ $p,"can $x"e}$e

Try it online!


Fun with Matching Braces The contest is to make a program or function that takes an arbitrary string
resembling source code and checks to see if the "braces" follow the basic rules for
brace matching. That is, the number of left braces and right braces have to match, and you
can't have a right brace without a corresponding prior left brace.

You may choose to use any "brace" among ( [ { <

Your program must output/return a true-y value or 'Y' if the input is legal and a false-y value or 'N' if the input is illegal.

Scoring

Your score is the number of bytes in your source minus bonuses.

Bonuses

-20 per each additional brace type handled among ( [ { <
-30 if you handle multiple brace types and don't allow mismatched braces like <(>)
-50 points if you handle /* */ or // comments (the same way C or Java does)
-20 points if you handle both types of comments
-50 if you ignore braces inside ' and " quotes. To get the points you also have to check that quotes properly match. Eg: ("')"') is not a valid "program" but ("')") is. You do not have to worry about escaped characters. "\"" is an illegal program if you go for this bonus.

So if your program is 327 ASCII characters long, handles ( and [, doesn't check mismatching, and handles // comments and quotes, you get:

327 - 20 * 1 - 0 - 50 - 0 - 50 = 207 points

EDIT: Added bonuses for ignoring braces inside ' and " quotes
EDIT 2: Return values cannot be any string. Must be true/false 1/0 'Y'/'N' ect.
EDIT 3: Since there is some confusion, here is some pseudo-BNF to give an idea of what is expected.

Grammar for minimal program:
exprs = expr exprs
expr = ( exprs ) || not_braces* || nil

Grammar for all bonuses:
exprs = expr exprs
expr = ( exprs ) || [ exprs ] || { exprs } || < exprs > || // not_newline* \n || /* not_end_comment* */ || not_braces* || nil

Note that if you do the bonuses, you will both accept and reject things that the basic program would not.

PHP, -4 (156 - 20*3 - 30 - 50 - 20)
<?php $x=preg_replace("!(//.*|/\*.*\*/|[^()[\]{}<>])!sm",'',$argv[1]);while(strlen($x)!=strlen($x=str_replace(str_split('()[]{}<>',2),'',$x)));print $x?0:1;

It removes comments
It filters out all characters different than (, ), [, ], {, }, <, >
It replaces all (), [], {}, <> pairs until there are no matches
Prints 1 if the string is empty, 0 otherwise

(Edit: changed the regex; the source code is now 156 instead of 175)