Golf the smallest sphere! Inspired by this challenge, as well as a problem I've been working on
Problem:
Given a non-empty set of points in 3D space, find the diameter of the smallest sphere that encloses them all. The problem is trivial if the number of points is three or fewer so, for the sake of this challenge, the number of points shall be greater than three.
Input: A list of 4 or more points, such that no three points are colinear and no four points are coplanar. Coordinates must be floats, and it is possible that two or more points may share a coordinate, although no two points will be the same.
Output: The diameter of the set (the diameter of the smallest sphere that encloses all points in the set), as a float. As has been pointed out, this is not necessarily the same as the largest distance between any two points in the set.
Rules:

You may assume that the points are not colinear.

The smallest program (in bytes) wins. Please include the language used, and the length in bytes as a header in the first line of your answer.

Example I/O:
Input:
 [[4, 3, 6], [0, 2, 4], [3, 0, 4], [0, 9, 1]]

Output:
9.9498743710662

Input:
 [[8, 6, 9], [2, 4, 5], [5, 5, 4], [5, 1, 6]]

Output:
7.524876236605994

Wolfram Language (Mathematica), 33 bytes
2#2&@@#~BoundingRegion~"MinBall"&

Try it online!
Nearly exactly the same as the Mathematica answer to the 2D version. Works for input points of any dimension.


Too much lines for me! The problem
You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months.
Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay.
Fortunatelly, you are not required to write everything by hand : there is a software for this, in which you can enter the address as plain text.
However, the software is not really well-made and very old. When you opened the files, every information was scared on several lines, and do not fit anymore on the envelope format you were given.
Definitely not wanting to repare this by hand, you decide to write a small programm that will put the data back in the right format for you.

Your task
Distribute the input on the right amount of lines.
Each line should have the same amount of inputs (regardless of their size in characters) when possible, and if not, the number of line with different lengths should be limited to its minimum.
Meaning that the distribution is to be made in terms of inputs and not characters.
For cases where two solutions are possible (7 inputs on 3 lines for example), the algorithm should maximise the number of inputs in the first lines (starting from the top). There is an example for this very case.

Input format
N M
string0
string1
string2
string3
string4
string5
...
string(N-1)

Where :
N is an int and corresponds to the number of fragments in which the data was scattered.
M is an int and corresponds to the number of lines in which the data should be. You may assume that M<=N if necessary.
string0 ... string(N-1) are strings that can contain any non-control ASCII character, including spaces and end with [space]\n. You thus do not need do add spaces between the strings in the output.
You may also assume that there is no horizontal length limit.
They do not contain any line break except the final one.

Examples
Input            Output

3 1            string0 string1 string2
string0
string1
string2

5 3            AA BBB
AA             C DDDDD
BBB            EEEE
C
DDDDD
EEEE
8 2            AAAAA BBB C DDD
AAAAA          EE FFF GGGG HH
BBB
C
DDD
EE
FFF
GGGG
HH

8 3           AAA BBB CCC
AAA           DDD EEE FFF
BBB           GGG HHH
CCC
DDD
EEE
FFF
GGG
HHH

7 3            string0 string1 string2
string0        string3 string4 string5
string1        string6
string2
string3
string4
string5
string6

Test cases
5 3
This
is
the
first
test case

8 6
Good Night, Good night!
Parting
is
such sweet
sorrow,
that I shall
say good night
till it be morrow.

8 3
I
am starting
to
run
out
of
ideas for
test cases.

Expected outputs:
This is  //2 strings [This ] and [is ]
the first //2 strings [the ] and [first ]
test case //1 string [test case ]

Good Night, Good night! Parting //2 strings [Good Night, Good night! ] and [Parting ]
is such sweet //2 strings [is such ] and [sweet ]
sorrow, //1 string [sorrow, ]
that I shall //1 string [that I shall ]
say good night //1 string [say good night ]
till it be morrow. //1 string [till it be morrow. ]

I am starting to //3 strings
run out of //3 strings
ideas for test cases. //2 strings

Rules
Please mark your answer as : Language - XX bytes.
It is code-golf, so the winner is the answer with the smallest score in bytes.
It would also be very nice if you could provide even briefs explainations, as it is always very enlightning to read this kind of post.

05AB1E, 23 21 bytes
This is my first 05AB1E program (In fact this is my first golfing using golfing language), so please, if you have any notes, tips or improvements - I would love to get some in the comments section.
Program:
`rs/î©\õ.gGs«N®%0Qi¶«}}

Explaination:
`rs/î©\õ.gGs«N®%0Qi¶«}}
`                             Push each element of the input to the stack
 r                            Reverse the stack
  s                           Swap the first two values in stack (which are the numbers)
   /                          Division between both numbers in order to get the number of words in each line
    î                         Round up
     ©                        Store that value in the register
      \                       Remove that number from the stack (remove head)
       õ                      Push empty string to pass over the first iteration
        .g                    Push the length of the stack (which is the number of words)
          G            }      Loop from 1 to The length of the stack
           s                  Swap the two words in the head of the stack
            «                 Concatenate
             N                Push counter_variable
              ®               Push the number we saved in the register (number of words per line)
               %              Modulo (To check if we need to concatenate a newline)
                0Q            Equals zero
                  i  }        If true
                   ¶          Push newline
                    «         Concatenate

Try it online!
Saving 2 bytes with the help of @KevinCruijssen:
`rs/îUõ.gGs«NX%_i¶«}}

Try it online!


Are the brackets fully matched? You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format.
Rules and definitions:

For the purpose of this challenge, a "bracket" is any of these characters: ()[]{}<>.

A pair of brackets is considered "matched" if the opening and closing brackets are in the right order and have no characters inside of them, such as
()
[]{}

Or if every subelement inside of it is also matched.
[()()()()]
{<[]>}
(()())

Subelements can also be nested several layers deep.
[(){<><>[()]}<>()]
<[{((()))}]>

A string is considered "Fully matched" if and only if:

Every single character is a bracket,

Each pair of brackets has the correct opening and closing bracket and in the right order, and

Each bracket is matched.

You may assume the input will only contain printable ASCII.

Test IO
Here are some inputs that should return a truthy value:
()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]

And here are some outputs that should return a falsy value:
(               Has no closing ')'
}{              Wrong order
(<)>            Each pair contains only half of a matched element
(()()foobar)    Contains invalid characters
[({}<>)>        The last bracket should be ']' instead of '>'
(((()))         Has 4 opening brackets, but only 3 closing brackets.

As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins.


Color RGB int to hex Given three integers rgb, output hexadecimal representation as a string.

Input:          Output:
72 61 139       #483D8B
75 0 130        #4B0082
0 255 127       #00FF7F

Shortest most unorthodox code wins

Ruby

I was going more for the "unorthodox" part. ;)

10;a=    gets.   split
.  map  {|       x|  #x
"%02X"  %(  x.   to_i)
}; $>   <<   ?#  <<  a[
00  ..   1+2].   join;

The font (on my web browser) is a bit tall, so it looks distorted, but it looks better in Courier New:

Sample run:

c:\a\ruby>rgb2hex
255 100 0
#FF6400


Lead your team to win the wrestlers world championship! You are the captain of a world-famous wrestling team. An Olympic-grade match is coming up, and you are determined not to let your team down. You also happen to be a competent programmer, so you are going to write a program to help your team win!
You have access to the strength ratings for each of your own team wrestlers, and each of the opponent wrestlers. A wrestler will win their match only when their strength rating is greater than their opponent's strength rating. You have to write a program that will calculate the optimum pairing for each of your own wrestlers against each of the opponent wrestlers, and then output the maximum number of matches that can be won as a result.
Input
Your program will take as input three strings:

The number of members per team (there will be an equal number of wrestlers on each team)
The strength rating of each of your team wrestlers, as a space-separated list
The strength rating of each of the opponent wrestlers, as a space-separated list

Note:

You don't have to take the first number if you don't want to. It's there if you want it for help iterating through the list/array/string.
The strength rating is a number between 1 and 10.
You may input the strength ratings as a list or array instead of a string.

Output
Calculate the optimum pairing for each of your own wrestlers against each of the opponent wrestlers, and then output the maximum number of matches that can be won as a result.
Test cases
Test case 1:
5
2 4 6 2 6
3 10 6 7 7

Output: 1
Test case 2:
10
1 9 5 5 1 6 2 8 3 6
6 10 2 8 2 3 5 6 10 10

Output: 6
Bounties
I will upvote all answers that meet the requirements and that include an explanation, to encourage participation and to educate other Code Golfers on how your program works.
There will be no accepted answer since I want to encourage programs in all languages.
This is code-golf so be as creative as you can!

Python 2, 59 57 bytes
-2 bytes thanks to @dingledooper!

lambda a,b:sum(b.sort()<b<[x]>b.pop(0)for x in sorted(a))

Try it online!
A function that takes 2 lists as arguments, and returns the maximum number of matches that can be won.
Approach
For each opponent (from weakest to strongest), match that opponent with the weakest available member of my team that can win.
For example, let's say the strength of 2 teams (sorted) are as follow:
No.       1  2  3  4  5
Me       [2, 2, 4, 5, 8]
Opponent [3, 6, 7, 7, 9]

The 1st opponent has strength 3, so we need to match that with our 3rd team member.
The 2nd opponent has strength 6, so we match that with our 5th.

We cannot win any more match. So in total we can win at most 2 matches.
Ungolfed code
a,b=map(sorted,input())  # sorted strength of my team and opponent team
s = 0                    # number of matches that can be won
for x in a:              # loop through my team, in order of increasing strength
  if x > b[0]:             # if current member can beat the weakest opponent left
    s += 1                   # then match those two
    b.pop(0)                 # and remove the weakest opponent
                           # (otherwise, current member is useless)
print s


All about basic binary Please excuse the punny title.

This is a question is inspired by A Curious Property of 82000.  In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5.  The post then poses the question "is there a number that is binary in bases 2, 3, 4, 5, and 6"?  (For those curious, I've checked values up to 10^1,000,000 and so far the answer is no.)

This got me thinking: given a number, what bases is it binary in?

Our curious number, 82000, is actually binary in six bases:

Base 2 = 10100000001010000
Base 3 = 11011111001
Base 4 = 110001100
Base 5 = 10111000
Base 81999 = 11
Base 82000 = 10

Not all numbers will have binary bases that are sequential.  Consider the number 83521.  It's binary in bases 2, 17, 289, 83520, and 83521.

Your challenge is to determine and display which bases a number is binary in.

Rules

A number is considered "binary" in a given base if its representation in that base consists of only zeroes and ones.  110110 is a binary value, while 12345 is not, A380F is definitely not.
Your number will be provided on standard input.  It will be an integer value between 2 and 2^32-1 inclusive and will be provided in base-10 format.
In ascending order, display each base greater than one that the number is binary in.  Each base should be on its own line.  If you include the binary value in that base (see the bonus scoring below), separate the base and the binary value with a space.  Only output to standard out will be judged, standard error and other sources will be ignored.

Scoring

Your score is your program's size in bytes.  The lower the score, the better.

Bonus:
If your program also outputs the binary values in the found bases, multiply your score by 0.75
Your displayed binary value should have no extra punctuation, no extraneous zeroes, no decimal point, just zeroes and ones.

Examples

Input:

82000

Output (receives bonus):

2 10100000001010000
3 11011111001
4 110001100
5 10111000
81999 11
82000 10

Input:

1234321

Output (no bonus):

2
1111
1234320
1234321

Pyth, 14 13
jbf!-jQTU2tSQ

Thanks to Jakube for pointing out the new S function.
Try it here.
The online version is too slow to do 1234321. This simply converts the input to each base from 2 to itself and discards the results that contain values other than 0 and 1.
Explanation:
                           : Q=eval(input) (implicit)
jb                         : join on newlines the list...
  f!                       : filter away nonempty values (impliticly named T)
    -jQTU2                 : sewtise difference of number converted to base and range(2)
     jQT                   : convert Q to base T
        U2                 : range(2)
          tSQ              : over the range [2 Q+1)

In addition, this is a (not well golfed now well golfed, again thanks to Jakube) bonus version (20 * .75 = 15):
VQI!-JjQK+2NU2pdKjkJ

Try it here


Tic-Tac-Toe - X or O? Background
Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!)
Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecutive and identical characters (X or O), either horizontally, vertically or diagonally. In case the board is filled and none of the players managed to get three consecutive characters as decribed above, the game ends in a tie. Note that there might be empty spots at the end of the game, in case either of the players wins in less than 9 moves in total (this cannot happen in case of a tie).
Task
Given a Tic-Tac-Toe board at the end of a game (in the form of a string, a matrix, a flat list of 9 ordered values, any other decent format), determine who wins the game.

The input will consist of distinct and consistent values, one for X, one for O and another one that represents an empty spot.

Your program should be able to output 3 distinct, consistent and non-empty values: one in case X wins, another one in case O wins or another if the players are tied.
Please specify these values in your answer. You can assume that the input will be a valid Tic-Tac-Toe board.

Test Cases
X, O, _ are the input values here; X wins, O wins and Tie are for the output.
X O X
O X _
O _ X

Output: X wins.
X _ O
X O _
X O X

Output: X wins.
X O X
_ O X
_ O _

Output: O wins.
X O X
O O X
X X O

Output: Tie.

As usual, all our standard rules apply. This is code-golf, the shortest code in bytes in every language wins!

Jelly,  16 15  14 bytes
U,Z;ŒD$€ẎḄỊÐḟḢ

A monadic link accepting a list of lists (the rows - or columns) with the values:
X = 0.155; O = -0.155; _ = 0

Returning results:
X wins = 1.085; O wins = -1.085; Tie = 0

Note: using a value of zero for _, and equal but opposite values for X and O, this value (here 0.155) may be in the range (1/6, 1/7) (exclusive at both ends) - I only chose a value in that range that gave a precisely representable floating point result for the win cases.
Try it online!
How?
U,Z;ŒD$€ẎḄỊÐḟḢ - Link: list of lists (as described above)
U              - upend (reverse each row)
  Z            - transpose (get the columns)
 ,             - pair the two
      $€       - last two links as a monad for each of them:
    ŒD         -   diagonals (leading diagonals - notes: 1. only one is of length 3;
               -              2. the upend means we get the anti-diagonals too)
   ;           -   concatenate (with the rows/columns)
        Ẏ      - tighten (make a single list of all the rows, columns and diagonals)
         Ḅ     - from binary (vectorises) (note that [0.155, 0.155, 0.155]
               -                           converts to 4*0.155+2*0.155+1*0.155 = 1.085
               -                           and [-0.155, -0.155, -0.155]
               -                           converts to 4*-0.155+2*-0.155+1*-0.155 = -1.085
               -                           while shorter lists or those of length three
               -                           with any other mixtures of 0.155, -0.155 and 0
               -                           yield results between -1 and 1
               -                           e.g. [.155,.155,0] -> 0.93)
           Ðḟ  - filter discard if:
          Ị    -   insignificant (if abs(z) <= 1) (discards all non-winning results)
             Ḣ - head (yields the first value from the list or zero if it's empty)


Visualize long division with ASCII art Write a program that visualizes long division with ASCII art.  Input consists of two integers, a numerator and a denominator, using the input format of your choice.

Examples:

1234 ÷ 56:

     22
   ----
56|1234
   112
   ---
    114
    112
    ---
      2

1002012 ÷ 12:

     83501
   -------
12|1002012
    96
   ---
     42
     36
     --
      60
      60
      --
        12
        12
        --

0 ÷ 35

   0
   -
35|0

Rules:

Use of the programming language's division operator is allowed.
Use of big integer support is also allowed.
For consistency:

If the quotient is zero, print a single zero at the end of the diving board.
If the remainder is zero, do not print it.
Do not print leading zeros on any numbers.

Excess newlines at the end and trailing spaces to the right are allowed.
Solution with the fewest characters wins.

Limits:

0 <= numerator <= 1072 - 1
1 <= denominator <= 9999999

This implies that the output will never be wider than 80 columns.

Test suite and sample implementation:

You can use long-division.c (gist) to test your program.  It is actually a bash script with a C program inside.  Tweak it to invoke your program in the test suite.  Look at the C code at the bottom to see the reference implementation.  Please let me know if there are any problems with the sample program or test suite.

$ ./long-division.c 10 7
   1
  --
7|10
   7
  --
   3
$ ./long-division.c
PASS 1234 ÷ 56
PASS 1002012 ÷ 12
PASS 1 ÷ 1
--- snip ---

Score: 35 / 35
All tests passed!

Edit: By request, I put the test suite input and expected output into text files (gist).  Sample usage (bash):

cat input | while read nd; do
    ./program $nd |
        sed 's/\s*$//' | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba'
done > output

diff -u expected output

The weird sed commands filter out trailing newlines and spaces from the program output.

Python 3, 284 257 characters

div.py

n,t=input().split()
d=int(t)
l=lambda x:len(str(x))
s=l(n)
def p(x):print(' '*(l(d)+s-l(x)+1)+str(x))
p(int(n)//d)
p('-'*s)
p(t+'|'+n)
s=z=f=0
while t:
 try:
  while z<d:z=z*10+int(n[s]);s+=1
 except:t=0
 if z*f:p(z)
 if t:f=1;t=z//d*d;p(t);p('-'*l(z));z-=t

Usage: python3 div.py
Input: from keyboard

test.py

import sys
sys.stdin=open('input'); sys.stdout=open('output','w')
for line in open('input'): exec(open('div.py').read())

output matches expected

Versions:
 1. 284
 2. 257: s,z,f=0,0,0→s=z=f=0; z and f→z*f; better looping; removed a few newlines.


2016 Time Capsule String: Climb The Integer Ladder Using the 74 characters from the 2016 time capsule string
H@~*^)$.`~+1A|Q)p~`\Z!IQ~e:O.~@``#|9@)Tf\eT`=(!``|`~!y!`) Q~$x.4|m4~~&!L{%

write N code snippets all in the same language where:

The 1st snippet outputs 1.
The 2nd snippet outputs 2.
The 3rd snippet outputs 3.
... etc. ...
The Nth snippet outputs N (the number, not the literal letter).

A "code snippet" is defined as any of these:

A full program with no required input that outputs the number normally.
A function with no required arguments that outputs/returns the number normally.
A REPL expression that evaluates to the number.

(You may mix and match these three variants in your N snippets.)
The characters you're allowed to use in the combined set of N snippets are precisely the 74 characters of the time capsule, plus floor(N/2) extra "wildcard" bytes that you may use anywhere.
For example, the time capsule contains three @'s so in the entirety of your N snippets there may only be up to three @'s present unless you decide to use some of your floor(N/2) wildcard bytes for additional @'s.
Thus, not counting wildcards, the combined set of characters in your N snippets must be a subset of the 74 time capsule characters. Their combined lengths cannot exceed 74.
You may not reuse time capsule characters or wildcard bytes between snippets.
Notes

The are no other limits on snippet length or how many wildcards may be used per snippet.

You must write all snippets for 1 through N. It's not 0 to N-1, not k to N+k-1.

The snippets must be individual, not one snippet that outputs the  list 1, 2, 3, ..., N.

Outputs may be floats like 3.0 in place of 3 and you can use a base other than decimal if it is your language's natural base. You must use the same base for all snippets.

The wildcards are counted as bytes in your language's encoding. This will probably be ASCII but e.g. if ∞ counts as one byte in your encoding then you can use it as a single wildcard byte.

You may use wildcard bytes for multibyte characters. e.g. ∞ is normally three bytes so you could use it in a snippet but it will cost three of your floor(N/2) wildcard bytes.

Newlines such as \r\n may be considered one byte.

Example
In Python, N = 4 is possible just using the REPL. There are floor(4/2) = 2 wildcards.

1 from the time capsule is an expression that evals to 1.

2 consists of a single wildcard, namely the 2. Evals to 2.

3 also consists of a single wildcard. Evals to 3. No more wildcards.

4 is luckily in the time capsule and it evals to 4.

These snippets are short and trivial. A real answer would likely be much more complex.
(Five and beyond in Python may certainly be possible but I'll leave it to the professionals.)
Scoring
The answer with the highest N wins; i.e. the one that climbs the integer ladder the highest.
In case of a tie, the answer that used the fewest wildcard bytes wins.
In case there is still a tie, the answer that used the fewest cumulative characters wins.
If there is still a tie, the earlier answer wins.

CJam, 23 snippets, 11 wildcards, 45 bytes

Q!
Q!)
Z
4
4)
6
7
8
9
A
B
C
D
E
F
G
H
I
J
QT|T+e`
O!)1
L!`e`(:)
6mf

Try it online! | wildcard counter (ignore the newlines)


Don't repeat yourself in Rock-Paper-Scissors Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as

a x x b

where a and b are words of any length and x is a word of length at least one, all made of the letters R, P, S.

Task

Write a program that generates the square-free words of the letters R, P, S of length n where the number 1 <= n <= 10 is taken as input.

Example

For example the square-free words of length 3 are

RPR, RSR, RPS, RSP, SPS, SRS, SRP, SPR, PRP, PSP, PSR, PRS

and those of length 4 are

RPRS, RPSR, RPSP, RSRP, RSPR, RSPS, PRPS, PRSR, PRSP, PSRP, PSRS, PSPR, SRPR, SRPS, SRSP, SPRP, SPRS, SPSR

and note that for example SPSP or PRPR are not square-free

Rules

This is codegolf, shortest program wins, standard loopholes are closed.
You may print the words or create them in memory.
Your program may be written as a function.

References

Wikipedia entry on square-free words

The number of square-free ternary words of given length are
in https://oeis.org/A006156

Related: Arbitrary-Length Ternary Squarefree Words

Ruby, 39 bytes

->n{(?P*n..?S*n).grep_v /[^RPS]|(.+)\1/}

This hilariously inefficient function generates all strings of length N that lie alphabetically between N Ps and N Ss, then filters out the vast majority that contain non-RPS characters. The actual squarefree check just uses a Regexp backreference: (.+)\1.

More idiomatic 65 bytes that finish in a reasonable amount of time for N=10:

->n{%w[R P S].repeated_permutation(n).map(&:join).grep_v /(.+)\1/}

Edit: Saved a byte thanks to G B.


Tips for golfing javascript code, especially converting while loop to expression The code:

function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h];
t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i,
E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o())
{o+=i+","}return o}}

For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a commented version of the code and some disclaimers about valid inputs and outputs)

I'm looking for suggestions on how to golf it further. I feel the last function is especially verbose. I managed to make every other function a single expression so I didn't need curly brackets or a return statement, but couldn't figure out how to make the last one not require a while loop.

I think the best way to get rid of the curly brackets is to go recursive.

Original function (46 bytes)

t.s=_=>{o="";while(i=t.o()){o+=i+","}return o}

Recursive version (29 bytes)

t.s=_=>(i=t.o())?i+[,t.s()]:i

The i+[,t.s()] trick saves a byte over i+','+t.s().

Because you stop when t.o() returns null, the result of your original version always ends with a comma. In the new version, we actually append null at the end (that's the :i) but it's coerced to an empty string because of the above trick, leading to the same behavior.


Check if B is composed of substrings of A of length n Given two strings \$ A \$  and \$ B \$ and a positive integer \$ n \$, determine whether \$ B \$ is composed entirely of (possibly overlapping) strict substrings of \$ A \$ of a length of at least \$ n \$.
Test cases
n  A               B               Output
-----------------------------------------
2  abcdefg         bcabcdebcdef    True
2  abcdefg         cdabfg          True
4  abracadabra     abrabrabrabra   True
1  abcdefg         ddbfeg          True
2  ab              abab            True
2  bb              bbbbb           True
5  abcdefghijklmn  defghabcdefghi  True
2  abcdefg         hijklmn         False
3  abcdefg         bcabcdebcdef    False
2  abcdefg         ddabfg          False
2  ab              aba             False
2  abcdefg         a               False
4  abracadabra     brabrabrabra    False
6  abcdefghijklmn  defghabcdefghi  False

Rules

You may assume that both \$ A \$ and \$ B \$ are non-empty; \$ n \ge 1 \$; and \$ A \$ has a length of at least \$ n \$
You may choose to operate on arrays with elements of any data type or set of values, rather than strings, as long as there are at least 8 distinct values for that element type
You can output using truthy or falsey values, or any two other disjoint sets of values, to indicate a true or false result
You may use any sensible I/O format
Standard loopholes are forbidden
This is code-golf, so the shortest code in bytes wins

Excel, 114 bytes
A nice low bar to start with.
=LET(x,SEQUENCE(LEN(C1)),t,TRANSPOSE(x),AND(MMULT((x<t+A1)*(x>=t),IFERROR(FIND(MID(C1&REPT(" ",A1),x,A1),B1),0))))


Find all Perrin pseudoprimes less than 100 million Simply put, the Perrin sequence has the following recurrence relation:

P(n) = P(n-2) + P(n-3);
P(0) = 3; P(1) = 0; P(2) = 2;

But wait!! There's more!!
The Perrin sequence has a very bizarre property:

If N is prime, then P(N) mod N = 0.

Furthermore, there are very few composite numbers which have this property.  This can serve as a simple primality test which gives very few false positives.
There are 5761462 numbers under 100 million which satisfy this congruence. Out of those, 5761455 (99.9999%) are prime numbers.
Your mission is to compute those 7 numbers which pass the test but which are not prime.  To be specific, your program must output these numbers in a reasonable format:
271441, 904631, 16532714, 24658561, 27422714, 27664033, 46672291

You can find more perrin pseudo primes (all of them up to 10^16) with factorization here. For this challenge only the first 7 are important, since they are the only one smaller than 100 million.
(Your program must compute these numbers without having them pre-made, or accessing the internet, or similar stuff.)
Also, your program should not produce integer overflows.  This may at first seem difficult because the 100 millionth Perrin number is really, really big.  Algorithms do exist, however, which would not cause overflows.
This is code golf, shorter solutions are better.

Ruby, 183

require'Prime'
f=->a{a=a.flat_map{|n|String===n ? n : n<3?%w[3 0 2][n]:[n-2,n-3]} until a.all?{|x|String===x}
a.map(&:to_i).inject :+}
n=1
p n if f[[n+=1]]%n==0&&!n.prime? while n<1e8

Technically works but runs in an unreasonable amount of time. Try setting the lower bound to 271435 and upper bound to 271450.


Format a floating point number exactly as decimal Any binary floating point can be formatted exactly in decimal. The resulting string might be somewhat long, but it is possible. In my article on floating point I cover the importance of precision, and now I want this function. This challenge is to write a program, or function, that takes a floating point value as input and formats an exact decimal string as output.

To ensure we are working with the correct floating point numbers a precise format must be provided as input to the program. This format will be two integers Significand Exponent, where the actual floating point value is Significand * 2 ^ Exponent. Note that either value can be negative.

Specifics:

The range and precision of at least a 32-bit float must be supported (no input will go beyond that)
The decimal formatted value must be an exact representation (simply close enough to guarantee a correct round-tip back to float is not good enough)
We don't trust standard library floating point formatting functions to be correct enough nor fast enough (ex: printf), and thus they may not be used. You must do the formatting. Integral formatting/conversion functions are allowed.
There may not be any leading or trailing zeros, except for the required one leading zero in front of the . if there is no whole number component
A function, or whole program, is allowed.

Examples:

1 -2 => 0.25
17 -3 => 2.125
-123 11 => -251904
17 50 => 19140298416324608
23 -13 => 0.0028076171875
3 120 => 3987683987354747618711421180841033728
3 -50 => 0.00000000000000266453525910037569701671600341796875
-3 -50 => -0.00000000000000266453525910037569701671600341796875
10 -2 => 2.5
-12345 -3 => -1543.125
0 0 => 0
161 -4 => 10.0625
512 -3 => 64

Shortest code wins.

CJam, 43

r_'-&\ize999rim<s1e3'0e[W%999/(i_L?\+'.*sW%

Try it online

Explanation:

The program works with exponents up to ±999, close to double precision (64 bit). It separates the minus sign (if present) from the significand, multiplies it by 10999 then does a bit shift with the exponent, which is now an exact calculation. It then pads to the left with zeros if the result has less than 1000 digits, separates the last 999 digits as the fractional part, removes trailing zeros by converting its reverse to integer, adds a decimal point if needed, and puts everything back together.

r_         read and duplicate the significand in string form
'-&        keep only the minus sign, if present
\          swap with the other copy of the significand
iz         convert to integer and get absolute value
e999       multiply by 10^999
ri         read the exponent and convert to integer
m<         shift left by it; negative values will shift right
            the result is an exact non-negative integer
s          convert to string
1e3'0e[    pad to the left with zero characters up to length 1000
            longer strings will be left intact
            we need 1 more than 999 for the 0.xxx case
W%         reverse the string
999/       split into slices of length 999
(          take out the first slice (reversed fractional part)
i          convert to integer
            this removes the leading zeros (trailing in reverse)
_L?        if it's zero, replace with an empty string
\+         concatenate back (to the left) with the second slice
'.*        join the with the dot character
            if the fractional part was zero, we only have the second slice
            (reversed integer part) and there is nothing to join
s          convert to string; this is the reversed result without the sign
W%         reverse back

At the end, the minus sign (if any) and the final string are automatically printed together.


Just Another Polyglot Hacker! Make a program which prints just another #{LANG} hacker where #{LANG} is the name of the language with which the program is being run.

For example, if I run your program with Bash, I'd expect just another Bash hacker as the output, but when running the same program through C++, I'd expect the output to be just another C++ hacker.

Your program must run in and produce correct output in at least two different languages.

This is in no way a duplicate of the other suggested question, Write a polyglot that prints the language's name; that question asks for a rather short (and in my opinion) uninteresting output, increasing the easiness of writing and number of languages in an answer, and then it assesses them (these polyglots) based on the source's length!

A correct response to this question, however, would produce longer outputs, and thus would have actually been fairly challenging and fun to write and it would be more difficult to add languages to your polyglot. I then assess the polyglots in a natural way; by the number of languages they support!

I think that this will lead to very different answers being submitted on either question, but also different uses for these answers; the programs which will be submitted here are the type of programs which would be flaunted around the internet for their ingenuity and creativity, "look! Here's a guy who can pull off a swaggy polyglot in 4 different languages! They're cool!"

When I asked this question, I thought I'd put a twist on the popular and well known Just Another Perl Hacker competition, but add some creativity and an extra "Wow!" factor; JAPH programs are often sported as signatures in forums etc., and I believe entries here will inspire similar use, unlike entries for the other question.

Also, because this isn't a form of code-golf like the other question, but I'm actually assessing answers on the number of languages they support, I believe we can expect some rather incredible entries, making use of language features and loopholes we never knew existed!

Rules:

Two different versions of the same language only count separately if:

You print out the version as well as the language name, for each version.
You detect which version is running thraough a less trivial method than running a ver() function or similar built-in of your language.
The two have different major version numbers.

For example, if you say your program runs in both Python 3.4.1 and 2.7.8, here are the necessary outputs:

Python 3.4.1

just another Python 3.4.1 hacker

Python 2.7.8

just another Python 2.7.8 hacker

If your program doesn't produce the above outputs for each version, then you cannot list the two separate versions as different languages under which your code runs.

You may not have any errors on the maximum level of warning in any of the languages.
Program must terminate.

Winner:

Whoever's (valid) answer supports the most languages. In the case of a tie, the shorter answer (by program byte count) wins.

C, C++, Perl, Bash – 230
#include <stdio.h>
#define c const char*\
s="just another %s hacker\n"
//bin/test;printf "$s" Bash;exit
int main(){c;printf(s,sizeof'a'-1?"C":"C++");}
/*==;seek DATA,0,0;@a=readline DATA;eval'$'.$a[2];printf $s,"Perl";
__DATA__*/

This was fun! :-)
230 chars including a newline at end of file. To run, save as both poly.c and poly.cpp and do:
$ gcc -Wall -Wextra -pedantic poly.c && ./a.out
just another C hacker
$ g++ -Wall -Wextra -pedantic poly.cpp && ./a.out
just another C++ hacker
$ perl poly.c
just another Perl hacker
$ bash poly.c
just another Bash hacker


Cyclic prime number program generator Challenge

Your submission should consist of 2 or more programs each written in distinct languages. They can be arbitrarily numbered from 1 to k.

Each program p, given a natural number n should print the next n prime numbers (initially, the next prime is the 0-th prime, 2) on a single line, followed by a single blank newline, followed by a program fragment, which, when appended to the p+1 mod kth program, produces the program which does precisely the same thing, but with the next prime being the n+1th prime number.

Details

Your programs may accept its input as a function argument, or from standard input, or the closest equivalent in your languages.
Your programs may not read data from any external source other than to read n from standard input. If this data is required by your program, it must be included in the source code fragment generated by the previous program.
Your programs may not compute any prime numbers less than the next prime number.
The prime numbers may be separated by any delimiter other than a newline.
You may not use any language primitives or libraries for prime number generation - you must write the algorithm yourself.
You may use standard libraries for things other than prime generation.
Two languages which differ only in their versions are not said to be distinct languages.
Two languages whose semantics largely overlap (for example, C and C++) are not said to be distinct.
Your programs may do whatever they like for undefined inputs.
Your programs are required to support generating prime numbers up to 2^32-1. You may assume whatever you need about the runtime environment to ensure this is the case (i.e. you can assume your C program will be run on a machine where int has at least 32 bits). If this assumptions is non-trivial it should be stated explicitly.
If running your program involves a non-trivial compilation step it should be stated how to do it, so others can reproduce it.

Input/Output

next    in    out
0       10    2,3,5,7,11,13,17,19,23,29
25      13    101,103,107,109,113,127,131,137,139,149,151,157,163
7       4     19,23,29,31

Scoring

Because disk space is very expensive, your programs should be as small as possible. Because more is obviously better, your submission should consist of as many programs as possible. The score of your submission is the average byte count of your programs divided by the number of distinct languages used. Lowest score wins.

Java + Python 2, Score = (302 + 218) / 2 / 2 = 130

Here is a brief explanation on how this works:

Choose a program and pick a positive integer, n; for Java, pass n as a command line argument; for Python, pass n through stdin.

The program will then print a list of n primes followed by 2 newlines and then a snippet.

Append this to a fresh copy of the program which was not chosen.
Choose a new n and pass it to this modified program

The program will then print a list of n primes followed by 2 newlines and then a snippet.

Append this to a fresh copy of the program which was originally chosen.
Rinse, repeat.

Golfed

Java, 302 bytes

Netbeans is able to compile this even with the A class missing, I haven't been able to figure out how. But once I do, I will add the flags to the byte count.

public class P{static int i=2;public static void main(String[]a){int l=2,n=Integer.parseInt(a[0]),x;String s="";try{new A().a();}catch(Exception e){}while(n>0){if(i>1){boolean b=false;for(x=2;x<i;x++){if(i%x==0 && i!=2)b=true;}if(!b){s+=s==""?i:","+i;l=i;n--;}i++;}}System.out.print(s+"\n\n+"+(l-1));}}

Python 2, 218 bytes

n=int(input())
s=[]
i=-1
while n:
 if i>1:
  for x in range(2,i):
   if i%x==0and i!=2:break
  else:s+=[i];n-=1
  i+=1
 if n==0:print",".join(str(y)for y in s)+"\n\nclass A{void a(){P.i="+str(s[-1]+1)+";}}"
 if i<0:i=2

Un-Golfed

Java

public class PPCG {

   public static int i = 2;

   public static void main(String[] args){
       int n = Integer.parseInt(args[0]);
       int last = 2;
       String s = "";
       try{
           new A().a();
       }catch(Exception e){}
       while(n>0){
           if(i>1){
               boolean broken=false;
               for(int x=2;x<i;x++){
                   if(i%x==0 && i!=2){
                       broken=true;
                   }
               }
               if(!broken){
                   s += s==""?i:","+i;
                   last = i;
                   n-=1;
               }
               i+=1;
           }
       }
       System.out.println(s+"\n\n+"+(last-1));
   }
}

Python 2

n=int(input())
s=[]
i=-1
while n:
  if i>1:
    for x in range(2,i):
      if i%x==0 and i!=2:
        break
    else:
      s+=[i]
      n -= 1
    i+=1
  if n==0:
    print ",".join(str(y) for y in s)+"\n\nclass A{public static void a(){PPCG.i="+str(s[-1]-1)+";}}"
  if i<0:
    i = 2

Update

-17 [16-12-13] Misc golfing


Make a Unicorn interpreter Recently, I made a made a typo and I wrote unicorn instead of unicode, I did what any normal person would do and I made an esolang out of it. In this challenge you will be writing a Unicorn interpreter.

Because Unicorn programs are horrible long, you'll have to write a short interpreter to compensate for this.

Example

These are the transpiled result, not the actual interpreted result your program should output

1

alert([x=(p=prompt())/2+Math.sqrt(p*p/4-prompt()),p-x])

"Hello, World!"

Specification

Unicorn is divided into "sections" which are space-separated
Each section represents a character
The number of unicorns () in each section is converted to it's associated character (i.e. 32 unicorns -> chr(32) -> ).
If the section contains goats (), the length of the amount of goats should be doubled, then converted to the associated character
If the section contains any other characters, the program should ignore the character.
Each section (character) should be joined to form a program
This resulting program should be evaluated in the language you have written the program in. (e.g. JavaScript's eval, Python's exec)
Unicorns are unicode U+1F984; goats are unicode U+1F410.
If you choose a compiled language, you may output/save the compiled, compiled unicorn code

 (unicorns) and  (goats) all count as one byte for this challenge.

If your language doesn't support emojis, you may identify unicorns as (u) and goats as (g). You may not support emojis and u,g

If you really want to see the unicodes unicorns, here is a picture of this post

+50 bounty: to the shortest program in (the original) Unicorn while being under 6500 chars. You must use this version, it must run on Firefox, Chrome, or Safari.

Unicorn (ES6), 5934 5278 bytes

Under the custom encoding, this is 5278 bytes (1 byte per char); but with UTF-8, it would 4 bytes per char (though only 1 for a space), or 20869 total.

(too many Unicorns and Goats to reasonably display here)

Instead, here's a pastebin. This Unicorn code transpiles to this JS snippet:

s=>eval(s.replace(/\S+ ?/g,c=>String.fromCharCode(c.length>>1<<c.charCodeAt()%2)))

Now, this isn't the shortest possible version; this is shorter:

s=>eval(s.replace(/\S+ ?/g,c=>String.fromCharCode(c.length>>1<<("">c))))

However, the one unicorn in there would transpile to 56034 goats, thus multiplying the score by roughly 11.

Here's the function I used to transpile to Unicorn:

function g(s){return s.replace(/./g,function(c){i=c.charCodeAt();return(i%2?"".repeat(i):"".repeat(i/2))+" "}).slice(0,-1)}
<textarea id=O cols=100></textarea><button id=P onclick="Q.value=g(O.value);R.innerHTML=(Q.value.length+Q.value.split(' ').length-1)/2">Run</button>
<textarea id=Q rows=10 cols=100>Output appears here.</textarea>

Length: 0

Note: I haven't actually tested the program, as there isn't an online interpreter that I could find (although I suppose I could hook up the .js file to HTML...?)


Convert an Expression to Panfix Notation I was browsing esolangs, and chanced upon this language: https://github.com/catseye/Quylthulg.
One interesting thing about this language, is that it doesn't use prefix, postfix, or infix, it uses all three of them, calling it "panfix" notation.
Here is an example. To represent normal infix 1+2 in panfix, it becomes: +1+2+. Notice how the operator is both before, in between, and after the operands. Another example is (1+2)*3. This becomes *+1+2+*3*. Notice again how * is in all three places with respect to the operands +1+2+ and 3.
The Challenge
As you may have guessed, your task in this challenge is to convert an expression from infix to panfix.
A few clarifications:

You only have to deal with the four basic operations: +-*/
You won't have to deal with the unary versions of those, only binary
You have to deal with parenthesis
Assume the normal precedence rules of */ then +- and left associativity for all of them.
The numbers will be nonnegative integers
You can optionally have a spaces in both the input and output

Test Cases
1+2  ->  +1+2+
1+2+3  ->  ++1+2++3+
(1+2)*3  ->  *+1+2+*3*
10/2*5  ->  */10/2/*5*
(5+3)*((9+18)/4-1)  ->  *+5+3+*-/+9+18+/4/-1-*

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

JavaScript (ES6), 285 282 281 267 251 243 241 238 234 232 231 bytes
~15 bytes thanks to Neil.
f=(I,E=I.match(/\d+|./g),i=0)=>(J=T=>T.map?T.map(J).join``:T)((R=(H,l=(P=_=>(t=E[i++])<")"?R(0):t)(),C,F)=>{for(;(C=P())>")"&&(q=C>"*"&&C<"/")*H-1;)F=q+H?l=[C,l,C,P(),C]:F?l[3]=[C,l[3],C,R(1),C]:l=R(1,l,i--)
i-=C>")"
return l})(0))

In JavaScript this is a bit harder than in Mathematica. This is basically an over-specialized and golfed operator-precedence parser.
Causes stack overflows on invalid inputs.
Demo

f=(I,E=I.match(/\d+|./g),i=0)=>(J=T=>T.map?T.map(J).join``:T)((R=(H,l=(P=_=>(t=E[i++])<")"?R(0):t)(),C,F)=>{for(;(C=P())>")"&&(q=C>"*"&&C<"/")*H-1;)F=q+H?l=[C,l,C,P(),C]:F?l[3]=[C,l[3],C,R(1),C]:l=R(1,l,i--)
i-=C>")"
return l})(0))
<input id="input" value="(5+3)*((9+18)/4-1)"/><button onclick="console.log(f(document.querySelector('#input').value))">Convert</button>

Ungolfed
convert = input => {
  tokens = input.match(/\d+|./g);
  i = 0;
  parse_token = () => (token = tokens[i++]) == "(" ? parse_tree(false) : token;
  parse_tree = (mul_div_mode, left = parse_token()) => {
    while ((oper = parse_token()) != ")" && !((is_plus_minus = oper == "+" || oper == "-") && mul_div_mode)) {
      if (is_plus_minus || mul_div_mode)
        left = [oper, left, oper, parse_token(), oper];
      else if (non_first)
        left[3] = [oper, left[3], oper, parse_tree(true), oper];
      else
        left = parse_tree(true, left, i--);
      non_first = true;
    }
    if (oper != ")")
      i--;
    return left;
  };
  format_tree = tree => tree.map ? tree.map(format_tree).join("") : tree;
  return format_tree(parse_tree(false));
}


Equal, sum or difference! Write shortest possible code that will return true if the two given integer values are equal or their sum or absolute difference is 5.

Example test cases:

4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True
-5 5 => False

The shortest I could come up with in python2 is 56 characters long:

x=input();y=input();print all([x-y,x+y-5,abs(x-y)-5])<1

-9, thanks @ElPedro. It takes input in format x,y:

x,y=input();print all([x-y,x+y-5,abs(x-y)-5])<1

Python 2, 30 bytes

lambda a,b:a in(b,5-b,b-5,b+5)

Try it online!

One byte saved by Arnauld

Three bytes saved by alephalpha


House of cards (version 2) Thanks to FryAmTheEggman for the idea for this second version.
  Version 1 here.

Not-so-simple challenge: given a number of cards, build the biggest house of cards you can with that number of cards, according to the following building order:

                          /\       /\         /\         /\/\
                 --       --       --         ----       ----
/\  →  /\/\  →  /\/\  →  /\/\  →  /\/\/\  →  /\/\/\  →  /\/\/\  →

                /\         /\
     --         --         --
    /\/\       /\/\       /\/\
    ----       ----       ----
→  /\/\/\  →  /\/\/\  →  /\/\/\/\  →  ...

So you start with a single-storey house, then build the adjacent group, then put the bridge card, then build the group in the second floor, then start building groups and bridges from the first floor diagonally to reach the third floor, and so on.

A single card will be represented with a /, a \ or a --. If after using as many cards as possible you have one card left, just output what you have accomplished so far (see example for 3 cards, the result is the same as for 2 cards). The only exception is the case of 1 card, that must output a flat card.

Examples:

Input: 1
Output:

--   <a card lying on the floor>

Input: 2
Output:

/\

Input: 3
Output:

/\

Input: 5
Output:

 --
/\/\

Input: 10
Output:

 /\
 ----
/\/\/\

Input: 20
Output:

  /\
  --
 /\/\/\
 ------
/\/\/\/\

Input: 39
Output:

    --
   /\/\
   ----
  /\/\/\
  ------
 /\/\/\/\
 --------
/\/\/\/\/\

Input: 40
Output:

    /\
    --
   /\/\
   ----
  /\/\/\
  ------
 /\/\/\/\
 --------
/\/\/\/\/\

Input can be numeric or a string, and will always be a positive integer. Output must be exactly as shown, with leading and trailing spaces and newlines allowed.

This is code-golf, so may the shortest program/function for each language win!

Charcoal, 67 bytes

Ｎθ⁼θ¹Ａ²ηＷ¬‹θη«←÷η³↓→/…\/÷η³↙Ａ⁻θηθＡ⁺³ηη»‖ＭＭ÷η³→Ｆθ≡﹪ι³¦¹«↗←\/»²«↑Ｐ²»«

Try it online! Note: The latest version of Charcoal doesn't need the »« for -2 bytes. Explanation:

Ｎθ

Read the input as an integer into θ.

⁼θ¹

Special case: if the input is 1, print a -.

Ａ²ηＷ¬‹θη«

η represents the number of cards needed to build the next layer, initially 2. A while loop repeats as long as there are enough cards for the layer.

←÷η³↓→/…\/÷η³↙

Print the left half of the next layer. (I wanted to print the right half, but I couldn't get it to reflect properly for some reason.) The number of -s is one third of the number of cards in the layer, rounded down. (See also my answer to part 1.)

Ａ⁻θηθＡ⁺³ηη»

Subtract the number of cards from the input number, and add three cards to the number required for the next layer.

‖Ｍ

Mirror the house so far. (This also turns the - into -- for the case of 1 card.)

Ｍ÷η³→

Move the cursor to the right of the house.

Ｆθ

Repeat for each remaining card (if any).

≡﹪ι³¦

If the card modulo 3 is:

¹«↗←\/»

1, then print a pair of cards;

²«↑Ｐ²»

2, then print a horizontal card;

«

Otherwise skip the card (because a pair is needed at this point).


Remove common leading spaces When coding in Python, sometimes you want a multiline string within a function, e.g.

def f():
    s = """\
    Line 1
    Line 2
    Line 3"""

(The backslash is to remove a leading newline)

If you try to actually print out s, however, you'll get

    Line 1
    Line 2
    Line 3

That's not what we want at all! There's too much leading whitespace!

The challenge

Given a multiline string consisting of only alphanumeric characters, spaces and newlines, remove all common spaces from the beginning of each line. Each line is guaranteed to have at least one non-space character, and will have no trailing spaces. The output may not have extraneous whitespace, whether it be before or after the entire output or an individual line (with the exception of a single optional trailing newline).

Input may be via STDIN or function argument, and output may be via STDOUT or function return value. You cannot use any builtins which are designed to dedent multiline strings or perform this exact task, e.g. Python's textwrap.dedent.

This is code-golf, so the solution in the fewest bytes wins. Standard loopholes apply.

Test cases

"a"                                  ->   "a"
"   abc"                             ->   "abc"
"   abc\n def\n  ghi"                ->   "  abc\ndef\n ghi"
"    a\n    b\n    c"                ->   "a\nb\nc"
"    a\n    b\n    c\nd"             ->   "    a\n    b\n    c\nd"
"   a   b\n     c     d\n    e f"    ->   "a   b\n  c     d\n e f"

For example, the last test case is

   a   b
     c     d
    e f

and should look like this after stripping leading spaces:

a   b
  c     d
 e f

CJam, 20 14 bytes
qN/_z{S-}#f>N*

Algorithm:

We first split the input on newlines and take a copy (qN/_)
Then the smallest column with non space character is calculated by transposing the newline separated array and then simply looking for the index of the first non-all-space row (z{S-}#)
Then we simply remove that many characters away from each line (f>)
Finally, we join by newline again (N*)

Code Expansion
qN/               e# Read the entire input and split it on newline
   _z             e# Take a copy and transpose rows with columns.
                  e# Now we would have a bunch of all space rows. These rows are the ones
                  e# we want to remove (in form of columns)
     {  }#        e# Get the index of the first item from the transposed array that returns
                  e# true for this block
      S-          e# From each part, remove spaces. If the part is all-space, it will return
                  e# an empty string, which is false in CJam. We finally will get the index
                  e# of the first non-all-space row (or column)
          f>      e# We take that index and remove that many characters from starting of each
                  e# row of the initial newline separated input
            N*    e# Join the array back using newlines and automatically print the result

Try it online here


Do the circles overlap? Given the coordinates of the centres and the radii of 2 circles, output a truthy value of whether they do or do not overlap.
Input

Input may be taken via STDIN or equivalent, function arguments, but not as a variable. You can take them as a single variable (list, string etc) or as multiple inputs / arguments, in whatever order you want.

The input will be six floats. These floats will be up to 3 decimal places. The coordinates can be positive or negative. The radii will be positive.

Output

Output can be via STDOUT or function return.

The program must have exactly 2 distinct outputs - one for a True value (the circles do overlap) and one for a False output (they don't overlap).

Test cases
(Input is given as list of tuples [(x1, y1, r1), (x2, y2, r2)] for the test cases; you can take input in any format)
True
[(5.86, 3.92, 1.670), (11.8, 2.98, 4.571)]
[(8.26, -2.72, 2.488), (4.59, -2.97, 1.345)]
[(9.32, -7.77, 2.8), (6.21, -8.51, 0.4)]

False
[(4.59, -2.97, 1.345), (11.8, 2.98, 4.571)]
[(9.32, -7.77, 2.8), (4.59, -2.97, 1.345)]
[(5.86, 3.92, 1.670), (6.21, -8.51, 0.4)]

This is Code Golf, shortest answer in bytes wins.

Jelly, 5 bytes

IA<S}

Takes two complex numbers (centers) as first argument, and two real numbers (radii) as second argument.

Try it online!

How it works

IA<S}  Main link.
       Left argument:  [x1 + iy1, x2 + iy2]
       Right argument: [r1, r2]

I      Increments; yield (x2 - x1) + i(y2 - y1).
 A     Absolute value; yield √((x2 - x1)² + (y2 - y1)²).
   S}  Take the sum of the right argument, yielding r1 + r2.
  <    Compare the results.


Help me manage my time I have been recently told to read an entire physics textbook by the new year (true story, unfortunately). I need your help to determine what chapters I should read each day. This is where you come in.
Input

Two dates, in any format. The second date will always be later than the first.
A list of chapter numbers. This comma-separated list can contain single chapters (12) or inclusive ranges (1-3). Ex. 1-3,5,6,10-13.
A list of weekdays (represented by the first two letters of the name: Monday -> Mo) to exclude from the schedule. Ex. Mo,Tu,Fr.

Output
Output will be a newline-separated list of dates and chapter numbers (see format below). The chapters should be evenly distributed over all days in the range, excluding the weekdays provided. If the chapters do not distribute evenly, have the days with lower amounts of chapters at the end of the period of time. Dates in output can be in a different format than input. Days with no chapters can be ommited, or just have no chapters with it.
Example:
Input: 9/17/2015 9/27/2015 1-15 Tu
Output:
9/17/2015: 1 2
9/18/2015: 3 4
9/19/2015: 5 6
9/20/2015: 7 8
9/21/2015: 9 10
9/23/2015: 11
9/24/2015: 12
9/25/2015: 13
9/26/2015: 14
9/27/2015: 15

JavaScript (ES6), 317 310 291 bytes

(a,b,c,d)=>{u=0;c.split`,`.map(m=>{p=m[s]`-`;for(q=n=p[0];n<=(p[1]||q);r=++u)c+=","+n++},c="");c=c.split`,`;x=d.map(p=>"SuMoTuWeThFrSa".search(p)/2);for(g=[];a<b;a.setTime(+a+864e5))x.indexOf(a.getDay())<0&&(t=y=g.push(a+" "));return g.map(w=>w+c.slice(u-r+1,u-(r-=r/y--+.99|0)+1)).join`
`}

Usage

f(new Date("2015-09-17"),new Date("2015-09-27"),"5,1-4,6,10-13,20-27",["Su","Tu"])
=> "Thu Sep 17 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 5,1,2
Fri Sep 18 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 3,4,6
Sat Sep 19 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 10,11
Mon Sep 21 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 12,13
Wed Sep 23 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 20,21
Thu Sep 24 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 22,23
Fri Sep 25 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 24,25
Sat Sep 26 2015 10:00:00 GMT+1000 (AUS Eastern Standard Time) 26,27"

Explanation

(a,b,c,d)=>{

  u=0;                                                 // u = total chapters
  c.split`,`.map(m=>{                                  // c = array of each chapter
    p=m[s]`-`;
    for(q=n=p[0];n<=(p[1]||q);r=++u)                   // get each chapter from ranges
      c+=","+n++
  },c="");
  c=c.split`,`;

  x=d.map(p=>"SuMoTuWeThFrSa".search(p)/2);            // x = days to skip
  for(g=[];a<b;a.setTime(+a+864e5))                    // for each day between a and b
    x.indexOf(a.getDay())<0&&                          // if this day is not skipped
      (t=y=g.push(a+" "));                             // add it to the list of days
                                                       // t = total days
                                                       // y = days remaining

  return g.map(w=>w+
    c.slice(u-r+1,u-(r-=r/y--+.99|0)+1)                // add the chapters of the day
  ).join`
`
}


Print a cube net of the specified size Challenge

Given a size s, print a cube net of that size made of hash symbols (#) and spaces ().

Examples:

1:
  #
# # #
  #
  #

2:
    # #
    # #
# # # # # #
# # # # # #
    # #
    # #
    # #
    # #

3:
      # # #
      # # #
      # # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
      # # #
      # # #
      # # #
      # # #
      # # #
      # # #

The net can actually be any valid cube net that can fold into a cube, for example these:

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

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

Rules

The resulting net must be geometrically valid (foldable into a cube)
Standard loopholes forbidden
Read the rules carefully
This is code-golf, shortest answer wins, but will not be selected

Python 2, 47 bytes

n=input()
for c in 1,4,1:exec"print'# '*c*n;"*n

Try it online!

Prints this net, chosen for being left-justified:

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

The lines have n or 4*n copies of '# '. For each of 1,4,1, we print n times that many copies, done n times for n lines. Having an exec loop inside a for loop seems wasteful, but I didn't see better.

Alternatives I tested:

lambda n:('# '*n*3+'\n')*n+('  '*n+'# '*n+'\n')*3*n

lambda n:('# '*n*3+'\n')*n+(' '*4*n+'# '*n*3+'\n')*n

def f(n):
 for c in[3]*n+[1]*3*n:print('# '*c*n).center(6*n)

def f(n):
 for c in[4]*n+[0]*n:print' '*c*n+'# '*n*3

def f(n):
 for c in[1]*n+[4]*n+[1]*n:print'# '*c*n

def f(n):
 c=1;exec("print'# '*c*n;"*n+"c^=5;"*n)*3

def f(n):
 for i in range(3*n):print'# '*[1,4,1][i/n]*n

def f(n):
 for c in 1,4,1:print('# '*c*n+'\n')*n,

def f(n):
 for c in 1,4,1:exec"print'# '*c*n;"*n

(The def functions can all be one shorter as a program.)


Is this a half-sort? The problem over here introduces an new type of strings: if you split the string into equal halfs and swap the pairs, it produces the same output as sorting the string. We call that a half-sort.

Given a purely ASCII string, check if the string is in a half-sort.

An example of a half-sort string

The string node is a half-sort string, because if you sort by codepoints (note that the codepoints are in decimal, not binary):

n 110
o 111
d 100
e 101

That gets turned into:

d 100
e 101
n 110
o 111

You'll see that the node to deno conversion is exactly moving the right half to the left position.

Specification

For odd-length strings, splitting should make the first half longer.
Sorting a string means sorting the string based on the codepoints of the characters.

Reference program & test cases

Here is the reference program I made for checking my test cases.

node -> True
rum  -> True
aaa  -> True

deno -> False
rim  -> False

J, 20 18 15 14 bytes

-1 thanks to Jonah.

Goes the other way around: sorts the string ('node' -> 'deno'), rotates it back ('deno' -> 'node') and checks if this equals the input. Fits better J trains.

-:<.@-:@#|./:~

Try it online!

How it works

-:<.@-:@#|./:~
           /:~  sort input
  <.@-:@#       length of input, halved and floored
         |.     rotate sorted input by that amount
-:              input equal to that?


R, 59 51 bytes

Outputs the valid numbers as the names of a list of 201's. Why 201? Because ASCII 0 is 48, and 4*48+9 is... yeah. Saved 6 bytes by aliasing ^ to Map and another 2 by using 1:9e3 as range.

"^"=Map;x=sum^utf8ToInt^grep(0,1:9e3,,,T);x[x==201]

Try it online!

Explanation

# Create list of sums of ASCII char values of numbers,
# with the original numbers as the names of the list
x <- Map(sum,
  # Create a list from the strings where each element is the string split
  # into ASCII char values
  Map(utf8ToInt,
      # Find all numbers between 1 and 9e3 that contain a zero
      # Return the matched values as a vector of strings (6th T arg)
      grep(pattern=0,x=1:9000,value=TRUE)
  )
)
# Pick out elements with value 201 (i.e. 4-digits that sum to 9)
# This implicitly only picks out elements with 4 digits, since 3-digit
# sums to 9 won't have this ASCII sum, letting us use the 1:9e3 range
x[x==201]


Tips for restricted source in Powershell Adapted from Tips for restricted source in Python

Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Powershell language.  Now, We already have a place to collect all these tips for code-golf, those for restricted-source remain transmitted by word of mouth or hidden deep within the Powershell documentation.
Let's collaborate on this thread to gather the tips for restricted-source in Powershell!
Please only include 1 tip per answer.

What makes a good tip here?
There are a couple of criteria I think a good tip should have:

It should be (somewhat) non obvious.
Similar to the code-golf tips it should be something that someone who has golfed in python a bit and read the tips page would not immediately think of.  For example "Replace a + b with a+b to avoid using spaces", is obvious to any golfer since it is already a way to make your code shorter and thus not a good tip.

It should not be too specific.
Since there are many different types of source restrictions, answers here should be at least somewhat applicable to multiple source restrictions, or one common source restriction.  For example tips of the form How to X without using character(s) Y are generally useful since banned characters is a common source restriction.  The thing your tip helps to do should also be somewhat general.  For example tips of the form How to create numbers with X restriction are useful since many programs utilize numbers regardless of the challenge.  Tips of the form How to implement Shor's algorithm with X restriction are basically just answers to a challenge you just invented and not very helpful to people solving other challenges.

Alternatives To Single And Double Quotes
{A}  #Normal Curly Braces; This makes a scriptblock, but the ToString prints the contents
‘B‘  # Left Single Quotation Mark              0x2018
’C’  # Right Single Quotation Mark             0x2019
‚D‚  # Single Low-9 Quotation Mark             0x201a
‛E‛  # Single High-Reversed-9 Quotation Mark   0x201b
“F“  # Left Double Quotation Mark              0x201c
”G”  # Right Double Quotation Mark             0x201d
„H„  # Double Low Quotation Mark               0x201E

PS C:\> {A}
A
PS C:\> ‘B‘
B
PS C:\> ’C’
C
PS C:\> ‚D‚
D
PS C:\> ‛E‛
E
PS C:\> “F“
F
PS C:\> ”G”
G
PS C:\> „H„
H

Yes, these work! But What's better? The quotes single quotes and double quotes act as their respective normal quotes, (') and ("), and {} behave like single quotes ('). Thus:
$x="A Variable"
‘$x‘
’$x’
‚$x‚
‛$x‛
“$x“
”$x”
„$x„
{$x}

outputs:
$x           # ‘$x‘
$x           # ’$x’
$x           # ‚$x‚
$x           # ‛$x‛
A Variable   # “$x“
A Variable   # ”$x”
A Variable   # „$x„
$x           # {$x}

As a final useful bit; you don't even have to match the starting and ending quotes, so long as they are of the same type (single/double). Meaning these:
‘$x‛
‚$x'
”$x“
„$x"

Are all perfectly valid, and output like so:
$x           # ‘$x‛
$x           # ‚$x'
A Variable   # ”$x“
A Variable   # „$x"

Alternative Dashes and Uncommon Whitespace
In addition to the additional quotes characters above, PowerShell recognizes some special dashes as equivalent to the hyphen (-):
5–4  # EN DASH          0x2013   [–]
3—2  # EM DASH          0x2014   [—]
1―1  # HORIZONTAL BAR   0x2015   [―]

Powershell also recognizes two other uncommon whitespace characters:
NoBreakSpace   0x00A0
NextLine       0x0085

These were found by @ZaelinGoodman's experiment here
If anything changes, or if you want to see the specifics of how these work, you can find the source code for this handling in the PowerShell Github
I made this community wiki, so this list can be freely updated.


Racketeer Taxi Driver The Scenario

You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go.

To earn more money, you need to drive as much as you can. However, there are two problems:

He always looks around. Therefore, you cannot pass from the same district twice.
The passenger is not so dumb. He knows the shortest way between the airport and the destination. Therefore, while you're driving, you should pass each of those districts.

The Input

Input is an undirected and edge weighted graph. The vertices are the districts and the edges are the ways that connect those districts. The weights of the edges indicate the distance between the districts. You can model the graph any way you want.

The Output

Given the source and destination, among with the shortest path, find the longest path that contains each vertex in the shortest path.

The Example

WHOOPS there are two different edge weights between B and C.
Source: A
Destination: K
Shortest Path: A-D-F-I-K
Solution: A-B-C-D-E-F-G-H-I-J-K

Rules

Your solution should be generic and can be applicable to all kinds of connected graphs.
No cycles are allowed. You can pass through a vertex only once
Brute-force is not allowed. Don't list all the possibilities and pick among them.
The edge weights are always positive.
It is a must to visit all vertices in the shortest path, however, the order is not important.

Duration: 1 week.
Tie breaker: Votes.
The code with the least run-time complexity (in terms of Big-O notation) wins!

Reduction to Traveling Salesman Problem, O(n^2*2^n).

In the above, n is the number of vertices in the graph.

I will give a description of the algorithm for now. Starting with the input graph, carry out the following steps:

Create a new graph with edge weights equal to the negation of the input edge weights. These weights represent the value to the taxi driver of traversing those edges.
Let N be the sum of all of the negative weights in the (new) graph minus 1. Add N to each outgoing edge from a node on the shortest path (as given in the input). This represents the fact that the taxi driver absolutely must cross each vertex in the shortest path.
Now, use dynamic programming to solve the traveling salesman problem on this new graph as follows:
Next, create a memo table, m, with entries that are pairs, (v,S), where v is the final vertex in the (partial) path created so far, and S is a subset of the vertices in the graph. The weight associated with this entry will be the minimum sum of edge weights to reach v after having passed through the vertices in S. Also, maintain a parent pointer.
Initialize the memo table with the entry m[(source,{source}]=0, p[(source,{source}]=None.
Fill in the memo table, using the recursion that m[(v,S)] = min(m[(u,S-{v})]+w[(u,v)] for u in S), where w is the the edge weight dictionary. Create parent pointers accordingly.
Using the completed memo table, find the minimum value of m[(destination,S)], for all subsets S of the input vertices.
Trace the parent pointers from this minimum value backwards until we reach the source node. The resulting path is the solution.

I don't feel like coding that all up, but I believe it is a correct solution. It runs in O(n^2*2^n) time because there are n*2^n entries in the memo table, and each is generated by taking a minimum over no more than n possibilities. All the other work takes far less than that amount of time.

This solves the problem because the traveling salesman path must go through all of the vertices on the shortest path, because skipping one of those vertices results in an increase in the traveling salesman cost of N, which cannot be offset by the negative edge weights in the graph, since N was chosen to be more negative than all of them combined.


Find the results of the poll with the Borda count method In a preference ballot there are many ways to decide who won. One of which is the Borda count method, where we give everyone point based on their places on the ballot.

For example, in these results:

  10  5  7  2
_____________
1  a  d  a  c
2  b  a  d  b
3  c  c  b  a
4  d  b  c  d

The results are

1: a : 87
2: d : 60
3: b : 55
4: c : 45

Because

4*10 is 40
5*3 is 15
7*4 is 28
2*2 is 4
40 + 15 + 28 + 4 is 87

Or is words:
We give first place 4 points , second 3, third 2, etc.

So a is in first place 17 times, so they get 68 points then they get 15 points for being in second 5 times and 4 points for being in third 2 times for a total of 87 points.

Because this process is a pain, I need you write a program that finds the results for me, but since I have limited space on my PC, your program will have to be as small as possible.

Your Challenge

Write a program or function the takes an input in this format

Number of Ballots : placings, Number of Ballots : placings, Etc...

and will output the results in this format:

1: a: 90
2: b: 80
Etc...

Rules:

This is Code Golf, so the shortest answer that does the task wins

Standard Loopholes Apply

Example:

Input:
3: A B C, 2: C B A, 1: C A B

Output:
1: A: 13
2: C: 12
3: B: 11

This is my first challenge, so please give me all the criticism you so desire, I won't take it offensively.

Perl 5, 131 bytes

for(split/, /,$ARGV[0]){($n,@v)=split/:? /;$s{$v[@v-$_]}+=$n*$_ for 1..@v}$,=": ";map{say++$i,"$_ ",$s{$_}}sort{$s{$b}<=>$s{$a}}@v

Use as perl -E'the string above' 'the input string'


(simple) variable and scope simulator Based on this closed question on stack overflow, what is the shortest way to stimulate scope for variables in an input.  For simplicity, print is replaced with >.
copying critical information from the linked source:

[ and ] start and end a new scope.

Within scopes any changes to a variable outside of that scope is not permanent and is reverted when the scope has left, but the outer values are used to determine if a variable is undefined and its starting value.

Input will always start with [ and will end with matching ]
If its not defined then value should be 0
All input that is not a variable is a number with no decimal points. as in 10 or 582
> a means print the contents of a
a 10 assigns 10 to a
a b assigns the contents of b to a
Variables should be considered strings: one 1 is valid syntax
It is not required for the input to contain the print command >

Note on scoring:
You may chose how to input and output the "code", but it should be explained in the answer.

I answered this on the linked page in java, but I did not go for shortest code.
Comment any suggestions or questions, so I can improve my future posts.  Shortest code by character wins.  Good luck.

Python 2, 165

def f(v):
 while 1:
    s=raw_input().split()
    if'['in s:f(dict(v))
    elif']'in s:break
    elif'>'in s:print v.get(s[1],0)
    else:v[s[0]]=v.get(s[1],s[1])
raw_input()
f({})

Character count assumes tabs are used for the second level of indentation.


Four Squares Together Lagrange's four square theorem tells us any natural number can be represented as the sum of four square numbers. Your task is to write a program that does this.

Input: A natural number (below 1 billion)

Output: Four numbers whose squares sum to that number (order doesn't matter)

Note: You don't have to do a brute force search! Details here and here. If there  is a function that trivializes this problem (I will determine), it's not allowed. Automated prime functions and square root are allowed. If there is more than one representation any one is fine. If you chose to do brute force, it must run within reasonable time (3 minutes)

sample input

123456789

sample output (either is fine)

10601 3328 2 0
10601 3328 2

Mathematica  61 66 51
Three methods are shown.  Only the first approach meets the time requirement.

1-FindInstance (51 char)
This returns a single solution the equation.
FindInstance[a^2 + b^2 + c^2 + d^2 == #, {a, b, c, d}, Integers] &

Examples and timings
FindInstance[a^2 + b^2 + c^2 + d^2 == 123456789, {a, b, c, d}, Integers] // AbsoluteTiming

{0.003584, {{a -> 2600, b -> 378, c -> 10468, d -> 2641}}}

FindInstance[a^2 + b^2 + c^2 + d^2 == #, {a, b, c, d}, Integers] &[805306368]

{0.004437, {{a -> 16384, b -> 16384, c -> 16384, d -> 0}}}

2-IntegerPartitions
This works also, but is too slow to meet the speed requirement.
f@n_ := Sqrt@IntegerPartitions[n, {4}, Range[0, Floor@Sqrt@n]^2, 1][[1]]

Range[0, Floor@Sqrt@n]^2 is the set of all squares less than the square root of n (the largest possible square in the partition).
{4} requires the integer partitions of n consist of 4 elements from the above-mentioned set of squares.
1, within the function IntegerPartitions returns the first solution.
[[1]] removes the outer braces; the solution was returned as a set of one element.

f[123456]

{348, 44, 20, 4}

3-PowerRepresentations
PowerRepresentations returns all of the solutions to the 4 squares problem.  It can also solve for sums of other powers.
PowersRepresentations returns, in under 5 seconds,  the 181 ways to express 123456789 as the sum of 4 squares:
n= 123456;
PowersRepresentations[n, 4, 2] //AbsoluteTiming

However, it is far too slow for other sums.


Check the jumbled words This is an easy one.

Anagrams are words which have the same characters but in different order. All you have to do is to figure out if two strings are anagram or not.

Rules:

Take two strings as a function argument, command-line argument or from standard input.
Write a function or program which returns truthy value if strings are anagram, falsy value otherwise
Anagrams may have different number of spaces () characters in them.
Anagrams are case insensitive matches.
Anagrams can only have printable ASCII characters for this code-golf.

For example(taken from the Wikipedia page itself): Doctor Who is an anagram of Torchwood . Note missing space and lack of capital D and W in Torchwood

This is code-golf so minimum bytes code win!

Happy golfing.

Java, 146 131 144 134 131 128

Not a very exciting answer. Returns true for anagrams, false for others. Actually works now. Cheapass abuse of generics in class declaration.

boolean b(T a,T b){return c(a).equals(c(b));}T c(T a){char[]c=a.toLowerCase().toCharArray();sort(c);return(T)valueOf(c).trim();}

Ungolfed:

boolean b(T a,T b) {
    return c(a).equals(c(b));
}

T c(T a) {
    char[] c = a.toLowerCase().toCharArray();
    sort(c);
    return (T) valueOf(c).trim();
}


Floating points: Make Gaussian elimination go wrong You know that some decimal numbers can't be expressed as IEEE 754 floating points. You also know that arithmetic with floating points can give results that seem to be wrong:

System.out.print(4.0-3.1); (source)
0.2 + 0.04 = 0.24000000000000002 (source)

While one wrong number with an error that is this small might not be significant, more of those error might be.

Task

Find a system of linear equations in form of a matrix A \in R^{n \times n} and b \in R^n, such that the result vector is as wrong as possible. Reference is the script below, executed with Python 2.7.

Points

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def pprint(A):
    n = len(A)
    for i in range(0, n):
        line = ""
        for j in range(0, n+1):
            line += str(A[i][j]) + "\t"
            if j == n-1:
                line +=  "| "
        print(line)
    print("")

def gauss(A):
    n = len(A)

    for i in range(0,n):
        # Search for maximum in this column
        maxEl = abs(A[i][i])
        maxRow = i
        for k in range(i+1,n):
            if abs(A[k][i]) > maxEl:
                maxEl = A[k][i]
                maxRow = k

        # Swap maximum row with current row (column by column)
        for k in range(i,n+1):
            tmp = A[maxRow][k]
            A[maxRow][k] = A[i][k]
            A[i][k] = tmp

        # Make all rows below this one 0 in current column
        for k in range(i+1,n):
            c = -A[k][i]/A[i][i]
            for j in range(i,n+1):
                if i==j:
                    A[k][j] = 0
                else:
                    A[k][j] += c * A[i][j]

    # Solve equation Ax=b for an upper triangular matrix A
    x=[0 for i in range(n)]
    for i in range(n-1,-1,-1):
        x[i] = A[i][n]/A[i][i]
        for k in range(i-1,-1,-1):
            A[k][n] -= A[k][i] * x[i]
    return x;

if __name__ == "__main__":
    from fractions import Fraction
    datatype = float # Fraction
    n = input()

    A = [[0 for j in range(n+1)] for i in range(n)]

    # Read input data
    for i in range(0,n):
        line = map(datatype, raw_input().split(" "))
        for j, el in enumerate(line):
            A[i][j] = el
    raw_input()

    line = raw_input().split(" ")
    lastLine = map(datatype, line)
    for i in range(0,n):
        A[i][n] = lastLine[i]

    # Print input
    pprint(A)

    # Calculate solution
    x = gauss(A)

    # Print result
    line = "Result:\t"
    for i in range(0,n):
       line += str(x[i]) + "\t"
    print(line)

Let x be the correct answer and x' the answer that the script above gives.

Your points are (||x-x'||^2)/n, where || . || is the euclidean distance.

Your solution gets 0 points if it gives nan as result.

Example

bad.in:

2
1 4
2 3.1

1 1

The first line is n, the next n lines describe the matrix A and the last line describes b.

$ python gauss.py < bad.in
1.0 4.0 | 1.0
2.0 3.1 | 1.0

Result: 0.183673469388  0.204081632653

The answer should be:

Result: 9/49    10/49

So the score would be:

((0.183673469388-9/49)^2+(0.204081632653-10/49)^2)/2
= 3.186172428154... × 10^-26

The last step was calculated with Wolfram|Alpha.

Taking this as a question about numerical inaccuracy in calculations rather than in conversion from numbers which can't be exactly represented in 64 bits to 64-bit representations, we're interested in nearly singular matrices.

Let's take the simplest possible case:

[a b] [x] = [p]
[c d] [y]   [q]

has solution

[x] = [(dp - bq) / (ad - bc)]
[y]   [(aq - cp) / (ad - bc)]

so that if ad - bc is very small we find that errors in dp - bq and aq - cp are magnified.

We also find that scaling p and q scales the absolute error linearly, which points out a massive flaw in the scoring system of this question.

How can we get a nearly singular matrix? In order of ill-conditionedness:

a=1+e, b=c=d=1 gives ad - bc = e. This allows us to get a determinant of 1 ulp (which for IEEE 64-bit is on the order of 10^-16).
a=1+e, d=1-e, b=c=1 gives ad - bc = -e^2. This allows us to get a determinant on the order of 10^-32.

2
1.000000000000001 1
1 0.999999999999999

1 1

gives output:

1.0 1.0 | 1.0
1.0 1.0 | 1.0

Result: -9.0    10.0

rather than x = 100000000000000, y = -100000000000000

Similarly,

2
1.000000000000001 1
1 0.999999999999999

1E307 1E307

gives

1.0 1.0 | 1e+307
1.0 1.0 | 1e+307

Result: -9.1120238836e+307  1.01120238836e+308

rather than x = 1E321, y = -1E321. This seems to roundly beat Johannes' solution (it gives a score on the order of 10^642 vs 10^588), and moreover it would continue to generate about the same score even if the input numbers were tweaked to be exactly representable in IEEE 64-bit, whereas his would then score 0.
a=d=e, bc=0 gives ad - bc = e^2 but this time we can choose e to be a very small number rather than 1 ULP. In principle this allows us to get a determinant on the order of 10^-600 (i.e. underflowing IEEE 64-bit). However, so far I haven't managed to get a decent score without an infinity in the answer, and I gather from your chat with Johannes that even though the question doesn't rule out infinite scores, in practice you do.


How hard can I crush my array? Lets define the process of crushing an array of numbers.  In a crush we read the array left to right.  If at a point we encounter two of the same element in a row we remove the first one and double the second one.  For example here is the process of crushing the following array

[5,2,2,3]
 ^
[5,2,2,3]
   ^
[5,2,2,3]
     ^
[5,4,3]
   ^
[5,4,3]
     ^

The same element can be collapsed multiple times, for example [1,1,2] becomes [4] when crushed.

We will call an array uncrushable when the process of crushing that array does not change it.  For example [1,2,3] is still [1,2,3] after being crushed.

Your task is to take an array and determine the number of crushes required to make it uncrushable.  You need only support integers on the range of 0 to 232-1

This is code-golf so answers will be scored in bytes with less bytes being better.

Test Cases

[1] -> 0
[1,1] -> 1
[2,1,1] -> 2
[4,2,1,1] -> 3
[2,2,2,1,1] -> 3
[0,0,0,0] -> 1
[4,0,0,0,4] -> 1
[4,0,0,0,0,4] -> 1
[] -> 0

x86 assembly (64-bit), 66 65 bytes

31 c0 57 59 56 51 56 5f 4d 31 c0 48 83 c6 08 48
83 e9 01 76 1b fc f2 48 a7 75 15 48 d1 67 f8 51
56 57 f3 48 a5 5f 5e 59 fd 48 a7 49 ff c0 eb e5
59 5e 4c 29 c1 48 ff c2 4d 85 c0 75 c7 48 ff c8
c3

String instructions were helpful. Having to correct for off-by-one errors in a 64-bit environment was not.

Fully commentated source code:

.globl crush
crush:
/* return value */
xor %eax, %eax
/* save our length in rcx */
push %rdi
pop %rcx
pass:
/* save the start of the string and the length */
push %rsi
push %rcx
/* this is the loop */
/* first copy source to dest */
push %rsi
pop %rdi
/* and zero a variable to record the number of squashes we make this pass */
xor %r8, %r8
/* increment source, and decrement ecx */
add $8,%rsi
sub $1,%rcx
/* if ecx is zero or -1, we're done (we can't depend on the code to take care of this
automatically since dec will leave the zero flag set and cmpsq won't change it) */
jbe endpass
compare:
/* make sure we're going forward */
cld
/* compare our two values until we find two that are the same */
repne cmpsq
/* if we reach here, we either found the end of the string, or
we found two values that are the same. check the zero flag to
find out which */
jne endpass
/* okay, so we found two values that are the same. what we need
to do is double the previous value of the destination, and then
shift everything leftwards once */
shlq $1, -8(%rdi)
/* easiest way to shift leftwards is rep movsq, especially since
our ecx is already right. we just need to save it and the rsi/rdi */
push %rcx
push %rsi
push %rdi
rep movsq
pop %rdi
pop %rsi
pop %rcx
/* problem: edi and esi are now one farther than they should be,
since we can squash this dest with a different source. consequently
we need to put them back where they were. */
std
cmpsq
/* we don't need to put ecx back since the list is now one shorter
than it was. */
/* finally, mark that we made a squash */
inc %r8
/* okay, once we've reached this point, we should have:
 edi and esi: next two values to compare
 ecx: number of comparisons left
so we just jump back to our comparison operation */
jmp compare
endpass:
/* we reached the end of the string. retrieve our old ecx and esi */
pop %rcx
pop %rsi
/* rsi is accurate, but rcx is not. we need to subtract the number of squashes
that we made this pass. */
sub %r8, %rcx
/* record that we performed a pass */
inc %rax
/* if we did make any squashes, we need to perform another pass */
test %r8, %r8
jnz pass
/* we reached the end; we've made as many passes as we can.
decrement our pass counter since we counted one too many */
dec %rax
/* and finally return it */
ret

I may try doing this in 32-bit, if only for fun, since those REX prefixes really killed me.

Edit: shaved one byte off by replacing lodsq with add, %rdx with %rax, and collapsing two cld's into one.


Generate a Davenport-Schinzel Sequence Background

A Davenport-Schinzel sequence has two positive integer parameters d and n. We will denote the set of all Davenport-Schinzel sequences for given parameters by DS(d,n).

Consider all sequences of the natural numbers 1 to n, inclusive, which satisfy:

No two consecutive numbers in the sequence are identical.
There is no subsequence (not necessarily consecutive) of length greater than d, which  alternates between two different numbers.

Let L denote the maximum length of such a sequence (given d and n). Then, DS(d,n) is the set of all such sequences with length L.

Some examples might help. Let d = 4, n = 3. The longest possible sequences with these constraints have L = 8. So the following is a member of DS(4,3):

[1, 2, 1, 3, 1, 3, 2, 3]

There are no consecutive identical numbers and there are alternating subsequences of length 4, but not longer ones:

 1  2  1           2
 1  2        1     2
 1        3  1  3
 1        3  1        3
    2     3        2  3
    2           3  2  3
       1  3  1  3
       1  3  1        3

The following examples are not in DS(4,3):

[1, 2, 2, 3, 1, 3, 2, 3]  # Two consecutive 2's.
[1, 2, 1, 3, 1, 3, 2, 1]  # Contains alternating subsequences of length 5.
[1, 2, 1, 3, 1, 3, 2]     # Longer valid sequences for d = 4, n = 3 exist.

For further information see MathWorld and OEIS and the references they list.

The Challenge

Given two positive integers, n and d, generate any Davenport-Schinzel sequence in DS(d,n). Note that these are not generally unique, so output any single valid result.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument, and returning the result from the function or printing it to STDOUT (or closest alternative).

You may use any convenient, unambiguous string or list format for output.

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

Sequence Lengths

Since the sequences are not unique, there is not much use for individual examples in this challenge. However, the two general validity problems are fairly easy to check for any output, so the main question is just whether the sequence has the right length (or there's a longer valid sequence). Therefore, here is a list of the known1 L for given d and n:

 \
 d\n 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
   \-----------------------------------------------------------
 1 | 1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
 2 | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
 3 | 1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39
 4 | 1  4  8 12 17 22 27 32 37 42 47 53 58 64 69 75 81 86 92 98
 5 | 1  5 10 16 22 29 ...
 6 | 1  6 14 23 34 ...
 7 | 1  7 16 28 41 ...
 8 | 1  8 20 35 53 ...
 9 | 1  9 22 40 61 ...
10 | 1 10 26 47 73 ...

You must not hardcode any information from this table into your submission.

1 This table is from 1994, so there may have been more progress since then, but I doubt that any submission will be able to handle even the larger entries in this table in a reasonable amount of time.

Python 2: 172

from itertools import*
d,n=input();S=[[1]]
for s in S:
 for v in range(1,n+1):
  if(v!=s[-1])*all(w[2:]!=w[:-2]for w in combinations(s+[v],d+1)):S.append(s+[v])
print S[-1]

Input is simply in the format 4, 3.

I iteratively create all sequences, which start with 1 and satisfy the two properties, and store them in S. Since I create them in sorted order (sorted by length [and by values]), the last entry has to be a Davenport-Schinzel-sequence. Uses the nice fact, that you can iterate over a list while appending to it.


Death By Shock Probe: That's a lot of dice In the webcomic Darths & Droids, Pete, who plays R2-D2 in the fictional roleplaying campaign around which the comic is based, once claims (warning: potential spoilers in the linked comic) that, with the Lost Orb of Phanastacoria rigged up to his shock probe, he can now dish out a whopping 1048576d4 of damage. (The GM has neither confirmed nor denied this.) Since it should be reasonably obvious that almost no one will actually have the patience to roll that many dice, write a computer program to do it for him, outputting the total value rolled in some reasonable format. Entries will be ranked by program size (shortest program, by byte count, wins), both overall and per-language, with run time breaking ties. Answer may be either a full program or a function definition.

Scores Per-Language

Pyth

Maltysen - 8 bytes*

Jakube - 10 bytes

APL

Alex A - 10 bytes

CJam

Optimizer - 11 bytes

J

ɐɔıʇǝɥʇuʎs - 12 bytes **

Clip10

Ypnypn - 12 bytes **

K

JohnE - 13 bytes

Ti-84 BASIC

SuperJedi224 - 17 bytes*

R

MickyT - 23 bytes

OCTAVE/MATLAB

Oebele - 24 bytes

PARI/GP

Charles - 25 bytes **

Wolfram/Mathematica

LegionMammal978 - 27 bytes

Perl

Nutki - 29 bytes

AsciiThenAnsii - 34 bytes

Ruby

Haegin - 32 bytes **

ConfusedMr_C - 51 bytes **

Commodore Basic

Mark - 37 bytes **

PHP

Ismael Miguel - 38 bytes

VBA

Sean Cheshire - 40 bytes **

PowerShell

Nacht - 41 bytes **

Javascript

Ralph Marshall - 41 bytes

edc65 - 54 bytes (Requires ES6 functionality not available in all browsers.)

Lua

cryptych - 51 bytes

Java

RobAu - 52 bytes **

Geobits - 65 bytes

C

Functino - 57 bytes

Python

CarpetPython - 58 bytes

Postgre/SQL

Andrew - 59 bytes **

Swift

Skrundz - 69 bytes

GoatInTheMachine - 81 bytes

Haskell

Zeta - 73 bytes **

ActionScript

Brian - 75 bytes **

><>

ConfusedMr_C - 76 bytes

GO

Kristoffer Sall-Storgaard - 78 bytes

C#

Brandon - 91 bytes **

Andrew - 105 bytes

Ewan - 148 bytes

Scratch

SuperJedi224 - 102 bytes

C++

Michelfrancis Bustillos - 154 bytes

Polyglots

Ismael Miguel (Javascript/ActionScript2) - 67 bytes

Top 10 Overall

Maltysen
Alex A
Jakube
Optimizer
ɐɔıʇǝɥʇuʎs/Ypnypn (order uncertain)
JohnE
SuperJedi224
MickyT
Oebele

Warning- entries marked with a * are VERY SLOW.

Programmed marked ** I have not yet been able to properly test

Pyth - 9 8 bytes
Uses obvious simple method of summation of randint. Took me minute to realize 1048576 was 2^20, now I feel really stupid. Thanks to @Jakube for saving me a byte by pointing out 2^20 = 4^10.
smhO4^4T

The runtime is horrible, it has yet to finish on my computer, so there is no point running it online so here is the 2^10 one: Try it online here.
s        Summation
 m       Map
  h      Incr (accounts for 0-indexed randint)
   O4    Randint 4
  ^4T    Four raised to ten


Not so triangular numbers Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on:
$$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$
(This is A118175: Binary representation of n-th iteration of the Rule 220 elementary cellular automaton starting with a single black cell.)
Given \$n>0\$, your task is to output \$a(n)\$, defined as the number of \$1\$'s among the \$T(n)\$ first terms of \$S\$, where \$T(n)\$ is the \$n\$-th triangular number.
The first few terms are:
$$1,2,3,6,9,11,15,21,24,28,36,42,46,55,65,70,78,91,99,105,...$$
One way to think of it is to count the number of \$1\$'s up to the \$n\$-th row of a triangle filled with the values of \$S\$:
1 (1)
01 (2)
100 (3)
1110 (6)
00111 (9)
100001 (11)
1111000 (15)
00111111 (21)
000000111 (24)
1111000000 (28)
01111111100 (36)
...

Rules
You may either:

take \$n\$ as input and return the \$n\$-th term, 1-indexed
take \$n\$ as input and return the \$n\$-th term, 0-indexed
take \$n\$ as input and return the \$n\$ first terms
take no input and print the sequence forever

This is a code-golf challenge.

Jelly, 9 bytes
ḤR>)FŒHṪS

A monadic Link accepting \$n\$ which yields \$a(n)\$.
Try it online! Or see the test-suite.
How?
We can think of \$S\$ as being built in blocks of length \$2i\$ where each block is a string of \$i\$ ones followed by \$i\$ zeros: 10 1100 111000 ....
If we stop at \$i=x\$ and call the result \$S_x\$ we know that \$S_x\$ necessarily contains an equal number of ones and zeros.
We also know that the length of \$S_x\$ will be  \$\sum_{i=1}^{x}2i = 2 \sum_{i=1}^{x}i = 2T(x)\$.
So the value of \$a(x)\$ is the count of ones in the first half of \$S_x\$.
An alternative way to get this same result is to subtract the count of the zeros in the first half of \$S_x\$ from \$T(x)\$, and since \$S_x\$ contains an equal number of ones and zeros this must also be the count of zeros in the second half of \$S_x\$. Therefore we can form the complement of \$S_x\$ and count the ones in its second half:
ḤR>)FŒHṪS - Link: integer, n
   )      - for each (i in [1..n]): e.g. i=3
Ḥ         -   double                       6
 R        -   range                        [1,2,3,4,5,6]
  >       -   greater than i?              [0,0,0,1,1,1]
    F     - flatten -> [0,1,0,0,1,1,0,0,0,1,1,1,...]
     ŒH   - split into two equal length parts
       Ṫ  - tail
        S - sum