String.prototype.isRepeated UPDATE : isaacg's Pyth submission is the winner!

Many of you must have heard that there is a cooler version of JavaScript in town (read ES6) which has a method String.prototype.repeat so that you can do

"Hello, World!".repeat(3)

and get

"Hello, World!Hello, World!Hello, World!"

as the output.

Your job is to write a function or a program in a language of your choice which detects if a string has been gone under such transformation.

i.e. The input string can be represented as an exact n times repetition of a smaller string. The output (as function's return statement or STDOUT) should be truthy if the string can be or falsy if the string cannot be represented as a repetition of smaller string.

Some sample input:

"asdfasdfasdf"  // true
"asdfasdfa"     // false
"ĴĴĴĴĴĴĴĴĴ"     // true
"ĴĴĴ123ĴĴĴ123"  // true
"abcdefgh"      // false

Note that the last input is false, thus n should be greater than 1

Complete rules

Write a function/program in any language to input (via function argument/command line args/STDIN) a string
Return/Print truthy value if the given string is formed via an exact repetition of a smaller string, repeating at least twice.
Maximum size of the input string is ideally Infinity
String can have all possible ASCII characters
This is a code-golf so smallest code in characters wins.

Python (24)

lambda s:s in(s+s)[1:-1]

Checks if the string is a substring of itself concatenated twice, eliminating the first and last characters to avoid trivial matches. If it is, it must be a nontrivial cyclic permutation of itself, and thus the sum of repeated segments.


Draw some ASCII stars Write a program or function that draws an ASCII star, given the size of the arms as input.

Here's a star of size 1

_/\_
\  /
|/\|

Here's a star of size 2

   /\
__/  \__
\      /
 \    /
 | /\ |
 |/  \|

Here's a star of size 3

     /\
    /  \
___/    \___
\          /
 \        /
  \      /
  |  /\  |
  | /  \ |
  |/    \|

And so on.

Input

A single positive integer in any convenient format, n > 0.

Output

An ASCII-art representation of a star, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the points line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Charcoal, 20 17 bytes

-3 bytes thanks to Neil.

Ｎν↙ν↑↑ν↖ν ×_ν↗ν‖Ｍ

Try it online! Link is to verbose version.

I'm pretty happy with this golf so...

Explanation

Ｎν                 take a number as input and store in ν
  ↙ν               print / ν times downwards to the left
    ↑              move up once
     ↑ν            print | ν times upwards
       ↖ν          print \ ν times upwards to the left
                   print a space
          ×_ν      print _ ν times
             ↗ν    print / ν times upwards to the right
               ‖Ｍ  reflect horizontally

     /\
    /  \    "No, this is Patrick!"
___/    \___
\   ☉ ☉    /
 \       /
  \      /
  |  /\  |
  | /  \ |
  |/    \|


Calculate Network Average Clustering Coefficient The clustering coefficient of a graph (or network) is a:

measure of degree to which nodes in a graph tend to cluster together

The Wikipedia article gives a much better description of how network average clustering coefficient is calculated from local clustering coefficients than I could give.
The Challenge
Given an adjacency matrix a describing an undirected network (or graph) with no self loops, calculate it's network average clustering coefficient.
Details

You must write a program/function/procedure/code block which calculates the network average clustering coefficient for any undirected graph with no self loops.
The output may only contain the coefficient and nothing else.
You are to assume that your program (or whatever) has access to an adjacency matrix describing the graph through a variable/the stack/file/whatever
You may not use any inbuilt functionality your language may have to calculate clustering coefficients
Shortest code wins

Test Examples
Test inputs and outputs can be found in this pastebin
My solution: GNU Octave, 93 chars
(behind spoiler)

 f=sum(a);c=0;for i=find(f>1)c+=sum(a(t=find(a(i,:)),t)(:))/(f(i)*(f(i)-1));endfor;c/length(a)

Which can be tested here, the matrix needs to be in the format a = [row ; row ; row ; ...]


Do Matrix Multiplication! In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations on vectors, which have numerous applications in applied mathematics, physics, and engineering. In more detail, if A is an n × m matrix and B is an m × p matrix, their matrix product AB is an n × p matrix, in which the m entries across a row of A are multiplied with the m entries down a columns of B and summed to produce an entry of AB. When two linear transformations are represented by matrices, then the matrix product represents the composition of the two transformations.

Source: Wikipedia

In other words, to multiply two matrices, for example:

1 2 3   1 4
2 3 4 × 3 1 =
3 4 5   4 6

First, take row number 1 in the first matrix, column number 1 in the second matrix, and multiply 1 by 1, 2 by 3, and 3 by 4.

1 × 1 = 1
2 × 3 = 6
3 × 4 = 12

Now add them together to get your first item:

1 2 3   1 4   19
2 3 4 × 3 1 =
3 4 5   4 6

For the second number in the first column of the result, you will need to take row number 2 instead of row number 1 and do the same thing.

1 × 2 = 2
3 × 3 = 9
4 × 4 = 16
      = 27

After you do the entire first column, the result looks like this:

1 2 3   1 4   19
2 3 4 × 3 1 = 27
3 4 5   4 6   35

Now, do the same exact thing again, but take the second column instead of the first column, resulting in:

1 2 3   1 4   19 24
2 3 4 × 3 1 = 27 35
3 4 5   4 6   35 46

Your task

Given two matrices (max dimensions 200x200), containing numbers in the range -10000 to 10000, where the number of columns on the first one equals the number of rows on the second, multiply the first one by the second one. (Matrix multiplication is non-commutative.)

You may take input and give output as an array of arrays (or equivalent), a matrix (if your language has that format) or a multiline string.

You may not use any built-ins for matrix multiplication.

Test cases

1 2   1 2 3 4 5    13 16 19 22 25
3 4 × 6 7 8 9 10 = 27 34 41 48 55
5 6                41 52 63 74 85

2 3   3 5   15 13
3 4 × 3 1 = 21 19

5 3            11    27
1 3      1 3   7     15
9 3    × 2 4 = 15    39
1 -1000        -1999 -3997

Remember, this is code-golf, so the code with the fewest bytes wins.

Jelly, 7 5 bytes

Z×þḅ1

Takes B and A as arguments and returns A × B.

Try it online!

How it works

Z×þḅ1  Main link. Left argument: B. Right argument: A

Z      Zip; transpose B's rows and columns.
 ×þ    Table multiplication; multiply all columns of B (rows of B's transpose) by
       all rows of A, element by element. Results are grouped by the rows of A.
   ḅ1  Unbase 1; compute the sum of all flat arrays in the result.


Pythy Finite Ordinals Write a program in any language that takes a single natural number n as input and generates a Pyth program that, in turn, produces, using nested lists, the nested set given by S(n), where:

  S(0) = ∅
  S(n+1) = S(n) ∪ {S(n)}

S(n) giving the set representation of the corresponding ordinal number.

Using the list representation required by this question, this gives (as the final output from the generated Pyth program):
0->[]
1->[[]]
2->[[],[[]]]
3->[[],[[]],[[],[[]]]]

Etc.

Again, the challenge is to write a program in another language for generating the corresponding Pyth program.

This is code golf, so shortest full program wins.

Pyth, 11 10 bytes
"u+G]G"z\]

"Answers must be at least 30 characters."


Determine if a coin system is Canonical The Cashier's Algorithm is an algorithm for making change in the minimal number of coins that works quite well for most currency systems.  However like most greedy algorithms it is not without its flaws.  If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm will fail to find the optimal change.
Take the following example:
We have 4¢, 3¢, and 1¢ coins.  We want to make 6¢.
The Cashier's Algorithm will first select as many of the largest coin (one 4¢ to start) and subtract and repeat.  This will result in one 4¢ coin and two 1¢ coins, for a total of 3 coins.
Unfortunately for the Algorithm there is a way to make 6¢ with only two coins (two 3¢ coins).
A system of change will be considered canonical iff for all integer values the Cashier's Algorithm will find the optimal number of coins.
Task
You task will be to take a system as a either an unordered container or sorted ordered container of integers representing coin values and output a truthy value if the system input is canonical and falsy otherwise.
Your program should work for all systems that can create any value.  (i.e. all systems will have a 1¢ coin)
This is code golf least bytes wins.
Test cases
This list is by no means exhaustive, your program should work for all valid input
1, 3, 4       -> 0
1, 5, 10, 25  -> 1
1, 6, 10, 25  -> 0
1, 2, 3       -> 1
1, 8, 17, 30  -> 0
1, 3, 8, 12   -> 0
1, 2, 8, 13   -> 0
1, 2, 4, 6, 8 -> 1

Haskell, 94 87 82 bytes
f s=and[j i-2<j(i-x)|let j i=last$0:[1+j(i-x)|x<-s,x<i],i<-[1..2*last s],x<-s,x<i]

this solution works by defining a function j which perform's the cashier's algorithm and tells us how many coins the cashier used. we then check up to twice the biggest number in the list, assuming that the system has been canonical for all previous numbers, that taking the biggest possible coin is the right choice.
this solution assumes the input is sorted.
proof checking up to twice the biggest number is enough:
assume that the system is not canonical for some number i, and let k be the biggest number in the list not bigger than i. assume that i >= 2k and the system is canonical for all numbers less than i.
take some optimal way to make i out of coins, and assume it doesn't contain the coin k. if we throw away one of the coins, the new sum of coins must be bigger than k and smaller than i - but the cashier's algorithm on this number would use the k coin - and therefore, this set of coins can be replaced with an equal set of coins containing the coin k, and therefore there is a set of coins containing the coin k for the number i, and by induction the cashier's algorithm returns the optimal choice.
this argument really shows that we only need to check until the sum of the two biggest elements - but it is lengthier to do so.
Edit: five bytes off thanks to Ørjan Johansen!


We're much closer than you think Martin Ender's 2D programming language Alice has two different modes depending on what orientation the IP has: orthogonal (Cardinal mode) or diagonal (Ordinal mode). Commands in Alice change their meaning depending on which mode the program is in when they're executed. One especially interesting implementation of this is Alice's Z, or "pack", command. For strings in Ordinal mode, this simply takes two strings a and b and interleaves (also known as "zip") them. For example:
a = "Hello"
b = "World"
Z -> "HWeolrllod"

However, while in Cardinal mode, Z pops two integers \$n\$ and \$m\$ and returns \$\pi(n,m)\$*, the Cantor pairing function. For example, for \$n = 2, m = 3\$, Z returns \$\pi(2, 3) = 18\$. The reasoning behind this is explained in this answer.
For clarity, the Cantor pairing function uses the following formula:
$$\pi(n,m) = \frac12(n+m)(n+m+1)+m$$

You are to write two non-identical programs that implement the two modes of Z. More specifically:

The first should take two non-empty strings containing only printable ASCII (0x20 to 0x7e) of the same length* and output these strings zipped/interleaved together
The second should take two non-negative integers \$x\$ and \$y\$ and should output \$\pi(x, y)\$ as specified above.

*: This isn't technically how the Z command works, read the Alice docs for more
You may input and output in any accepted method, and you may assume all inputs are reasonable for your language.
Your score is the Levenshtein distance between your two programs multiplied by the sum of the program lengths, aiming for a lower score. You can use this website to calculate Levenshtein distance.
Test Cases
For the first program:
a, b -> Z
"a", "b" -> "ab"
"Hello,", "World!" -> "HWeolrllod,!"
"World!", "Hello," -> "WHoerllldo!,"
"Alice", "     " -> "A l i c e "

The second program:
n, m -> π(n, m)
2, 3 -> 18
5, 5 -> 60
0, 1 -> 2
1, 0 -> 1
100, 75 -> 15475

Jelly, Score 1 * 8 bytes = 8
String zip:
+Ẇɼ+

Try it online!
Cantor pairing function:
+ẆL+

Try it online!
We use the fact that the Cantor pairing is equal to
$$ {n + m + 1 \choose 2} + m $$
Where the left term just happens to be the number of nonempty contiguous slices of \$m+n\$. This saves two bytes per program over the naive +‘×+H+, and one byte over the (less naive) +‘c2+.
Conveniently, in Jelly + zips strings (I had no idea!).
Explanations:
          Implicit input: strings s1, s2
+         Zip s1, s2.
 Ẇ        All nonempty slices.
  ɼ       Save the result to register (ignore previous 2).
   +      Zip s1, s2.

          Implicit input: numbers n, m
+         Compute m+n.
 Ẇ        All nonempty slices of implicit range m+n.
  L       Length.
   +      Add m.

Note that there are many ways to get 4 for the pairing function (+R;S, +R+ƒ, etc)


(Σ*)² ⟲ Σ* (Round-Trip a String Pair) We're back! And this time with an objective scoring criteria!

This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :)
Your Task
Define two functions combine and separate with respective types String × String → String and String → String × String such that separate ∘ combine = id.
More precisely, define two functions (or methods/procedures/etc), which I will refer to as combine and separate, and which exhibit the following characteristics:

When invoked with a single string, separate produces two strings as results. (You may use any reasonable string type. Most languages don't canonically allow producing multiple values, so feel free to to do something equivalent, such as returning a 2-tuple or modifying two global variables.)

When invoked with two strings, combine produces a single string as result. (You may accept input to separate in the same form that combine produces, or any other reasonable form.)

For any two strings a and b, separate(combine(a, b)) must result in two strings which are (structurally) equivalent to a and b.

The above bullets are the only restrictions on combine and separate. So, for instance, combine ∘ separate need not be id, and separate can even be a partial function, if you like.

The functions need not actually be named combine and separate

Intent
My goal with this challenge is to inspire creative and interesting solutions. As such, in order to avoid priming/suggesting your thinking about how to solve this problem, I will not be providing test cases, and I strongly suggest that you do not look at the existing answers until you submit your own.
Winning Criteria
This challenge is code-golf; the answer with the lowest score wins. Score is defined as number of bytes, except that it's -75% if combine ∘ separate = id as well (i.e., if combine is bijective and separate = combine⁻¹).
For brownie points, also try making your solution, in principle,

work on any alphabet rather than char, possibly including alphabets of size- 0, 1, or 2
generalize nicely to \$n\$-tuples or lists

Have fun!

Jelly, 2 bytes
combine
Ṿ

Try it online!
separate
V

Try it online!
A boring, but short, solution. Uses Jelly's repr and eval atoms.
Ṿ is the right-inverse of V, meaning that ṾV (the Jelly way of composing 2 functions) returns the argument unchanged. Therefore, if passed [A, B], ṾV will return [A, B]
The first program takes input as a pair [A, B] and unevals it. The second takes a string as input and evals it as a Jelly program

Just a quick precursor on strings and Jelly. Jelly does not like strings. At all. Internally, strings are just lists of characters to Jelly, and when outputting, Jelly will do all it can to "mash" everything together so that it doesn't look like it should. An example that you'd expect to output ['a', 'b', 'c', 2], or even ['abc', 2]. As such, the Footers of the two programs above contain code to print the strings as-is, as lists of characters. Unfortunately, this can make them difficult to read.
But how do the programs work? Well, most of the work is done by the combine function. The separate function is simply "eval the argument as Jelly code".
Ṿ
Ṿ is a weird atom, as Jelly atoms go. It's entire purpose is to act as the inverse to V (as a side note, if an character has an "underdot" below it in Jelly, it's likely to be the "inverse" to the atom without that underdot. For example, O/Ọ (ord/chr) or Y/Ỵ (join/split at newlines)) and the function it uses in the interpreter, jelly_uneval, is only used by one other atom, Ṙ, which just prints the same value as Ṿ.
However, Ṿ does a pretty good job at yielding some Jelly code that, when evaluated, yields it's argument. I won't break down into the exact details, but it's able to handle when string delimiters such as “ are contained in the input, so is a pretty solid "uneval" atom, as these things go.


Summation from a to b The program has an input of a and b, and outputs the sum of numbers from a to b, inclusive. Score is in bytes. As always, standard loopholes are disallowed.

If your input is in the format [a,b], +3 bytes

Stuck, 4 Bytes

I'm amazed Stuck finally is winning something! The inclusive range function checks to see if the top of the stack is a list of length 2, and uses it for the parameters of the range function if so.

t]R+

Input is | separated, as t takes a bunch of inputs separated by |s and places them on the stack. ] just wraps the elements in a list, and lets the range function do it's job.

If that still falls in the penalty, then this works (5 Bytes): ii]R+


Write a Hangman Solver You are required to write a Hangman solver. Testing against this English word list[1], the solver that solves the most number of words wins, with the number of total incorrect guesses being the tie-breaker. All words in the word list will be tested in random order.

[1]: This word list is taken from here, then the numbers are removed, then words with length 1 or with non-alphabetical characters are removed, then the most frequent 4096 unique words are chosen as this word list.

The details:

Your program will interact with the game program, which will give you through stdin the underscores and correctly guessed letters. Your program will give to stdout your guesses, and it has to infer from the input whether the previous guess was right or wrong. After being wrong for 6 times, your program loses. Your program must be ready for the next game after each game ends (after win or loss).

Your code length must be strictly less than 2048 bytes, and your program must not use any external resources (including but not limited to accessing the wordlist on local storage or from the Internet).

Example: (Input is preceded by > here only for clarification - it is not actually present in the input)

>_______         // 7 underscores
a                // Now you wait for input again
>_a___a_
e
>_a___a_         // Implies that your guess is wrong
>_____           // new round, this will be given ONLY IF you already have 6 losses

Suppose you are wrong for 6 times, you will receive a final input which implies your guess is wrong, and your program must be ready to start a new round (i.e. take another input).

If you win,

>_angman
h
>hangman
>_____           // new round

After knowing that you have won (because the input has no underscores), you must be ready to accept the next round.

Your program must terminate when it receives an input END.

If your program is not deterministic (depends on randomness, pseudorandomness, system time, ambient temperature, my mood etc.), you must explicitly state that in your submission, and your score will be taken 10 times (by me, unless otherwise instructed) and averaged.

Note: if you use languages like python, please explicitly flush your stdout after each print statement.

The game program is as follows (credit to nneonneo):

import sys, random, subprocess

proc = subprocess.Popen(sys.argv[1:], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def p(x):
    proc.stdin.write(x+'\n')
    proc.stdin.flush()

wordlist=[]
f=open('wordlist.txt', 'r')
for i in f:
    wordlist.append(i[:-1] if i[-1]=='\n' else i)
# wordlist=[i[:-1] for i in f]
random.shuffle(wordlist)

score=0
totalerr=0

for s in wordlist:
    s2=[]
    for i in s:
        s2.append('_')
    err=0
    p(''.join(s2))
    while err<6 and '_' in s2:
        c=proc.stdout.readline().strip()
        nomatch=True
        for i in range(0, len(s)):
            if s[i]==c:
                s2[i]=c
                nomatch=False
        if nomatch:
            err+=1
            totalerr+=1
        p(''.join(s2))
    if err<6:
        score+=1
p('END')
sys.stderr.write('score is '+str(score)+', totalerr is '+str(totalerr)+'\n')

Usage: python ./game.py [yoursolverprogram]

Example: python ./game.py ruby ./solver.rb

This should work like the old scoring program, but does not depend on named pipes, so it can work on other platforms. Refer to the revision history if you are interested in the old one.


Compute the Carmichael function Task description

In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n.

Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins.

Your program should theoretically work for arbitrarily large inputs, but doesn’t need to be efficient.

Tips

The sequence of all λ(n) is OEIS A002322.

An ungolfed Python implementation would look like

from fractions import gcd

def carmichael(n):
    coprimes = [x for x in range(1, n) if gcd(x, n) == 1]
    k = 1
    while not all(pow(x, k, n) == 1 for x in coprimes):
        k += 1
    return k

(In Python, pow(A, B, C) efficiently computes pow(A, B) % C.)

Test cases

Input    Output
1        1
2        1
3        2
10       4
35       12
101      100
530      52
3010     84
6511     3056
10000    500

Mathematica, 16 bytes

CarmichaelLambda

Well...


Get list of badges on this site that nobody received yet Make a code that gets list of badges that nobody received yet (for example, by using this website API for badges), and output the sorted list of such badges, with new line after each.

Example output (may be smaller, depending on when you do this challenge):

Archaeologist
Caucus
Constituent
Copy Editor
Deputy
Electorate
Epic
Generalist
Hacker
Legendary
Marshal
Outspoken
Research Assistant
Sheriff
Steward
Strunk & White
Tenacious
Unsung Hero

Smallest code wins.

JavaScript with jQuery (loaded onto SE sites by default), 58

$('.badge',$('.badge-count:not(:has(*))').parent()).text()

Must be run on https://codegolf.stackexchange.com/help/badges. ;)

Strictly conforming output, 116 chars:

[].join.call($('.badge',$('.badge-count:not(:has(*))').parent()).map(function(){return $(this).text()}).sort(),'\n')

Screenshot of console output (click to enlarge):


Draw a BCD Binary clock Create a BCD binary clock
in ASCII. As implied, it shall display time in six columns of dots:

(source: Wikimedia Commons)

Each column is a binary-coded digit, reading hours, minutes and seconds
from left to right. Hours are given in 24-hour format.

The time to display is read from the command-line or from stdin (whichever
fits better). If empty, the current time should be used instead.

Output size is a little constrained here and we can only fit two lines of
text. So you are required to put the dots into only two lines. The
characters ., : and ' come in handy here.

Input

The time to display in ISO-8601 format, i.e. HH:MM:SS without fractional
seconds. Mandatory 24-hour format. Input can be empty in which case the
current time will be used.

Output

Two lines with represent the BCD binary clock as in the image above. Each
line is exactly six characters long and the only allowed characters are
space, period, colon and apostrophe.

Winner

Shortest code by byte count wins. In a tie, the solution posted first wins.

Sample input 1

(empty)

Sample output 1

     .
''. ::

Sample input 2

17:59:20

Sample output 2

 ..'
.:..'

Sample input 3

01:08:01

Sample output 3

   '
 .   .

Ruby, 107 103 99 94 90 characters
$><<[$/,(gets||Time.now.to_s[11,8]).tr(z=" .':","").bytes.map{|a|$><<z[a/4-12];z[a%4]}]*""

Note that the input shouldn't contain a linebreak, so to test the solution use something like echo -n "01:08:01" | ruby1.9 bcd.rb.
To test the default behavior, run it with ruby1.9 bcd.rb and enter ^D (i.e. a literal EOF).


Jordan Decomposition Important note: Because this challenge only applies to square matrices, any time I use the term "matrix", it is assumed that I am referring to a square matrix. I am leaving off the "square" description for brevity's sake.
Background
Many matrix-related operations, such as computing the determinant, solving a linear system, or extending scalar-valued functions to matrices are made easier by using a diagonal matrix (one whose elements that are not on the main diagonal are 0) that is similar to the original matrix (meaning, for the input matrix A and the diagonal matrix D, there exists some invertible matrix P such that D = P^(-1) * A * P; also, D and A share some important properties, like eigenvalues, determinant, and trace). For matrices with distinct eigenvalues (the roots to the matrix's characteristic polynomial, given by solving det(A-λI) = 0 for λ, where I is the identity matrix with the same dimensions as A), diagonalization is simple: D is a matrix with the eigenvalues on the main diagonal, and P is a matrix formed from eigenvectors corresponding to those eigenvalues (in the same order). This process is called eigendecomposition.
However, matrices with repeated eigenvalues cannot be diagonalized in this manner. Luckily, the Jordan normal form of any matrix can be computed rather easily, and is not much harder to work with than a regular diagonal matrix. It also has the nice property that, if the eigenvalues are unique, then Jordan decomposition is identical to eigendecomposition.
Jordan decomposition explained
For a square matrix A whose eigenvalues all have a geometric multiplicity of 1, the process of Jordan decomposition can be described as such:

Let λ = {λ_1, λ_2, ... λ_n} be the list of eigenvalues of A, with multiplicity, with repeated eigenvalues appearing consecutively.
Create a diagonal matrix J whose elements are the elements of λ, in the same order.
For each eigenvalue with multiplicity greater than 1, place a 1 to the right of each of the repetitions of the eigenvalue in the main diagonal of J, except the last.

The resulting matrix J is a Jordan normal form of A (there can be multiple Jordan normal forms for a given matrix, depending on the order of the eigenvalues).
A worked example
Let A be the following matrix:

The eigenvalues of A, with multiplicity, are λ = {1, 2, 4, 4}. By putting these into a diagonal matrix, we get this result:

Next, we place 1s to the right of all but one of each of the repeated eigenvalues. Since 4 is the only repeated eigenvalue, we place a single 1 next to the first 4:

This is a Jordan normal form of A (a single matrix can potentially have several valid Jordan normal forms, but I'm glossing over that detail for the purpose of explanation).
The task
Given a square matrix A as input, output a valid Jordan normal form of A.

The input and output may be in any reasonable format (2D array/list/whatever, list/array/whatever of column or row vectors, a builtin matrix data type, etc.).
The elements and eigenvalues of A will always be integers in the range [-200, 200].
For the sake of simplicity, all of the eigenvalues will have a geometric multiplicity of 1 (and thus the above process holds).
A will at most be a 10x10 matrix and at least a 2x2 matrix.
Builtins that compute eigenvalues and/or eigenvectors or perform eigendecomposition, Jordan decomposition, or any other kind of decomposition/diagonalization are not allowed. Matrix arithmetic, matrix inversion, and other matrix builtins are allowed.

Test cases
[[1, 0], [0, 1]] -> [[1, 1], [0, 1]]
[[3, 0], [0, 3]] -> [[1, 1], [0, 1]]
[[4, 2, 2], [1, 2, 2],[0, 3, 3]] -> [[6, 0, 0], [0, 3, 0], [0, 0, 0]]
[[42, 48, 40, 64, 64], [41, 47, 31, 58, 42], [-55, -47, -27, -74, -46], [-46, -58, -46, -70, -68], [30, 20, 12, 34, 18]] -> [[10, 0, 0, 0, 0], [0, -18, 0, 0, 0], [0, 0, 6, 1, 0], [0, 0, 0, 6, 1], [0, 0, 0, 0, 6]]

Mathematica, 140 139 105 bytes

Total[DiagonalMatrix@@@{{#},{1-Sign[Differences@#^2],1}}]&@(x/.Solve[#~CharacteristicPolynomial~x==0,x])&

I just found the builtin DiagonalMatrix which allows for an easy way to place the 0s and 1s along the superdiagonal.

Usage


Mario Kart Scoring w/ Ties I ran into this problem while working on another challenge I'm making for this site. In that challenge I utilize "Mario Kart 8 Scoring". The amount of points the player in kth place gets is represented by this 1-indexed array: [15,12,10,9,8,7,6,5,4,3,2,1]. So 1st place gets 15 points, 2nd place gets 12 points, etc.

It's easy enough to assign points like this, however the tricky part comes with how I handle ties. What I do is give each tying player the average of the points given for each tying place. For example, if only 1st and 2nd tied, then both players get (15+12)/2 = 13.5 points. (Note: You're allowed to round to the nearest int, so 13 or 14 are both also acceptable.) Then 3rd - 12th place get the normal amount of points for their position.

Challenge

Given 12 non-negative integer scores that are decreasingly sorted, output the number of points each player gets. You can also take the points list [15,12,10,9,...] as input. Note that the number of points each player gets does not depend on the actual values of the scores, but how they compare to the other scores.

Test Cases

[21,21,15,14,12,9,6,5,4,3,2,1] => [14,14,10,9,8,7,6,5,4,3,2,1]
[20,15,15,15,10,9,8,7,6,5,4,3] => [15,10,10,10,8,7,6,5,4,3,2,1]

explanation: (12+10+9)/3 = 10.3333

[1,1,1,1,1,1,1,1,1,1,1,1] => [7,7,7,7,7,7,7,7,7,7,7,7]

explanation: (15+12+10+9+8+7+6+5+4+3+2+1)/12 = 6.8333

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

explanation: (15+12+10+9)/4 = 11.5, (8+7+6)/3 = 7

[100,99,98,95,95,95,94,93,93,92,91,91] => [15,12,10,8,8,8,6,5,5,3,2,2]

explanation: (9+8+7)/3 = 8, (5+4)/2 = 4.5, (2+1)/2 = 1.5

Related: Rank a list of scores with "skips"

JavaScript (ES6), 57 bytes

Takes input in currying syntax (p)(s), where p is the list of points and s is the list of scores.

p=>s=>s.map(v=>s.reduce((t,x,i)=>x-v?t:t+p[n++,i],n=0)/n)

Test cases

let f =

p=>s=>s.map(v=>s.reduce((t,x,i)=>x-v?t:t+p[n++,i],n=0)/n)

points = [15,12,10,9,8,7,6,5,4,3,2,1];

console.log(JSON.stringify(f(points)([21,21,15,14,12,9,6,5,4,3,2,1])))
console.log(JSON.stringify(f(points)([20,15,15,15,10,9,8,7,6,5,4,3])))
console.log(JSON.stringify(f(points)([1,1,1,1,1,1,1,1,1,1,1,1])))
console.log(JSON.stringify(f(points)([20,20,20,20,10,10,10,9,8,7,6,5])))
console.log(JSON.stringify(f(points)([100,99,98,95,95,95,94,93,93,92,91,91])))


Detect Duplicate Questions Detect Duplicate Questions

Once upon a time, there was a golfing site. It had a problem: people would post similar or identical questions again and again. You have been chosen selected forced conscripted blackmailed requested to automate the process of deciding whether a question is a duplicate of an existing one, by whatever means necessary (see Rules).

Input

Your program must accept a single URL as input. It may assume that this leads to a question on codegolf.stackexchange.com.

Output

Search the site for similar questions. If you think that the input question is a duplicate of an existing question (or vice versa), output the other question's URL. You may output multiple URLs, separated by new lines. At the end of your output, output end (on a separate line).

Scoring

If a question that you output was indeed marked as a duplicate of the input question (or vice versa), you score 4 points. This is a "correct guess".
For each false positive (aka "incorrect guess"), you lose 2 points.
For each question that was actually a duplicate but does not appear in your output (aka "missing guess"), lose 1 point.

The highest score after handling 32 input questions wins. These 32 questions are a "round". At the beginning of each round, the scores will be reset to 0. One round will be run every few days, and the leaderboard updated after each round.

Rules

If questions A and C are both closed as duplicates of B, A will count as a duplicate of C and vice versa.
At the start of each round, your program may not possess any data about any questions (i.e. no hardcoding), except on how to parse the website.
However, you may keep data in external files during a round.
No data may be kept between rounds.
Your output must have a trailing new line.
You may not use any data from the website except search results and the URL, title, tags and text of a question, with or without formatting. For example, you may not use the text "marked as duplicate by foo, bar..." that appears on duplicate questions.
You may retrieve this data directly from the site, via data.SE or via the API.
Each submission must have a name.
Each submission must have clear version numbering.
If a submission does not produce output after a time limit (to be decided; please state how long your submission takes) it will be killed and lose 8 points.

Python 3
I am giving this entry the name The Differ.
Code:
import urllib.request, gzip, re, json, difflib, sys
API_URL = "https://api.stackexchange.com/"
qurl = input()
qid = int(re.search("\d+",qurl).group(0))
def request(url,wrapper=False,**params):
    params.setdefault("filter","withbody")
    params.setdefault("site","codegolf")
    url = API_URL + url + "?"+"&".join([str(k)+"="+str(v) for k,v in params.items()])
    compressed_response = urllib.request.urlopen(url)
    response = gzip.decompress(compressed_response.read()).decode("utf8")
    response_object = json.loads(response)
    if wrapper:
        return response_object
    else:
        return response_object["items"]
question = request("questions/%s"%qurl)[0]
tags = ";".join(question["tags"])
title = question["title"]
escaped = title.replace(" ","%20")
related = request("similar",title=escaped,pagesize=100)
hasmore = False
length = sys.maxsize
for tag in question["tags"]:
    result = request("search",tagged=tag,
                     wrapper=True,
                     filter="!-*f(6rc.cI8O",
                     pagesize=100)
    if result["total"] < length:
        length = result["total"]
        related.extend(result["items"])
        hasmore = result["has_more"]
        besttag = tag
related.extend(best)
if length < 1500:
    for page in itertools.count(2):
        if not hasmore:
            break
        response = request("search",
                           tagged=besttag,
                           page=page,
                           pagesize=100,
                           filter="!-*f(6rc.cI8O",
                           wrapper=True)
        hasmore = response["has_more"]
        related.extend(result["items"])
matcher = difflib.SequenceMatcher(None, question["body"], None)
titlematcher = difflib.SequenceMatcher(None, question["title"], None)
seen = set()
seen.add(question["question_id"])
for possible in related:
    matcher.set_seq2(possible["body"])
    titlematcher.set_seq2(possible["title"])
    score = matcher.ratio()+titlematcher.ratio()
    qid = possible["question_id"]
    if score > .85 and qid not in seen:
        print(qid)
        seen.add(qid)
print("end")

The filter "!-*f(6rc.cI8O" included the total parameter on the global wrapper object and the body parameter on questions.
This entry makes two API requests plus one per tag on the question plus one per hundred questions in its least used tag. If it hits an api throttle (which it doesn't check for), it will raise an urllib.error.HTTPError: HTTP Error 400: Bad Request


Simulate a Minsky Register Machine (II) This is an extension of Simulate a Minsky Register Machine (I). I'm not going to repeat all of the description there, so please read that problem description first.

The grammar in part (I) was as simple as possible, but results in rather long programs. Since this is a code golf site, we'd rather have a golfed grammar, wouldn't we?

At a high level, the changes from the original grammar are as follows:

The label on the first line is optional
Whitespace is optional except where required to separate two adjacent identifiers
States can be inlined. To ensure non-ambiguous parsing, if the first state of a decrement operation is an inlined state, it must be enclosed in parentheses. This means that any program can be golfed into a one-liner.

For example, in the original test cases we had:

b+=a, t=0

init : t - init d0
d0 : a - d1 a0
d1 : b + d2
d2 : t + d0
a0 : t - a1 "Ok"
a1 : a + a0
a=3 b=4

In the golfed grammar this could be shortened to:

init:t-init d
d:a-(b+t+d)a
a:t-(a+a)"Ok"
a=3 b=4

or even:

init:t-init d:a-(b+t+d)a:t-(a+a)"Ok"
a=3 b=4

The new BNF for the "program" lines (as opposed to the final line, which is data) is:

program    ::= first_line (newline line)*
first_line ::= cmd
line       ::= named_cmd
state      ::= state_name
             | cmd
             | '"' message '"'
delim_state::= '(' cmd ')'
             | '"' message '"'
cmd        ::= raw_cmd
             | named_cmd
named_cmd  ::= state_name ' '* ':' ' '* raw_cmd
raw_cmd    ::= inc_cmd
             | dec_cmd
inc_cmd    ::= reg_name ' '* '+' ' '* state
dec_cmd    ::= reg_name ' '* '-' ' '* delim_state ' '* state
             | reg_name ' '* '-' ' '* state_name ' '* delim_state
             | reg_name ' '* '-' ' '* state_name ' '+ state
state_name ::= identifier
reg_name   ::= identifier

Identifiers and messages are flexible as in the previous challenge.

All of the test cases from the previous challenge are still applicable. In addition, the following golfed Josephus solution should exercise most of the grammar:

in:k-(r+t+in)in2:t-(k+in2)r-(i+n-0"ERROR n is 0")"ERROR k is 0"
0:n-(i+2:k-(r+t+2)5:t-(k+5)7:i-(r-(t+7)c:t-(i+r+c)i+0)a:t-(i+a)7)"Ok"
n=40 k=3

Expected output:

Ok
i=40 k=3 n=0 r=27 t=0

And I think this covers the remaining case:

k+k-"nop""assert false"
k=3

Expected output:

nop
k=3

You may assume that all programs will have sensible semantics. In particular, they will have at least one state and will not redefine a state. However, as before, a state may be used before it is defined.

The scoring is a variant on code-golf. You can write a self-contained program and it will score as the length of the program in bytes after UTF-8-encoding. Alternatively, because code reuse is a Good Thing, if you have implemented part (I) in n1 bytes, you can write a program which turns a part (II) program into a part (I) program, ready for piping to the original. Your score will then be the length of your transformation program plus ceil(n1 / 2).

NB If you opt for the transformation, you will need to generate names for the anonymous states in such a way that you guarantee that they don't clash with named states.

Haskell, 552 499 493 characters

import Control.Monad.RWS
import Data.Map
main=interact$z.lines
z x=let(s:_,w)=evalRWS(mapM(q.t)x)w[]in s.f.i.t$last x
p=get>>=q
q(l:":":x)=x%do a<-p;tell$f[(l,a)];r a
q(v:"+":x)=x%fmap(.a v 1)p
q(v:"-":x)=x%liftM2(d v)p p
q(('"':s):x)=x%r(\w->unlines[init s,do(v,x)<-assocs w;v++'=':show x++" "])
q(n:x)|n<"*"=x%p|1<3=x%asks(!n)
d v p n w|member v w&&w!v>0=p$a v(-1)w|1<3=n w
t[]=[];t x=lex x>>= \(y,x)->y:t x
i(v:_:x:t)=(v,read x):i t;i[]=[]
x%m=put x>>m;r=return;a=insertWith(+);f=fromList

Did more or less a full rewrite. Replaced CPS with a RWS monad which reads its own output to look up states it hasn't parsed yet (yay for laziness!), plus some other tweaks.


Mode (most common element) of a list Write a snippet to calculate the mode (most common number) of a list of positive integers.

For example, the mode of

d = [4,3,1,0,6,1,6,4,4,0,3,1,7,7,3,4,1,1,2,8]

is 1, because it occurs the maximum of 5 times.

You may assume that the list is stored in a variable such as d and has a unique mode.

e.g.: Python, 49

max(((i,d.count(i))for i in set(d)), key=lambda x:x[1])

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

Python 2 - 18
max(d,key=d.count)

Since your python answer doesn't seem to print, I expect this is what you want.
Add 6 bytes for print  normally.


Interpreter for a 99 Bottles of Beer program Write a program (in a first language A) that interprets a "99 Bottles of Beer" program and a FizzBuzz program (both in a second language B) on its standard input. The output should go to standard output; you may implement the interpreter as a function in languages lacking standardized I/O interfaces.

Constraints

The 99-Bottles program must come from either this site's problem or from http://99-bottles-of-beer.net/. Link to (do not copy and paste) the 99-Bottles program in your answer. The specific output is not important; what matters is whether the interpreter produces exactly the same output as a more complete one does.

You may write the FizzBuzz program yourself, or you may obtain it from the Internet or another source. Do not copy and paste the program into your answer in the latter case.

Both languages (and the 99-Bottles program) must have existed prior to September 22, 2011 (when this challenge was first posted). Specifically, you may not invent your own language for the specific purpose.

Any interpreter that hardcodes a non-whitespace character or string to be sent to the output (or that accesses the Internet) is cheating and not permissible. For example, an interpreter that contains "beer", "Buzz", or even "b" as a string or character literal is not acceptable, but looping from 1 to 99 is acceptable if a corresponding print statement is not hardcoded.

Both languages' names must not begin with the same letter and must not have any three character substring in common. For example:

APL and AWK begin with the same letter, and so do C, C++, and C#.
JavaScript and VBScript have SCR in common.

Additionally, the 99-Bottles and FizzBuzz programs must not be valid in language A or any other language that the interpreter depends on – the direct use of eval, exec, or similar language features or methods to compile and execute them is expressly forbidden.

Scoring

The score is the sum of:

Ten times the interpreter's character count
Ten times the FizzBuzz program's character count.
The 99-Bottles program's actual character count (because it should not be a golfed program). This excludes any leading and trailing whitespace but includes whitespace used for indentation. Each newline counts as one character.

For verification, include the code of everything you have written yourself, and link to any published sources you have used.

JavaScript interpreter for C (3834)

Interpreter (180 * 10 = 1800)

f() is the function to be called.

function prvarf(x){a=arguments;i=0;s+=(t=x.replace(/%./g,function(){return a[++i]}));return t}function f(x){Function(x.replace(/int/g,'var').replace(/#|ma/g,'f//'))(s='');return s}

99-Bottles (1074)

http://99-bottles-of-beer.net/language-c-844.html

FizzBuzz (96 * 10 = 960)

Adapted from one of the programs at http://perl.guru.org/scott/misc/golf.html:

main()
{int b=0;for(;++b<101;)printf(printf("%s%s",b%3?"":"Fizz",b%5?"":"Buzz")?"\n":"%d\n",b);}


Interpret the Pig series Given an input of a Pig,
SickPig,
DeadPig,
QuinePig, or
DeafPig program, choose one of those
"languages" randomly and interpret the input as that "language."

First, randomly choose between one of the five members of the "Pig series":

Pig

If the choice was Pig, mimic the reference
interpreter by doing the following:

Find the first occurrence of the word PIG in the input
(case-sensitive).
If the word PIG does not appear in the input, output the message
File must contain the string 'PIG'. and exit.
Otherwise, split the input string on the first occurrence of PIG.
Output the text after the first occurrence of PIG to a file with a
filename of the text before PIG.

PIG may be contained in the text to be output (so, an input of
fooPIGbarPIGbaz should output barPIGbaz to a file called foo).

Note that the reference interpreter takes input via a command line argument
that specifies a filename to read from. However, your submission may take input in
any of the standard methods accepted on PPCG.
SickPig

If the choice was SickPig, follow the same instructions as Pig. However,
instead of writing the text after PIG to the file, choose randomly from
the following list

GRUNT
MOAN
OINK
BURP
GROAN
WHINE

and output that to the file instead. This random choice must be
independent of the previous choice (so, an output of GRUNT should
have a 1/5 * 1/6 = 1/30 chance overall).
DeadPig

DeadPig is like SickPig, but it always outputs the following string instead
of randomly choosing a string:

Your pig has unfortunately died. Please try again.

QuinePig

QuinePig is like Pig, but instead of writing the text after PIG to the
file, it instead writes the entire input to the file (so, an input of
fooPIGbarPIGbaz should output fooPIGbarPIGbaz to a file called foo).
DeafPig

If the choice was DeafPig, do nothing. (The pig is deaf... what do you
expect?)

Miscellaneous rules:

"Random" means each choice should be roughly equally likely (so, choosing Pig 90% of the time and the other variants only 2.5% of the time is invalid).
You may assume that the requested filenames will always be valid for your
file system (but they may contain spaces, etc.).
For all the variants of Pig, your code may optionally output a single
trailing newline to the file as well.
Since this is code-golf, the shortest code in bytes will win.

Bash, 251 246 bytes

r=$RANDOM
((r%5<4))||exit
[[ $1 =~ PIG ]]||(echo "File must contain the string 'PIG'.";exit)
s=(GRUNT MOAN OINK BURP GROAN WHINE)
m=("${1#*PIG}" ${s[r%6]}
"Your pig has unfortunately died. Please try again." "$1")
echo -n "${m[r%5]}">"${1%%PIG*}"

This would be a lot shorter if deaf pigs could at least read...


What can you see on a hexagonal spiral? This code-golf challenge will have you computing OEIS sequence A300154.

Consider a spiral on an infinite hexagonal grid. a(n) is the number of cells in the part of the spiral from 1st to n-th cell that are on the same [row*] or diagonal (in any of three directions) as the n-th cell along the spiral, including that cell itself.

(*I have very slightly changed the definition to match the orientation of the GIF below.)
The sequence begins
1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 6, 7, 7, 8, 7, 8, 9, 8, 9, 8, 9, 10, 9, 10, 11, 9, 10, 11, 10, 11, 12, 10, 11, 12, 13, 11, 12, 13, 11, 12, 13, 14, 12, 13, 14, 15, 12, 13, 14, 15, 13, 14, 15, 16, 13, 14, 15, 16, 17, 14

Example
Below is an example of the first fifteen terms of the sequence. On a hexagonal tiling, go in a spiral, and after each step, count the number of cells that you can "see" from that position, including the cell itself.

Challenge
The challenge is simple, write a program that takes a positive integer n and computes \$A300154(n)\$. Again, this is code-golf so shortest code wins.
(Note: I will also award an additional bounty of 200 rep to the first person who completes this challenge in Hexagony.)

JavaScript (ES6),  178 169  168 bytes
Returns the \$n\$ first terms as an array.

n=>(X=[1],Y=[L=1],d=5,j=x=y=0,g=a=>--n?g([...a,(X[x+=~-'210012'[d%=6]]=-~X[x])+(Y[y+=~-'1221'[j?d:d++]]=-~Y[y])+(Z[x+y]=-~Z[x+y])-2],++j%L?0:(j%=L*6)?d++:L++):a)(Z=[1])

Try it online!
How?
This is a rather naive approach that actually computes the spiral with cube coordinates \$(x,y,x+y)\$ and keeps track of the number of cells on each row \$Z[x+y]\$, each diagonal \$Y[y]\$ and each anti-diagonal \$X[x]\$.
Commented
n => (                            // n = input
  X = [1], Y = [L = 1],           // X[] = anti-diagonals, Y[] = diagonals, L = layer
  d = 5,                          // d = direction in [0..5]
  j =                             // j = cell index in the current layer
  x = y = 0,                      // (x, y) = coordinates
  g = a =>                        // g = main recursive function taking the output a[]
    --n ?                         // decrement n; if we haven't computed enough terms:
      g(                          //   recursive call:
        [ ...a,                   //     append the previous terms
          ( X[x +=                //     update x and increment X[x]
              ~-'210012'[d %= 6]  //       pick dx according to d
            ] = -~X[x]            //
          ) +                     //
          ( Y[y +=                //     update y and increment Y[y]
              ~-'1221'[j ? d      //       pick dy according to d
                         : d++]   //       increment d afterwards if j = 0
            ] = -~Y[y]            //       (i.e. this is the 1st cell of the layer)
          ) +                     //
          (Z[x + y] = -~Z[x + y]) //     increment Z[x + y]
          - 2                     //     subtract 2 from X[x] + Y[y] + Z[z] because
        ],                        //     the current cell is counted three times
        ++j                       //     increment j
        % L ?                     //     if it's not the last cell of this side:
          0                       //       do nothing
        :                         //     else:
          (j %= L * 6) ?          //       if it's not the last cell of the layer:
            d++                   //         increment d
          :                       //       else:
            L++                   //         increment L
      )                           //   end of recursive call
    :                             // else:
      a                           //   we're done: return a[]
)(Z = [1])                        // initial call to g with a[] = Z[] = [1]


How many states do I border? When I was younger, I had a big map of the US tacked up on my wall across from my bed. When I was bored, I would stare at that map and think about stuff. Stuff like the four-color-theorem, or which state bordered the most other states. To save younger me some brainpower in counting, you are going to invent a time machine and tell me how many states border the input. Because time is finicky, this needs to be as short as possible.

The Task

Given one of the 50 US states, either by its full name or by its postal abbreviation, as found on this page (archive.org mirror), return the number of states it borders. The following is a mapping of all inputs for full state names to the number of states adjacent, found on this website.

Missouri, Tennessee -> 8
Colorado, Kentucky -> 7
Arkansas, Idaho, Illinois, Iowa, Nebraska, New York, Oklahoma, Pennsylvania, South Dakota, Utah, Wyoming -> 6
Arizona, Georgia, Massachusetts, Michigan, Minnesota, Nevada, New Mexico, Ohio, Virginia, West Virginia -> 5
Alabama, Indiana, Kansas, Maryland, Mississippi, Montana, North Carolina, Oregon, Texas, Wisconsin -> 4
California, Connecticut, Delaware, Louisiana, New Hampshire, New Jersey, North Dakota, Rhode Island, Vermont -> 3
Florida, South Carolina, Washington -> 2
Maine -> 1
Alaska, Hawaii -> 0

The Rules

Your program can either handle the full state name or the postal code - it cannot use a combination.
You can specify the case of the input, but you cannot remove whitespace in the input.
You do not have to handle Washington, D.C., or anything that is not one of the 50 states.
The number of states bordered does not include the input state.
This is code-golf, so shortest answer in bytes wins.

While I know this may just be whoever has the best compression or finds the best regex pattern per number, if I get too many of those answers, I'll award a bounty to an answer that generates a map of the US and uses that to calculate the number of bordering states.

Mathematica, 112 111 bytes
-5 byte thanks to Mark S. and LegionMammal978!
-22 bytes (and noticing a problem with the output) thanks to ngenisis!
Tr[1^Entity["AdministrativeDivision",#~StringDelete~" "]@"BorderingStates"]+Boole@StringMatchQ[#,"Il*"|"Mic*"]&

Of course, there's a Mathematica builtin for it. Includes D.C. in the count.


Randomly select from an array This challenge is rather simple:
You are given an array of positive (not including 0) integers, and have to select a random element from this array.
But here's the twist:
The probability of selecting an element is dependent on the value of the integer, meaning as the integer grows larger, the probability of it to get selected does too!
Example
You are given the array [4, 1, 5].
The probability of selecting 4 is equal to 4 divided by the sum of all elements in the array, in this case 4 / ( 4 + 1 + 5 ) = 4 / 10 = 40%.
The probability of selecting 1 is 1 / 10 or 10%.
Input
An array of positive integers.
Output
Return the selected integer if using a method, or directly print it to stdout.
Rules

This is code-golf so shortest code in bytes in any language wins.
Standard loopholes are forbidden.

Jelly, 3 bytes

x`X

Try it online!

Look 'ma, no Unicode!

Explanation:

x`X
 `  Make monad from dyad and use same left and right arguments
x   Repeat each element of the left argument (implicit) list its respective number of times in the right argument list
  X Random element


Convert a fraction to a repeated decimal Almost the polar opposite if this challenge, and I suspect it will be slightly easier.

Your task is to take two integers in the format a/b (Forming a rational number) then output the number in decimal exactly.

For example, if you were to input 1/3, it would output:

0.33333333333333333

And would keep on printing 3s until the end of time, with an optional leading 0. (You could also print one character per line if and only if your language does not allow printing on the same line.)

The behaviour for x/0 will be undefined. For a number that looks like it doesn't repeat (Like, say 5/4) it actually does repeat. Either of the following two forms would be acceptable for 5/4:

1.25000000000000000
1.24999999999999999

(The same with whole numbers, 1.9999999 or 2.000000)

The fraction may not be in its simplest form, and a or b may be negative (Note -a/b = -(a/b), -a/-b = a/b, a/-b = -a/b, and -.6249999 is invalid, but -0.6249999 is acceptable, but you still can use.

C, 108 79
Edit Modified to work with negative numbers.
Input from stdin. Old K&R style.
main(a,b){char*s="-%d.";scanf("%d/%d",&a,&b);for(a*b<0?(a<0?a=-a:(b=-b)):++s;printf(s,a/b);s="%d")a=a%b*10;}


Narayana-Zidek-Capell numbers Generate the nth Narayana-Zidek-Capell number given an input n. Fewest bytes win.

f(1)=1, f(n) is the sum of the previous floor(n/2) Narayana-Zidek-Capell terms.

Test Cases:

f(1)=1

f(9)=42

f(14)=1308

f(15)=2605

f(23)=664299

Ruby, 34 32 bytes

This uses a formula from the OEIS page for the Narayana-Zidek-Cappell numbers.

Edit: Got rid of parentheses using operator precedence with thanks to feersum and Neil.

f=->x{x<4?1:2*f[x-1]-x%2*f[x/2]}


Octave, 29 bytes

@(n)accumarray((x=1:n)'+!x,1)

Try it online!


Code close to the challenge: Sum of integers This is a simple challenge:
Given a sequence of integers, find the sum of all integers in it.

But with a twist.
Your score is the Levenshtein distance between your code and the following phrase (The challenge):

  Given a set of integers, find the sum of all integers in it.

You may assume there are no newlines or trailing spaces in the input.

Example input/output:

Input: 1 5 -6 2 4 5
Output: 11
Input: 1 -2 10
Output: 9

An online calculator for Levenshtein distance can be found here: http://planetcalc.com/1721/

Python, distance 3

#Given a set of integers, find the
sum#of all integers in it.

This gives the built-in function sum, which can sum a set like sum({3,5,7})==17. The remaining parts are commented. This has distance 3, with 3 edits:

Add the initial #
Add a newline
Replace the space after sum with #


Print the alphabet Christmas tree I know it's 1.5 weeks after Christmas but trying to print an isosceles triangle in a monospaced font makes it look weird.

Challenge

Print the alphabet from A to Z so that it forms a filled triangle in the output.
For each line in the output, starting from "A", add the next letter.

No inputs, only outputs. Pad the leading edge of the triangle with spaces.

Best answer is the code with the least bytes.

Output

            A
            AB
           ABC
           ABCD
          ABCDE
          ABCDEF
         ABCDEFG
         ABCDEFGH
        ABCDEFGHI
        ABCDEFGHIJ
       ABCDEFGHIJK
       ABCDEFGHIJKL
      ABCDEFGHIJKLM
      ABCDEFGHIJKLMN
     ABCDEFGHIJKLMNO
     ABCDEFGHIJKLMNOP
    ABCDEFGHIJKLMNOPQ
    ABCDEFGHIJKLMNOPQR
   ABCDEFGHIJKLMNOPQRS
   ABCDEFGHIJKLMNOPQRST
  ABCDEFGHIJKLMNOPQRSTU
  ABCDEFGHIJKLMNOPQRSTUV
 ABCDEFGHIJKLMNOPQRSTUVW
 ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWXY
ABCDEFGHIJKLMNOPQRSTUVWXYZ

Sample Java Code (430 bytes)

public static void main(String args[]) {
    String spaces = "";
    String alpha = "";
    char A = 'A';

    for (int i = 0; i < 26; i++) {
        for (int j = 13 - (i/2); j > 0; j--) {
           spaces += " ";
        }

        alpha += (char)(A + i);

        System.out.println(spaces + alpha);
        spaces = "";
    }
}

Ruby, 44 bytes

t=''
26.times{|x|puts' '*(12-x/2)+(t<<65+x)}

Try it online!


Esolang-Comment-Template-Generator Lots of people on this site use esoteric languages, and since these languages are unusual and hard to understand, they will frequently write an explanation in a certain format. For example, if the code was

abcdefghijklmnop

And this languages uses # for comments, they would write an explanation like this:

a                #Explanation of what 'a' does
 bc              #Bc
   d             #d
    e            #Explanation of e
     fgh         #foobar
        ij       #hello world
          k      #etc.
           l     #so on
            mn   #and
              op #so forth

I frequently do this too, but every time I do this, I feel like creating the layout of text is really obnoxious and time-consuming. So I want you to create a "Esolang-Comment-Template-Generator" for me. For example, if we ignore the comments, the previous code has this template:

a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #

The Challenge:

You must write a program or function that takes two strings as input, and outputs this "Esolang-Comment-Template". The first input will be the code, but with bars (|) inserted where the newlines go. The second input is what we will use for comments. So our last example would have this for input:

"a|bc|d|e|fgh|ij|k|l|mn|op", "#"

Unfortunately this excludes bars from being part of the code input, but that's OK. You can assume that the comment input will be a single character. For simplicity's sake, the comment char will not be a bar. The code input will only contain printable ASCII, and it will not contain any newlines.

Hopefully you can infer what to do from the testcases, but I'll try to clarify some things.

You must split the code input up into "code-sections" on every bar. Then, each section of code is output on its own line and left-padded with the length of all the previous code (not including the bars). Then, each line is right-padded with enough spaces so that the last two characters on every line are "One additional space" + "The comment character".

One trailing newline is allowed.

Here is another example. For the input

"Hello|World", "/"

The first section of code is "Hello" and the second is "World". So it should give the output:

Hello      /
     World /

Here are some more samples:

Input:
"a|b|c|d|e|f|g", ","

Output:
a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,

Input:
"abcdefg", ":"

Output:
abcdefg :

Input:
"4|8|15|16|23|42", "%"

Output:
4          %
 8         %
  15       %
    16     %
      23   %
        42 %

Input:
"E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last!", "!"

Output:
E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !

Input:
"This|Code|has||empty||sections", "@"

Output:
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @

Rules:

You may take these inputs and outputs in any reasonable format. For example, reading/writing a file, STDIN/STOUT, function arguments/return value, etc. As usual, this is code-golf, so try to make your code as short as possible and you win if you can get the shortest solution in your language! I will also select the shortest solution as the overall winner. Standard loopholes are banned.

Java 10, 189 159 bytes

s->c->{var r="";int p=0,i;for(var a:s.split("\\|")){for(i=p;i-->0;r+=" ");r+=a;for(p+=a.length();i++<s.replace("|","").length()-p;r+=" ");r+=c+"\n";}return r;}

-30 bytes converting Java 7 to Java 10 and optimizing the loops.
Try it online.
Explanation:
s->c->{                     // Method with String & char parameters and String return-type
  var r="";                 //  Result-String, starting empty
  int p=0,                  //  Position-integer, starting at 0
      i;                    //  Index integer
  for(var a:s.split("\\|")){//  Loop over the parts split by "|"
    for(i=p;i-->0;r+=" ");  //   Add `p` amount of spaces to the result-String
    r+=a;                   //   Add the current part to the result-String
    for(p+=a.length();      //   Add the length of the current part to the position-integer
        i++<s.replace("|","").length()-p;r+=" ");
                            //   Add the row's trailing spaces to the result-String
    r+=c+"\n";}             //   Add the character and a new-line to the result-String
  return r;}                //  Return the result-String


Find the Closest Double Palindrome Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome.

Input

A floating point number x. You may use any format you like for input, but the format you chose must be able to represent every possible IEEE 754 binary64 value, including denormals, distinct representations for +0 and -0, and +Inf, -Inf, and NaN.

Output

A floating point number y. You may use any format you like for output, with the same restrictions as the input format.

The Task

y is any value such that:

The IEEE 754 binary64 bitstring for y is a palindrome. That is, the first 32 bits are the reverse of the last 32 bits.
abs(x-y) is minimal by the totalOrder predicate.

Notes

abs(x-y) must be computed with strict IEEE 754 double-precision floating point arithmetic.
totalOrder puts non-numeric values and signed zeroes in this order: - NaN < -Inf < -1 < -0 < +0 < +1 < +Inf < +NaN. Otherwise it behaves like the normal < operator.
The rules for performing arithmetic on non-numeric values can be found at this website
For an overview of how binary64 floats work, see wikipedia.
If there is more than one value for y that satisfies the conditions, output any one of them. Note that this can only occur if abs(x-y1) == abs(x-y2), or if they are both NaN.
The input and output formats may be different if desired; both formats still need to obey all the rules.
It may be convenient to use a raw binary format for IO; this is permitted.
For the purposes of this challenge you may consider all NaN values as equivalent, since NaN payload behavior is implementation defined.
It is not sufficient to just mirror the first 32 bits. See test cases 2, 4, 5, and 7 for examples.
Any non-NaN double palindrome is valid output for x=+Inf or x=-Inf, since the distance is still just +Inf. Reversing the first 32 bits would not be correct though since the resulting NaN value would have a distance of +NaN > +Inf from the input.
A NaN though, any double palindrome would be correct.

Test Cases

Input:  0x8A2B_7C82_A27D_6D8F = -1.1173033799881615e-259
Output: 0x8A2B_7C82_413E_D451 = -1.1173031443752871e-259

Input:  0x5000_0000_0000_0001 = 2.3158417847463244e+77
Output: 0x4FFF_FFFF_FFFF_FFF2 = 2.3158417847463203e+77

Input:  0x5000_0000_0000_0002 = 2.315841784746325e+77
Output: 0x5000_0000_0000_000A = 2.315841784746329e+77

Input:  0x7FF0_0000_0000_0000 = +Inf
Output: 0x0000_0000_0000_0000 (others are possible)

Input:  0xFFF0_0000_0000_0000 = -Inf
Output: 0x0000_0000_0000_0000 (others are possible)

Input:  0x7FFC_0498_90A3_38C4 = NaN
Output: 0x0000_0000_0000_0000 (others are possible)

Input:  0x8000_0000_0000_0000 = -0
Output: 0x0000_0000_0000_0000 = +0

Input:  0x0000_0000_0000_0000 = +0
Output: 0x0000_0000_0000_0000 = +0

Input:  0x8A2B_7C82_413E_D451 = -1.1173031443752871e-259
Output: 0x8A2B_7C82_413E_D451 = -1.1173031443752871e-259

Input:  0x000F_FFFF_FFFF_FFFF = 2.225073858507201e-308
Output: 0x000F_FFFF_FFFF_F000 = 2.2250738585051777e-308

Input:  0x0000_B815_7268_FDAF = 1e-309
Output: 0x0000_B815_A81D_0000 = 1.0000044514797e-309

code-golf scoring, Standard Loopholes forbidden.

C (gcc), 172 bytes
#define D double
i;D f(D x){unsigned a[]={0,0};D*A=&a;D c=0;do{for(i=0;i<32;++i){*a=*a&~(1<<i)|!!(a[1]&1<<(31-i))<<i;};c=fabs(x-*A)<fabs(x-c)?*A:c;}while(++a[1]);return c;}

(Almost) purely brute-force; takes about 24 minutes per run on my machine.
f is a function that takes a double and returns the closest palindromic double. It iterates over every palindromic 64-bit sequence (as a double), storing the closing one, and returns it at the end.
This solution uses gcc on Ubuntu 16.04 32-bit, on a little-endian 32-bit single-core Pentium 4 2.8 GHz CPU.
Explanation/Ungolfed:
int i;
double f(double x) {
    unsigned int a[]={0, 0}; // a 2-array of ints is much easier to maipulate bitwise
    double *A = &a; // than a double, so refer to the same memory
    // in two different ways, a as int[2], A as double*
    double current = 0.0;
    do {
        for(i = 0; i < 32; ++i) {
            *a = ( *a&~(1<<i) )|( (!!( (a[1]&1)<<(31-i) ))<<i);
            // reverse the bits of the second half into the first half
            // (*a is shorter than a[0])
        }
        current = fabs(x-*A)<fabs(x-current) ? *A : current;
        // if *A is closer to x than current, replace c with *A
    } while (++a[1]);
    // do-while instead of while to ensure each value is tried
    // at UINT32_MAX, overflows to 0, ending the loop.
    return current;
}

A C float (binary32) version that takes ~0.0015% as long to run (about 0.02 seconds on my machine) because it checks 1/65536 as many values: (185 179 bytes)
#define F float
i;F f(F x){unsigned short a[]={0,0};F*A=&a;F c=0;do{for(i=0;i<16;++i){*a=*a&~(1<<i)|!!(a[1]&1<<(15-i))<<i;};c=fabsf(x-*A)<fabsf(x-c)?*A:c;}while(++a[1]);return c;}


Make a Voronoi diagram (ASCII variant) Suppose you're given some distinct uppercase letters scattered in a rectangular array of otherwise-blank cells. Each cell in the array belongs to the letter nearest to it, defined as the letter reachable in the smallest number of horizontal and/or vertical steps -- no diagonal steps. (If a cell is equidistant from two or more nearest letters, it belongs to whichever of those letters is first in alphabetical order. A cell with an uppercase letter in it belongs to that letter.) Boundary-cells are those that are horizontally or vertically adjacent to one or more cells that do not belong to the letter that they themselves belong to.

Write a procedure subprogram with the following behavior, producing a kind of Voronoi diagram ...

Input: Any ASCII string composed only of dots, uppercase letters, and newlines, such that when printed it displays a rectangular array of the kind described above, with dots acting as blanks.

Output: A printout of the input string with each blank boundary-cell replaced by the lowercase version of the letter it belongs to. (The subprogram does the printing.)

Example 1

Input:

......B..
.........
...A.....
.........
.......D.
.........
.C.......
.....E...
.........

Output:

...ab.B..
....ab.bb
...A.abdd
aa...ad..
cca.ad.D.
..caeed..
.C.ce.edd
..ce.E.ee
..ce.....

A sketch highlighting the boundaries:

Example 2

Input:

............................U...........
......T.................................
........................................
.....................G..................
..R.......S..........F.D.E............I.
.........................H..............
.....YW.Z...............................
......X.................................
........................................
........................................
......MN...........V....................
......PQ................................
........................................
.............L...............J..........
........................................
........................................
....C...........K.......................
........................................
..................................A.....
...........B............................

Output:

..rt.....ts...sg......gduu..U.....ui....
..rt..T..ts...sg......gddeu......ui.....
...rt...ts....sg......gddeeu....ui......
....rttts.....sggggggGgdde.euuuui.......
..R.rywss.S....sfffffFdDdEeeeeeei.....I.
...ryywwzs.....sf....fddhHhhhhhhhi......
..ryyYWwZzs..sssffff.fddh.......hi......
..rxxxXxzzs.sllvvvvvffddh....hhhhi......
rrrxxxxnzzssl.lv....vfddh...hjjjjii.....
mmmmmmmnnnnnl.lv.....vvdh..hj....jai....
mmmmmmMNnnnnl.lv...V...vvhhj.....jaai...
ppppppPQqqql...lv.......vhj......ja.ai..
ppppp.pq.ql....lkv.....vjj.......ja..aii
cccccppqql...L.lkkv...vj.....J...ja...aa
.....cpqqlll..lk..kvvvvj........ja......
......cccbbbllk....kkkkj.......ja.......
....C...cb..bk..K......kj.....ja........
.......cb....bk........kjjjjjja.........
......cb......bk.......kaaaaaa....A.....
.....cb....B...bk......ka...............

Color enhancement:

Python 3 - 424 422 417 332 295 characters:
def v(s):
 w=s.find("\n")+1;n=(-1,1,-w,w);r=range(len(s));x=str.replace;s=x(x(s,*".~"),*"\n~")+"~"*w;t=0
 while s!=t:t=s;s=[min(s[i+j]for j in n).lower()if"~"==s[i]and(i+1)%w else s[i]for i in r]+["~"]*w
 print(x("".join(s[i]if any(s[i]!=s[i+j].lower()!="~"for j in n)else"."for i in r),*"~\n"))

There are three parts, each of which needs to be on its own line due to Python's syntax:

The first line sets up the variables. w is the width of a row of the board (including the newline at the end, which will be recycled as a padding column). r is a range object that indexes all the characters in s. n is a tuple of index offsets to get at the neighbors of a character (so if you wanted to allow the letters to spread out diagonally, you'd just need to add -w-1,-w+1,w-1,w+1 to the tuple). x is a short name for the str.replace method, which gets used several times in the later code (the calls will look odd though, since I use x(s,*"xy") to save characters, rather than the conventional s.replace("x", "y")). The s parameter string is modified slightly at this point as well, with its . characters and newlines being replaced by ~ characters (because they sort after all letters). A row's worth of padding ~ characters are also added to the end. t will later be used as a reference to the "old" version of s, but it needs to be initialized to something not equal to s at the start, and zero takes only one character (a more Pythonic value would be None, but that's three extra characters).
The second line has a loop that repeatedly updates s using a list comprehension. As the comprehension iterates over the indexes of s, ~ characters are replaced by the min of their neighbors. If a ~ character was completely surrounded by other ~s, this will do nothing. If it was next to one or more letters, it will become the smallest of them (favoring "a" over "b", etc.).  The newlines that were turned to ~ characters are preserved by detecting their indexes with the modulus operator. The padding row at the end isn't updated in the list comprehension (because the range of indexes, r, was calculated before they were added to s). Instead, a fresh row of ~ characters is added after the comprehension is done. Note that s becomes a list of characters rather than a string after first pass of the loop (but because Python is flexible about types we can still index to get at the characters in the same way).
The last line hollows out the insides of the diagram and rebuilds the characters into a string to be printed. First, any letter that is surrounded only by other copies of itself (or ~ characters from the padding) gets replaced by .. Next, the characters are all concatenated together into a single string. Finally, the padding ~ characters are converted back to newlines and the string is printed.


Subtracting, the old-fashioned way Overview
Adding slightly to the complexity of working with Roman numerals...
The ancient Romans devised a number system using Latin letters, which served them well, and which is still used by modern civilization, though to a much smaller degree. In the time of its use, Romans would have had to learn to use and manipulate these numbers in order to be of much use for many applications. For example, if a man owned 35 oxen, and he sold 27 of them, how would he know the new total other than counting them all? (Ok, that and using an abacus...) If the Romans could do it, surely we can figure it out as well.

Objective
Write the shortest algorithm/function/program that will subtract two Roman numerals together and output the result without converting the string representation of either input into a number.

Rules/Constraints
Because of historical/pre-medieval inconsistencies in formatting, I'm going to outline some non-standard (per modern usage) rules for orthography. See the value guide below as an example.

Since we are subtracting, negative numbers are permissible. 0s, as they have no representation in the Roman system, should be returned as NULL or an empty string.
The letters I, X, C, and M can be repeated up to four times in succession, but no more. D, L, and V can never be repeated.
The letter immediately to the right of another letter in the Roman representation will be of the same or lesser value than that to its left.

In other words, VIIII == 9 but IX != 9 and is invalid/not allowed.

All input values will be 2,000 (MM) or less; no representation for numbers greater than M is necessary.
All input values will be a valid Roman numeral, pursuant to the rules above.
You may not convert any numbers to decimal, binary, or any other number system as part of your solution (you are welcome to use such a method to VERIFY your results).
This is code golf, so shortest code wins.

I do have a solution to this problem that has already been beaten, but I'll hold off on posting it for a few days to see if any other answers come up.

Value Guide

Symbol        Value
I             1
II            2
III           3
IIII          4
V             5
VIIII         9
X             10
XIIII         14
XXXXIIII      44
L             50
LXXXXVIIII    99
C             100
D             500
M             1,000

Examples

XII - VIII = IIII (12 - 8 = 4)
MCCXXII - MCCXXII = '' (2,222 - 2,222 = 0)
XXIIII - XXXXII = -XVIII (24 - 42 = -18)

If any further clarification is needed, please ask.

sed 144

Most of you will know this little episode from roman times, when Cesar invented the Cesar crypting (aka rot13) using SED.

As a big fanatic of SED, he printed the most common used commands: substitute, print, quit and read (SPQR) on signs which he carried with him to teach his soldiers the use of SED.

#  63 = sed-file
#  81 = this
# 144 summa summarum
tac a|rev|sed y/gs/sg/ >b
echo $1|sed -f a|sed "s/$(echo $2|sed -f a)//"|sed -f b

first version 181:

# 126 = 2 sed-files =126
#  55 = this
# 181 summa summarum
echo $1|sed -f a|sed "s/$(echo $2|sed -f a)//"|sed -f b

2 files to use which count to the solution:

a:

s/M/DD/g
s/D/CCCCC/g
s/C/LL/g
s/L/XXXXX/g
s/X/VV/g
s/V/IIIII/g

b:

s/IIIII/V/g
s/VV/X/g
s/XXXXX/L/g
s/LL/C/g
s/CCCCC/D/g
s/DD/M/g

but b can be produced with the first line of the new solution from a: it is - more or less - the inverse, and so we read the file from bottom to top (tac) and from right to left (rev), and switch s and g which are now in the wrong order.

Invocation:

./cg-6061-roman-minus.sh MDCCCCLXV LXVI
MDCCCLXXXXVIIII

I guess I can golf this further, but I liked to occupy wallstreet the sed slot. :)

Since the logic isn't only in the sed files, but in the invocation too, I sum it all up. It could be argued about echo $1, but what about the nested $2? Let's just sum it together.

The sedfiles are pretty long and very redundant in their structure. There seems to be room for optimization.

Luckily, the romans already had QVANTVM <OMPVTVVMZ, so they didn't care for the otherwise lousy performance.

tl;dr:

I convert both numbers into church numerals (IIIIII=6), remove the second from the first, and reconvert the result back.

s.e.d. - sod errat demonstrandum.


Help me with my Halloween decoration The Halloween is upon us, and I haven't decorated my house yet, so I gonna need your help to do this task

Input
The input will be a list of 4 digits numbers, where each digit represent a portion of decoration:

EMBU
||||
|||+-upper decoration
||+-bottom decoration
|+-mouth/nose
+-eyes

Eyes:
0 - °
1 - ¯
2 - -
3 - ^
4 - '

Mouth/Nose
0 - v
1 - w
2 - o
3 - _
4 - -

Bottom decoration
0 - nothing
1 - skeleton
2 - pumpkin

Upper decoration
0 - nothing
1 - flying bat
2 - resting bat
3 - spider

Output

Skeleton:
(EME)
 _|_
/[|]\
  |
 / \

Pumpkin
  ,
(EME)

Flying bat

 ^"^

Resting bat
  ()
  ´`

Spider
  |
 .|.
 :":

Each decoration has a 5 character width
Upper decorations start from the top
Lower decorations start from the bottom
If the spider is over the pumpkin or there is no bottom decoration the web length will be 3, if it's over the skeleton, the web length will be 1
When the bottom decoration is 0 the first 2 digits are irrelevant
Between each decoration there will be an empty column

Example
Input
3123 ??02 1021 0310
Output

   |     ()
   |     ´`   ^"^
  .|.              (°_°)
  :":               _|_
                   /[|]\
   ,           ,     |
 (^w^)       (¯v¯)  / \

Trailing spaces at the end of each line are optional
Trailing newline at the end of the entire output is allowed

Winning criteria
This is code-golf so the shortest answer wins


Lonely Multiplication Based on this question from Code Review.

Given precisely three positive integers, return the product of all of the distinct inputs. If none of the inputs are distinct, return 1. That is, implement the function:

\$ f(a,b,c) = \cases{1 & $a = b = c $ \\ a & $ b = c $ \\ b & $ a = c $ \\ c & $ a = b $ \\ a b c & otherwise } \$

Shortest code in each language wins.

Test cases

a, b, c -> f(a,b,c)
7, 7, 7 -> 1
3, 3, 5 -> 5
2, 6, 6 -> 2
3, 4, 3 -> 4
1, 2, 3 -> 6
12, 9, 16 -> 1728

05AB1E, 3 bytes

¢ÏP

Try it online!

¢       # count occurences of each number
 Ï      # keep only those where the count is 1
  P     # product (1 if the list is empty)


Get the sequence steps Challenge

Given a sequence of numbers, create a function which returns the sequence steps.

Assume a sequence will be N >= 3
Sequence will repeat it steps at least once
Sequence will only contain natural numbers
Your function or program should return the shortest possible sequence of steps

Example:

Input: [1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17]

Output: [1, 1, 2]

Explanation: The initial sequence goes from 1 => 2 (1 step), 2 => 3 (1 step), 3 => 5 (2 steps). Then it repeats. The output then is [1 step, 1 step, 2 steps] => [1, 1, 2]

Another example:

Input: [2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20]

Output: [3, 1, 1, 1]

[2, 5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20]
 \  /\ /\ /\ /
  3   1  1  1  Then it repeats...

Test Cases

Input: [1, 4, 8, 9, 10, 13, 17, 18, 19, 22, 26, 27, 28] => Output: [3,4,1,1]

Input: [6, 11, 13, 18, 20, 25, 27, 32, 34, 39, 41] => Output: [5,2]

Input: [2, 6, 10, 13, 17, 21, 25, 28, 32, 36, 40, 43, 47] => Output: [4,4,3,4]

Input: [5, 6, 7] => Output: [1]

Clarifications

The input length - 1 is divisible by the output length
Assume sequence will always going to be increasing

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

Jelly, 9 7 bytes

IsJEƇḢḢ

Try it online!

How it works

IsJEƇḢḢ  Main link. Argument: A (array)

I        Increment; compute D, the array of A's forward differences.
  J      Indices; yield [1, ..., len(A)].
 s       Split D into chunks of length k, for each k in [1, ..., len(A)].
   EƇ    Comb equal; keep only partitions of identical chunks.
     Ḣ   Head; extract the first matching parititon.
      Ḣ  Head; extract the first chunk.


Number of sums of factors Given a positive integer n > 1 determine how many numbers can be made by adding integers greater than 1 whose product is n.  For example if n = 24 we can express n as a product in the following ways

24 = 24             -> 24            = 24
24 = 12 * 2         -> 12 + 2        = 14
24 = 6 * 2 * 2      -> 6 + 2 + 2     = 10
24 = 6 * 4          -> 6 + 4         = 10
24 = 3 * 2 * 2 * 2  -> 3 + 2 + 2 + 2 = 9
24 = 3 * 4 * 2      -> 3 + 4 + 2     = 9
24 = 3 * 8          -> 3 + 8         = 11

We can get the following numbers this way:

24, 14, 11, 10, 9

That is a total of 5 numbers, so our result is 5.

Task

Write a program or function that takes n as input and returns the number of results that can be obtained this way.

This is a code-golf question so answers will be scored in bytes, with fewer bytes being better.

OEIS sequence

OEIS A069016

Brachylog, 8 bytes

{~×≜+}ᶜ¹

Try it online!

Explanation

{    }ᶜ¹  Count unique results of this predicate:
 ~×       Create list of numbers whose product is the input.
   ≜      Label the list, forcing it to take a concrete value.
    +     Take its sum.

I'm not entirely sure why ~× only produces lists with elements above 1, but it seems to do so, which works great in this challenge.


Implement a One-Time Pad Background

A one-time pad is a form of encryption that has been proven impossible to crack if used properly.

Encryption is performed by taking a plaintext (comprised of only letters A-Z) and generating a random string on the same length (also only letters). This string acts as the key. Each character in the plaintext is then paired up with the corresponding character in the key. The ciphertext is computed as follows: For each pair, both characters are converted to numbers (A=0, B=1, ... Z=25). The two numbers are added modulo 26. This number is the converted back into a character.

Decryption is exactly the opposite. The characters in the ciphertext and key are paired up and converted to numbers. The key is then subtracted from the ciphertext modulo 26, and the result is converted back into a character A-Z.

The Challenge

Your challenge is to write the shortest program possible that can both encrypt and decrypt a one-time pad.

On the first line of input (to STDIN), there will be either the word "ENCRYPT" or the word "DECRYPT".

If the word is encrypt, then the next line will be the plaintext. Your program should output two lines (to STDOUT), the first being the key, and the second being the ciphertext.

If the word is decrypt, your program will get two more line of input. The first line will be the key, and the second line will be the ciphertext. You program should output one line, which will be the plaintext that has been decrypted.

The plaintext, ciphertext, and key should always consist of uppercase letters A-Z. They will always be a single line and contain no whitespace.

The key should always be random. No large parts of it should repeat between runs, and there should be no patterns that can be found in the text.

Two simple examples:

ENCRYPT
HAPPYBIRTHDAY
>ABKJAQLRJESMG
>HBZYYRTICLVME

DECRYPT
ABKJAQLRJESMG
HBZYYRTICLVME
>HAPPYBIRTHDAY

The > represents which lines are output, so you don't have to print that symbol as output.

GolfScript, 53 chars

n%(0=2%{~.,[{26rand 65+}*]:K]}*zip{{-}*~)26%65+}%K]n*

This is a task for which GolfScript seems just about perfectly suited.

To keep the code short, I'm using the same code for both encryption and decryption: to decrypt, I subtract the key from the ciphertext, while for encryption, I first generate a random ciphertext and then subtract the plaintext from it.  Even so, the extra code for implementing encryption mode takes just a little over half the length of the program.

De-golfed version with comments:

n %             # split input into an array of lines

# KEY GENERATION FOR ENCRYPTION MODE:
(               # extract the first line from the array
0 = 2 %         # check if the first char of that line is odd (E = 69)...
{               # ...and execute this block if it is:
    ~           # dump the remaining lines (of which the should be only one) on the stack
    . ,         # calculate the length of the last line...
    [ { 26 rand 65 + } * ]  # ...make an array of that many random letters...
    :K          # ...and assign it to K
    ]           # collect all the lines, including K, back into an array
} *

# ENCRYPTION / DECRYPTION ROUTINE:
zip             # transpose the array of 2 n-char strings into n 2-char strings...
{               # ...and execute this block for each 2-char string:
    {-} *       # subtract the second char code from the first
    ~ )         # negate the result (using the two's complement trick -x = ~x+1)
    26 % 65 +   # reduce modulo 26 and add 65 = A
} %

# OUTPUT:
K ] n*         # join the result and K (if defined) with a newline, stringifying them


Find the simplest value between two values Goal

Your goal is to find the simplest value in an open interval. In other words, given two values a,b with a<b, output the simplest x with a<x<b. This is a code golf, so fewest bytes wins.

Simplicity

All values in this problem are dyadic rationals, which means their binary expansions are finite, or equivalently, are rationals in simplest form a/2^b for some integer a and non-negative integer b. Integers are dyadic rationals with b=0.

Being simpler means having smaller b, tiebroken by smaller absolute value |a|.

Equivalently in terms of binary expansions, to find the simpler number:

Take the one with a shorter fractional part (fewer binary digits after the point).
In case of tie, take the lexicographically earlier one with length the primary sort, ignoring sign.

So, the numbers in simplicity order are

0, ±1, ±2, ±3, ±4, ...
±1/2, ±3/2, ±5/2, ...
±1/4, ±3/4, ±5/4, ...
±1/8, ±3/8, ...
±1/16, ...
...

There's no need to say which of ±x is simpler because any interval that contains both candidates also contains 0, which is simpler than both.

(A bit of background and motivation: In combinatorial game theory, positions in a two-player games have a numerical value representing magnitude of advantage, with the sign saying which player is favored. This value is determined recursively from the two values resulting from the best move of each player. You might guess that one averages them, but in fact it's the simplest value in between.)

Program requirements

Write, in as few bytes as possible, a program or named function that takes two dyadic rationals a,b and outputs the simplest dyadic rational x with a<x<b. Input can be function input or STDIN, and output can be function return or printing.

Input format

Two dyadic rationals a,b in whatever type your languages use for real or finite-precision binary values (float, double, etc). Fraction or rational types that store the value as a numerator and denominator are not acceptable. If you language has no valid type (and only then), you may use binary strings like 101.1101, or post a comment and we'll work something out.

You are guaranteed that a,b are dyadic rationals and a<b. Integer values will be given like 3.0, not 3.

You can assume you have sufficient precision to store the values, the output, and any intermediate steps exactly. So, you shouldn't worry about precision or overflows. I won't give an explicit bound on inputs, but your algorithm should take a reasonable amount of time on inputs like the test cases.

You may take your two numbers in any reasonable built-in container like pair, tuple, list, array, or set. Structures specifically representing intervals are not allowed though.

Output

The simplest dyadic rational strictly between a and b. The same rules for the input types apply, except outputting 3 rather than 3.0 is OK.

Test cases

(-1.0, 1.0)
0.0
(0.0, 2.0)
1.0
(0.0, 4.0)
1.0
(0.5, 2.0)
1.0
(-3.25, -2.5)
-3.0
(-4, 1.375)
0.0
(4.5, 4.625)
4.5625
(-1.875, -1.5)
-1.75

Python 2 - 100
I think I revised my entire method for this answer a good 4 or 5 times (which is probably an indication that it's a good code-golf question). I don't know if this answer can be golfed down any more but I do feel as if I'm missing some more clever methodological ways to shorten this.
def f(a,b,i=1.):
    r=0if a<0 else(a*i+1)//1/i
    return-f(-b,-a,i)if b<=0 else r if r<b else f(a,b,i*2)


Fold the integer to save space! The crazy mathematician owns a wide collection of numbers, and therefore the space he has left is quite limited. To save some, he must fold his integers, but unfortunately he is really lazy. Your task, if you wish to help him, is to create a function / program that folds a given positive integer for our number maniac.
How to fold an integer?
If it is evenly divisible by the sum of its digits, divide it by the sum of its digits. If it doesn't meet that requirement, take its remainder when divided by the sum of its digits. Repeat the process until the result reaches 1. The folded integer is the number of operations you had to perform. Let's take an example (say 1782):

Get the sum of its digits: 1 + 7 + 8 + 2 = 18. 1782 is evenly divisible by 18, so the next number is 1782 / 18 = 99.

99 is not evenly divisible by 9 + 9 = 18, hence we take the remainder: 99 % 18 = 9.

9 is obviously divisible by 9, so we divide it and obtain 1.

The result is 3, because 3 operations were required in order to reach 1.
Rules and Specs

Some integers might have the sum of digits equal to 1, such as 10 or 100. Your program doesn't need to handle such cases. That means, you will be guaranteed that the integer given as input doesn't have the sum of digits equal to 1, and no operation with the given integer will result in a number whose sum of digits is 1 (except for 1 itself, which is the "target"). For example, you will never receive 10 or 20 as input.

The input will be a positive integer higher than 1.

Default Loopholes apply.

You can take input and provide output by any standard mean.

Test Cases

Input     -> Output

2         -> 1
5         -> 1
9         -> 1
18        -> 2
72        -> 2
152790    -> 2
152       -> 3
666       -> 3
777       -> 3
2010      -> 3
898786854 -> 4

Here is a program that lets you visualize the process and try more test cases.

This is code-golf, so the shortest code in each language (scored in bytes) wins!

05AB1E, 13 12 bytes

[¼DSO‰0Kθ©#®

Try it online!

Explanation

[               # start loop
 ¼              # increment counter
  D             # duplicate current value
   SO           # sum the digits in the copy
     ‰          # divmod the current value by its digit-sum
      0K        # remove 0 from the resulting list
        θ       # pop the last element
         ©      # store a copy in register
          #     # if the current value is 1, break
           ®    # push the copy from register
                # implicitly output counter


Bl lu ur rr ry yv vi is si io on - Blur the text Task

Given a string as input, generate a "blurred" version of that string.

Input

Your input will be a single-line string of ASCII characters, containing a minimum of 2 alphanumeric characters

Output

A string that is the "blurred" version of the input string.

A blurred string is one where every alphanumeric character from the original string has been paired with the ones adjacent to it, and each pair is separated by a space.

Any non-alphanumeric characters (whitespace, puncuation) in the input string must be ignored when determining adjacency of alphanumeric characters, and they must not included in the blurred string.

There must be no leading or trailing whitespace in the output string.

Examples

Ab -> Ab
Abc -> Ab bc
Abcd -> Ab bc cd
E?h? -> Eh
Blurry vision -> Bl lu ur rr ry yv vi is si io on
We're #1! -> We er re e1
I'm an example! -> Im ma an ne ex xa am mp pl le
This is _not_ legible -> Th hi is si is sn no ot tl le eg gi ib bl le
(a*b*c)+5^-x -> ab bc c5 5x
??a_%,1!=z#@ -> a1 1z

This is code-golf, so fewest bytes wins!

Python 3, 57 55 bytes

lambda s:"".join((c+" "+c)*c.isalnum()for c in s)[2:-2]

Try it online!

How:

For each alpha-numeric character c in the string, replace it with c+" "+c.
E.g: "abcd" -> "a ab bc cd d"
Remove the redundant first and last 2 characters:
E.g: "a ab bc cd d" -> "ab bc cd"


Decompose string into blocks Your program's input is a string containing whitespaces, parentheses, and other characters. The string is assumed to be parenthesed correctly, i.e. each right parenthesis matches a unique left parenthesis and vice versa : so the program is allowed to do anything on incorrectly parenthesed strings, such as )abc, (abc or )abc(.
The character interval between a left parenthesis and the corresponding right parenthesis (including the parentheses) is called a parenthesed interval.
Your program's job is to decompose the string into blocks according to the rules below, and output the result as a "vertical list", with one block per line.

Now, two characters in the string are in the same block if either

(a) there is no whitespace character strictly between them

or

(b) there is a parenthesed interval containing them both.

Also,

(c) Whitespaces not in any parenthesed interval  are mere separators
and to be discarded in the decomposition. All the other characters (including whitespaces) are retained.

For example, if the input is

I guess     () if(you say ( so)), I'll have((  ))to pack my (((things))) and go

The output should be

I
guess
()
if(you say ( so)),
I'll
have((  ))to
pack
my
(((things)))
and
go

Another useful test (thanks to NinjaBearMonkey) :

Hit the ( Road (Jack Don't) come ) back (no (more ) ) no more

The output should be

Hit
the
( Road (Jack Don't) come )
back
(no (more ) )
no
more

The shortest code in bytes wins.

Retina, 31 bytes

S-_` (?=([^)]|(\()|(?<-2>.))+$)

Try it online!

This is a standard exercise in balancing groups. We simply match all spaces from which we can reach the end of the string while passing only correctly matched parentheses (since the ones we don't want to remove are followed by an unmatched closing parenthesis), and split the input around those matches. The _ option removes empty segments in case there are several spaces in a row and the - suppresses the default behaviour to include captured substrings in the result.


Ain't there nothing up my sleeves Note: reference to Nothing up my sleeve number.
Your task is to take no input and generate this exact output:
d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501
698098d8 8b44f7af ffff5bb1 895cd7be 6b901122 fd987193 a679438e 49b40821
f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 02441453 d8a1e681 e7d3fbc8
21e1cde6 c33707d6 f4d50d87 455a14ed a9e3e905 fcefa3f8 676f02d9 8d2a4c8a
fffa3942 8771f681 6d9d6122 fde5380c a4beea44 4bdecfa9 f6bb4b60 bebfbc70
289b7ec6 eaa127fa d4ef3085 04881d05 d9d4d039 e6db99e5 1fa27cf8 c4ac5665
f4292244 432aff97 ab9423a7 fc93a039 655b59c3 8f0ccc92 ffeff47d 85845dd1
6fa87e4f fe2ce6e0 a3014314 4e0811a1 f7537e82 bd3af235 2ad7d2bb eb86d391

A trailing newline is optional.
The MD5 hash for the version with trailing newline is:

FC1D37B5295177E7F28509EC9197688F

The MD5 hash for the version without trailing newline is:

FAC194EC5EFD2E5A5AC07C2A4925699B

How the string is generated
Those 64 strings are actually the 64 hexadecimal numbers used in the MD5 hash.
The pseudocode for them:
numbers = floor(2^32 × abs(sin(i))) for i in [1,2,...,64]

The reference Python code:
from math import*
for i in range(8):print" ".join("{:08x}".format(int(abs(2**32*sin(-~j))))for j in range(8*i,8*i+8))

Ungolfed:
from math import*
for i in range(8):
    temp = []
    for j in range(8*i,8*i+8):
        temp += ["{:08x}".format(int(abs(2**32*sin(j+1))))]
    print " ".join(temp)

Jelly, 26 24 23 bytes

64RÆSA‘æ«32Ḟb⁴Ḋ€‘ịØhs8G

Try it online!

How it works

64RÆSA‘æ«32Ḟb⁴Ḋ€‘ịØhs8G  Main link. No arguments.

64R                      Yield [1, ..., 64].
   ÆS                    Apply sine to each.
     A                   Take absolute values.
      ‘                  Increment.
                         This avoid padding the hex strings to 8 characters.
       æ«32              Left-shift by 32 units.
           Ḟ             Floor.
            b⁴           Convert to base 16 (list of integers).
              Ḋ€         Remove the first digit of each, undoing the increment.
                ‘        Increment each base 16 digit (for 1-based indexing).
                 ịØh     Index into "0123456789abcdef".
                    s8   Split into chunks of length 8.
                      G  Grid; separate columns by spaces, rows by linefeeds.