Simulate a model neuron An Izhikevich neuron is a simple yet quite effective model of a biological neuron, designed for use in a discrete time-stepping simulation. In this golfing challenge, you will be implementing this model.

Parameters

This model involves only 7 variables organized into 2 differential equations, compared to the dozens of parameters of a physiologically accurate model.

v and u are the two state variables of the neuron. Here, v is the "fast" variable representing the cell potential over time, and u is the "slow" variable representing certain membrane properties.  The v variable is the most important one, as this is the output of the simulation.
a, b, c, and d are fixed constants that describe the properties of the neuron.  Different types of neurons have different constants, depending on the desired behavior.  Notably, c is the reset potential, which is the membrane potential the cell returns to after spiking.
I represents the input current to the neuron. In network simulations, this will change over time, but for our purposes we will treat I as a fixed constant.

The Model

This model has very simple pseudocode.  First, we take the constant values of abcd and use them to initialize v and u:

v = c
u = b * c

Next, we loop through the simulation code as many times as desired.  Each iteration represents 1 millisecond of time.

for 1..t:
  if v >= 30:    # reset after a spike
    v = c
    u = u + d
  v += 0.04*v^2 + 5*v + 140 - u + I
  u += a * (b*v - u)
  print v

Certain real-world implementations include additional steps for numerical accuracy, but we aren't including those here.

Input

As input, your program/function should take the values of a, b, c, d, I, and t (the number of time steps to simulate). Once set, none of these parameters will be changing during our simple simulation. The order of input does not matter: you can specify the order in which your program takes these parameters.

Output

Output will be a list of numbers representing the cell's membrane potential (given by variable v) over the course of the simulation.  The list can be in any appropriate format.

You have the choice of whether to include the 0th value of the simulation (the initial configuration before any time has passed) in your output.  For example, for an input of 0.02 0.2 -50 2 10 6 (for a b c d I t), an output of either

-50
-40
-16.04
73.876224
-42.667044096
-25.8262335380956
29.0355029192068

or

-40
-16.04
73.876224
-42.667044096
-25.8262335380956
29.0355029192068

is acceptable.

Your values do not have to be exactly the same as those above, depending on how your language handles floats.

Reference Implementation

Here is a TIO implementation I wrote in Perl to demonstrate the model.  The parameters are that of a "chattering" neuron from the paper linked above, and this serves as a demonstration of how this model is able to recreate some of the more complex properties of neurons, such as alternating between states of high and low activity. If you look at the output, you can see where the neuron immediately spikes several times, but then waits a while before spiking several more times (despite the cell input voltage I being constant the whole time).

R, 110 99 bytes

Anonymous function that takes 6 arguments. Nothing fancy, just a straightforward port of the reference implementation. The updating of u, v, and the printing of v have all been combined into a single line, thanks to the fact that R's print returns the value that is being printed, so you can use it in assignment. Many thanks to Giuseppe for saving 11 bytes!

pryr::f({v=c;u=b*c;for(i in 1:t){if(v>=30){v=c;u=u+d}
u=a*b*(v=print((.04*v+6)*v+140+I-u))-a*u+u}})

Try it online!


Connect Four Validator Introduction

Connect Four is a game where you attempt to get four in a row: horizontally, vertically, or diagonally.  In this code golf, we will be trying to find who won, given a game board.  There will always be one winner, and only one winner.

Task

Given a Connect Four board, figure out who the winner is: X or Y.  There will always be one winner, and only one winner.  The board size will always be 6 by 7 like how the game board is in the in picture.

Given a board the following board, in this instance, X is red and Y is blue:

Your input would be:

OOOOOOO
OOOOOOO
OOOOOOO
OOOOXOO
OOOXXOO
OOXYYYY

You can separate rows of the game by newline character (like above), no dividing character, divide the rows into an array or list, or you can input a matrix of characters.

Correct output for this example:

Y

Y has four in a row; so, Y is the winner. So, we output Y.

Test cases

Input:

OOOOOOO
OOOOOOO
OOOOOOO
OOOOOOO
OOYYOOO
OYXXXXO

Output:

X

Input:

OOOOOOO
OOOOOOO
OOOOOOO
XXXXOOO
YXYYOOO
YXYYXYX

Output:

X

Input:

YXYYXOO
XYXXYOO
XXXYYOO
YYYXXOO
XXYYYYO
XXYYXXO

Output:

Y

Input:

OOOOOOO
OOOOOOO
OYOOOOO
OOYOOOO
OOOYOOO
OOOOYOO

Output:

Y

Input:

OOOOOOO
OOOOOOO
OYOOOOX
OOYOOOX
OOOXOOX
OXOXYOX

Output:

X

Scoring

Least number of bytes wins!

Retina, 51 48 bytes

 Thanks to Martin Ender for saving 3 bytes

M`X((.{6}X){3}|(.{8}X){3}|(.{7}X){3}|XXX)
T`d`YX

Try it Online!

Takes input as a comma-separated list of rows


8-bit Chess Pixel Counting Goal

You're playing a computerised chess game.  The display is in black and white only and the pixels are chunky.  White pixels use a lot power compared to black pixels and you're concerned about your carbon footprint.

Given a square and a piece in chess notation, return the number of white pixels displayed in the square.

The solution may be in the form of a function or a complete program.

Input

A 4-character string defining:

One of wb for a white or black piece. (Not part of normal Chess notation, but required for this puzzle.)
One of KQBNRP for a King, Queen, Bishop, kNight, Rook or Pawn.
One of abcdefgh for the piece's file (column).
One of 12345678 for the piece's rank (row).

Output

The number of white pixels used to draw the chess piece and the underlying square.

Requirements

Chess squares are 8x8 pixels and are either all white or all black.
a1 is a black square.
White chess pieces are drawn as white with a black outline.  Black pieces are black with a white outline.  All pieces have transparent pixels which show the underlying square.
Input is case-sensitive.
Assume the input is valid.

The chess pieces have sprites as follows.
. is the piece's colour.
# is the inverse of the piece's colour.
/ is the underlying square's colour.

King        Queen       Bishop
////////    ////////    ////////
///#.#//    /#.#.#.#    ///#.#//
//#...#/    //#...#/    //##..#/
///#.#//    ///###//    //#.#.#/
///###//    //#...#/    ///###//
//#...#/    //#...#/    //#...#/
//#...#/    //#...#/    //#...#/
//#.#.#/    //#.#.#/    //#.#.#/

kNight      Rook        Pawn
////////    ////////    ////////
////////    /#.#.#.#    ////////
//#..#//    /#.....#    ////////
/#....#/    /##...##    ///#.#//
///#..#/    //#...#/    //#...#/
//#..#//    //#...#/    ///#.#//
//#...#/    //#...#/    //#...#/
//#...#/    //#...#/    //#...#/

The number of pixels in the piece's colour, piece's outline and underlying square for each piece is:

Piece    Fill  Outline  Square
==============================
King     13    16       35
Queen    17    18       29
Bishop   13    18       33
Knight   16    12       36
Rook     23    18       23
Pawn     11    10       43

Test Cases

Input  Output
wRa1   23
bRa1   18
wPc2   54
bKg8   51

Scoring

The shortest code in bytes by Christmas Day gets a little something extra in their stocking.

C#6, 107 bytes

Here's my own answer.  I don't expect any points being the one who posed the challenge.

I have taken some inspiration from user81655's answer.

long P(string a)=>(a[0]>99?12201284685:11042628752)+(a[2]+a[3])%2*46566348643>>"KQBNRP".IndexOf(a[1])*6&63;

The pixel counts are encoded in 6-bit blocks.  The outline or fill is added to the square (if it's white).  Finally, the 6-bit block for the appropriate piece is extracted.

Thankfully, operation precedence worked heavily in my favor.


Create Balanced BST from Sorted List of Integers Given a unique, sorted list of integers, create a balanced binary-search tree represented as an array without using recursion.

For example:

func( [1,2,3,5,8,13,21] ) => [5,2,13,1,3,8,21]

Before we start, a hint: we can simplify this problem a ton so that we don't actually have to think about the input integers (or any comparable object for that matter!).

If we know the input list is sorted already, it's contents are irrelevant. We can simply think about it in terms of indices into the original array.

An internal representation of the input array then becomes:

func( [0,1,2,3,4,5,6] ) => [3,1,5,0,2,4,6]

This means rather than writing something that has to deal with comparable objects, we really only need to write a function which maps from the range [0,n) to the resulting array. Once we have the new order, we can simply apply the mapping back to the values in the input to create the return array.

Valid solutions must:

Accept a zero-element array and return an empty array.
Accept an integer array of length n and return an integer array

Of length between n and the next highest power of 2 minus 1. (e.g., for input size 13 return anywhere between 13 and 15).
Array which represents a BST where the root node is at position 0 and the height is equal to log(n) where 0 represents a missing node (or a null-like value if your language allows). Empty nodes, if present, must only exist at the end of the tree (e.g., [2,1,0])

The input integer array has the following guarantees:

Values are 32-bit signed integers greater than zero.
Values are unique.
Values are in ascending order from position zero.
Values may be sparse (i.e., not adjacent to each other).

The most terse code by ascii character count wins, but I'm also interested in seeing elegant solutions for any particular language.

Test cases

The outputs for simple arrays containing 1 to n for various n. As described above, the trailing 0s are optional.

[]
[1]
[2,1,0]
[2,1,3]
[3,2,4,1,0,0,0]
[4,2,5,1,3,0,0]
[4,2,6,1,3,5,0]
[4,2,6,1,3,5,7]
[5,3,7,2,4,6,8,1,0,0,0,0,0,0,0]
[6,4,8,2,5,7,9,1,3,0,0,0,0,0,0]
[7,4,9,2,6,8,10,1,3,5,0,0,0,0,0]
[8,4,10,2,6,9,11,1,3,5,7,0,0,0,0]
[8,4,11,2,6,10,12,1,3,5,7,9,0,0,0]
[8,4,12,2,6,10,13,1,3,5,7,9,11,0,0]
[8,4,12,2,6,10,14,1,3,5,7,9,11,13,0]
[8,4,12,2,6,10,14,1,3,5,7,9,11,13,15]

Ruby, 143

s=ARGV.size;r,q=[],[[0,s]];s.times{b,e=q.shift;k=Math::log2(e-b).to_i-1;m=(e-b+2)>(3<<k)?b+(2<<k)-1:e-(1<<k);r<<ARGV[m];q<<[b,m]<<[m+1,e]};p r

It is a (loosely) compressed version of the following code which basically does a BFS on the tree.

def l(n)
    k = Math::log2(n).to_i-1
    if n+2 > (3<<k) then
        (2<<k)-1
    else
        n-(1<<k)
    end
end

def bfs(tab)
  result = []
  queue = [[0,tab.size]]
  until queue.empty? do
    b,e = queue.shift
    m = b+l(e-b)
    result << tab[m]
    queue << [b,m] if b < m
    queue << [m+1,e] if m+1 < e
  end
  result
end

p bfs(ARGV)

Besides, because it's BFS, not DFS, a requirement of non-recursive solution is not significant, and it puts some languages at a disadvantage.

Edit: Fixed solution, thanks to @PeterTaylor for his comment!


Construct a line graph / conjugate graph Introduction

Given an undirected graph G, we can construct a graph L(G) (called the line graph or conjugate graph) that represents the connections between edges in G. This is done by creating a new vertex in L(G) for every edge in G and connecting these vertices if the edges they represent have a vertex in common.

Here's an example from Wikipedia showing the construction of a line graph (in green).

As another example, take this graph G with vertices A, B, C, and D.

    A
    |
    |
B---C---D---E

We create a new vertex for each edge in G. In this case, the edge between A and C is represented by a new vertex called AC.

   AC

 BC  CD  DE

And connect vertices when the edges they represent have a vertex in common. In this case, the edges from A to C and from B to C have vertex C in common, so vertices AC and BC are connected.

   AC
  /  \
 BC--CD--DE

This new graph is the line graph of G!

See Wikipedia for more information.

Challenge

Given the adjacency list for a graph G, your program should print or return the adjacency list for the line graph L(G). This is code-golf, so the answer with the fewest bytes wins!

Input

A list of pairs of strings representing the the edges of G. Each pair describes the vertices that are connected by that edge.

Each pair (X,Y) is guaranteed to be unique, meaning that that the list will not contain (Y,X) or a second (X,Y).

For example:

[("1","2"),("1","3"),("1","4"),("2","5"),("3","4"),("4","5")]
[("D","E"),("C","D"),("B","C"),("A","C")]

Output

A list of pairs of strings representing the the edges of L(G). Each pair describes the vertices that are connected by that edge.

Each pair (X,Y) must be unique, meaning that that the list will not contain (Y,X) or a second (X,Y).
For any edge (X,Y) in G, the vertex it creates in L(G) must be named XY (the names are concatenated together in same order that they're specified in the input).

For example:

[("12","13"),("12","14"),("12","25"),("13","14"),("13","34"),("14","34"),("14","45"),("25","45"),("34","45")]
[("DE","CD"),("CD","CB"),("CD","CA"),("BC","AB")]

Test Cases

[] -> []

[("0","1")] -> []

[("0","1"),("1","2")] -> [("01","12")]

[("a","b"),("b","c"),("c","a")] -> [("ab","bc"),("bc","ca"),("ca","ab")]

[("1","2"),("1","3"),("1","4"),("2","5"),("3","4"),("4","5")] -> [("12","13"),("12","14"),("12","25"),("13","14"),("13","34"),("14","34"),("14","45"),("25","45"),("34","45")]

Ruby, 51 bytes

->a{a.combination(2){|x,y|p [x*'',y*'']if(x&y)[0]}}

Try it online!

For each combination of two edges, if they have a vertex in common (i.e. if the first element of their intersection is non-nil), print an array containing the two edges to STDOUT.


Basic Algebraic Expansion Problem

I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that I am only able to parse specific algebra, otherwise the universe folds into itself, which is bad. Fortunately, I only need a few basic operations in this amazing new program's input, but I still need it expanded!

Rules

An answer must be able to simplify the following expressions

2+2 should reduce to 4
(5+x)+6 should reduce to x+11
(x+2)^2 should reduce to x^2+4*x+4
(x-5)*(3+7*x) should reduce to 7*x^2-32*x-15
5*x+9*x should reduce to 14*x
(2*x^2)*x^3 should reduce to 2*x^5

Answers must be able to COMPLETELY remove parenthesis, which implies that all distribution must take place.
Answers should be able to handle all of the following operators and standard tokens:

+ (The addition function)
- (The subtraction function)
* (The multiplication function)
( (The left parenthesis, used to indicate a group)
) (The right parenthesis, used to indicate the end of the last started group)
x (The standard variable)
[0-9]+ (literal nonnegative numbers)

Answers must be capable of at least squaring, using the notation expr^2, including (expr)^2 recursively, since (expr) is itself an expression ;)
A solution must be in a standard infix notation, none of the RPN nonsense!
No library functions such as Mathematica's Simplify to do this for you.
Solution should be a function that takes in a single argument and return the expanded version

As this is code-golf, the answer with the fewest (key)strokes wins, 1 week from OP.

Notes

There are no spaces in this world of math, of course! Only parenthesis.

So no division is required to save from factoring

Standard order of operations apply.

I'm aware that some of what I'm asking is simplification (e.g. 2+2=4) where other parts are actually the opposite, such as expanding (x+1)^2 to be x^2+2x+1. This is intentional. :)

-25 strokes for a solution that can do (expr)^n instead of just (expr)^2

-15 strokes for a solution able to evaluate juxtaposed multiplication, such as 4x+5x == 9x, or 4(x+1) = 4x+4

-5 strokes for a solution able to handle multiple variables (A variable being exactly one lowercase alphabet character)

-5 strokes for a solution able to remove leading 0's (007 to just 7 [Not today, Bond!] [Jeez now I feel like I'm writing Lisp])


Compute the Join and Meet of Partitions Background

In this challenge, a partition of a set S means a collection of nonempty subsets of S, which are mutually disjoint and whose union is S. We say that a partition p is finer than another partition q (and q is coarser than p), if it can be obtained from q by splitting some of its sets into smaller pieces. The join (or least upper bound) of two partitions is the finest partition which is coarser than both of them, and their meet (or greatest lower bound) is the coarsest partition which is finer than both of them. See the Wikipedia pages on partitions and lattices for more information and nice pictures.

One way to compute the join and meet of two partitions p and q is the following. Form a graph whose vertex set is S, and add an edge a - b for each pair a, b that are in the same set in either p or q. Then the join of p and q contains the connected components of this graph. The meet of p and q consists of all nonempty intersections of a set in p with a set in q.

For example, consider the partitions [[0,1],[2,3]] and [[0,1,2],[3]] of S = [0,1,2,3]. The graph mentioned above is

0-1
|/
2-3

where the edge 2 - 3 comes from the first partition (2 and 3 are in the same set), and the triangle comes from the second one (0, 1 and 2 are in the same set). This means that the join is [[0,1,2,3]]. The intersections of all the sets in the partitions are

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

Removing the empty set, we have the meet [[0,1],[2],[3]].

Input

Two partitions of a finite set of integers, given as arrays of arrays.

Output

The join and meet of the input partitions, in this order.

Test Cases

[[1]] [[1]] -> [[1]] [[1]]
[[0,1],[2,3]] [[0,1,2],[3]] -> [[0,1,2,3]] [[0,1],[2],[3]]
[[0],[1],[2,3,4,7,6]] [[2,3],[4,7],[6],[1,0]] -> [[0,1],[2,3,4,6,7]] [[0],[1],[2,3],[4,7],[6]]
[[0],[1,2],[5,4],[3,6]] [[0,3],[6,4],[5,2],[1]] -> [[0,1,2,3,4,5,6]] [[0],[2],[1],[4],[5],[3],[6]]

Detailed Rules

The order of the sets in the output partitions, and of the numbers in those sets, does not matter. You can assume that the inputs are correct, that is, they contain the same numbers, each exactly once, and no empty arrays. Note that the numbers do not necessarily form an interval (the third test case contains no 5).

You can write either a full program or a function. You can also write two programs/functions in the same language, one of which computes the join and other the meet, but there's a bonus of -10 bytes if you don't choose this option. The shortest byte count wins, and standard loopholes are disallowed.

CJam, 32 - 10 = 22

q_~{_{T&},:U-U:+a+}fTp~m*::&La-p

::& is newer than this question.

CJam, 36 - 10 = 26

q_~{:T;_{T&},:U-U:+a+}/p~m*{~&}%La-p

Input:

[[0] [1] [2 3 4 7 6]]
[[2 3] [4 7] [6] [1 0]]

Output:

[[2 3 4 7 6] [0 1]]
[[0] [1] [2 3] [4 7] [6]]

Explanation

q                 " Read the input. ";
_~                " Evaluate a copy. ";
{:T;              " For each list T in the second partition: ";
    _{T&},        " Select all lists in the first partition which share items with T. ";
    :U-           " Save to U and remove them from the first partition. ";
    U:+a+         " Append the union of U to the first partition. ";
}/
p                 " Print the meet. ";
~                 " Evaluate another copy. ";
m*                " Get the Cartesian product. ";
{~&}%             " Get the intersections of each pair of lists. ";
La-               " Remove empty lists. ";
p                 " Print. ";


Coding Around The Clock Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:

MyProgram

When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times need be supported.

Specifically:

When your program is arranged like clock hands at 12 o'clock ()

m
a
r
g
o
r
P
y
M

running it should output 12.
When your program is arranged like clock hands at 3 o'clock ()

m
a
r
g
o
r
P
y
MyProgram

running it should output 3.
When your program is arranged like clock hands at 6 o'clock ()

m
a
r
g
o
r
P
y
M
y
P
r
o
g
r
a
m

running it should output 6.
When your program is arranged like clock hands at 9 o'clock ()

........m
........a
........r
........g
........o
........r
........P
........y
margorPyM

running it should output 9.

Notes

The first character in your program is always placed at the center of the clock. (Note how there is only one M in the 6 o'clock example.)
Any one non-newline character may be used to indent the program for the 9 o'clock arrangement. In the examples . is used, but space or / or # would be just as valid.
For the 3 o'clock arrangement, no characters should be in the empty upper right region. (i.e. keep it empty, don't fill it with spaces.)
The initial program arrangement (MyProgram as is) does not need to do anything. Only the 12, 3, 6, and 9 o'clock arrangements need to have correct, well-defined output.
Code that only works as a function or REPL command is not allowed. Each of the four arrangements should be ready to run as full programs as is.

The shortest program in bytes wins. e.g. MyProgram has a length of 9 bytes.

GolfScript, 11 10 bytes

21;;3#9];6

Uses # as padding character.

12 o'clock

6
;
]
9
#
3
;
;
1
2

Try it online!

How it works.

6 is pushed on the stack, ; discards it.
] wraps the stack in an array (does not affect output).
9 and 3 are pushed on the stack, ; and ; discard them.
Finally, 1 and 2 are pushed on the stack, and implicitly printed without separation.

3 o'clock

6
;
]
9
#
3
;
;
1
21;;3#9];6

Try it online!

How it works

6 is pushed on the stack, ; discards it.
] wraps the stack in an array (does not affect output).
9 and 3 are pushed on the stack, ; and ; discard them.
1 and 21 are pushed on the stack, ;; discards them.
3 is pushed on the stack.
# begins a comment until the end of the line.

6 o'clock

6
;
]
9
#
3
;
;
1
2
1
;
;
3
#
9
]
;
6

Try it online!

How it works

6 is pushed on the stack, ; discards it.
] wraps the stack in an array (does not affect output).
9 and 3 are pushed on the stack, ; and ; discard them.
1, 2 and 1 are pushed on the stack.
; and ; discard the last 1 and 2.
3 and 9 are pushed on the stack.
] and ; wrap the stack in an array and discard it, clearing the stack.
6 is pushed on the stack.

9 o'clock

#########6
#########;
#########]
#########9
##########
#########3
#########;
#########;
#########1
6;]9#3;;12

Try it online!

How it works

All lines but the last are comments.
6 is pushed on the stack, ; discards it.
] wraps the stack in an array (does not affect output).
9 is pushed on the stack.
# begins a comment until the end of the line.


How many steps does it take from n to 1 by subtracting the greatest divisor? Inspired by this question over at Mathematics.

The Problem

  Let n be a natural number ≥ 2. Take the biggest divisor of n – which is different from n itself – and subtract it from n. Repeat until you get 1.

The Question

How many steps does it take to reach 1 for a given number n ≥ 2.

Detailed Example

  Let n = 30.

The greatest divisor of:

1.   30 is 15  -->  30 - 15 = 15
2.   15 is  5  -->  15 -  5 = 10
3.   10 is  5  -->  10 -  5 =  5
4.    5 is  1  -->   5 -  1 =  4
5.    4 is  2  -->   4 -  2 =  2
6.    2 is  1  -->   2 -  1 =  1

It takes 6 steps to reach 1.

Input

Input is an integer n, where n ≥ 2.
Your program should support input up to the language's maximum integer value.

Output

Simply output the number of steps, like 6.
Leading/trailing whitespaces or newlines are fine.

Examples

f(5)        --> 3
f(30)       --> 6
f(31)       --> 7
f(32)       --> 5
f(100)      --> 8
f(200)      --> 9
f(2016^155) --> 2015

Requirements

You can get input from STDIN, command line arguments, as function parameters or from the closest equivalent.
You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.
This is code-golf so shortest answer in bytes wins.
Standard loopholes are disallowed.

This series can be found on OEIS as well: A064097

  A quasi-logarithm defined inductively by a(1) = 0 and a(p) = 1 + a(p-1) if p is prime and a(n*m) = a(n) + a(m) if m,n > 1.

Jelly, 9 bytes
ÆṪÐĿÆFL€S

Try it online! or verify all test cases.
Background
The definition of sequence A064097 implies that

By Euler's product formula

where φ denotes Euler's totient function and p varies only over prime numbers.
Combining both, we deduce the property

where ω denotes the number of distinct prime factors of n.
Applying the resulting formula k + 1 times, where k is large enough so that φk+1(n) = 1, we get

From this property, we obtain the formula

where the last equality holds because ω(1) = 0.
How it works
ÆṪÐĿÆFL€S  Main link. Argument: n

  ÐĿ       Repeatedly apply the link to the left until the results are no longer
           unique, and return the list of unique results.
ÆṪ           Apply Euler's totient function.
           Since φ(1) = 1, This computes φ-towers until 1 is reached.
    ÆF     Break each resulting integer into [prime, exponent] pairs.
      L€   Compute the length of each list.
           This counts the number of distinct prime factors.
        S  Add the results.


Find the largest banknote Banknotes in many countries come in denominations of 1,2,5,10,20,50,100,200,500,1000, etc. That is, one of \$ \{ 1,2,5\} \$ times a power of \$10\$. This is OEIS A051109, except we'll extend the sequence to bigger values.
Given a positive integer as the input, the program should output the largest bank note that is less than or equal to the input. The input will be less than \$2^{63}\$.
Examples:
1 => 1
2 => 2
3 => 2
5 => 5
9 => 5
42 => 20
49 => 20
50 => 50
99 => 50
100 => 100
729871 => 500000
3789345345234 => 2000000000000
999999999999999999 => 500000000000000000

Python 2, 39 bytes

f=lambda n:n>9and 10*f(n/10)or 5>>5/-~n

Try it online!


Return a word with a prescribed sum of letters Identify each letter of the English alphabet with the number denoting its position in the alphabet, that is,

a = 1, b = 2, c = 3, ..., z = 26

(no distinction between lower and upper case letters is made). Every other character is identified with 0.

The "sum" of a word is the sum of its characters, for example: the sum of e-mail is 40 = 5 + 0 + 13 + 1 + 9 + 12, since e = 5, - = 0, m = 13, a = 1, i = 9, l = 12.

The Challenge

Write a program or a function that takes as input an integer n in the range 10-100 and returns a word of the English language whose sum is equal to n

This is codegolf, standard loopholes are forbidden.

ADDENDUM:

For a list of English words, see: https://github.com/dwyl/english-words
Reading a remote list of words is forbidden.

Python 3.8 (pre-release), 262 235 bytes

lambda x:f'JKLmGoPlheAhVegytMtosOdtthfvtWypvttgYsRWspytps    e  eegli ra eehnkPooeoroyyauiuruotoituooup    b   aggd  p ai    mnrwiwpnwsnyotrosturwutr{"":8}d{"":14}gnlz   nht ntkpstmsltty'[(k:=x-10)//46*23+k%23::46].strip()+k//23%2*'er'

Try it online!

Uses words from the list that appear with and without a trailing er, cutting the number of required words almost in half.


Find one-handed words 'exaggerated' is an example of a word which can be typed on the left hand, on a normal qwerty keyboard map.  'monopoly' is an example for the right hand.

Searching the unix words file for words that can be typed on one hand.  Output should be two lines:  space separated list of such words for the left hand, followed by the list for the right hand.  e.g.

a abaft abase abased abases abate abated abates abbess abbesses ...
h hi hill hilly him hip hippo hippy ho hokum ...

The left-hand letters are:

qwertasdfgzxcvb

The right-hand letters are:

yuiophjklnm'

Uppercase letters count as one-handed; letters with diacritics count as two-handed and hence words containing them can be ignored.

Bash (100 89 chars)

for x in a-gq-tvwxz h-puy\'
do grep -iE ^[$x]*$ /usr/share/dict/words|tr '
' \
echo
done

Note that 21 chars go to the full path to the words file: if we're allowed to assume that pwd is /usr/share/dict then 16 of those can be saved.

Credit to chron for the shorter regexes.


Shortest Code that creates a Deadlock Write the shortest code to create a deadlock. Code execution must halt, so this doesn't work:

public class DeadlockFail extends Thread{ //Java code
    public static void main(String[]a){
        Thread t = new DeadlockFail();
        t.start();
        t.join();
    }
    //this part is an infinite loop; continues running the loop.
    public void run(){while(true){}}
}

It doesn't need to be certain that the code goes into deadlock, just almost surely (if you run for infinite time, it will deadlock).

Dyalog APL (10)

⎕TSYNC⎕TID

⎕TSYNC makes the thread wait until the given thread ends,  ⎕TID gives the current thread.

Dyalog APL can recognize deadlocks though, so it immediately responds with

DEADLOCK

The fun thing is, you don't even need to spawn any extra threads, making the UI thread wait for itself is plenty.

If this is cheating and new threads are actually required, you can do it in 27 characters:

{∇⎕TSYNC&{⎕TSYNC⎕TID+1}&0}0

F & x runs F in a new thread on value x, and returns the thread ID. So:

{⎕TSYNC⎕TID+1}&0 creates a thread that will synchronize with the thread whose ID is one higher than its own,
⎕TSYNC& creates a new thread that will synchronize with the previous thread, and which gets an ID one higher than the thread that was just created (assuming nothing else is creating threads).
∇ causes an infinite loop (so we keep creating threads until there's a deadlock).

This will deadlock as soon as the second thread gets created before the first one starts running, which is pretty soon:

9:DEADLOCK


Distance between the Sun and the nth planet Challenge
Predict the distance between the Sun and the nth planet when using any formula that gives the same result as the Titius–Bode law: d=(3*2^n+4)/10.
BUT WAIT... there is one restriction:

Your source code can not include any of the Titius–Bode law's digits
So, your program can not contain the characters 0, 1, 2, 3, or 4

Input
n a non-negative integer value:

For Mercury n is -∞ no need to handle this case.
n=0 for Venus
n=1 for Earth
n=2 for Mars, and so on ...

Output
Distance in astronomical unit between the Sun and the nth planet (decimal with at least one decimal place).
Titius–Bode law
Distance in astronomical unit between the Sun and the nth planet is estimated by d=(3*2^n+4)/10.
Example
0          --> 0.7
1          --> 1.0 or 1
11         --> 614.8

Rules

The input and output can be given in any convenient format.
No need to handle invalid input values
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

05AB1E, 7 bytes

oxOÌÌT/

Try it online!

Explanation

o          # push 2^input
 x         # pop a and push a, 2*a
  O        # sum stack
   ÌÌ      # add 2 twice
     T/    # divide by 10


Thwart Lepton compression Dropbox recently released Lepton (GitHub), a method that losslessly compresses JPEG images round-trip, saving an average of 22%.

Because of the pigeonhole principle, any general compression algorithm cannot be guaranteed to result in a smaller file (general because it doesn't apply to inputs constrained to a specific format). Lepton exploits common characteristics about JPEGs, which if subverted, might pigeonhole it to produce a file larger than the source.

Requirements

Write a program that generates:

A valid JPEG/JFIF image,
with a size between 0.5 MB and 1 MB,
no smaller than 256 × 256 px,
no larger than 4096 × 4096 px,
recognizable by Lepton (it can successfully "compress" to a .lep image), and
decompresses to an identical .jpg (as the input).
APPx, COM, and other metadata, non-graphical marker sections are restricted in the JPEG (injecting arbitrary amounts of random bytes into the image to asymptotically approach 1:1 compression is lame.)

an APP0 JFIF marker is permitted but no thumbnail is allowed (should be exactly 16 bytes)
tl;dr If you're not intentionally shoving metadata into an EXIF segment and you disable any sort of thumbnail your language library of choice wants to put into the image, that should be OK.

Post the code and image.

If you want to write a program that produces a Lepton image that when converted yields a JPEG meeting the criteria, that's fine. It must remain identical across arbitrarily many JPEG → Lepton → JPEG → ... cycles.

Scoring

The byte size of the Lepton image divided by the source JPEG image. Higher (worse Lepton compression) is better. Run Lepton with default flags and switches.

Getting Lepton

A 5-second crash-course to build Lepton:

git clone https://github.com/dropbox/lepton.git
cd lepton
./autogen.sh && ./configure && make

# fish shell: ./autogen.sh ;and ./configure ;and make

Then ./lepton --help should tell you things.

Python 3 + mozjpeg + /dev/urandom, 720×720: avg. score 102%
Depends on the mozjpeg package, the code assumes it's installed into /usr/local/opt/mozjpeg. (on OS X it's trivial to install, just run brew install mozjpeg)
Also it depends on /dev/urandom special file, it's used for generating random data.
The code simply feeds random data to mozjpeg compressor (in TGA format, because cjpeg understands it and it has very simple header), and lets it create an optimized jpeg file. Quality is set to the maximum because it makes DCT coefficients the least compressable, and it doesn't matter much what algorithm is used to compress uncompressable data.
I checked that the jpeg->lepton->jpeg cycle is lossless — it is true.
import subprocess
from subprocess import PIPE

c_mozjpeg_path = '/usr/local/opt/mozjpeg/bin/cjpeg'
cjpeg_params = '-quality 100 -dc-scan-opt 2 -dct float -targa'
image_size = 720

def write_random_tga_image(w, h, of, rf):
    def wb(value, size):
        of.write(int.to_bytes(value, size, 'little'))

    wb(0, 2)
    wb(3, 1)
    wb(0, 9)
    wb(w, 2)
    wb(h, 2)
    wb(8, 1)
    wb(0, 1)

    data_size = w * h
    while data_size > 0:
        data_size -= of.write(rf.read(data_size))

def main():
    with open('/dev/urandom', 'rb') as rf:
        with open('oops.jpg', 'wb') as f:
            p = subprocess.Popen((c_mozjpeg_path,) + tuple(cjpeg_params.split(' ')), stdin=PIPE, stdout=f)
            write_random_tga_image(image_size, image_size, p.stdin, rf)
            p.communicate()

if __name__ == '__main__':
    main()

Code is not golfed, obviously.
Example image:
Fun fact: generated JPEG file is larger than the source uncompressed TGA image, even though JPEG uses lossy compression.
Fun fact 2: Imgur (the default image hosting for SO) does very bad job at this file — for some reason it recompresses it to lower quality, even though it's less than 1MB. So I used Github to upload the example image.
Fun fact 3: In general, mozjpeg indeed does better JPEG compression while staying compatible with existing JPEG decoders. And it also has tool to losslessly optimize JPEG files, too — jpegtran.


How many countries are in the European Union? Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease.

Your job is to take a date and output the number of EU1 members on that date, according to the following table:

| Start      | End        | Number of members
| 0          | 1957-12-31 | 0
| 1958-01-01 | 1972-12-31 | 6
| 1973-01-01 | 1980-12-31 | 9
| 1981-01-01 | 1985-12-31 | 10
| 1986-01-01 | 1994-12-31 | 12
| 1995-01-01 | 2004-04-30 | 15
| 2004-05-01 | 2006-12-31 | 25
| 2007-01-01 | 2013-06-30 | 27
| 2013-07-01 | 2020-01-31 | 28
| 2020-02-01 | Inf        | 27

Input may take one of the following forms:

your language's date format
any ordering of integers for year, month and day with any separator (e.g. YYYYMMDD or DD/MM/YYYY)
number of days lapsed since some epoch.

This is code-golf, so shortest code wins!

1. or EEC before 1993

Javascript, 85 83 Bytes
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:d<666?27:d<745?28:27

It takes an input as a float as the months / fractions of months passed since 1958-01-01
(0 for 1958-01-01T00:00:00 and a negative number for any previous date)
(Since number of days from some epoch is allowed, I assume that also a number of months is valid, as well)
Try it Online

80 Bytes
(credits: Arnauld)
a=d=>d<0?0:d<180?6:d<276?9:d<336?10:d<444?12:d<556?15:d<588?25:27+(d>=666&d<745)

Sad to see you go, UK


The Rule of Thumb for Title Capitalization According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is

  Capitalize all words in titles of publications and documents, except
  a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
  nor.

This might not be true as I'm unable to find such a recommendation in the Style Manual, but let's use this rule anyway.

The Challenge

Given an input string consisting of lower case words delimited by spaces, output the capitalization of the string according to the following rules

The first and last word is capitalized.
All other words are capitalized, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor.

The input string will contain at least one word and each word contains at least one letter and only characters from a to z.

This is a code golf challenge, so try to use as few bytes as possible in the language of your choice. You may write a full program or a function to accomplish the task.

Testcases

"the rule of thumb for title capitalization" -> "The Rule of Thumb for Title Capitalization"
"programming puzzles and code golf" -> "Programming Puzzles and Code Golf"
"the many uses of the letter a" -> "The Many Uses of the Letter A"
"title" -> "Title"
"and and and" -> "And and And"
"a an and as at but by for in nor of on or the to up" -> "A an and as at but by for in nor of on or the to Up"
"on computable numbers with an application to the entscheidungsproblem" -> "On Computable Numbers With an Application to the Entscheidungsproblem"

Python 2, 118 bytes

Look ma, no regex!

for w in`input()`.split():print[w.title(),w][`w`in"'a'an'and'as'at'the'by'but'for'nor'in'of'on'or'to'up'"].strip("'"),

Input must be wrapped in quotes. Output has a trailing space and no trailing newline (I assume that's okay). Verify all test cases on Ideone.

Explanation

Let's take the input a or an as our example.

Using Python 2's `x` shortcut for repr, we wrap the input in single quotes: 'a or an'. Then we split on whitespace and iterate over the words.

Inside the loop, we take the repr again. For the first and last words, this gives "'a" and "an'". For other words, it gives 'or'. We want to avoid capitalizing words if they fit the latter pattern and are in the short-words list. So we can represent the word list as the string "'a'an'...'up'" and know that the repr of any short word will be a substring.

`w` in "..." gives a boolean value, which we can treat as 0 or 1 for the purposes of indexing into the list [w.title(), w]. In short, we title-case the word if it is at the beginning, at the end, or not in the list of short words. Otherwise, we leave it alone. Fortunately, title() still works as expected with input like 'a.

Finally, we strip any single quotes from the word and print it with a trailing space.


Match Roman Numerals Challenge
Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=MMMCMXCIX), and a falsey value otherwise.
Details

The input is a non-empty string that only comprises the characters IVXLCDM.
The roman numerals (that we use here in this challenge) are defined as follows:

We use only following symbols:
Symbol  I   V   X   L   C   D    M
Value   1   5  10  50 100 500 1000

To define which strings are actually valid roman numerals, it is probably easiest to provide the rule of conversation: To write a decimal number a3 a2 a1 a0 (where each ai represents one digit. So for example to represent 792 we have a3=0, a2=7, a1=9, a0=2.) as a roman numeral, we decompose it into the power of tens. The different powers of ten can be written as follows:
      1-9: I, II, III, IV, V, VI, VII, VIII, IX
    10-90: X, XX, XXX, XL, L, LX, LXX, LXXX, XC
  100-900: C, CC, CCC, CD, D, DC, DCC, DCCC, CM
1000-3000: M, MM, MMM

Beginning at the left side with the most significant digit of the, we can convert the number that each digit represents separately and concatenate them. So for the example from above this would look like so:
Digit        a3    a2   a1   a0
Decimal       0     7    9    2
Roman             DCC   XC   II

Therefore the roman numeral for 792 is DCCXCII. Here is a full list of all roman numerals that are relevant for this challenge: OEIS a006968.txt
Examples
Truthy
MCCXXXIV (1234)
CMLXXXVIII (988)
DXIV (514)
CI (101)

Falsey
MMIXVIII
IVX
IXV
MMMM
XXXVX
IVI
VIV

Verbose, 1362 bytes
GET A ROMAN NUMERAL TYPED IN BY THE CURRENT PERSON USING THIS PROGRAM AND PUT IT ONTO THE TOP OF THE PROGRAM STACK
PUT THE NUMBER MMMM ONTO THE TOP OF THE PROGRAM STACK
MOVE THE FIRST ELEMENT OF THE PROGRAM STACK TO THE SECOND ELEMENT'S PLACE AND THE SECOND ELEMENT OF THE STACK TO THE FIRST ELEMENT'S PLACE
DIVIDE THE FIRST ELEMENT OF THE PROGRAM STACK BY THE SECOND ELEMENT OF THE PROGRAM STACK AND PUT THE RESULT ONTO THE TOP OF THE PROGRAM STACK
PUT THE NUMBER V ONTO THE TOP OF THE PROGRAM STACK
GET THE FIRST ELEMENT OF THE PROGRAM STACK AND THE SECOND ELEMENT OF THE PROGRAM STACK AND IF THE SECOND ELEMENT OF THE PROGRAM STACK IS NOT ZERO JUMP TO THE INSTRUCTION THAT IS THE CURRENT INSTRUCTION NUMBER AND THE FIRST ELEMENT ADDED TOGETHER'S RESULT
PUT THE NUMBER I ONTO THE TOP OF THE PROGRAM STACK
GET THE TOP ELEMENT OF THE STACK AND OUTPUT IT FOR THE CURRENT PERSON USING THIS PROGRAM TO SEE
PUT THE NUMBER III ONTO THE TOP OF THE PROGRAM STACK
GET THE FIRST ELEMENT OF THE PROGRAM STACK AND THE SECOND ELEMENT OF THE PROGRAM STACK AND IF THE SECOND ELEMENT OF THE PROGRAM STACK IS NOT ZERO JUMP TO THE INSTRUCTION THAT IS THE CURRENT INSTRUCTION NUMBER AND THE FIRST ELEMENT ADDED TOGETHER'S RESULT
PUT THE NUMBER NULLA ONTO THE TOP OF THE PROGRAM STACK
GET THE TOP ELEMENT OF THE STACK AND OUTPUT IT FOR THE CURRENT PERSON USING THIS PROGRAM TO SEE

Outputs I for valid roman numerals in the range I-MMMCMXCIX and NULLA (0) or informs user input is not a valid roman numeral otherwise.


Create a basic autocorrecting spell checker In this challenge, you have to implement a basic spell checker and autocorrector. Your program will use the first input as a source for a dictionary of words, and will use that to autocorrect the second input, finding a close match to some incorrectly spelt words, outputting the result
Specifications

You will receive two inputs, one is a sentence/paragraph you use as a source for your spell checker, and the other includes wrong words (they can be correct too) which you have to correct using the first input.
Possible mistakes: Missing one letter (e.g. helo), one extra letter (e.g. heello), substitution of one character (e.g. hilp instead of help), transposition of two adjacent characters (e.g. hlep instead of help).
In other words, the mistake and the original word have to have a Damerau–Levenshtein distance of one.
You can separate the inputs in any reasonable format. For example, instead of using a newline, you can use a pipe sign to separate them. (|) However, watch out so you don't use something like letters because they are used in the 1st input.
It's possible for a word to have neither an identical word nor a word with 1 distance from the first input. You will have to leave them unchanged.
You don't need to do anything with punctuation. That is, I won't test words that are followed by a punctuation. (E.g. From the first example, I won't ask the correction of 'blod')
Challenge is case insensitive, both the input and output. Meaning that if 'The' is used in the 1st input and the 2nd input is 'teh' you can change it to 'The', 'teh', 'teH', and similar cases.
If a word is in the first input, but also has a distance of 1 with one of the other words, do not correct it.
If there are two words with the same distance, you can output either of them. (E.g. 'en' can change into 'on' and 'in' if the words are both in the first input.) You can also output both of them, but you'll have to use a slash between them. (E.g. 'en' can be corrected into 'in/on')
You can assume words are just sequences of letters separated by spaces.
You can use STDIN or the closest alternative in your language.
Standard loophole rules apply.
This is code-golf, so the shortest code wins.

Examples
Input:
A criminal strain ran in his blood, which, instead of being modified, was increased and rendered infinitely more dangerous by his extraordinary mental powers.

increasd mnetal

Output:
increased mental

Input:
The fact is that upon his entrance I had instantly recognized the extreme personal danger in which I lay.

I recognizid dnger en

Output:
I recognized danger in

CJam, 90 87 bytes

qelN%Sf%~f{1$:W,,_:_2ewWf{\~e\}\Wf{' t_S-}W,),Wf{1$m<S\+m>}++Sf/26,'af+\ff*:+\&\a+0=}S*

Try it online in the CJam interpreter.


Output a solid PNG from scratch Input: An RGBA hex color c (ex. FFFF00FF) and an integer > 0 and < 1000 n (ex. 200).

Output: Raw bytes of a PNG file such that when the output is saved to a file and opened in an image viewer, an n by n image filled with the color c is displayed.

Specification: Your program should output exactly:

a PNG header (89504E470D0A1A0A in hex)
an IHDR chunk containing these specifications:

width: the previous input n
height: the previous input n
bit depth: 8 (RGBA)
color type: 6 (truecolor with alpha)
compression method: 0
filter method: 0
interlace method: 0

one or more IDAT chunks containing the image data (a solid image of color previously input c); may be compressed or uncompressed
an IEND image end chunk

Further details available on Wikipedia, on the W3 site, or via a Google search.

Restrictions:

You may not use any image libraries or functions designed to work with images of any kind.
Your program must run in under 3 minutes and output a file under 10 MB for all inputs (sanity check).
This is code-golf, so the shortest code in bytes will win!

Perl, 181

/ /;use String::CRC32;use Compress::Zlib;sub k{$_=pop;pack'Na*N',y///c-4,$_,crc32$_}$_="\x89PNG\r\n\cZ\n".k(IHDR.pack NNCV,$',$',8,6).k(IDAT.compress pack('CH*',0,$`x$')x$').k IEND

Size is 180 bytes and option -p is needed (+1). Score is then 181.

The arguments are given via STDIN in a line, separated by a space,
the color as hex value (16 chars) and the number of pixels for width/height, e.g.:

 echo "FFFF00FF 200" | perl -p solidpng.pl >yellow200.png

The file size is 832 bytes. The maximal sized image (n=999) with the same color has 6834 bytes (way below 10 MB).

The solution uses two libraries:

use Digest::CRC crc32; for the CRC32 values at the chunk ends.
use IO::Compress::Deflate deflate; to compress the image data.

Both libraries are not related to images.

Ungolfed:

# Perl option "-p" adds the following around the program:
#     LINE:
#     while (<>) {
#         ... # the program goes here
#     } continue {
#         print or die "-p destination: $!\n";

/ /;    # match the separator of the arguments in the input line
        # first argument, color in hex:  $`
        # second argument, width/height: $'                              #'

# load the libraries for the CRC32 fields and the data compression
use String::CRC32;
use Compress::Zlib;

# function that generates a PNG chunk:
#   N (4 bytes, big-endian: data length
#   N:                      chunk type
#   a* (binary data):       data
#   N:                      CRC32 of chunk type and data
sub k {
    $_ = pop; # chunk data including chunk type and
              # excluding length and CRC32 fields
    pack 'Na*N',
        y///c - 4,   # chunk length                                      #/
                     # netto length without length, type, and CRC32 fields
        $_,          # chunk type and data
        crc32($_)    # checksum field
}

$_ =                      # $_ is printed by option "-p".
    "\x89PNG\r\n\cZ\n"    # PNG header
        # IHDR chunk: image header with
        #   width, height,
        #   bit depth (8), color type (6),
        #   compresson method (0), filter method (0), interlace method (0)
    . k('IHDR' . pack NNCV, $', $', 8, 6)
        # IDAT chunk: image data
    . k('IDAT' .
          compress        # compress/deflate data
          pack('CH*',     # scan line with filter byte
              0,          # filter byte: None
              ($` x $')   # pixel data for one scan line                 #'`
          ) x $'          # n lines                                      #'
      )
        # IHDR chunk: image end
    . k('IEND');

Edits

use IO::Compress::Deflate':all'; is replaced by use Compress::Zlib;. The latter does export the deflate function compress by default. The function
does not need references as arguments and also returns the
result directly. That allows to get rid of variable $o.

Thanks for Michael's answer:

Function k: A call of pack could be removed by using template Na*N for the first pack in the function.
pack template NNCV with four values optimizes NNC3n with six values.

Thanks for VadimR's comment with lots of tips:

use String::CRC32; is shorter than use Digest::CRC crc32;.
y///c-4 is shorter than -4+y///c.
The scan line is now constructed by the template CH* with the repetition in the value.
Removal of $i by using a value reference.
Bare words instead of strings for the chunk types.
Options now read by matching a STDIN input line (option -p) with matching
the space separator / /. Then the first option is in $` and the second argument goes in $'.
Option -p also automatically prints $_.
"\cZ" is shorter than "\x1a".

Better compression

At the cost of code size the image data can be further compressed, if filtering is applied.

Unfiltered file size for FFFF0FF 200: 832 bytes
Filter Sub (horizontal pixel differences): 560 bytes

$i = (                            # scan line:
         "\1"                     # filter "Sub"
         . pack('H*',$c)          # first pixel in scan line
         . ("\0" x (4 * $n - 4))  # fill rest of line with zeros
      ) x $n;                     # $n scan lines

Filter Sub for the first line and Up for the remaining lines: 590 bytes

$i = # first scan line
     "\1"                     # filter "Sub"
     . pack('H*',$c)          # first pixel in scan line
     . ("\0" x (4 * $n - 4))  # fill rest of line with zeros
     # remaining scan lines
     . (
           "\2"               # filter "Up"
           . "\0" x (4 * $n)  # fill rest of line with zeros
       ) x ($n - 1);

First unfiltered line, then filter Up: 586 bytes

$i = # first scan line
     pack('H*', ("00" . ($c x $n)))  # scan line with filter byte: none
     # remaining scan lines
     . (
           "\2"               # filter "Up"
           . "\0" x (4 * $n)  # fill rest of line with zeros
       ) x ($n - 1);

Also Compress::Zlib can be tuned; the highest compression level can be set by additional option for the compression level in function compress at the cost of two bytes:

compress ..., 9;

File size of example yellow200.png without filtering decreases from 832 bytes to 472 bytes.
Applied to the example with Sub filter, the file size shrinks from 560 bytes to 445 bytes (pngcrush -brute can't compress further).


SKI calculus golf: Half of a Church numeral Background

SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce.

The three combinators in SKI calculus are defined as follows:

$$
\begin{aligned}
S\;x\;y\;z & \overset{S}{\implies} x\;z\;(y\;z) \\
K\;x\;y & \overset{K}{\implies} x \\
I\;x & \overset{I}{\implies} x
\end{aligned}
$$

For example, the SKI expression \$ e=S(K(S\;I))K \$ is equivalent to the lambda expression \$ λx.λy.y\;x \$, as applying two arguments to \$ e \$ reduces to the desired result:

$$
\begin{aligned}
S(K(S\;I))K\;x\;y & \overset{S}{\implies} (K(S\;I)x)(K\;x)y \\
& \overset{K}{\implies} S\;I(K\;x)y \\
& \overset{S}{\implies} (I\;y)(K\;x\;y) \\
& \overset{I,K}{\implies} y\;x
\end{aligned}
$$

It is known that any lambda expression can be converted to a SKI expression.

A Church numeral is an encoding of natural numbers (including zero) as a lambda expression. The Church encoding of a natural number \$ n \$ is \$ λf. λx. f^n\;x \$ - given a function \$ f \$ and an argument \$ x \$, \$ f \$ repeatedly applied to \$ x \$ \$ n \$ times.

It is possible to construct a lambda expression (and therefore a SKI expression) that performs various arithmetic (e.g. addition, multiplication) in Church encoding. Here are a few examples of Church numerals and Church arithmetic functions: (The given SKI expressions are possibly not minimal.)

$$
\begin{array}{r|r|r}
\text{Expr} & \text{Lambda}   & \text{SKI} \\ \hline
0           & λf. λx. x       & K\;I       \\
1           & λf. λx. f\;x    & I          \\
2           & λf. λx. f(f\;x) & S (S (K\;S) K) I \\
\text{Succ} \; n & λn. λf. λx. f(n\;f\;x) & S (S (K\;S) K) \\
m+n         & λm. λn. λf. λx. m\;f(n\;f\;x) & S (K S) (S (K (S (K\;S) K)))
\end{array}
$$

Challenge

Write an SKI expression that accepts a Church numeral of \$ n \$ and evaluates to the Church numeral of \$ \lfloor n/2 \rfloor \$.

Scoring and winning criterion

The score is the total number of S, K, and I combinators used. The submission with the lowest score wins.

Here is a Python script to check the correctness and score of your SKI expression. For the record, I have a (relatively naïve) solution of score 126.

40 combinators

S(S(SI(K(S(S(KS)K)(K(S(S(KS)(S(KK)S))(K(S(KK)(S(S(KS)K)))))))))(K(S(SI(K(KI)))(K(KI)))))(KK)

Try it online!

Generated with a little help from a slightly modified version of my answer to Combinatory Conundrum:

$$\begin{align*}
\textit{zero} &= λf. λx. x = KI \\
\textit{succ} &= λn. λf. λx. f\,(n\,f\,x) = S(S(KS)K) \\
\textit{zero-pair} &= λf. f\,\textit{zero}\,\textit{zero} = S(SI(K\,\textit{zero}))(K\,\textit{zero}) \\
\textit{next-pair-helper} &= λf. λm. λn. f\,n\,(\textit{succ}\,m) \\ &= S(S(KS)(S(KK)S))(K(S(KK)\,\textit{succ})) \\
\textit{next-pair} &= λp. λf. p\,(\textit{next-pair-helper}\,f) \\ &= S(S(KS)K)(K\,\textit{next-pair-helper}) \\
\textit{half} &= λn. n\,\textit{next-pair}\,\textit{zero-pair}\,K \\ &= S(S(SI(K\,\textit{next-pair}))(K\,\textit{zero-pair}))(KK)
\end{align*}$$


Make a scalable Christmas Tree Your challenge: Make a Christmas tree. The size must be choosable by some input method, but doesn't have to be directly related to any part of the tree; however, larger inputs should produce a larger tree.

How can you make it? You can make the tree any way you like, other than by printing the unicode character for the tree, such as ouputting an image, ascii art, with other aspects, etc. Whatever you do, remember that this is a popularity-contest, so be creative.

The answer with the most upvotes by the end of December wins, but I'll accept another if it gets higher

Python

A fractal Christmas tree using the turtle package:

n = input()*1.

from turtle import *
speed("fastest")
left(90)
forward(3*n)
color("orange", "yellow")
begin_fill()
left(126)
for i in range(5):
    forward(n/5)
    right(144)
    forward(n/5)
    left(72)
end_fill()
right(126)

color("dark green")
backward(n*4.8)
def tree(d, s):
    if d <= 0: return
    forward(s)
    tree(d-1, s*.8)
    right(120)
    tree(d-3, s*.5)
    right(120)
    tree(d-3, s*.5)
    right(120)
    backward(s)
tree(15, n)
backward(n/2)

import time
time.sleep(60)

n is the size parameter, the shown tree is for n=50.  Takes a minute or two to draw.


Layout Text in Columns Write a program or function that given some text, a number of columns, and the column width, formats the text into columns. This is plain text typography.
Rules
Input

The text will be a string of printable ASCII and may contain newlines and spaces (but not tabs).
The number of columns will be a positive integer.
The column width is an integer greater or equal to 2 that specifies how many characters per column.

For this challenge, a word will consist of any non-whitespace characters. The input consists of one string and two integers, which may be taken in any order.
Output
Output is the text formatted into balanced columns with as many words on each line as will fit.

If a word is too long to fit in a column, put the word on the next line if there is another word on the current line and the line could be padded to the column width with three spaces or less.
Otherwise, hyphenate the word so that it fills the rest of the line. Hyphenate wherever the line ends; don't worry about hyphenating between syllables.
Columns should be separated by a margin of four space characters.
The columns should be balanced so that they all have an equal number of lines if possible.
The leftmost columns should have an extra line if necessary.
Any line breaks and multiple spaces should be preserved. Trailing spaces are optional after the last column.

Examples
Text:
The number of columns will be a positive integer.  Columns should be separated by a margin of four space characters.

The columns should be balanced.  The column width is greater than two.

Columns: 3, width: 10
The number    separated     ns should
of columns    by a marg-    be balanc-
will be a     in of four    ed.  The
positive      space cha-    column wi-
integer.      racters.      dth is gr-
Columns                     eater than
should be     The colum-    two.

Text:
This line is hyphenated.
This line, on the other hand, is not.

Columns: 1, width: 20
This line is hyphen-
ated.
This line, on the
other hand, is not.

Text: Tiny columns. columns: 4, width: 2
T-    c-    u-    s.
i-    o-    m-
ny    l-    n-

Text: Two  spaces.<space> columns: 5, width: 2
T-          p-    c-    s.
wo    s-    a-    e-

Text: <newline>A phrase columns: 2, width: 5
         rase
A ph-

Text: A short sentence. columns: 10, width: 5
A sh-    ort      sent-    ence.

Text: It's "no word" 1234567890 -+-+-+-+ (*&!) columns: 3, width: 6
It's      12345-    +-+
"no       67890     (*&!)
word"     -+-+--

This is code-golf; standard rules apply.

Python 2, 346 338 bytes
i,C,W=input()
r=[]
for l in [x or' 'for x in i.split('\n')]:
 while l:
  if' '==l[0]:l=l[1:]
  w=l[:W];x=W;s=w.rfind(' ')+1
  if max(W-3,0)<s:w=w[:s];x-=W-s
  elif x<len(l)and' 'not in l[x:x+1]:w=w[:-1]+'-';x-=1
  r+=[w];l=l[x:]
r=[s.ljust(W)for s in r+['']*(C-1)]
print'\n'.join('    '.join(s)for s in zip(*zip(*[iter(r)]*((len(r))/C))))

Input as 'string',C,W


Pyramid Scheme Negation In my language Pyramid Scheme, there is a slightly funny construct: the empty triangle:

^
-

When given no arguments, it returns 0. To generate 1 using this construct, we could use this:

   ^
  /!\
 ^---
 -

This simply passes 0 to the negation function. We can continue negating this result:

 ^
/!\
---^
  /!\
 ^---
 -

To get 0. One more negation gives:

   ^
  /!\
 ^---
/!\
---^
  /!\
 ^---
 -

Challenge

Given an integer n ≥ 1, output the empty pyramid being negated n times in the described fashion.

Test cases

input
output

1
   ^
  /!\
 ^---
 -

2
 ^
/!\
---^
  /!\
 ^---
 -

3
   ^
  /!\
 ^---
/!\
---^
  /!\
 ^---
 -

6
 ^
/!\
---^
  /!\
 ^---
/!\
---^
  /!\
 ^---
/!\
---^
  /!\
 ^---
 -


Is my Rep in Stack-Exchange Form? Premise:

Your reputation is in Stack-Exchange Form if it can be represented by decomposing your medal counts (gold, silver, and bronze counted separately) into their base-10 digits and joining them in any given order, with a few caveats.

While decomposing, each

Gold medal digit is worth three digits.
Silver is worth two digits.
Bronze is one digit.
Additionally, since SE does not display a medal type if you do not have any, a count of 0 medals for a type will not yield a [0].

Example:

[1 Gold, 2 Silvers, 3 Bronzes] will decompose into [1,1,1,2,2,3]. 321112 and 213121 are two examples of an SE-form number for these medals.
[20 Golds, 0 Silvers, 20 Bronzes] will decompose into [2,2,2,0,0,0,2,0]. 20002022 is an SE-form number.
[11 Golds, 0 Silvers, 0 Bronzes] will decompose into [1,1,1,1,1,1]. 111111 is the only SE-form number for this.

There will be no leading 0's when considering a SE number. E.g., in the 2nd example above, 00002222 -> 2222 would not be considered a SE-form number for [20,0,20].

Input/Output:

Input is a list/tuple/array/whatever of [reputation, gold_medals, silver_medals, bronze_medals] which are all non-negative integers. This is the assumed order but can be changed. Just make a note in your answer if you do.

Output is any two consistent values for true and false.

Rules:

Input will always be valid
You will always have at least 1 Rep
You can have no medals at all, which should always return false then.
The medal counts have no bearing on reality. Having several hundred golds and no bronzes is fine.
This is code-golf so shortest answer in bytes wins.

Test Cases:

#[Rep, Gold, Silver, Bronze] -> Output
[4, 0, 0, 4]       -> True
[1447, 0, 4, 17]   -> True
[74414, 4, 0, 17]  -> True
[4444, 4, 0, 4]    -> True
[4455, 0, 54, 0]   -> True
[5355, 5, 0, 3]    -> True
[53535, 5, 3, 0]   -> True
[4444, 0, 0, 4444] -> True
[444, 4, 0, 0]     -> True
[1234, 0, 0, 1234] -> True
[1234, 0, 0, 4321] -> True

[4444, 1, 0, 1]      -> False
[5555, 5, 0, 55]     -> False
[1234, 1, 23, 4]     -> False
[1, 0, 0, 0]         -> False
[1001001, 0, 10, 10] -> False

05AB1E, 16 14 13 11 10 bytes
∞×0KJ‚€{íË

Takes the medals input in the order [bronze, silver, gold] as first input, and reputation as second input.
-1 byte thanks to @Grimy.
Try it online or verify all test cases.
Explanation:

∞           # Push an infinite positive list: [1,2,3,...]
 ×          # Repeat the values in the (implicit) input-list that many times as string
            # (since the input-list contains just 3 values, the rest of the infinite
            #  list is ignored)
  0K        # Remove all 0s (so all "0", "00" and "000")
    J       # Join the strings in the list together
     ‚      # Pair this string with the (implicit) second input
      €{í   # Sort the digits in both strings in descending order
         Ë  # And check if both are now equal
            # (after which the result is output implicitly as result)


Use that goodn't meme There is currently a meme on the internet that consist of taking a sentence, reverse the meaning and adding n't at the end. For example, I am small becomes I am talln't

Challenge

For the sake of the challenge, we'll simplify this : Your task will be to detect whenever there is a negation in a sentence, and replace it with the 'positive' one with n't added at the end. There will be some tricky parts that will be explained in the rules.

Rules

You have to take a String as input, and return a String as output.
Input will be a sentence in lowercase, with only . and , as punctuation marks.
You have to replace any no <any_word> or not <any_word> with <any_word>n't.
no/not have to be a word and not a substring : you don't have to change anything in none of those
If the word already finish with a n, you have to replace n't with 't : no plan become plan't and not plann't
When no or not isn't followed by any word, a punctuation mark  or another no/not, you have to replace it with yesn't.
compound words count as one word. so even if no-op contain the substring no, it doesn't contain the word no. So the result will be no-op and not -opn't.
You do not have to worry about grammar errors. For example, there is no way will result to there is wayn't.
No standard loopholes allowed.
This is codegolf, so the shortest code wins.

There are some examples, even if this challenge looks clearn't for now.

Examples

  Input : i love codegolfing, but i do not like short programs.
  does this sentence makes sense ... of course no.
  Output : i love codegolfing, but i do liken't short programs.
  does this sentence makes sense ... of course yesn't.

  Input : you are not invited. get out.
  Output : you are invitedn't. get out.

  Input : i am not ok, i have no plan and i have no gunn
  Output : i am okn't, i have plan't and i have gunn't

  Input : oh no no no i refuse.
  Output : oh yesn't yesn't in't refuse.

  Input : oh no no no, i refuse.
  Output : oh yesn't yesn't yesn't, i refuse.

  Input : i cannot believe this, you can't codegolf.
  Output : i cannot believe this, you can't codegolf.

  Input : oh no ... he did it again.
  Output : oh yesn't ... he did it again.

  Input : nn't is not a word, kevin. so this is not nn't.
  Output : nn't is an't word, kevin. so this is nn'tn't.

  Input : is it not clearn't for everyone
  Output : is this clearn'tn't for everyone

  Input : this is non't sense ...
  Output : this is non't sense ...

Retina, 86 70 65 bytes
T`-'`L
\bnot?\s+(?!not?\b)(\w+?)n?\b
$1n't
\bnot?\b
yesn't
T`L`-'

-16 bytes thanks to @Neil.
-5 bytes thanks to @ovs.
Try it online.
Explanation:
T`-'`L             # Replace all "-" with "A" and all "'" with "B" to store them

\bnot?             # Then replace the word "no" or "not",
 \s+               #  followed by 1 or more whitespaces,
 (?!not?\b)(\w+?)  #  followed by a word/letter that is not "not" or "no"
 n?\b              #  minus a single trailing "n" if there are any
$1                 # with: the word/letter
 n't               #  appended with "n't"

\bnot?\b           # Then replace any remaining loose "no" or "not"
yesn't             # with "yesn't"

T`L`-'             # And finally replace all "A" with "-" and all "B" with "'" again


Write a polyglot that prints the language's name Your task is to write a program that executes in as many languages as possible, with as few characters as you can. To avoid trivial solutions, the program must print the name of the language it was run in.
Scoring
Your program has to work in at least 5 languages. A program's score is given as:
$$\frac {\text{(number of languages)}^{1.5}} {\text{(length of program)}}$$
The highest score wins, not sooner than 10 days after the first valid answer.

Bash, C, C++, Obj-C, Obj-C++, Perl, PHP, Ruby, 183 chars

score ~ 0.1236

For the C and C-like codes I owe a debt to @baby-rabbit. The others are inspired by the recognition that many languages have an eval statement that will grudgingly accept invalid syntax.

Outputs the language name to standard output. Sometimes generates a lot of error messages on standard error, so suppress them with 2>/dev/null as you run them.

#if 0
'PHP<?/*';eval "print\$=?'Perl':'Ruby';echo Bash";exit
__END__
#endif
#include <stdio.h>
main(){puts(
#ifdef __OBJC__
"obj-"
#endif
"C"
#ifdef __cplusplus
"++"
#endif
);}//*/?>'

The php solution outputs 'PHP' (including the single quotes), which may be bending the rules a little bit.

Last edit: shaved 12 chars from insight that $= is false in Ruby, 60 in Perl, and print$=?... is almost surely an error in Bash. Shaved 7 more from insight the Perl/Ruby/Bash test can now go into a single eval statement.

If the rules can tolerate more bending, I present this 8 language, 43 character solution (score 0.5262)

print("phperluarscriptrubypythoncatebg13");

for which the output includes the name of the interpreter for php, perl, lua, rscript, ruby, python, cat, and rot13.


Bowl a rectangular quine Code-Bowling Quine Challenge
You must bowl a quine following the rules of code bowling and quines but the source code must be in the shape of a rectangle (details specified below)

Quine
Quines returned must be returned via the ways defined in the standard I/O rules.

Rules
Code-Bowling Rules

Character : Byte Ratio  In Code-Bowling a character-count is
preferred over a byte-count. The obvious reasoning for this is that
multi-byte unicode characters (e.g. ) can be used in place of
single-byte unicode characters to fluff up byte count and will make
bowling more about who renames the most variables with high-byte
unicode characters rather than who most strategically creates
meaningful complex code. (See Useful tools section at end for
character-counting widget)

Variable/Function/Object Names  All variable names (or object pointers, function names, etc) should be 1 character long. The only
acceptable time to use 2-character variables names is after all
possible 1-character variables have been used. The only acceptable
time to use 3-character variables names is after all possible
2-character variables have been used. Etc.

Non-simplified Arithmetic  All arithmetic should be in simplified form unless there is a justifiable reason for doing otherwise (e.g.
circumventing penalties defined in the scoring system of the
challenge (In which case you still must use the smallest possible
alternative form)). Finding the simplified form of any equation (as
well as a list of small alternative forms) is easy to do using
Wolfram|Alpha. (See Useful tools section at end)

Un-used Code  All code must be used. Meaning the program must fail to always properly complete the task if any individual character (or
varying set(s) of characters) is/are removed. Naturally, a subset of
the program should not be able complete the task on its own without
the rest of the program.

Line-breaks and White-space  Unless necessary for code function or otherwise specified by the challenge, all line-breaks and
white-space should be removed from code before scoring by counting
characters.

Comments  Comments are not permitted towards character-count, unless somehow utilized by your program/function.

Rectangle Rules
Your code must be in the shape of a rectangle, i.e. every line has the same number of characters. Your code must have at least 2 lines, with at least 3 chars on each line.
Also, each line of code must be distinct to a certain threshold. Distinctness is calculated using the Levenshtein distance. The threshold is 85%, meaning the Levenshtein distance between any two lines must be greater than or equal to 0.85*w, where w is the number of characters used in a line of your rectangle.
And for convenience, here is a Levenshtein distance calculator and a character length calculator.

Scoring
This is a code-bowling variant. The program with the highest number of characters wins!

Python 3, 89 bytes

a='a=%r;b=%r;p=\\';b='print;p(a%(a,b));';p=\
print;p(a%(a,b));c='c=%r;p(b+c%%c)';p(b+c%c)

Try it online
The Levenshtein distance is 38, which is 86.36% of 44.
Explanation:
This is similar to the standard quine s='s=%r;print s%%s';print s%s. I had to try a lot of combinations and modifications in order to find my program. Creating the function p was used to make the second line shorter. The \ on the end of the first line is a line-continuation character.
a
a='a=%r;b=%r;p=\\'

A string template that results in the first line

b
b='print;p(a%(a,b));'

String that represents the first part of the 2nd line

p
p=\
print

Shorten stuff, change lengths

line 1
p(a%(a,b))

Print the first line

c
c='c=%r;p(b+c%%c)'

String representing itself plus the part after that prints b

line 2
p(b+c%c)

Outputs the second line


Quine in Bytes, not Characters Introduction

A quine is a program that takes no input and produces a copy of its own source code as output. Writing a quine is a standard test of a programming language. Most quines operate using strings of characters: that is what the source code is made of, after all! However, this quine is slightly different.

Challenge

Your challenge is to write a program that takes no input and produces the number of bytes in the program as output.

By "takes no input", I mean does not change based on input. Your program can still take command line arguments, or even arguments from stdin, but it cannot do anything with them. It must either discard or ignore them. Basically, your program should produce the same output no matter what input is given.
Your program must output the number of bytes in it. If it is a function, it can output through its return value. If, and only if your language has no stdout, you may store output in a variable. The input can be printed as a string or an integer; the user cannot tell the difference between the output of print('5') or print(5)! Note that I said byte count, not character count. If your program uses Unicode characters that take up more than 1 byte (like some Jelly or APL programs), the output must reflect that.

Rules

This is code-golf so shortest answer in bytes wins! Edit: Actually, since there is a 1 byte answer, let's do top 3 shortest.

Edit: this question is not the same as Output your Score. For one, this one does not disallow cheating quines. Also, I do not require a trailing " bytes" in output.

Most languages, 0 bytes

Try it online!

Outputs via exit code, which is 0 for almost any language where an empty program is valid.


Calculate the Gamma function for half-integer arguments Gamma function is defined as

It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is

  Γ(1/2) = π1/2

Actually, the Gamma function can be evaluated for all half-integer arguments, and the result is a rational number multiplied by π1/2. The formulas, as mentioned in Wikipedia, are:

 (for n > 0)

In this challenge, you should write code (program or function) that receives an integer n and returns the rational representation of Γ(1/2 + n) / π1/2, as a rational-number object, a pair of integers or a visual plain-text representation like 15/8.

The numerator and denominator don't need to be relatively prime. The code should support values of n at least in the range -10 ... 10 (I chose 10 because 20! < 264 and 19!! < 232).

Test cases (taken from Wikipedia):

Input | Output (visual) | Output (pair of numbers)
0     | 1               | 1, 1
1     | 1/2             | 1, 2
-1    | -2              | -2, 1
-2    | 4/3             | 4, 3
-3    | -8/15           | -8, 15

M, 7 bytes

,0_.!÷/

Try it online! or verify all test cases.

Trivia

Meet M!

M is a fork of Jelly, aimed at mathematical challenges. The core difference between Jelly and M is that M uses infinite precision for all internal calculations, representing results symbolically. Once M is more mature, Jelly will gradually become more multi-purpose and less math-oriented.

M is very much work in progress (full of bugs, and not really that different from Jelly right now), but it works like a charm for this challenge and I just couldn't resist.

How it works

,0_.!÷/  Main link. Argument: n

,0       Pair with 0. Yields [n, 0].
  _.     Subtract 1/2. Yields [n - 1/2, -1/2].
    !    Apply the Π function. Yields [Π(n - 1/2), Π(-1/2)] = [Γ(n + 1/2), Γ(1/2)].
     ÷/  Reduce by division. Yields Γ(n + 1/2) ÷ Γ(1/2) = Γ(n + 1/2) ÷ √π.


Nearest partition numbers The number of partitions of an integer is the number of ways that integer can be represented as a sum of positive integers.

For example:

5
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1

There are 7 ways to represent the number 5, therefore 7 is the partition number corresponding to the number 5.

Partition numbers: OEIS: #A000041

Directions

Write a program that takes a positive integer as input, and outputs the two numbers that generate the two closest partition numbers to the input number.

Input must be 1 positive integer.
If the input is not a partition number, the output must be the 2 different positive integers that generate the two closest partition numbers to the input number. (If two partition numbers are equal candidates for one of the output numbers, it doesn't matter which one you choose.)
If the input is a partition number, the output must be 1 positive integer that generates the input number.
Input and output may be in any reasonable format.
You may assume that the input will not be larger than 100 million (eg. output will never be larger than 95).
Built-in functions to calculate partition numbers are not allowed, along with other Standard loopholes.
This is code-golf, so least number of bytes wins.

Partition numbers: OEIS: #A000041

Examples

Input: 66
Output: 11, 12

(The partition numbers that correspond to the numbers 11 and 12 are 56 and 77, which are the two closest partition numbers to 66.)

Input: 42
Output: 10

(The number 42 is already a partition number, so just output the number that corresponds to the partition number.)

Input: 136
Output: 13, 14

(The two closest partition numbers to 136 are actually both LESS than 136 (eg. 101 and 135), therefore the output is 13 and 14 as opposed to 14 and 15.)

Input: 1
Output: 0   or   1

(Both 0 and 1 are valid outputs in this special case.)

Input: 2484
Output: 26, 25   or   26, 27

(Both of these outputs are valid, because 2484 is equal distance from 1958 and 3010.)

Input: 4
Output: 3, 4

(Yup)

Python 2, 179 bytes
Z=range(1,99)
R=Z+[1]
for i in Z:R[i]=sum(-(-1)**k*(3*k*k-k<=i*2and R[i-k*(3*k-1)/2])for k in range(-i,i+1)if k)
f=lambda n:zip(*sorted((abs(n-R[i]),i)for i in Z))[1][:2-(n in R)]

Uses the recursive formula from Euler's pentagonal theorem.
Call with f(2484). Output is a tuple with one or two numbers.


RGB to Xterm Color Converter 256-color Xterm-compatible terminals add 240 colors on top of the usual 16 system colors. Colors 16-231 use 6 levels (0, 95, 135, 175, 215, 255) of red, green, and blue, ordered lexicographically. Colors 232-255 are simply 24 levels of gray (8...238 by 10s). To get a better idea of what I'm talking about, see this table.

The Challenge

Your goal is to make a program or function that takes, as input, rgb values, and outputs the number corresponding with the closest Xterm color to that rgb value. Since the 16 system colors (colors 0-15) are often customizable, you will be excluding them from this conversion.

To better define what the "closest" color is, use the Manhattan distance along red, green, and blue components. For example, rgb(10, 180, 90) is 20 units away from rgb(0, 175, 95) (color 35) because abs(10 - 0) + abs(180 - 175) + abs(90 - 95) == 20. If the input color is equally between two or more Xterm colors, output the Xterm color with the highest index.

Examples

 R   G   B     Xterm
  0   0   0 ==> 16
 95 135   0 ==> 64
255 255 255 ==> 231
238 238 238 ==> 255

 90 133 140 ==> 66
218 215 216 ==> 188
175 177 178 ==> 249

175   0 155 ==> 127
 75  75  75 ==> 239
 23  23  23 ==> 234
115 155 235 ==> 111

Rules

Standard loopholes are forbidden
Your program or function is allowed to take rgb values in any reasonable format, including:

Separate arguments for red, green, and blue
A list, tuple, dictionary, or similar
Delimiter-separated string or stdin
Hex colors (e.g. #ff8000)

You may assume that all r, g, and b, values will be integers between 0 and 255.
Since the 16 system colors are to be excluded from the mapping, all outputs should be in the range 16...255.

This is code-golf, so shortest code wins.

Haskell, 132 bytes

v=0:[95,135..255]
f c=snd$maximum[(-sum(abs<$>zipWith(-)c x),i)|(i,x)<-zip[16..]$[[r,g,b]|r<-v,g<-v,b<-v]++[[g,g,g]|g<-[8,18..238]]]

Try it online!

Takes input as a list of integers [red, green, blue].

Fairly straightforward implementation. First I build a list of the Xterm colors we're using with two list comprehensions concatenated together. The first of which handles colors 16-231 by triple iterating over v which contains the values those colors use. The second one just iterates over the grey values and puts them in all three slots. Then I index it with zip (starting at 16) and make a pair with the manhattan distance (negated) and that index and take the maximum. I used maximum because we're tie-breaking on the largest index and this way saves me one extra -.


Calculate π with quadratic convergence Write a function or complete program that takes a positive number n and performs n steps of an iterative algorithm for calculating π that has quadratic convergence (i.e. it approximately doubles the number of accurate digits at every iteration) then returns or prints out 2n correct digits (including the beginning 3). One such algorithm is the Gauss–Legendre algorithm, but you are free to use a different algorithm if you prefer.

Examples:

input 1 → output 3.1
input 2 → output 3.141
input 5 → output 3.1415926535897932384626433832795

Requirements:

Each iteration of the algorithm must perform a constant number of basic operations such as addition, subtraction, multiplication, division, power and root (with integer exponent/degree) - each such operation on "big" integer/decimal numbers is counted as one even if it involves one or more loops internally. To be clear, trigonometric functions and powers involving complex numbers are not basic operations.
The algorithm is expected to have an initialization step which must also have a constant number of operations.
If the algorithm needs 1 or 2 more iterations to get to 2n correct digits, you can perform up to n+2 iterations instead of just n.
If it wasn't clear enough, after the correct 2n digits, your program must not print anything else (such as more correct digits, wrong digits or the complete works of Shakespeare).
Your program must support values of n from 1 to at least 20.
Your program should not take more than an hour for n=20 on a modern computer (not a hard rule, but try to keep it reasonable).
The program must not obtain more than 20 accurate digits after the initialization and first iteration of the algorithm.
The program must be runnable in Linux using freely available software.
The source code must use only ASCII characters.

Scoring:

Straightforward code golf, shortest code wins.

Winner:

The winner is Digital Trauma, I finally finished running his code on n=20 (just kidding). Special prize goes to primo for his very fast python solution and different algorithm :)

dc, 99 bytes
Golfed:
2?dsi1+^k1dddsa2v/sb4/stsp[lalb*vlalb+2/dla-d*lp*ltr-stsasblp2*spli1-dsi0<m]dsmxK2/1-klalb+d*4lt*/p

With whitespace and comments for "readability":
2?dsi               # Push 2. push input n, duplicate and store in i
1+^k                # Set calculation precision to 2^(n+1)
1dddsa              # Push four 1s. Store 1st in a
2v/sb               # Store 1/sqrt(2) in b
4/st                # Store 1/4 in t
sp                  # Store 1 in p
[                   # Start iteration loop macro
lalb*v              # Save sqrt(a*b) on stack
lalb+2/d            # Save a[i+1] = (a[i]+b[i])/2 on stack and duplicate
la-d*lp*ltr-        # Save t-p(a[i]-a[i+1])^2 on the stack
st                  # Store t result from stack
sa                  # Store a result from stack
sb                  # Store b result from stack
lp2*sp              # Store 2p in p
li1-dsi0<m]         # Decrement iteration counter i; recurse into macro if < 0
dsmx                # Duplicate, store and run macro
K2/1-k              # Set display precision to 2^n-1
lalb+d*4lt*/        # Save (a+b)^2/4t on stack
p                   # Print result

dc needs to be told how many digits of precision should be used.  The calculation precision needs to be higher than the final display precision, so the calculation precision is set to be 2^(n+1) digits.  I have verified the accuracy of the output with n=10 against http://www.angio.net/pi/digits/pi1000000.txt.
This slows down dramatically for larger n; n=12 takes 1.5 mins on my VM.  Running a few different samples shows the time complexity is O(e^n) (not surprising).  Extrapolating this to n=20 would have a runtime of 233 days.  Oh well.  Better than heat-death-of-the-universe at least.
This is moderately golfed - the stack is used to eliminate temporary variables during the calculations of each iteration, but there is possibly more use of the stack to shorten this more.
$ dc glpi.dc <<< 1
3.1
$ dc glpi.dc <<< 2
3.141
$ dc glpi.dc <<< 5
3.1415926535897932384626433832795
$ time dc glpi.dc <<< 7
3.1415926535897932384626433832795028841971693993751058209749445923078\
164062862089986280348253421170679821480865132823066470938446

real    0m0.048s
user    0m0.039s
sys 0m0.000s
$

If you don't like dc wrapping output at 70 chars, you can set the environment variable DC_LINE_LENGTH to 0:
$ DC_LINE_LENGTH=0 dc glpi.dc <<< 8
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648
$


There, I fixed it (with tape) Challenge:
Given a string only containing upper- and/or lowercase letters (whichever you prefer), put tape horizontally to fix it. We do this by checking the difference of two adjacent letters in the alphabet (ignoring wrap-around and only going forward), and filling the space with as much TAPE/tape as we would need.

Example:
Input: abcmnnnopstzra
Output: abcTAPETAPETmnnnopTAstTAPETzra
Why?

Between c and m should be defghijkl (length 9), so we fill this with TAPETAPET;
Between p and s should be qr (length 2), so we fill this with TA;
Between t and z should be uvwxy (length 5), so we fill this with TAPET.

Challenge rules:

The difference only applies forward, so no tape between zra.
It is possible to have multiple of the same adjacent letters like nnn.
You are allowed to take the input in any reasonable format. Can be a single string, string-array/list, character-array/list, etc. Output has the same flexibility.
You are allowed to use lowercase and/or uppercase any way you'd like. This applies both to the input, output, and TAPE.
It is possible no TAPE is necessary, in which case the input remains unchanged.

General rules:

This is code-golf, so the shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link to a test for your code.
Also, please add an explanation if necessary.

Test cases:
Input:  "abcmnnnopstzra"
Output: "abcTAPETAPETmnnnopTAstTAPETzra"

Input:  "aza"
Output: "aTAPETAPETAPETAPETAPETAPEza"

Input:  "ghijk"
Output: "ghijk"

Input:  "aabbddeeffiiacek"
Output: "aabbTddeeffTAiiaTcTeTAPETk"

Input:  "zyxxccba"
Output: "zyxxccba"

Input:  "abccxxyz"
Output: "abccTAPETAPETAPETAPETAPExxyz"

Input:  "abtapegh"
Output: "abTAPETAPETAPETAPETtaTAPETAPETAPETApeTgh"

Input:  "tape"
Output: "taTAPETAPETAPETApe"

Jelly, 13 bytes

OI’“¡ʂƁ»ṁ$€ż@

Try it online!

Explanation

OI’“¡ʂƁ»ṁ$€ż@ – Full program. Take a string as a command line argument.
O             – Ordinal. Get the ASCII values of each character.
 I’           – Get the increments (deltas), and subtract 1 from each.
          €   – For each difference I...
   “¡ʂƁ»ṁ$    – Mold the compressed string "tape" according to these values.
                Basically extends / shortens "tape" to the necessary length.
           ż@ – Interleave with the input.


Ordering words to fit in a given string Given a string of letters and a set of words, output an ordering of the words so
that they can be found in the string by dropping letters that are not needed.
Words may occur more than once in the word set. The input string and all words
will consist of 1 to 1000 lower case letters each. The letters to be dropped may occur inside words or between words.

Your program or function can accept the letter string and words as lists, a string, or from STDIN, and must output all words in a correct order as a list
or string output. If there is more than one correct solution, only output one of
them. If there is no possible correct solution, output an empty list or an empty
string.

Examples:

dogcatfrog cat frog dog
-> dog cat frog

xxcatfixsxhingonxgrapexxxfishingcxat cat grape catfish fishing
-> catfish grape fishing cat

dababbabadbaccbcbaaacdacdbdd aa bb cc dd ba ba ba ab ac da db dc
-> da ab ba ba ba cc bb aa ac dc db dd

flea antelope
->
(no solution)

This is code golf. Lowest number of bytes wins.

Edit: Explained that extra characters can be inside words.

Pyth, 20 24 bytes
My first attempt on Pyth :)
Jcw;FG.ptJI:hJj".*"G0jdG

How it works:
Jcw;FG.ptJI:hJj".*"G0jdG
Jcw                         assign("J",chop(input()))
    FG.ptJ                  for G in permutations(tail(J)):
          I:hJj".*"G0        if match(head(J),join(".*",G)):
                     jdG      print(join(" ",G))

Notes: it takes a long time in the third example (dababbabadbaccbcbaaacdacdbdd aa bb cc dd ba ba ba ab ac da db dc).


Appending String Lengths Challenge:

Given a string s on the characters a-z, A-Z, 0-9, append the length of s to itself, counting the additional character(s) in the length as part of the total length of s.

Input:

Just a string of arbitrary length (can be empty).

Output:

The same string, but with its length appended to the end.  The characters that represent the length should also be counted as part of the length.  In cases where there are multiple valid lengths to append, choose the smallest one possible (see test cases for examples).

Test Cases:

INPUT     -> OUTPUT       // Comment
aaa       -> aaa4
          -> 1            // Empty string
aaaaaaaa  -> aaaaaaaa9    // aaaaaaaa10 would also normally be valid, but violates using the smallest number rule mentioned above
aaaaaaaaa -> aaaaaaaaa11
a1        -> a13          // Input can contain numbers at the end of the string, you do not have to handle the fact that it looks like 13 rather than 3.

Longer test case(s):

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa101
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa102

Rules:

This is code-golf, so shortest code in bytes wins.  Standard loopholes are forbidden.  Submissions may be an entire program or a function, and you may either print the result to stdout or return it as a variable from a function.

JavaScript (ES6), 32 bytes

f=(s,n=0)=>(s+n)[n]?f(s,n+1):s+n

How it works

f = (s, n = 0) =>   // given a string 's' and starting with n = 0:
  (s + n)[n] ?      // if the Nth character of (s + n) exists:
    f(s, n + 1)     //   try again with n + 1
  :                 // else
    s + n           //   return s + n

Starting with N=0, we test the Nth character (0-based) of the string made of the concatenation of the original input string and the decimal representation of N. We increment N until this character doesn't exist anymore.

Example:

N =  0 : abcdefghi0
         ^
N =  1 : abcdefghi1
          ^
N =  2 : abcdefghi2
           ^
...
N =  8 : abcdefghi8
                 ^
N =  9 : abcdefghi9
                  ^
N = 10 : abcdefghi10
                   ^
N = 11 : abcdefghi11    -> success
                    ^

Test cases

f=(s,n=0)=>(s+n)[n]?f(s,n+1):s+n

console.log(f("aaa"));       // -> aaa4
console.log(f(""));          // -> 1
console.log(f("aaaaaaaa"));  // -> aaaaaaaa9
console.log(f("aaaaaaaaa")); // -> aaaaaaaaa11
console.log(f("a1"));        // -> a13


It took me a lot of time to make this, pls like. (YouTube Comments #1) Hold up..... this isn't trolling.

Background
These days on YouTube, comment sections are littered with such patterns:
S
St
Str
Stri
Strin
String
Strin
Stri
Str
St
S

where String is a mere placeholder and refers to any combination of characters. These patterns are usually accompanied by a It took me a lot of time to make this, pls like or something, and often the OP succeeds in amassing a number of likes.

The Task
Although you've got a great talent of accumulating upvotes on PPCG with your charming golfing skills, you're definitely not the top choice for making witty remarks or referencing memes in YouTube comment sections. Thus, your constructive comments made with deliberate thought amass a few to no 'likes' on YouTube. You want this to change. So, you resort to making the abovementioned clichéd patterns to achieve your ultimate ambition, but without wasting any time trying to manually write them.
Simply put, your task is to take a string, say s, and output 2*s.length - 1 substrings of s, delimited by a newline, so as to comply with the following pattern:
(for s = "Hello")
H
He
Hel
Hell
Hello
Hell
Hel
He
H

Input
A single string s. Input defaults of the community apply.
You can assume that the input string will only contain printable ASCII characters.

Output
Several lines separated by a newline, constituting an appropriate pattern as explained above. Output defaults of the community apply.
Leading and trailing blank (containing no characters or characters that cannot be seen, like a space) lines in the output are permitted.

Test Case
A multi-word test case:
Input => "Oh yeah yeah"

Output =>

O
Oh
Oh
Oh y
Oh ye
Oh yea
Oh yeah
Oh yeah
Oh yeah y
Oh yeah ye
Oh yeah yea
Oh yeah yeah
Oh yeah yea
Oh yeah ye
Oh yeah y
Oh yeah
Oh yeah
Oh yea
Oh ye
Oh y
Oh
Oh
O

Note that there are apparent distortions in the above test case's output's shape (for instance, line two and line three of the output appear the same). Those are because we can't see the trailing whitespaces. Your program need NOT to try to fix these distortions.

Winning Criterion
This is code-golf, so the shortest code in bytes in each language wins!

brainfuck, 32 bytes

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

Try it online!

The same loop is used for both halves of the pattern.

Explanation:

,             Take first input character as initial line
[             Until line to output is empty:
  [<]>        Move to beginning of line
  [.>]        Output all characters in line
  ++++++++++. Output newline
  ,           Input next character
  [>>]        Move two cells right if input character nonzero
  <[-]        Otherwise remove last character in line
  <           Move to new last character in line
]