Ducttape the Ducttape Your boss has found out that quite a bunch of his employees (including you) like to steal code from others. He ordered you to write him a program that he can use to find people who steal code from others.

Task:

Write a program/function that detects if somebody copied (part of) his code from somewhere else.

The program will get all the existing programs and the program that it should test from two separate inputs.
Edit: Since there are no answers so far, you may use regular expressions!

Output

The program should then output all the stolen pieces of code, separated by either a space or a newline. (It may have a space or a newline at the end.)
A piece of code is considered to be stolen/copied if it consists of 10 or more successive bytes. (Sorry, Java fans!)
You have to output as much as possible, but if there are overlapping ones, you may ignore one of them or output both of them.

Twist:

As mentioned before, you also love duct tape coding. That means, everything in your code will be copy-pasted from a stack exchange site!
You can copy whatever you want (not limited to code in code blocks) and as much as you want. (But at least 10 bytes)
(Same rule as above about what is considered to be stolen/copied.)
(Please do note that any answers that were posted after this question may not be used.)
Please provide links to where you got your code from.

Examples:

Input:
x = document.getElementById("ninja'd"); (The first input)
y = document.getElementById("id"); (The second input)

Output:

 = document.getElementById("

Input:
foo (The first input)
foo+bar (The second input)

Output:
Nothing.

Input:
public static void main(String[] args) (The first input)
public  static  void  main(String[] args) (The second input)

Output:

 main(String[] args)

Input:
for(var i=0; i<x.length; i++){} (The first input)
for(var i=0; i<oops.length; i++){break;} (The second input)

Output:

for(var i=0; i<
.length; i++){

or

for(var i=0; i< .length; i++){

Python 2, 224 bytes
from difflib import SequenceMatcher
def similar(a, b):
    return SequenceMatcher(None, a, b).get_matching_blocks()
a=raw_input()
b=raw_input()
for start, _, size in similar(a, b):
 if(size > 9):
  print a[start:start+size]

Copied from this answer:
from difflib import SequenceMatcher
def similar(a, b):
    return SequenceMatcher(None, a, b).

get_matching_blocks() is copied from this answer
a=raw_input()
b=raw_input()

is copied from this question
for start, _, size in is copied from this answer and the second occurence of similar(a, b) is copied from the same place as the first.
if(size > 9) is copied from this question.
:
    print

is copied from this question
a[start: is copied from this answer.
and finally, start+size] is copied from this questipn
Finally answered after one and a half years ...


Generate a number by using a given list of numbers and arithmetic operators You are given a list of numbers L = [17, 5, 9, 17, 59, 14], a bag of operators O = {+:7, -:3, *:5, /:1} and a number N = 569.

Task

Output an equation that uses all numbers in L on the left-hand side and only the number N on the right-hand side. If this is not possible, output False.  Example solution:

59*(17-5)-9*17+14 = 569

Limitations and Clarification

You may not concatenate numbers ([13,37] may not be used as 1337)
Only natural numbers and zero will appear in L.
The order in L doesn't matter.
You must use all numbers in L.
Only the operators +,-,*,/ will appear in O.
O can have more operators than you need, but at least |L|-1 operators
You may use each operator any number of times up to the value in O.
All four operations in O are the standard mathematical operations; in particular, / is normal division with exact fractions.

Points

The less points, the better
Every character of your code gives you one point

You have to provide an un-golfed version that is easy to read.

Background

A similar question was asked on Stack Overflow. I thought it might be an interesting code-golf challenge.

Computational Complexity

As Peter Taylor said in the comments, you can solve subset sum with this:

You have an instance of subset sum (hence a set S of integers and a number x)
L := S + [0, ..., 0] (|S| times a zero), N := x, O := {+:|S|-1, *: |S| - 1, /:0, -: 0}
Now solve this instance of my problem
The solution for subset sum is the numbers of S that don't get multiplied with zero.

If you find an Algorithm that is better than O(2^n), you prove that P=NP. As P vs NP is a Millennium Prize Problem and hence worth 1,000,000 US-Dollar, it is very unlikely that somebody finds a solution for this. So I removed this part of the ranking.

Test cases

The following are not the only valid answers, other solutions exist, and are permitted:

([17,5,9,17,59,14], {+:7, -:3, *:5, /:1}, 569)
=> 59 * (17-5)- 9 * 17 + 14 = 569
([2,2], {'+':3, '-':3, '*':3, '/':3}, 1)
=> 2/2 = 1
([2,3,5,7,10,0,0,0,0,0,0,0], {'+':20, '-':20, '*':20, '/':20}, 16)
=> 5+10-2*3+7+0+0+0+0+0+0+0 = 16
([2,3,5,7,10,0,0,0,0,0,0,0], {'+':20, '-':20, '*':20, '/':20}, 15)
=> 5+10+0*(2+3+7)+0+0+0+0+0+0 = 15

Python 2.7 / 478 chars

L=[17,5,9,17,59,14]
O={'+':7,'-':3,'*':5,'/':1}
N=569
P=eval("{'+l+y,'-l-y,'*l*y,'/l/y}".replace('l',"':lambda x,y:x"))
def S(R,T):
 if len(T)>1:
  c,d=y=T.pop();a,b=x=T.pop()
  for o in O:
   if O[o]>0 and(o!='/'or y[0]):
    T+=[(P[o](a, c),'('+b+o+d+')')];O[o]-=1
    if S(R,T):return 1
    O[o]+=1;T.pop()
  T+=[x,y]
 elif not R:
  v,r=T[0]
  if v==N:print r
  return v==N
 for x in R[:]:
  R.remove(x);T+=[x]
  if S(R,T):return 1
  T.pop();R+=[x]
S([(x,`x`)for x in L],[])

The main idea is to use postfix form of an expression to search. For example, 2*(3+4) in postfix form will be 234+*. So the problem become finding a partly permutation of L+O that evalates to N.

The following version is the ungolfed version. The stack stk looks like [(5, '5'), (2, '5-3', (10, ((4+2)+(2*(4/2))))].

L = [17, 5, 9, 17, 59, 14]
O = {'+':7, '-':3, '*':5, '/':1}
N = 569

P = {'+':lambda x,y:x+y,
     '-':lambda x,y:x-y,
     '*':lambda x,y:x*y,
     '/':lambda x,y:x/y}

def postfix_search(rest, stk):
    if len(stk) >= 2:
        y = (v2, r2) = stk.pop()
        x = (v1, r1) = stk.pop()
        for opr in O:
            if O[opr] > 0 and not (opr == '/' and v2 == 0):
                stk += [(P[opr](v1, v2), '('+r1+opr+r2+')')]
                O[opr] -= 1
                if postfix_search(rest, stk): return 1
                O[opr] += 1
                stk.pop()
        stk += [x, y]
    elif not rest:
        v, r = stk[0]
        if v == N: print(r)
        return v == N
    for x in list(rest):
        rest.remove(x)
        stk += [x]
        if postfix_search(rest, stk):
            return True
        stk.pop()
        rest += [x]
postfix_search(list(zip(L, map(str, L))), [])


Golf a string twister How strings are twisted

The twisting algorithm is very simple. Each column is shifted down by its index (col 0 moves down 0, col 1 moves 1, ...). The column shift wraps to the top. It works like this:

aaaa
bbbb
cccc

Becomes:

a
ba
cba
----
 cba
  cb
   c

With everything under the line wrapping to the top. Real example:

Original:
\\\\\\\\\\\\
............
............
............

Twisted:
\...\...\...
.\...\...\..
..\...\...\.
...\...\...\

Input

Input is either an array of strings, or a multi-line string. All lines have the same length.

Output

The twisted string, multi-line output to std-out (or closest alternative).

Examples:

(> denotes input, trailing space is important)

>Hello, world!
>I am another
>string to be
>twisted!

Hwrmoe oo br!
Ieii ,dttr e
s lsna !ohl
ttaltgnw  ed

>\\\\\\\\\\\\
>............
>............
>............

\...\...\...
.\...\...\..
..\...\...\.
...\...\...\

>abcdefg
>.......

a.c.e.g
.b.d.f.

>abcdefghij
>..........
>..........

a..d..g..j
.b..e..h..
..c..f..i.

>\\\\.....././
>...../.......
>........././.
>..../.^\\....

\.........../
.\....^..../.
..\../.\../..
...\/...\/...

>cdeab
>deabc
>eabcd
>abcde

cbbbb
ddccc
eeedd
aaaae

>aeimquy37
>bfjnrvz48
>cgkosw159
>dhlptx260

ahknqx147
beloru258
cfipsvy69
dgjmtwz30

>abcdefghi
>jklmnopqr
>stuvwxyz1
>234567890

a3ume7yqi
jb4vnf8zr
skc5wog91
2tld6xph0

Pyth, 11

jC.>R~hZC.z

Try it here

jC.>R~hZC.z    ##  implicit: .z = list of input split by lines
        C.z    ##  transpose .z to get columns
  .>R~hZ       ##  shift each column by it's index
               ##  equivalent to .e.>bk
jC             ##  transpose back and join by newlines


Counting hypercube Tetris pieces Consider the Tetris pieces, but made out of some number of (hyper)cubes instead of four squares, where two blocks are considered the same if one is a rotation, reflection, or translation of another. The goal of this challenge is to take two positive integer input values, n and k, and count the number of \$n\$-celled polyominoes consisting of \$k\$-dimensional hypercubes.

This is a code-golf challenge, so the shortest code wins.

Example

For example, when \$n = 4\$ and \$k = 3\$ there are seven different shapes:

Notice that the first piece could be made using \$1\$-cubes (line segments) instead of cubes, the next four could be made using \$2\$-cubes (squares), and only the last two require \$3\$-cubes (ordinary cubes). Thus \$p(4,1) = 1\$, \$p(4,2) = 5\$, and \$p(4,3) = 7\$.

Test Data

 n | k | p(n,k)
---+---+--------
 1 | 0 | 1
 2 | 0 | 0
 2 | 1 | 1
 3 | 2 | 2
 4 | 1 | 1
 4 | 2 | 5
 4 | 3 | 7
 4 | 4 | 7
 4 | 5 | 7
 5 | 4 | 26
 6 | 3 | 112
 7 | 3 | 607
 8 | 2 | 369

Python 2, 338 335 330

Try it online!

from itertools import*
n,k=input()
O=[([0]*k,)]
R=range(k)
exec"O={min(tuple(sorted(zip(*[[x-min(p)for x in p]for p in f])))for q in permutations(zip(*(o+(r,))))for f in product(*[[p,[-x for x in p]]for p in q]))for o in O for s in o for r in[tuple(s[i]+x*(i==j)for i in R)for j in R for x in-1,1]if not r in o};"*~-n
print len(O)

Reads n,k as a list from stdin (e.g. [4,2]) and prints the number of polyominoes.

Starts with a single polyomino with a single cell at the origin.

n-1 times, replaces the polyominoes with all possible polyominoes created by adding an adjacent cell to an existing polyomino, and canonizing that polyomino by finding the minimum of all possible rotations of it.

-6 bytes thanks to math junkie, -2 bytes thanks to Surculose Sputum.


Boil eggs using hourglasses These are the classical puzzles:

You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef.
But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes?
(taken from here)

Let's write a program which will produce a solution for any such puzzle.
Input: 3 numbers a, b, x
Here a and b are the durations of the hourglasses, and x is the required time for boiling the eggs. Let's assume the following:

0 < a < b (without loss of generality)
x is not divisible by a or b (to make the problem non-trivial)
x > 0
x is divisible by gcd(a, b) (to ensure a solution exists)

Output: a string which contains commands, such that after executing the commands, we get our eggs boiled for exactly x minutes.
The possible commands are:

'A' - turn hourglass A
'B' - turn hourglass B
'a' - wait until hourglass A runs out
'b' - wait until hourglass B runs out
's' - start boiling the eggs

You may use any single non-whitespace character to encode each command.
You may also use longer strings to encode commands, but then the string of commands must contain separators between each pair of commands.
You may also add a special command "stop boiling the eggs" if it makes implementation easier (naturally, you cannot restart the boiling - the "stop" command is for the case your algorithm cannot restrain itself from printing additional commands after it prints the solution).
You don't need to optimize your string of commands: it may use an inefficient algorithm or contain unnecessary commands, as long as the result is correct.
Test cases:
3, 5, 1 => ABaAbBsa
4, 7, 9 => ABaAbBsaAaAa
7, 11, 15 => ABaAsbBb
69, 105, 42 => ABaAbBaAaAbBaAbBaAaAbBaAsb
60, 256, 2020 => ABaAaAaAaAbBaAaAaAaAbBaAsaAaAaAbBaAaAaAaAaAbBaAaAaAaAbBaAaAaAaAbBaAaAaAaAbBaAaAaAaAaAbBaAaAaAaAbBb

Note: these solutions were generated by a script, so they contain completely unnecessary commands.

Python 2, 157 154 108 103 bytes

a,b,c=input()
t=c
while t%a:t+=b
print"".join("aA"[i%a*2:]+"bB"[i%b*2:]+"s"[i^t-c:]for i in range(t+1))

Try it online! or Check all test cases!
Input: from STDIN, 3 positive integers a,b,c representing the 2 hourglass times and the time needed for the egg to boil.
Output: print to STDOUT a string of commands following the specification.
Big idea
There exists positive integers \$x,y\$ such that:
$$ax-by=c$$
(Proof in the last section)
Thus, if we continuously flip both hourglasses, the time between when the second hourglass finishes \$y\$ flips and when the first hourglass finishes \$x\$ flips is exactly equal to the time needed to boil the egg.
Code overview
t keeps track of \$by+c\$. We increment \$y\$ until \$\frac{by+c}{a}\$ is an integer.
When a valid value of t is found, t will be the time needed to flip the first hourglass \$x\$ times, and also the time when the egg should be done. t-c is the time when the second hourglass finishes \$y\$ flips, and also the time when the egg should start to be boiled.
The command string is created by increasing the time i, and insert "aA" or "bB" every time \$a\$ or \$b\$ divides the current time. "s" is inserted when the time is t-c.
Proof of the existence of \$x\$ and \$y\$.
Since \$c\$ is a multiple of \$gcd(a,b)\$, Bézout's identity claims that there exists integers \$k_1, k_2\$ (which can be negative) such that:
$$k_1a-k_2b=c$$
Since \$ba - ab = 0\$, we can increase \$k_1\$ and \$k_2\$ by \$b\$ and \$a\$ without changing the result:
$$(k_1+b)a-(k_2+a)b=c$$
Thus, we can keep increasing \$k_1\$ and \$k_2\$ until they are both positive.


Moving modest minimum Inspired by a question over at Stack Overflow. The title here is entirely my fault.

The challenge

Given a list of positive integers containing at least two entries, replace each number by the minimum of all entries excluding itself.

Test cases

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

Rules

The algorithm should theoretically work for any input size (greater than one) and values (positive integers). It's accepted if the program is limited by time, memory or data types and so only works for numbers up to a given value, or for input size up to a given value.

Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.

Input can be taken by any reasonable means; and with any format. Same for output. Input and output formats may be different.

Shortest code in bytes wins.

Python 2, 41 bytes

lambda l:[sorted(l)[x==min(l)]for x in l]

Try it online!

For each element x we check whether x==min(l). If not, this is False, which is treated as 0 when used as a list index into sorted(l), giving the smallest element. Otherwise, it's True aka 1, giving the second-smallest element, since that element itself is smallest and should be ignored.


Self Referential Puzzle - medium 2 The following puzzle was asked in puzzling SE. This puzzle is quite hard to solve by hand because every answer depends on another answer. So, for example, a solution with all answers being A does not work because then the question 7 would contradict question 8, for example.

One of the answers there at puzzling SE suggested to write a program to test all possible answers and show one of them (if it exists). So, I'm bringing this to the experts :)

The puzzle consists in finding an array of ten characters (each one of them being either A, B, C, D or E) that satisfies all the following questions (where each character in the array is an "answer" and its index is a "question") without contradiction:

The first question whose answer is D is the question

  A.  8
  B.  7
  C.  6
  D.  5
  E.  4

Identical answers have questions

  A.  3 and 4
  B.  4 and 5
  C.  5 and 6
  D.  6 and 7
  E.  7 and 8

The number of questions with the answer E is

  A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions with the answer A is

  A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions with the answer A equals the number of questions with the answer

  A.  A
  B.  B
  C.  C
  D.  D
  E.  none of the above

The last question whose answer is B is the question

  A.  5
  B.  6
  C.  7
  D.  8
  E.  9

Alphabetically, the answer to this question and the answer to the following question are

  A.  4 apart
  B.  3 apart
  C.  2 apart
  D.  1 apart
  E.  the same

The answer to this question is the same as the answer to the question

  A.  1
  B.  2
  C.  3
  D.  4
  E.  5

The number of questions whose answers are consonants

  A.  3
  B.  4
  C.  5
  D.  6
  E.  7

The answer to this question is

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

The objective of this chalenge is to write the shortest program that can generate all the possible answers and check how many of them (if any) satisfy what every one of the previous questions are asking (the output of the program would be the list of the answers that satisfy all the questions without contradiction).

The original test can be found here (although it is irrelevant for this chalenge).

Pyth, 104 bytes
f!s[nhd-8xd3@.+d+3@d1nh@d2/d4nh@d3/d0!&/3@d4!-/d0/d@d4!-10x_d1@d5n@d6a4@.+d6n@d7@d@d7!+3@d8@ds/LdS3)^U5T

It... uh... takes a while to run. Try it online... if the server doesn't time out or run out of memory.
Explanation coming SoonTM.  Prints all the valid solutions as a 0-based list (ten elements long in which A is represented by 0, B by 1, and so on).
This is a naive solution that can probably be golfed a lot.  Just wanted to get something out there.


Unique Sudoku Finder Challenge:

Given a Sudoku board on standard input, find the minimum number of numbers added to make the board unique.

Specifics/Rules:

The input is formatted as follows (all whitespace is significant)

516|827|943
278|394|615
349|615|872
---+---+---
98 |4 2|156
465|189|237
12 |5 6|489
---+---+---
892|743|561
634|951|728
751|268|394

The output is formatted with one number per line, formatted like (x,y):z - x and y start from one at the top left and increase down and right; z is the number to be added.

In this case these would all be valid outputs: (3,4):3, (3,4):7, (5,4):3, (5,4):7, (3,6):3, (3,6):7, (5,6):3, and (5,6):7, as any one of these would allow the board to be solved.

If a unique/solved Sudoku board is entered, the program should not print anything, even a newline.
The program should run in less than an hour for any board (I suggest testing using a fully blank board, or a board with one random number on it...).

Scoring:

Take your total (golfed) code size in characters, including all whitespace...

Bonuses:

1/2 code size:  If the program prints a single exclamation point and stops upon having a board with no solutions entered.

1/2 code size:  If the program prints two exclamation points and stops upon having a board with an internal contradiction entered (two numbers the same on the same row/column/square).

Brachylog, 245 bytes /2 = 122.5

@n:1a:"-"x:7fF:3a$\:3a@3:4a,Fc~bCh[0:0:0]gO,Co~c[V:O:T]h:F:6f:10ao:ba(h:11a;!);"!!"w!
h"-".|:"|"x:2f.
e(~m["0123456789":.]`;0<.<=9)
:ha#d.
:@3az:ca:5a.
:3a.
hs.:=a,?t:9ac:=fl1
:Im:8f:[[I]]z:ca.
:Jm:J.
:ha.
lg:?c.
b:+a[X:Y],?h:Y:Xr:"(~d,~d):~d
"w

(Note that you have to use the version of the language as of this commit. This code would need some slight changes for it to work properly in the following versions of Brachylog)

This prints "!!" if the given board has internal contradictions (This takes a few seconds in that case however on TIO, so be patient).

I'm not sure I understand the first bonus correctly so I'm not addressing it.

This is obviously non-competing since the language is much more recent than the challenge, however since there are no other answers I'm not sure this matters a whole lot…

Explanation

Main predicate:

@n                Split the input on line breaks
:1a:"-"x          Transform into a list of lists, each sublist contains a line's values
:7fF              Transform so that cells are [Value:X:Y]
:3a               All values on lines must be different
$\:3a             All values on columns must be different (by transposition)
@3:4a,            All 3*3 block values must be different
Fc~bCh[0:0:0]gO,  Append a fake cell [0:0:0]
Co~c[V:O:T]       Sort the board, the blank cells V will be those before O ([0:0:0])
h:F:6f            Find all subsets of blank cells with specific values for which
                      the board has only one solution
:10ao             Sort the subsets by lengths
:ba               Discard the lengths
(
  h:11a             Print the first subset = an answer
;                 Or (board is already fully determined)
  !                 Terminate
)
;                 Or (Some values don't respect the constraints)
"!!"w!            Print "!!" and terminate

Predicate 1: Remove all "|" on lines, transform the ---+---+--- into - to remove them after

h"-".    If the first char is "-", then Output is "-"
|        Or
:"|"x    Remove all occurences of "|" from the input
:2f.     Output is the result of all outputs of predicate 2 on the filtered string

Predicate 2: Convert one char to an integer, or if blank to a variable between 1 and 9.

e                      Take a char of the input string
(
  ~m["0123456789":.]     Output is the index of the char in "0123456789"
  `                      Discard the choice point caused by the ;
;                      Or
  0<.<=9                 Output is an integer between 1 and 9
)

Predicate 3: Impose that all values of the input list of cells must be distinct

:ha    Retrieve the head of each cell (i.e. the value) in the input
#d.    Apply a constraint of distinctness to those values

Predicate 4: Apply the distinctness constraint to values in 3*3 blocks

:@3a            Split 3 lines of the board in 3 parts
    z           Zip them together
     :ca:5a.    Concatenate each element of the zip, apply predicate 5 to that

Predicate 5:

:3a.    Apply predicate 3 to each element of the input

Predicate 6: Assign values satisfying the constraints to a subset of the blank cells, then with those values there is only one solution to the board.

hs.       Output is a subset of the blank cells
:=a,      Assign values to those cells
?t:9ac    Concatenate the values of all cells of the board
:=f       Find all solved boards
l1        There is only 1 such solved board

Predicate 7: Transforms the board such that each cell is now [V:X:Y] instead of only V (the value).

:Im       Take the Ith line of the board
:8f       Transform all elements of the line using predicate 8
:[[I]]z   Zip the result with [I]
:ca.      Concatenate each element of the zip

Predicate 8: Transforms a line such that each cell is now [V:X].

:Jm    Take the Jth element of the line
:J.    Output is [That element:J]

Predicate 9: Retrieve the values of cells

:ha.   Take the head of each element of the input

Predicate 10: Append the length of a subset at the beginning of it

lg     Put the length of the input in a list
:?c.   Concatenate it with the input

Predicate 11: Print one cell

b:+a[X:Y],        Increment coordinates by 1 to get X and Y
?h:Y:Xr:          Build the list [X:Y:Value]
"(~d,~d):~d\n"w   Format that list as "('X','Y'):'Value'\n" to STDOUT


Find a set of 10 numbers such that all pairs have a different GCF The set of ten numbers below:

223092870
17237308840522
1075474925835771
12574206406402195
79458974087499419
265057843710517649
466012798920390527
926434345611831877
1390237791335182649
2336970054109245767

has the property that no two pairs of numbers have the same greatest common factor. (In this case, the greatest common factor of each pair of numbers is actually a distinct prime.)

Your task is to find the set of 10 positive integers with the smallest sum that satisfy this property.

For reference, the sum of the above ten numbers is 5 477 838 726 638 839 246 (≈5.48×1018).


What's my IP Address? I'm surprised this hasn't come up in a challenge yet.

Output the IP address of the machine you're running on. You are required to output both the local and external IP addresses.

Local IP address, ie along the default format of 192.168.x.x

Public IP address can be verified by using google https://www.google.co.uk/search?source=hp&q=whats+my+ip

Output can be in any format. IPv4 or IPv6 or any mix of each is allowed, however they must be the only output. Code can be a full program or a function.

code-golf rules apply so shortest code wins.

Standard Loopholes are forbidden.

EDIT:
As per @Peter Taylor's comment, in the case where multiple of either type of address are present, you can choose to either output the first one, or as many as you can access. So long as at least one local and one public are present.

Bash + curl + iproute2, 54 50 49 48 33 bytes

ip r g 1|awk '$0=$7'
curl eth0.me

Thanks @DomHastings for golfing off 1 byte!

Thanks @Sisyphus for coming up with a shorter URL!

Thanks @zeppelin for golfing off 9 bytes!


Approximate the perfect fifth Starting at 1-TET, give equal temperaments that have better and better approximation of the perfect fifth(just ratio 3/2). (OEIS sequence A060528)

The formal description of the sequence, copied from the OEIS:

  A list of equal temperaments (equal divisions of the octave) whose nearest scale steps are closer and closer approximations to the ratios of two tones of musical harmony: the perfect 4th, 4/3 and its complement the perfect 5th, 3/2.

Note that by symmetry, the perfect fourth doesn't matter.

Let's say we know that 3 is in the sequence. The frequencies in 3-TET are:

2^0, 2^⅓, 2^⅔

Where 2^⅔ is the closest logarithmic approximation of 3/2.

Is 4 in the sequence? The frequencies in 4-TET are:

2^0, 2^¼, 2^½, 2^¾

Where 2^½ is the closest approximation of 3/2. This is not better than 2^⅔, so 4 is not in the sequence.

By similar method, we confirm that 5 is in the sequence, and so on.

When given an integer n as input, the output must be the first N numbers of the sequence in order. For example, when n = 7, the output should be:

1 2 3 5 7 12 29

Sequence description by xnor

The irrational constant \$ \log_2(3) \approx 1.5849625007211563\dots\$ can be approximated by a sequence of rational fractions

$$ \frac{2}{1}, \frac{3}{2}, \frac{5}{3}, \frac{8}{5}, \frac{11}{7}, \frac{19}{12}, \frac{46}{29}, \dots$$

A fraction is included in the sequence if it's the new closest one by absolute distance \$ \left| \frac{p}{q} - \log_2(3)\ \right|\$, that is, closer than any  other fraction with a smaller or equal denominator.

Your goal is to output the first \$n\$ denominators in order. These are sequence A060528 (table). The numerators (not required) are given by A254351 (table)

Rules:

Do not import the sequence A060528 directly.
The format doesn't matter as long as the numbers are distinguishable. In the example above, the output can also be:

[1,2,3,5,7,12,29]
As this is a code-golf, the shortest code in bytes wins.

05AB1E, 19 18 bytes

µ¯ßNLN/3.²<αßDˆ›D–

Try it online!

µ                      # repeat until counter == input
 ¯                     #  push the global array
  ß                    #  get the minimum (let's call it M)
   N                   #  1-based iteration count
    L                  #  range 1..N
     N/                #  divide each by N
       3.²             #  log2(3)
          <            #  -1
           α           #  absolute difference with each element of the range
            ß          #  get the minimum
             Dˆ        #  add a copy to the global array
               ›       #  is M strictly greater than this new minimum?
                D–     #  if true, print N
                       #  implicit: if true, add 1 to the counter


Are there More Hard Objects or Soft Objects Tangentially inspired by the opening to the What-If book.

The input is a rectangle of spaces as a string, list of string, etc., with objects made of #'s inside:

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

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

The objects will always be non-intersecting, non-touching, rectangles. A soft object is defined as an object that isn't filled up with #'s in the middle and is only a border, a hard object is one that is filled up. An object with width or height <=2 is considered hard. All objects are either hard or soft.

If there are more hard objects in the input, output "Hard", if more soft, output "Soft", if they are equal, output "Equal".

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

Test Cases

These cases aren't full inputs, but rather what each object should be characterized as. The actual input will be like the ascii-art at the top of the question.

Hard

#

####

##
##

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

Soft

###
# #
###

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

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

Actual Test Cases

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

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

Hard

###
###
###

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

Equal

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

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

Soft

MATL, 105 104 58 50 49 bytes

Thanks to @Neil for a suggestion that allowed me to remove 46 bytes!

2\TTYaEq4:HeqgEqZ+K/Zot0>+ss'Soft Hard Equal'Ybw)

Input is a 2D char array, with rows separated by ;. The example in the challenge is

['########          ';'#      #          ';'########          ';'                  ';'   ###        ####';'   ###        ####';'   ###            ']

Here's another example:

['###                ';'###                ';'###                ';'                   ';'###################';'#                 #';'#                 #';'#                 #';'###################']

This corresponds to

###
###
###

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

and thus should give 'Equal'.

As a third example, corresponding to 'Soft',

['   ######    ';'   #    #    ';'   ######    ';'          ###';'   ##  #  # #';'          ###';'             ';'             ';' ########    ';' #      #    ';' ########    ']

that is,

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

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

Try it online!

Explanation

This uses 2D convolution to detect shapes. The input is converted to a 2D array with 1 indicating # and -1 for space; and is padded with a frame of -1 values. This assures that shapes at the edge of the original field are also detected.

A soft object is detected by the mask

 1   1
 1  -1

which corresponds to the object's upper-left corner with one empty interior point. Note that the convolution inverts the mask, so it is defined as [-1 1; 1 1] in the code. The number S of positions in which the convolution equals 4 is the total number of soft objects.

An object (soft or hard) is detected by the mask

-1  -1
-1   1

which correponds to the object's upper-left corner together with some empty exterior points. This mask is the negated version of the previous one, so the previous convolution result can be reused. Specifically, the number T of positions in which that result equals -4 is the total number of objects.

The number H of hard objects is T−S. The output string is determined by the sign of S−H = 2*S−T.

2\                 % Input. Modulo 2: '#' gives 1, ' ' gives 0
TTYa               % Add a frame of zeros
Eq                 % Convert 0 to -1
4:HeqgEq           % Generate mask [-1 1; 1 1], for soft objects
Z+                 % 2D convolution, preserving size
K/Zo               % Divide by 4 and round towards 0. Gives 1 or -1 for 4 or -4
t0>                % Duplicate. 1 for positive entries (soft objects), 0 otherwise
+                  % Add. This corresponds to the factor 2 that multiplies number S
ss                 % Sum of 2D array. Gives 2*S-T
'Soft Hard Equal'  % Push this string
Yb                 % Split by spaces. Gives cell array
w)                 % Swap. Apply (modular) index to select one string


your Uncle help Drunk needs Drunk Uncle (sorry M.E. and AUS for region lock) is a fictional character from Saturday Night Live. He often confuses words for others that sound like them. For this challenge you need to convert normal speech into drunkspeak.

Algorithm

Translating to drunkspeak requires swapping the order of words in the text. Swapping is based on the drunkenness similarity of two words. Drunkenness similarity is defined as the number of letters that two words have occuring at the same indices. However, two identical words have a drunkenness similarity of -1. For example, tree and friend have a drunkenness similarity of 2, because they both have an 'r' at index 1, and an 'e' at index 3.

All you have to do is find the two words in the text with the highest drunkenness similarity, then swap them. Once you swap two terms, they do not move any more. Then you look at the remaining swappable terms and swap the two that have the highest drunkenness similarity. You keep doing this until you can't swap any more. Then you output (or return, for a function) the updated text.

Specifics

For simplicity, input is a list of words consisting of characters in [A-Za-z]
Every input contains at least one word
Letter matching is case-insensitive: A matches with a (Note: Due to this rule Dog and dog are identical, and thus have a D.S. of -1)
If multiple pairs have the highest drunkenness similarity:

Of the words, that can maximize drunkenness similarity, pick the one with the lowest index in the list
Pair that word with the lowest-index word that maximizes drunkenness similarity

Examples

Drunk Uncle needs your help (title)

S1: Drunk<=>your (DS: 1) your Uncle needs Drunk help
S2: needs<=>help (DS: 1) your Uncle help Drunk needs
Output: your Uncle help Drunk needs

I love fidget spinners (boring example)

S1: I<=>love (DS: 0) love I fidget spinners
S2: fidget<=>spinners (DS: 0) love I spinners fidget

dog eat dog ear

S1: eat<=>ear (DS: 2) dog ear dog eat
S2: dog<=>dog (DS: -1) dog ear dog eat (this step just formality)

Let me tell you a story

S1: Let<=>me (DS: 1) me Let tell you a story
S2: tell<=>you (DS: 0) me Let you tell a story
S3: a<=>story (DS: 0) me Let you tell story a

Too many money and purple people

S1: purple<=>people (DS: 4) Too many money and people purple
S2: many<=>money (DS: 2) Too money many and people purple
S3: Too<=>and (DS: 0) and money many Too people purple

Let me know if there are more examples you want me to cover.


caN it be acrOnymised? The Typical Way to Make an Acronym Out of a Phrase Is to Take the First Letter of Each Word: TTWMAOPITFLEW. howeveR, sometimEs, you can make an acronym of random leTters In a seNtence such As like this: RETINA. The only condition is that the letters have to be in the correct order. For instance:

LORD can be acronymised from Hello World: heLlO woRlD
LEOD cannot be acronymised from Hello World, as no ls are before e

Your task is to take two strings as input as to determine if one can be acronymised into the other.

The first input, the phrase, will only contain letters (A-Z or a-z) and spaces, and the second input, the acronym, will only contain letters (A-Z or a-z). The acronym will always be shorter, or of equal size, to the phrase, and both the acronym and the phrase will be, at minimum, 1 letter long. You may choose which case (upper or lower) you want the inputs to be.

You may choose any two values to represent true and false, as long as those values are consistent.

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

Examples

HELLO WORLD, LORD -> true
CODE GOLF AND CODING CHALLENGES, DANGLE -> true
SANDBOX FOR PROPOSED CHALLENGES, CODE -> false
HELLO WORLD, LLLD -> true
HELLO WORLD, LLDL -> false
NEW YORK POLICE DEPARTMENT, NOODLE -> false
MASSACHUSETTS INSTITUTE OF TECHNOLOGY, MUTTON -> true
BOB, BOB -> true
PRESIDENT OF THE UNITED STATES, I -> true


I really wanted a rhombus, but all I got was this stupid rectangle Given only a straightedge and compass, inscribe a rhombus inside the given rectangle, sharing two opposite points.

Input
Input is the dimensions of the rectangle. In the example shown, that would be 125, 50. You can take input in whatever way is most convenient (as two integers, list, strings, etc).
The larger dimension will be 100 minimum, while the smaller will be 25 minimum. Both cap at 200.
Output
Output will be an image (displayed on screen or saved as a file) showing

The input rectangle
All "working" lines/circles
The inscribed rhombus

in distinct colors. In the image above, The rectangle is black, working lines blue, and rhombus orange. The lines should be drawn in the order shown in the list (eg rhombus overwrites working lines and rectangle).
The output image needs to be large enough to contain everything. For example, the circles shown cannot go out of bounds.
Method
The method used in the example image above is:

Draw a circle using the lower left corner as center, and the upper right as a point on the perimeter, giving a radius equal to the rectangle's diagonal.
Do the same, but swapping center and perimeter points.
Draw a line between the intersections of the two circles, giving a perpendicular bisector to the rectangle's diagonal.
Use the intersections of the new line and rectangle to draw the rhombus.

This works because the interior diagonals of a rhombus always perpendicularly bisect each other. I'm not including a full proof of this here, though.
This is not the only method to get your rhombus, and you can use another, given that you explain what you are doing. I believe it's probably the easiest, though.
Rules
You can only draw circles and lines (or rather, line segments). A circle is defined with a center point and perimeter point. A line is defined by any two points. Lines do not have to be any specified length, but they must at least cover the defining points (note the example image: the line goes a bit past the circle intersections, but not to the edge). For circles, the radius from center to the chosen perimeter point is considered a working line, and must be shown.
To rasterize the lines, you can use any recognized algorithm (e.g. Bresenham's), or rely on whatever builtins your language might have. If your output is vector-based, please ensure that it is show at a resolution at least as large as the input rectangle in pixels. Also, you'll be drawing on a plain canvas, so please suppress any grid marks or extraneous output.
No cheating! You can only determine placement of points/lines/circles using what you've established so far. If you can't explain how to use your working lines/circles to show it's a rhombus, you're doing it wrong.
You can use whichever pair of opposite points you want, and the rectangle does not need to be drawn axis-aligned, so long as the output is correct.
Input will always be a non-square rectangle, so don't worry about special-casing that.
Lastly, this is standard code golf, so lowest size in bytes wins.

HTML + JavaScript (ES6), 34 + 353 = 387 bytes

Input should be given in the format [125,50].

[w,h]=eval(prompt(c=C.getContext("2d"))).sort();d=q=>(c.strokeStyle=q,b);l=(x,y=Z)=>x?c.lineTo(x,y)||l:c.stroke();b=(x,y=H,r)=>(c.beginPath(),r?c.arc(x,y,Math.sqrt(r),0,2*Math.PI):c.moveTo(x,y),l);b(Z=300,Z)(W=Z+w)(W,H=Z+h)(Z,H)(Z)();d`red`(Z,H,s=w*w+h*h)();b(W,Z,s)();b(Z)(W)();b(Z+w/2-h,Z+h/2-w)(H+w/2,W+h/2)();d`lime`(Z)(W-s/2/w)(W)(Z+s/2/w,H)(Z,H)()
<canvas id=C width=800 height=800>

Just a lot of math and drawing... The rectangle is drawn sideways if the height is greater than the width, which I believe is allowed.


Get a random n digit number with distinct digits and first not a 0 I read this question and thought it would make a nice challenge.
Task
Give an input 0<n<10 generate a random number with

exactly n digits
the first not a 0

so f(n)>10**(n-1)-1

distinct digits

Winning criteria
This is code-golf so shortest code wins.
Random
I mean evenly distributed random. So from the view of the program each possible number has the same chance. If the language you're writing in has a weird random number generator, it's okay to use that one.
Example
The list of values to randomly select from for n=2 is:
[10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]

Python 2, 77 bytes

from random import*
r=range(10)
while[1]>r:shuffle(r)
print`r`[1:input()*3:3]

Try it online!

Shuffles the list of 10 digits until it doesn't start with 0, then makes a number with the first n digits listed.


Swap the two given indices Given an array of positive integers and two distinct valid indices, return the array with the two elements corresponding to the two indices swapped.

You may choose to use 0-indexing or 1-indexing, but the testcases below will be 0-indexed.

array        m n output
[1,2,3,4]    0 1 [2,1,3,4]
[5,8,9]      0 2 [9,8,5]
[11,13,15,3] 1 2 [11,15,13,3]
[11,13,15,3] 2 1 [11,15,13,3]
[11,15,15,3] 2 1 [11,15,15,3]

This is code-golf. Shortest answer in bytes wins. Standard loopholes apply.

C/C++, 53 50 39 bytes

f(a,m,n)int*a;{a[m]^=a[n]^=a[m]^=a[n];}

Try it online

Saved 11 bytes thanks to @Dennis


Inherit from class with inaccessible abstract members and all constructors inaccessible The class System.Globalization.EastAsianLunisolarCalendar of the mscorlib.dll assembly is non-nested public but its sole instance constructor is internal and it also declares some internal abstract members.

The problem: Write a C# class in your own assembly (code must compile with usual C# compiler) where a class derives from (inherits) the System.Globalization.EastAsianLunisolarCalendar of the BCL.

Your class must have System.Globalization.EastAsianLunisolarCalendar as its direct base class. It is not allowed to have a third class in "between" your class and that class in the inheritance hierarchy.

(Advanced stuff like dynamic assemblies or runtime IL emission is not needed.)

(Stated as a C# problem. Discussions on whether the equivalent problem can be solved in other object-oriented languages too, will also be considered interesting.)

It is not required that the class you write is usable in any way ;-)

Well, I have either to call a base constructor (which is not accessible) or an other constructor in the same class.

public abstract class Class1 : System.Globalization.EastAsianLunisolarCalendar {
    private Class1() : this(1) {}
    private Class1(int i) : this() {}
}

So let's call the constructors recursive. Not very useful, but who cares?


Convert Japanese Mario titles to American titles The naming conventions for games in the Super Mario series is very strange, and don't match up between regions.
| Japanese Name       | American Name                      |
|---------------------|------------------------------------|
| Super Mario Bros.   | Super Mario Bros.                  |
| Super Mario Bros. 2 | Super Mario Bros.: The Lost Levels |
| Super Mario USA     | Super Mario Bros. 2                |
| Super Mario Bros. 3 | Super Mario Bros. 3                |
| Super Mario Bros. 4 | Super Mario World                  |

What a mess!

Challenge:
Given a string consisting of the Japanese name of a Super Mario game, output the corresponding American name. You may input the Japanese string through any reasonable method, and output the American string (with an optional newline) through any reasonable method.
You must use the exact strings shown above. Standard loopholes are forbidden!
The shortest code (in bytes) is the winner.

sed, 52

1 byte saved thanks to @MikeScott

Straightforward replacement:
s/ 2/: The Lost Levels/
s/USA/Bros. 2/
s/B.*4/World/

Try it online.


Find largest sum of subsequence Given a sequence of integers find the largest sum of a subsequence (integers on consecutive positions) of the sequence. The subsequence can be empty (in which case the sum is 0).

Input is read from standard input, one integer per line. The largest sum must be written to standard output.

I wrote a small generator for you:

#include <stdio.h>
#include <assert.h>

/* From http://en.wikipedia.org/wiki/Random_number_generation */
unsigned m_w;
unsigned m_z;

unsigned get_random()
{
  m_z = 36969 * (m_z & 65535) + (m_z >> 16);
  m_w = 18000 * (m_w & 65535) + (m_w >> 16);
  return (m_z << 16) + m_w;  /* 32-bit result */
}

int main(int argc, char **argv)
{
  int i;

  assert(argc == 3);
  m_w = atoi(argv[1]);
  m_z = atoi(argv[2]);

  i = 10;
  while (i--);
    get_random();

  i = atoi(argv[2]);
  while (i--)
    printf("%d\n", (int) get_random() << 8 >> 22);

  return 0;
}

Examples:

$ printf "1\n2\n-1\n4\n" | ./sum
6
$ printf "0\n-2\n-3\n" | ./sum
0

$ ./a.out 1 1 | ./sum
387
$ ./a.out 1 10 | ./sum
571
$ ./a.out 1 100 | ./sum
5867
$ ./a.out 1 1000 | ./sum
7531
$ ./a.out 1 10000 | ./sum
27268
$ ./a.out 1 100000 | ./sum
101332
$ ./a.out 1 1000000 | ./sum
187480
$ ./a.out 1 10000000 | ./sum
666307

./sum is my solution
./a.out is the generator

Your solution must run in reasonable time for all tests above (mine runs in 1.2s on the last test case).

Shortest code wins.

Edit: Please provide an example run on one of the tests above.

Python, 91 84 64 chars

s=m=0
try:
 while 1:s=max(s+input(),0);m=max(m,s)
except:print m

Takes about 14 12 72 seconds on the last test case.  Edit: using algorithm Paul R found. Edit: nixed the import, using input().


unRSA: solve the private key Given positive integer n and e, knowing that e<n and that n is the product of two different odd primes(but the primes are not directly given to you), find such a positive integer d smaller than n that, for each integer m, (me)d ≡ m (mod n).

Your program should handle n up to 24096 in 1TB space, but not necessary reasonable time. You can assume such a d exist.

Sample Input: n=53*61=3233, e=17

Sample output: d=413

Note that your program will not be given the prime factor of n.

Shortest code in bytes win.

Python 3, 77 bytes

def f(n,e):r=range(n);all(any(m-pow(m,e*d,n)for m in r)or print(d)for d in r)

Try it online!

Direct translation of the requirement. any(...) becomes false when the smallest correct d is found, and print(d) returns None, making all(...) stop running.

76 bytes, if unlimited memory is allowed

def f(n,e):r=range(n);all(any(m**(e*d)%n-m for m in r)or print(d)for d in r)

Try it online!


Converting a number from Zeckendorf Representation to Decimal About Zeckendorf Representations/Base Fibonacci Numbers

This is a number system which uses Fibonacci numbers as its base. The numbers consist of 0 and 1's and each 1 means that the number contains the corresponding Fibonacci number, and 0 means it does not.

For example, let's convert all natural numbers <=10 to base Fibonacci.

1 will become 1, because it is the sum of 1, which is a Fibonacci number,
2 will become 10, because it is the sum of 2, which is a Fibonacci number, and it does not need 1, because we already achieved the desired sum.
3 will become 100, because it is the sum of 3, which is a Fibonacci number and it does not need 2 or 1 because we already achieved the desired sum.
4 will become 101, because it is the sum of [3,1], both of which are Fibonacci numbers.
5 will become 1000, because it is the sum of 5, which is a Fibonacci number, and we do not need any of the other numbers.
6 will become 1001, because it is the sum of the Fibonacci numbers 5 and 1.
7 will become 1010, because it is the sum of the Fibonacci numbers 5 and 2.
8 will become 10000, because it is a Fibonacci number.
9 will become 10001, because it is the sum of the Fibonacci numbers 8 and 1.
10 will become 10010, because it is the sum of the Fibonacci numbers 8 and 2.

Let's convert a random Base Fibonacci number, 10101001010 to decimal:
First we write the corresponding Fibonacci numbers.
Then we compute the sum of the numbers under 1's.

 1   0   1   0   1   0   0   1   0   1   0
 144 89  55  34  21  13  8   5   3   2   1  -> 144+55+21+5+2 = 227.

Read more about Base Fibonacci numbers: link, it also has a tool which converts regular integers to base Fibonacci. You can experiment with it.

Now the Question:

Your task is to take a number in the Zeckendorf Representation, and output its decimal value.

Input is a string which contains only 0 and 1's (although you can take the input in any way you want).

Output one number in decimal.

Test cases: (in the format input->output)

 1001 -> 6
 100101000 -> 73
 1000000000 -> 89
 1001000000100100010 -> 8432
 1010000010001000100001010000 -> 723452

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

Note: The input will not contain any leading 0's or consecutive 1's.

Taxi, 1987 1927 bytes

-60 bytes due to the realization that linebreaks are optional.

Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Chop Suey.Go to Chop Suey:n 1 r 1 l 4 r 1 l.[B]Switch to plan C if no one is waiting.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 3 l.Pickup a passenger going to Narrow Path Park.Pickup a passenger going to Sunny Skies Park.Go to Zoom Zoom:n.Go to Sunny Skies Park:w 2 l.Go to Narrow Path Park:n 1 r 1 r 1 l 1 r.Go to Chop Suey:e 1 r 1 l 1 r.Switch to plan B.[C]1 is waiting at Starchild Numerology.1 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 3 l 3 l 2 r.Pickup a passenger going to Addition Alley.Pickup a passenger going to Cyclone.Go to Cyclone:w 1 r 4 l.[D]Pickup a passenger going to Addition Alley.Pickup a passenger going to Cyclone.Go to Addition Alley:n 2 r 1 r.Go to Cyclone:n 1 l 1 l.Pickup a passenger going to Multiplication Station.Go to Zoom Zoom:n.Go to Narrow Path Park:w 1 l 1 l 1 r.Switch to plan E if no one is waiting.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:e 1 r.Pickup a passenger going to Multiplication Station.Go to Multiplication Station:n 1 r 2 l.Pickup a passenger going to Joyless Park.Go to Joyless Park:n 2 l 1 r 1 r.Go to Addition Alley:w 1 r 2 l 1 l.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l.Pickup a passenger going to Addition Alley.Switch to plan D.[E]Go to Addition Alley:w 1 l 1 r 1 l.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge:n 1 r.Go to Joyless Park:e 1 r 2 l.Pickup a passenger going to Addition Alley.[F]Switch to plan G if no one is waiting.Pickup a passenger going to Addition Alley.Go to Fueler Up:w 1 l.Go to Addition Alley:n 3 l 1 l.Pickup a passenger going to Addition Alley.Go to Joyless Park:n 1 r 1 r 2 l.Switch to plan F.[G]Go to Addition Alley:w 1 r 2 l 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Try it online!

Because I don't return to the Taxi Garage at the end, my boss fires me, so it exits with an error.


The Unique Padlock PIN List! Introduction
In a private chat, a friend of mine apparently recently stumbled across a security system which has the following two restrictions on its valid pins:

Each digit must be unique (that is "1" may only appear once)
The order of the digits doesn't matter ("1234"="4321")

So to illustrate how bad this padlock system is, let's actually enumerate all valid PINs!
Input
Your input will consist of a single, positive integer, which denotes the length of the PIN.
Output
Your output consists of a list of non-negative integers or strings*, which enumerate all valid PINs of the given length.
*More precisely something that a human can use to try all combinations if you would print it for them. This means set of sets of digits and arrays of arrays of digits are fine.
Who wins?
This is code-golf so the shortest answer in bytes wins! Standard rules and loopholes apply.
Corner Cases

The output behaviour is undefined if an integer greater than 10 is input.
The ordering of the digits within each output entry is undefined, as entries with a zero actually contain said zero, that is you may not strip "0123" to "123" but "1230", "1203" and "1023" are all valid as is "0123".

Test Cases
1
[0,1,2,3,4,5,6,7,8,9]

2
[10,20,30,40,50,60,70,80,90,21,31,41,51,61,71,81,91,32,42,52,62,72,82,92,43,53,63,73,83,93,54,64,74,84,94,65,75,85,95,76,86,96,87,97,98]

3
[210,310,410,510,610,710,810,910,320,420,520,620,720,820,920,430,530,630,730,830,930,540,640,740,840,940,650,750,850,950,760,860,960,870,970,980,321,421,521,621,721,821,921,431,531,631,731,831,931,541,641,741,841,941,651,751,851,951,761,861,961,871,971,981,432,532,632,732,832,932,542,642,742,842,942,652,752,852,952,762,862,962,872,972,982,543,643,743,843,943,653,753,853,953,763,863,963,873,973,983,654,754,854,954,764,864,964,874,974,984,765,865,965,875,975,985,876,976,986,987]

4
[3210,4210,5210,6210,7210,8210,9210,4310,5310,6310,7310,8310,9310,5410,6410,7410,8410,9410,6510,7510,8510,9510,7610,8610,9610,8710,9710,9810,4320,5320,6320,7320,8320,9320,5420,6420,7420,8420,9420,6520,7520,8520,9520,7620,8620,9620,8720,9720,9820,5430,6430,7430,8430,9430,6530,7530,8530,9530,7630,8630,9630,8730,9730,9830,6540,7540,8540,9540,7640,8640,9640,8740,9740,9840,7650,8650,9650,8750,9750,9850,8760,9760,9860,9870,4321,5321,6321,7321,8321,9321,5421,6421,7421,8421,9421,6521,7521,8521,9521,7621,8621,9621,8721,9721,9821,5431,6431,7431,8431,9431,6531,7531,8531,9531,7631,8631,9631,8731,9731,9831,6541,7541,8541,9541,7641,8641,9641,8741,9741,9841,7651,8651,9651,8751,9751,9851,8761,9761,9861,9871,5432,6432,7432,8432,9432,6532,7532,8532,9532,7632,8632,9632,8732,9732,9832,6542,7542,8542,9542,7642,8642,9642,8742,9742,9842,7652,8652,9652,8752,9752,9852,8762,9762,9862,9872,6543,7543,8543,9543,7643,8643,9643,8743,9743,9843,7653,8653,9653,8753,9753,9853,8763,9763,9863,9873,7654,8654,9654,8754,9754,9854,8764,9764,9864,9874,8765,9765,9865,9875,9876]

Jelly, 4 bytes

ØDœc

Try it online!

Explanation

ØDœc  Double-builtin; main link
  œc  Number of combinations of          of length
ØD                              [digits]
                                                   <right argument>

Behavior for n > 10 is empty list.


Difference of three input integers Implement a function diff that takes as input three integers x, y, and z. It should return whether subtracting one of these numbers from another gives the third.

Test cases:
diff(5, 3, 2) yields True because 5 - 3 = 2
diff(2, 3, 5) yields True because 5 - 3 = 2
diff(2, 5, 3) yields True because 5 - 3 = 2
diff(-2, 3, 5) yields True because 3 - 5 is -2
diff(-5, -3, -2) # -5 - -2 is -3
diff(2, 3, -5) yields False
diff(10, 6, 4) yields True because 10 - 6 = 4
diff(10, 6, 3) yields False

You don't have to name the function, you may implement default input methods the examples above are not a strict guideline.

Python 3, 21 bytes
lambda*l:sum(l)/2in l

If two numbers add to the other, the sum of all three will be double that other number, so half the sum will be an element of the list. Python 3 is needed to avoid floor-division, unless the numbers are given like 3.0 rather than 3.


Deplane! Deplane! (Or: RGBRGBRGB => RRRGGGBBB?) Imagine bytes in memory for an RGB image--R and G and B represented by bytes in sequence.  If an image is NxM then the memory layout will be M repetitions for vertical scanlines of 3*N bytes in sequence for the horizontal pixels.  (As one might expect.)

A mandate has come down from on high that you need to be able to isolate contiguous color planes.  You might be asked for the R, G, or B plane.  When you give back the plane it must be the N*M bytes in sequence for that color.

Yet there is a twist: You cannot use additional memory proportional to the size of the image.  Thus you must shuffle the bytes somewhere inside of the existing RGB data to provide the contiguous plane for the requested color.  And you must be able to recover the original image when processing of that color plane is finished.

The image size is actually not relevant to the problem as it operates on the buffer as a whole.  Input is bytes (expressed as hexadecimal ASCII) followed by which plane to extract:

00112233445566778899AABBCCDDEE
G

Output is the extracted color plane, then the original input *(also in hexadecimal ASCII):

114477AADD
00112233445566778899AABBCCDDEE

Where you shuffle the memory is up to you.  But you must actually shuffle the data to produce contiguous bytes (requiring the client to use an iterator is cheating).  And you must be able to reverse the operation to restore the original information.

Lowest big-O implementation wins.  Between two implementations with equal big-O performance... winner decided by code golf rules.

C

only shuffle, not print

lenght in bytes, not pixels

plane: 0,1,2 for R,G,B

not checked!

void deplane(unsigned char *data, int length, int plane) {
    unsigned char *t = data;
    unsigned char *s = data + plane;
    unsigned char p;
    while (s < data + length) {
        p = *s; *s = *t; *t = p;
        t++; s += 3;
    }
    // now plane start at data
    while (t > data) {
        s -= 3; t--;
        p = *s; *s = *t; *t = p;
    }
    // back to original
}


Solving Systems of Equations using Cramer's Rule Create an algorithm that uses Cramer's Rule (with determinants of matrices) to solve for the solutions of a system of linear equations. The code should work for an "n" number of variables.

You may use whatever data structure you want to hold the matrix and return the result

Note: Also, consider that a possible system can have no solutions and may have infinitely many solutions :), so, your solution should take account of this...

If this is the case, just print out or return "none" or "infinitely many".

Since this is code golf, smallest code wins...

EDIT: To make this more challenging, you cannot use a language's built-in matrix operations libraries.

Also, your algorithm DOES NOT have to deal how to get the input, just how to process the input and return the correct output. As said before, you can store this input in whatever structure.

Mathematica 40

Setting up the problem in your reference link:

s = {{2, 1, 1}, {1, -1, -1}, {1, 1, 1}};
r = {3, 0, 0};

The algorithm (spaces not needed):

i = 1; (a = s; a[[All, i++]] = r; Det@a/Det@s) & /@ r

result:

{1, -2, 3}

If the system has infinite solutions it returns Indeterminate or ComplexInfinite

Please note that Mathematica can solve linear systems natively. Among other possible ways you could use:

s~LinearSolve~r

or

Solve[s.{x,y,z}==r]


Shortest program to split a string at non-digits without RegExps EDIT: If you're using Lisp, I have given some guidelines at the bottom in counting bytes.
Objective: Make the shortest function that splits a string at non-digits and returns an array consisting of only digits in each string, without the use of any regular expressions. Leading zeroes are to be included in each string.
Current Standings (separated in categories):

C/C++/C#/Java: 68 (C) ....
GolfScript/APL/J: 13 (APL)
All others: 17 (Bash, uses tr), 24 (Ruby)

Rules:

The format must be as a function with a single string argument. Up to two additional arguments may be added if necessary for the proper return of the array (e.g. sh/csh/DOS Batch needs an extra variable reference to return, etc.).

The primary function declaration doesn't count, and nor does importing other standard libraries. #includes, imports, and usings don't count. Everything else does. This does include #defines and helper functions. Sorry for the confusion. Refer to this as a helpful guide as to what does/does not count (written in C-style syntax)
// doesn't count toward total, may be omitted unless
// non-obvious, like half of Java's standard library.
#include &lt;stdio.h&gt;

import some.builtin.Class // doesn't count, see above

#define printf p // counts towards total

/* Any other preprocessor directives, etc. count. */

int i = 0; // counts

someFunction(); // counts

char[][] myMainSplitFunction(char[][] array) { // doesn't count
  // Everything in here counts
  return returnArray; // Even this counts.
} // doesn't count

/* Everything in here counts, including the declaration */
char[][] someHelperFunction(char[] string) {
    // stuff
} // even this counts

The output must be a string array or similar (Array lists in Java and similar are acceptable). Examples of accepted output: String[], char[][], Array<String>, List<String>, and Array (object).

The array must contain only contain variable-length string primitives or string objects. No empty strings should be present in the return, with the exception below. Note: the strings are to contain a string of consecutive matches, such as the example input and output below.

If there are no matches, then the function body should return null, an empty array/list,  or an array/list containing an empty string.

No external libraries allowed.

DOS line endings count as one byte, not two (already covered in meta, but needs to be emphasized)

And the biggest rule here: no regular expressions allowed.

This is a code-golf question, so shortest code wins. Good luck!
And here are some example inputs and outputs (with C-style escapes):

Input:  "abc123def456"
Output: ["123", "456"]

Input:  "aitew034snk582:3c"
Output: ["034", "582", "3"]

Input:  "as5493tax54\\430-52@g9.fc"
Output: ["5493", "54", "430", "52", "9"]

Input:  "sasprs]tore\"re\\forz"
Output: null, [], [""], or similar

Please put how many bytes used by your answers, and as always, happy golfing!

Guidelines for Lisp
Here's what does and doesn't count in Lisp dialects:

;;; Option 1
(defun extract-strings (a b) ; Doesn't count
(stuff) ;;; Everything in here counts
) ; Doesn't count
;;; Option 2
(defun extract-strings (string &aux (start 0) (end 0)) ; Doesn't count
(stuff) ;;; Everything in here counts
) ; Doesn't count.

All other lambdas fully count towards the byte count.

APL, 13 chars

(or 28 / 30 bytes, read below)

{⍵⊂⍨⍵∊∊⍕¨⍳10}

I see you've banned GolfScript from your question. I understand your sentiment, but I hope this community won't eventually ban APL, because it's a truly remarkable programming language with a long history, not to mention a lot of fun to code in. Maybe it could just be scored differently, if people feel it's competing unfairly. I'll post my thoughts on this matter to that thread you've linked.

On that same token, I've always added a footnote to my APL posts, claiming that APL could be scored as 1 char = 1 byte. My claim rests on the fact that a few (mostly commercial) APL implementations still support their own legacy single-byte encoding, with the APL symbols mapped to the upper 128 byte values. But maybe this is too much of a stretch, in which case you may want to score this entry as 28 bytes in UTF-16 or 30 bytes in UTF-8.

Explanation

{        ⍳10}  make an array of naturals from 1 to 10
       ⍕¨      convert each number into a string
      ∊        concatenate the strings into one (it doesn't matter that there are two 1s)
    ⍵∊         test which chars from the argument are contained in the digit string
 ⍵⊂⍨           use it to perform a partitioned enclose, which splits the string as needed

Examples

      {⍵⊂⍨⍵∊∊⍕¨⍳10} 'ab5c0x'
 5  0
      {⍵⊂⍨⍵∊∊⍕¨⍳10}  'z526ks4f.;8]\p'
 526  4  8

The default output format for an array of strings does not make it clear how many strings are there in the array, nor how many blanks. But a quick manipulation to add quotes should make it clear enough:

      {q,⍵,q←'"'}¨ {⍵⊂⍨⍵∊∊⍕¨⍳10} 'ab5c0x'
 "5"  "0"
      {q,⍵,q←'"'}¨ {⍵⊂⍨⍵∊∊⍕¨⍳10}  'z526ks4f.;8]\p'
 "526"  "4"  "8"


Better way to read multiple int in C than scanf I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it:

scanf("%d%d%d%d",&w,&x,&y,&z)

that's 29 chars, which is huge considering that my total code size is 101 chars. I can rid of the first int since I don't really need it, so I get this code:

scanf("%*d%d%d%d",&x,&y,&z)

which is 27 chars, but it's still lengthy.

So my question is, is there any other way (tricks, functions, K&R stuff) to read ints that I don't know of that could help me reduce this bit of code?

Thanks a lot.

EDIT: some users have reported that my question is similar to Tips for golfing in C

While this topic contain a lot of useful informations to shorten C codes, it isn't relevant to my actual use case since it doesn't provide a better way to read inputs.

I don't know if there is actually a better way than scanf to read multiple integers (that's why I'm asking the question in the first place), but if there is, I think my question is relevant and is sufficiently different than global tips and tricks.

If there is no better way, my question can still be useful in the near future if someone find a better solution.

EDIT2: I'm looking for a full program (so no function trick) and all librairies possible. It needs to be C, not C++. Currently, my whole program looks like this:

main(w,x,y,z){scanf("%*d%d%d%d",&x,&y,&z)}

any tricks is welcome, as long as it shorten the code (this is code golf :) ) and as long as it isn't c++

You can write a function instead of a program as your submission. In C you can omit int from function signatures:

f(w,x,y,z){}


Interpret /// (pronounced 'slashes') Because we can't get enough of esoteric language golfs, can we?

///—pronounced slashes—is a fun little language based on the s/// regex-replacement function of Perl fame. It contains only two special characters, slash / and backslash \. You can find a full article on it at the esolangs wiki, but I will reproduce a description of the language below, as well as some examples.

In short, it works by identifying /pattern/repl/rest in the program and making the substitution as many times as possible. No characters are special except / and \: / demarcates patterns and replacements in the program, while \ allows you to insert literal / or \ characters into your code. Notably, these are not regular expressions, just plain string substitutions.

Your challenge is to produce an interpreter for the /// language, as either a program reading STDIN or a function taking a string argument, in as few characters as possible.

You may use any language except for /// itself. You may not use any libraries that interpret ///; you may, however, use regexes, regex libraries, or string-matching libraries.

Execution

There are four states, print, pattern, replacement, and substitution. In every state except substitution:

If the program is empty, execution halts.
Else, if the first character is \, do something with the next character (if present) and remove both from the program.
Else, if the first character is /, remove it, and change to the next state.
Else, do something with the first character and remove it from the program.
Repeat.

The states cycle through print, pattern, replacement, and substitution in order.

In print mode, 'do something' means output the character.
In pattern mode, 'do something' means add the character to the current Pattern.
In replacement mode, 'do something' means add the character to the current Replacement.

In substitution mode, you follow a different set of rules. Repeatedly substitute the first occurrence of the current Pattern with the current Replacement in the program, until no more substitutions are possible. At that point, clear the Pattern and Replacement and return to print mode.

In the program /foo/foobar/foo foo foo, the following happens:

/foo/foobar/foo foo foo
foo foo foo
foobar foo foo
foobarbar foo foo
foobarbarbar foo foo
...

This loops forever and never exits substitution mode. Similarly, if the Pattern is empty, then the first occurrence of the empty string—at the beginning of the program—always matches, so substitution mode loops forever, never halting.

Examples

no

Output: no.

/ world! world!/Hello,/ world! world! world!

Output: Hello, world!.

/foo/Hello, world!//B\/\\R/foo/B/\R

Output: Hello, world!.

a/ab/bbaa/abb

Output: a. Program does not halt.

//

Output: none.

///

Output: none. Program does not halt.

/\\/good/\/

Output: good.

There is also a quine on the wiki you can try.

J - 181 190 170 char

This was a nightmare. I rewrote it from scratch, twice, because it just kept bugging me. This is a function taking a single string argument, outputting to STDOUT.

(0&$`((2{.{:@>&.>)((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i 5;@}.&,'/';"0;&.>)@.(2<#)@}.[4:1!:2~{:@>@p=.>@{.@[)@((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)i=. ::](^:_)

To explain, I will break it up into subexpressions.

i =. ::](^:_))
parse =: ((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)
print =: 4:1!:2~{:@>@p=.>@{.@[
eval  =: 0&$`((2{.{:@>&.>)sub 5;@}.&,'/';"0;&.>)@.(2<#)@}.
sub   =: ((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i

interp =: (eval [ print) @ parse i

i (short for iterate) is an adverb. It takes a verb argument on the left and returns a verb (f)i, which when applied to an argument, applies f repeatedly to the argument until one of two things happens: it finds a fixed point (y = f y), or it throws an error. The fixed-point behaviour is inherent to ^:_, and ::] does the error handling.
parse tokenizes the input into what I call half-parsed form, and then cuts it up at the unescaped '/'. It binds escaping backslashes to their characters, but doesn't get rid of the backslashes—so we can either revert it or finish it depending on which we want.

The bulk of the interesting work occurs in ;:. This is a sequential-machine interpreter primitive, taking a description of the machine ((0;(0,:~1 0,.2);'\';&<1 0)) on the left and something to parse on the right. This does the tokenizing. I will note that this specific machine actually treats the first character unspecial, even if it's a \ and should bind. I do this for a few reasons: (1) the state table is simpler, so it can be golfed further; (2) we can easily just add a dummy character to the front to dodge the problem; and (3) that dummy-character gets half-parsed at no extra cost, so I can use it to set up for the cutting phase, next.

We also use <;._1 to cut the tokenized result on unescaped / (which is what I choose to be the first char). This is handy for pulling out the output, pattern, and replacement from out/patt/repl/rest all in one step, but unfortunately also cuts up the rest of the program, where we need those / to stay untouched. I splice these back in during eval, because making <;._1 leave them alone ends up costing a lot more.
The fork (eval [ print) executes print on the result from parse for its side-effects, and then runs eval. print is a simple verb that opens up the first box (the one we know for sure is output), finishes parsing it, and sends it to STDOUT. However, we also take the chance to define a utility verb p.

p is defined as >@{.@[, so it takes its left arg (acts like the identity if given only one arg), takes the first item of that (identity when given a scalar), and unboxes it (identity if already unboxed). This will come in very handy in sub.
eval evaluates the remainder of the processed program. If we don't have a full pattern or a full replacement, eval throws it out and just returns an empty list, which terminates evaluation by making ;: (from parse) error out on the next iteration. Else, eval fully parses the pattern and replacement, corrects the remainder of the source, and then passes both to sub. By explosion:

                                              @}.  NB. throw out printed part
                                       @.(2<#)     NB. if we have a pattern and repl:
      2{.                                          NB.  take the first two cuts:
             &.>                                   NB.   in each cut:
         {:@>                                      NB.    drop escaping \ from chars
     (          )                                  NB.  (these are pattern and repl)
                                   &.>             NB.  in each cut:
                                  ;                NB.   revert to source form
                            '/';"0                 NB.  attach a / to each cut
                          &,                       NB.  linearize (/ before each cut)
                     5  }.                         NB.  drop '/pattern/repl/'
                      ;@                           NB.  splice together
    (            sub                  )            NB.  feed these into sub
   `                                               NB. else:
0&$                                                NB.  truncate to an empty list

sub is where one (possibly infinite) round of substitutions happens. Because of the way we set up eval, the source is the right argument, and the pattern and replacement are bundled together in the left. Since the arguments are ordered like this and we know the pattern and replacement don't change within a round of substitutions, we can use another feature of i—the fact that it modifies only the right argument and keeps passing in the same left—to delegate to J the need to worry about keeping track of the state.

There are two spots of trouble, though. The first is that J verbs can have at most two arguments, so we don't have an easy way to access any that are bundled together, like pattern and replacement, here. Through clever use of the p utility we defined, this isn't that big of a problem. In fact, we can access the pattern in one character, just by using p, because of its >@{.@[ definition: the Unbox of the First item of the Left arg. Getting the replacement is tricker, but the shortest way would be p&|., 2 chars shorter than manually getting it out.

The second problem is that i exits on fixed points instead of looping forever, and if the pattern and replacement are equal and you make a substitution, that looks like a fixed point to J. We handle this by entering an infinite loop of negating 1 over and over if we detect they are equal: this is the -i@=`p@.~:~/ portion, replacing p&|..

                                    p    E.]    NB. string search, patt in src
                                      I.@       NB. indices of matches
                                  0{            NB. take the first (error if none)
                               j=.              NB. assign to j for later use
                           #@p+                 NB. add length of pattern
                       ]}.~                     NB. drop that many chars from src
                   /@[                          NB. between patt and repl:
                  ~                             NB.  patt as right arg, repl as left
              @.~:                              NB.  if equal:
        -i@=                                    NB.   loop forever
            `p                                  NB.  else: return repl
 (j{.])                                         NB. first j chars of src
       ,              ,                         NB. append all together
(                                           )i  NB. iterate

This cycle repeats due to the use of i, until something outside of sub errors out. As far as I'm aware, this can only happen when we are out of characters, of when we throw out an incomplete set of pattern-and-replacement.

Fun facts about this golf:

For once, using ;: is shorter than manually iterating through the string.
0{ should have a chance to error out before sub goes into an infinite loop, so this it should work fine if the pattern matches the replacement but never shows up in the remainder of the source. However, this may or may not be unspecified behaviour, since I can't find a citation either way in the docs. Whoopsie.
Keyboard interrupts are processed as spontaneous errors inside running functions. However, due to the nature of i, those errors get trapped too. Depending on when you hit Ctrl+C, you might:

Exit out of the negate-forever loop, error out of the sub loop by trying to concatenate a number to a string, and then go on interpreting /// as if you finished substituting a string with itself an infinite number of times.
Leave sub halfway through and go on interpreting a half-subbed /// expression.
Break out of the interpreter and return an unevaluated /// program to the REPL (not STDOUT, though).

Example usage:

   f=:(0&$`((2{.{:@>&.>)((j{.]),-i@=`p@.~:~/@[,]}.~#@p+j=.0{p I.@E.])i 5;@}.&,'/';"0;&.>)@.(2<#)@}.[4:1!:2~{:@>@p=.>@{.@[)@((0;(0,:~1 0,.2);'\';&<1 0)<;._1@;:'/'&,)i=. ::](^:_)
   f 'no'
no
   f '/ world! world!/Hello,/ world! world! world!'
Hello, world!
   f '/foo/Hello, world!//B\/\\R/foo/B/\R'
Hello, world!
   f '//'  NB. empty string

   f '/\\/good/\/'
good


Determine if a number is prime without using arithmetic Write a program which determines if a given number is prime.
The catch: No digits or arithmetical operators. This means:

No digits from 0 to 9, anywhere in the program, and whatever the meaning
No using any built-in operators for addition (and incrementing), subtraction (and decrementing), multiplication, division, exponentiation, or modulus, anywhere in the program
This includes symbols like + and functions like num.add()
All other operations are permitted
You may define your own functions for the forbidden operations
You may use symbols like - when they mean things other than the forbidden operations

Shortest code wins - any language permitted.
Example solution
An ungolfed solution in Java can be found here.

PHP, 117 characters

This one is based on regular expressions. If a string containing $n characters can be split into chunks of equal length, then $n must be composite.

(Assumes $n is a positive integer.)

function p($n){$u=true;$s=str_repeat('x',$n);return($s!='x'&&!preg_match('/^(xx{'.$u.',})\\'.$u.'{'.$u.',}$/U',$s));}

Output:

for ($i=1; $i<=100; $i++) if (p($i)) echo "$i ";

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97


Morse code to standard output This question involves taking input in Morse code as . (period) and - (minus symbol), with spaces to separate the input.  Your task is to convert the code to standard output.  You can assume that the only input contains character symbols found in the International Morse Code alphabet, found here: http://en.wikipedia.org/wiki/Morse_code#Letters.2C_numbers.2C_punctuation.

All output should use lowercase letters. A double space should be interpreted as a word space.

Sample input:

. -..- .- -- .--. .-.. . .-.-.-  ... --- ...

Output:

example. sos

Shortest code after two weeks wins.

Drat, I was hoping to get here before the GolfScripters arrived :-(
Anyhoo...
C: 228 characters:
char n,t,m[9],*c=" etianmsurwdkgohvf l pjbxcyzq  54 3   2& +    16=/   ( 7   8 90    $       ?_    \"  .    @   '  -        ;! )     ,    :";
main(){while(scanf("%s",m)>0){for(t=m[6]=n=0;m[n];n++)t+=t+1+(m[n]&1);putchar(c[t]);}}

I thought I'd add an explanation of how this works.
The input data is parsed according to the tree data in *c, which can be expanded as follows (using · to represent a vacant node):
                     dot <-- (start) --> dash
                e                               t
        i               a               n               m
    s       u       r       w       d       k       g       o
  h   v   f   ·   l   ·   p   j   b   x   c   y   z   q   ·   ·
 5 4 · 3 · · · 2 & · + · · · · 1 6 = / · · · ( · 7 · · · 8 · 9 0
····$·······?_····"··.····@···'··-········;!·)·····,····:·······

Starting at the top of the tree, work your way down while moving to the left for a dot and to the right  for a dash. Then output whatever character you happen to be at when the input string ends (i.e., when a whitespace character is encountered). So for example, three dots and a dash will take you to v via e, i and s. Instead of explicitly checking for dots (ASCII \x2e) and dashes (ASCII \x2d), we only need to check the last bit (m[n]&1), which is 0 for . and 1 for -.
Six rows are enough to encode everything except $, which has 7 dot/dashes: ...-..-, but since the input data is guaranteed to be valid, this can easily be fixed by truncating the input at 6 characters (m[6]=0) and interpreting ...-.. as $ instead. We can also cut away the last 7 bytes from the tree data, since they are all empty and aren't needed if the input is valid.


Unicode character classification Real-world programs often use libraries like ICU to support Unicode.

The puzzle is to create the smallest possible function that can determine whether a given Unicode character is lowercase, uppercase, or neither (a commonly used Unicode character property).

You may indicate the property in any way (whatever is shortest for your language); just explain what the output means in your answer.

Of course, using a language feature or a function from the standard library that already provides this distinction is forbidden.

This could potentially have some practical use, since some embedded programs have to choose between including a bulky library and not supporting Unicode.

C & C++, 1922 1216 bytes/chars (BMP only 1451 1005 bytes/chars)

This is the "shortest" solution that came to mind that is both valid C and C++ and that supports all of Unicode version 6.1, not just the BMP:

int s[]={-74,-68,31054,-50,-49,-48,-47,-46,-44,-43,-39,-38,-37,-34,-33,-32,-30,-29,-28,-27,-26,-25,-24,-23,-22,-17,-16,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,19,20,27,28,29,53195,31,34,36,42,49,50,52,54,58,59,62,64,66,73,81,98,102,103,140,194,263,275,290,1066,1222,1230,2685,2732,2890,3379,6009,21254,22391,30996,53209};
char l[]="l5Hf`7HIAH2IH@IH7IJFIFHJIJKHLJKFHFJFIJIHIJKIJHJFHNFJ@IH?IHJIK1IBHFJHILDI!HI4HpIFKFHWZ-HIHKFH<IDHIFJHc&H9IQ4IJBIH(Ie+H{)Hh<HI.Hn I@H$I@HPCHRAHPAHPCHRAHPAHP;HJAHPAHPAHPDHIHNKFHIHPEHJHPAHRFHIHrKHKZFLJHPEHLdx'HJKHEILIHICHM$IHOILT,HIM~8IX=IoBIFH/IAHFIJDILIJIUDIk|BHTDHt5Hv*H\\5HYBHI9HY5HYEHFIBHI>HY5HY5HY5HY5HY5HY5HY5HY5HY3H[6HICHY6HICHY6HICHY6HICHY6HICHIG";
char u[]="i5Hm8HIBH^3IJAIJ7IHFIKHFIHIFHJEHIHIFHKHIHEIHIJIHIFHFIHKOEJAIJ@IFJIFH1IOHIHJIEHDIsIKVIFHFIHI:HI@H_JFHK=IMJIHJ#Ha:IQ3IHBIJ)IR,Hy,HIMz IQ%IQAHPCHRAHPAHPCHSEIPAHjEHTEHTEHTDHSEHqLKFHJFHJKDHNEIEHJEHRHMgw'HbIFHJEIEHIJPFH$IPIL\"8IX=IoBIK0IRFIHDILIJIUCI}5Hu*H\1775HY5HY5HYIHFJHJEHIAHY5HYHIEHJAHIBHZHIEHIDHIKBHZ5HY5HY5HY5HY5HY5H]6H^6H^6H^6H^6H^G";
int x(int a,char*p){int c=0,i=0,b=-1;while(c>0||s[*p-32]){if(!c)c=s[*p-32]<0?-s[*p++-32]:1,i=s[*p++-32];b+=i,--c;if(a==b)return 1;}return 0;}

Please note that "shortest" in this case does not mean that the solution is in any way efficient; it simply means that it is the shortest source code solution. It does not require any Unicode support in the standard library, and in fact does not use the standard library at all. (Which I now understand is what code golf means ... I'm a newbie around here, what can I say.)

To build the lower and upper case data tables I worked as follows:

Downloaded UnicodeData.txt.
Extracted a list of all lines that included the text ";Ll;" or ";Lu;" to indicate a lower case letter or upper case letter respectively.
Built two vectors of code points using the data from step 2.
Converted each absolute code point value to a relative value, the difference between the previous code point and this code point. Because it is convenient for the difference to always be a positive integer (not zero or negative), I use -1 as the value of the first previous code point. In this way zero will not appear anywhere in the sequence.
Used a form of run length encoding to compress runs of identical values into a pair of values. If the next value appears two or more times consecutively, replace the sequence with the negative of the length of the sequence and the value. Otherwise the value only appears once, so just use it as is.
Terminated the compressed vector with zero to mark the end of the sequence.
I noticed there were 96 unique values in the run length encoded vectors, so I built an array of the unique integers and used the index into that array for the lower and upper case vectors.

The above process compressed the vector of lower case code points from 1751 unique values to 350 mostly small non-unique values. In like fashion, the upper case code point vector went from 1441 values to 331 values.

Next I wrote the unique value vector out as a comma separated list of integers suitable for including in source code. I assumed int was 32 bits to avoid using long so that I could save an additional four characters / bytes of source code. Then I wrote out the lower and upper case vectors as strings, where each character in the string has a code 32 greater than its index into the unique integer array. This saves about half the characters necessary to encode the lower & upper case array through omission of comma characters. Three of the characters used have to be escaped (\", \, and \177). They are assigned to unique integers that only appear once in the data so as to minimize the size of the string literals.

What I wound up with was a global array of integers, two global arrays of characters, and a function. An array named s for the unique signed integers, an array named u for the character based upper case code point indexes, and another array named l for the character based lower case code point indexes. The function x takes code point a and pointer to an array of characters p and returns 1 if the code point is in the decompressed / normalized array of code points or 0 otherwise.

If you want to determine if code point cp is lower case, you call "x(cp, l)". If you want to determine if it is upper case, you call "x(cp, u)".

Since the point to this exercise is to make the smallest code to accomplish the task, I never save the decompressed / normalized data. I decompress it piecemeal as I need it every time I call it.

It would be possible to terminate the while loop early if the code point I'm checking has already been passed by during decompression. That would add extra code so I didn't bother, deciding I'd rather pay the speed penalty.

I admit the code is ugly. I did not write it this way originally. Here is the C++ version that I derived the compact C version from:

const int Ii[] = {-74,-68,31054,-50,-49,-48,-47,-46,-44,-43,-39,-38,-37,-34,-33,-32,-30,-29,-28,-27,-26,-25,-24,-23,-22,-17,-16,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,19,20,27,28,29,53195,31,34,36,42,49,50,52,54,58,59,62,64,66,73,81,98,102,103,140,194,263,275,290,1066,1222,1230,2685,2732,2890,3379,6009,21254,22391,30996,53209};
const char Ll[] = "l5Hf`7HIAH2IH@IH7IJFIFHJIJKHLJKFHFJFIJIHIJKIJHJFHNFJ@IH?IHJIK1IBHFJHILDI!HI4HpIFKFHWZ-HIHKFH<IDHIFJHc&H9IQ4IJBIH(Ie+H{)Hh<HI.Hn I@H$I@HPCHRAHPAHPCHRAHPAHP;HJAHPAHPAHPDHIHNKFHIHPEHJHPAHRFHIHrKHKZFLJHPEHLdx'HJKHEILIHICHM$IHOILT,HIM~8IX=IoBIFH/IAHFIJDILIJIUDIk|BHTDHt5Hv*H\\5HYBHI9HY5HYEHFIBHI>HY5HY5HY5HY5HY5HY5HY5HY5HY3H[6HICHY6HICHY6HICHY6HICHY6HICHIG";
const char Lu[] = "i5Hm8HIBH^3IJAIJ7IHFIKHFIHIFHJEHIHIFHKHIHEIHIJIHIFHFIHKOEJAIJ@IFJIFH1IOHIHJIEHDIsIKVIFHFIHI:HI@H_JFHK=IMJIHJ#Ha:IQ3IHBIJ)IR,Hy,HIMz IQ%IQAHPCHRAHPAHPCHSEIPAHjEHTEHTEHTDHSEHqLKFHJFHJKDHNEIEHJEHRHMgw'HbIFHJEIEHIJPFH$IPIL\"8IX=IoBIK0IRFIHDILIJIUCI}5Hu*H\1775HY5HY5HYIHFJHJEHIAHY5HYHIEHJAHIBHZHIEHIDHIKBHZ5HY5HY5HY5HY5HY5H]6H^6H^6H^6H^6H^G";

bool isXx(int cp, const char* Xx)
{
    int count = 0, step = 0, code = -1;

    while ((count > 0) || (Ii[*Xx-32] != 0))
    {
        if (count == 0)
        {
            count = (Ii[*Xx-32] < 0) ? -(Ii[*(Xx++)-32]) : 1;
            step = Ii[*(Xx++)-32];
        }

        code += step;
        --count;

        if (cp < code)
            break;

        if (cp == code)
            return true;
    }

    return false;
}

inline bool isLl(int cp)
{
    return isXx(cp, Ll);
}

inline bool isLu(int cp)
{
    return isXx(cp, Lu);
}

In the end, the compact version takes 1922 1216 bytes (including CR+LF end of line sequences). The original version only takes 2271 1578 bytes.

To put this in context of the other solutions that only support the BMP, the equivalent compact version only takes 1451 1005 bytes (or 1800 1367 bytes for the original version).


History homework helper Doing my history reading and note-taking, I can't help but get tired of writing out all these long dates –– 1784 is six entire pencil lifts! jǝǝz!

As you can see, I –– like most challenge posters on this site –– am lazy when it comes to writing stuff. Thus, I ask you to please help me shorten some dates. Of course, your solution must be as short as possible since my hand is already tired from writing typing out the test cases.

How do I shorten a date?

Well funny you should ask. It's fairly simple:

Take two integers as input in whatever order you want ((smallest, biggest) or (biggest, smallest)).
Take the larger of the two numbers, and take only the part not in the smaller number.
 For example, given 2010, 2017, shorten 2017 to -7 because 201_ is in both at the same digit-places.
Print or return the smaller number, followed by a dash and then the shortened larger number.

For example:

Bonus brownies for you if you figure out these dates' significance :)
1505, 1516 -> 1505-16
1989, 1991 -> 1989-91
1914, 1918 -> 1914-8
1833, 1871 -> 1833-71
1000, 2000 -> 1000-2000
1776, 2017 -> 1776-2017
2016, 2016 -> 2016-

These dates lack significance :(
1234567890, 1234567891 -> 1234567890-1
600, 1600 -> 600-1600
1235, 1424 -> 1235-424
600, 6000 -> 600-6000

Jelly,  17   16 bytes

DUµn/TṪṁ@Ṫ,j”-FṚ

A full program taking a list of years from, to and printing the result.

Try it online! or see the test suite.

How?

DUµn/TṪṁ@Ṫ,j”-FṚ - Main link: list of years [from, to]    e.g [1833,1871]
D                - convert to decimals                        [[1,8,3,3],[1,8,7,1]]
 U               - upend (to cater for differing lengths)     [[3,3,8,1],[1,7,8,1]]
  µ              - monadic chain separation, call that V
    /            - reduce V with:
   n             -   not equal?                               [1,1,0,0]
     T           - truthy indices                             [1, 2]
      Ṫ          - tail                                       2
         Ṫ       - tail V (pop from & modify V)               [1,7,8,1]
       ṁ@        - mould (swap @rguments) V like that length  [1,7]
          ,      - pair that with (the modified) V            [[1,7],[[3,3,8,1]]
            ”-   - literal '-' character
           j     - join                                       [1,7,'-',[3,3,8,1]]
              F  - flatten                                    [1,7,'-',3,3,8,1]
               Ṛ - reverse                                    [1,8,3,3,'-',7,1]
                 - implicit print                             1833-71


Convert Complex Chinese Numbers into Arabic Numbers Your task is to convert Chinese numerals into Arabic numerals.
A problem similar to Convert Chinese numbers, however, more complex. Also, answers given there mostly don't satisfy all the conditions.
Chinese digits/numbers are as follows:
0 零 1 一 2 二 2 两 3 三 4 四 5 五 6 六 7 七 8 八 9 九 10 十 100 百 1000 千 10000 万 10^8 亿
Multiple-digit numbers
Multiple-digit numbers are created by adding from highest to lowest and by multiplying from lowest to highest. In case of additions, each number higher than 9 can be multiplied by 1 and it won't change its meaning. Both 亿万千百十一 and 一亿一万一千一百一十一 are equal to 100011111.
We multiply in the following fashion: 五千 = 5000 一百万 = 1000000 三千万 = 30000000.
Chinese always takes the lowest possible multiplier (just like we don't say hundred hundred but ten thousand). So 百千 doesn't exist to represent 100000 since we have 十万, 十千 doesn't exist since we have 万, 十千万 doesn't exist, since we have 亿, 十百 doesn't exist, since we have 千.
Special cases
0 is very important and it was actually the biggest problem in the other code golf question. Trailing zeroes are omitted in Chinese, so 零 indicates interior zeroes.
Let's look at some examples:

三百零五 = 305
三百五 = 350 - no interior zeroes. You can notice that we don't need 十 here, since a trailing zero is omitted.
一千万零一百 = 10000100
三千零四万 = 30040000
六亿零四百零二 = 600000402 - here we have 2 interior zeroes. As you can see though, even if there's a gap of more than one order of magnitute (in the example it's 亿 and 百), two 零s can't stand next to each other, one is enough for each gap, no matter how big it is.
一亿零一 = 100000001 - again, no need for more than one 零 if there's one gap, no matter how big.
八千万九千 = 80009000 - no need for 零 since there are no interior zeroes. Why are there no interior zeroes? Because it follows the highest-to-lowest addition without omitting an order of magnitude. Right after 万 we have 千 (九 is a multiplication component, not addition one) and not, let's say, 百.

More examples: Check out the two "示例" paragraphs
2 is also special in Chinese as it can be represented with a character 两 if it's a multiplier of 100 and higher numerals. Both 两千两百二十二 and 二千二百二十二 are 2222.
Rules
Constraints: 0 <= N < 10^9
Edit: I don't care what happens from 10^9 onwards. Input doesn't have any examples equal or higher than 10^9 for that reason.
Test cases
Input:
一亿两千三百零二万四千二百零三
四千万零一十
三十四万五千五
四亿二十万零九百零一
两千万九千零一十
二十四万零二百二十二
两千零十二
零

Output:
123024203
40000010
345500
400200901
20009010
240222
2012
0

Good luck!

05AB1E, 52 51 bytes

0•9∊»£¬ƵçoiKβÐg•19вIÇƵª%èvX¨UOy¬iθ°UX‰¤_ªX*]DgiX*}O

Try it online!

0                              # literal 0
 •9∊»£¬ƵçoiKβÐg•19в            # compressed list [2, 14, 0, 3, 0, 8, 0, 6, 2, 9, 0, 18, 0, 1, 0, 13, 5, 0, 10, 0, 0, 7, 12, 4]
                   IÇ          # codepoints of the input
                     Ƶª%       # modulo 270
                        è      # index into the above list, with wraparound
v                 ]            # for each number y in that list:
 X                             #  push the variable X
  ¨                            #  drop the last digit
   U                           #  store that in X
    O                          #  sum all numbers on the stack
     y                         #  push y
      ¬i          ]            #  if the first digit of y is 1:
        θ°                     #   10**(the last digit of y)
          U                    #   store that in X
           X‰                  #   divmod X
             ¤_ª               #   if the modulo is 0, append 1
                X*             #   multiply by X
Dgi  }                         # if length of the top of stack is 1:
   X*                          #  multiply it by X
      O                        # sum of the stack
                               # implicit output


Given a string and integer n, split the string at n characters, and print as follows: Given a string and integer n, split the string at n character, and print as follows:
Ex)

laptop 3 should print lap top

laptop 2 should print la pt op (see how it splits the string at every 2nd char)

Special cases:

laptop 0 should print laptop (since we split at every 0th char, thus none)

laptop 9 should print laptop (since length of laptop < 9, so no splitting)

bob 2 should print bo b (we split at the o (2nd char), but then there aren't enough characters after, so we just leave as is`

You may assume n >= 0

Japt, 7 bytes

òVªLl)¸

Test it online!

Explanation

            Implicit: U, V = inputs
UòV   )     Split U into slices of length V.
   ªLl      If V is 0, instead use 100! (roughly 9.3326e+157).
       ¸    Join with spaces.
            Implicit: output result of last expression

9.3326e+157 is far larger than JavaScript's max string size of 9.0072e+15, so this will work for any input.


Help Pac-Man count the Pac-Dots On the advice of Ms. Pac-Man who's worried about him getting overweight, Pac-Man has decided to keep track of his daily Pac-Dot intake. Help him count the number of Pac-Dots on a given path in the maze!
The maze

To help you build your own encoding of the maze, you can get some raw data here.
Pac-Man's journey
In the context of this challenge, the following rules apply:

First, the good news: the ghosts aren't there.
Pac-Man always starts his race at the position indicated on the above picture, heading to the East. There is no Pac-Dot at the starting position.
As long as he's following a straight path, he keeps advancing to the next squares.
When he encounters a 90° turn without any other available path (orange squares on the map), he automatically and systematically takes the turn.
When he encounters a junction where several paths are available (green squares on the map), he may either continue on the same direction -- if applicable -- or choose another direction (including doing a U-turn).
When Pac-Man passes through one of the exits on the middle left or middle right side of the maze, he immediately reappears on the opposite side.
Pac-Man eats all the Pac-Dots on the path he's following. Once a Pac-Dot has been eaten, it is removed from the maze.

The challenge
Input
You'll be given a string describing Pac-Man's behavior on the junctions that he's going to reach. This string will be made of the following characters:

L: do a 90° turn to the left
R: do a 90° turn to the right
F: go forwards (no direction change)
B: go backwards (do a U-turn)

When all characters have been processed, Pac-Man stops at the next junction he encounters.
Output
You have to print or output the number of Pac-Dots eaten along the input path.
Rules

You can write a full program or a function.
You can take input in either uppercase or lowercase, as either a string or an array of characters. You may also use other characters (but only one character per direction) or integers in [0 .. 9]. If you do so, please specify it clearly in your answer.
You can assume that the input is always valid. (The jsFiddle below will detect errors, but you're not supposed to.)
This is code-golf, so the shortest code in bytes wins.
Standard loopholes are forbidden.

Hint
It may not be required nor optimal to store the exact shape of the maze.
Test cases and demo
The following test cases -- or any other input -- can be tested in this jsFiddle.
1. Input  : ""
   Output : 1
   Comment: Pac-Man just advances to the first junction, eats the Pac-Dot on it and stops.

2. Input  : "L"
   Output : 7

3. Input  : "FFR"
   Output : 13

4. Input  : "LFLR"
   Output : 17
   Comment: Pac-Man will exit on the middle right side and re-appear on the left side.

5. Input  : "BBBB"
   Output : 2

6. Input  : "BRRFFFL"
   Output : 15

7. Input  : "LFFRLFFFFRF"
   Output : 50

8. Input  : "BRFRLRFRLFR"
   Output : 54
   Comment: Pac-Man will exit on the middle left side and re-appear on the right side.

9. Input  : "FFLRLFFLLLLFFBFLFLRRRLRRFRFLRLFFFLFLLLLFRRFBRLLLFBLFFLBFRLLR"
   Output : 244
   Comment: All cleared!