Binary Countdown Length inspired by Count down from infinity

Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0:

Convert N to binary (4812390 -> 10010010110111001100110)
Flip each bit (10010010110111001100110 -> 01101101001000110011001)
Trim leading zeroes (01101101001000110011001 -> 1101101001000110011001)
Convert back to decimal (1101101001000110011001 -> 3576217)

Rules

Input and output may be in any unambiguous, consistent format
The input will be within the native representable integer range for your language (if your language supports arbitrarily-large integers, there is no bound)

Test Cases

0 -> 0
1 -> 1
42 -> 6
97 -> 3
170 -> 8
255 -> 1
682 -> 10
8675309 -> 11
4812390 -> 14
178956970 -> 28
2863311530 -> 32

This sequence is A005811 in the OEIS.

Jelly, 6 4 bytes

^HBS

Try it online! or verify all test cases.

Background

Let n be a non-negative integer.

Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.

This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.

For n = 8675309, the process looks as follows in binary.

100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0

Instead of counting these groups (which would fail for edge case 0), we do the following.

n and n:2 have the following binary representations.

n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2

Note that n:2's binary representation is simply n's, shifted one bit to the left.

If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.

How it works

^HBS  Main link. Argument: n

 H    Halve; yield n:2.
^     XOR n with n:2.
  B   Convert the result to binary.
   S  Compute the sum of the resulting binary digits.


Convert number bases What your function must do:
be as short (in bytes) as possible
take 3 inputs that are strings: number , fromdigits, todigits
assume no digit is repeated in fromdigits or todigits
assume fromdigit and todigit contain only alphanumeric characters
assume number is a natural number
output (a string): number converted to frombase
examples:
convert("ff","0123456789abcdef","0123456789")="255"
convert("ee","fecdba9876543210","9876543210")="82"
example code (283 bytes, in python 3.4.1):

def convert(number,fromdigits,todigits):
    x=0
    for digit in str(number):
        x = x*len(fromdigits)+fromdigits.index(digit)
    res=""
    while x>0:
        digit = x % len(todigits)
        res = todigits[digit] + res
        x //= len(todigits)
    return res

Python - 101

To get started I basically golfed your example code...

def c(n,f,t,x=0,r=""):
 for d in n:x=x*len(f)+f.index(d)
 while x:l=len(t);r=t[x%l]+r;x//=l
 return r


Predict where the man will go A man lives in the north-west corner (0, 0) of a town with height h and width w . Everyday he walks from his home to the border (?, w) or (h, ?). In the following example, the man goes to (3, 3) today.

(0, 0) +--+  +  +  . (0, 4)
          |
       +  +--+--+  .
                |
       +  +  +  +  .
                |
(3, 0) .  .  .  .  . (3, 4)

The man records a bit at each points (+ in example above). Every time he reaches a point, he goes east if the bit is 1 and south otherwise. The bit is flipped after he leaves. For example:

Day 1: 1--0  1  1    Day 2: 0  1  1  1    Day 3: 1--1--1--1--  Day 4: 0  0  0  0
          |                 |                                         |
       0  1--0  0           0  0  1  0           1  0  1  0           1--0  1  0
             |              |                                            |
       1  0  1--0           1--0  0  1           0  1  0  1           0  1--0  1
                |              |                                            |
Destination: (3, 3)  Destination: (3, 1)  Destination: (0, 4)  Destination: (3, 2)

Given the size of the town and the man's record, calculate the man's destination after n days.

Input:

In the first line are three integers, h, w and n.

In the following h lines are w integers, denoting the man's record.

h <= 1000, w <= 1000, n <= 1000000000

Output:

Two integers, denoting the man's destination after n days.

Sample Input:

3 4 3
1 0 1 1
0 1 0 0
1 0 1 0

Sample Output:

0 4

Sample Code:

#include <iostream>
using namespace std;
bool d[1000][1000];
int main(){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> d[i][j];
    int i, j;
    while(n--)
        for(i = 0, j = 0; i < h && j < w;){
            bool &b = d[i][j];
            d[i][j] ? j++ : i++;
            b = !b;
        }
    cout << i << " " << j << endl;
}

Scoring:

Lowest byte count in UTF-8 wins.
If the running time of your code is independent of n, reduce your score by 50%.

Don't just calculate the results of all 1000000000 days or do anything similarly stupid to get this bonus. Find an efficient algorithm!

Python 2, 192 bytes * 0.5 bonus = 96
To solve this problem efficiently, the key realization is that we can compute how many times each cell is visited based on the number of times the cells above and to the left are visited, without needing to determine the exact paths taken. Effectively, we simulate n trips at once and keep track of how many times each cell is used.
Substantial improvement due to push-based approach inspired by johnchen902's solution:
r=lambda:map(int,raw_input().split())
h,w,n=r()
v=[n]+w*[0]
x=y=0
for i in range(h):
 for j,b in enumerate(r()):
    if i-x==j-y==0:d=v[j]&1^b;x+=d;y+=1^d
    f=v[j]+b>>1;v[j]-=f;v[j+1]+=f
print x,y

Previous, pull-based implementation:
r=lambda i:map(int,raw_input().split())
h,w,n=r(0)
x=range(h)
g=map(r,x)
v=[w*[0]for i in x]
v[0][0]=n-1
for i in x:
 for j in range(w):v[i][j]+=(i and(v[i-1][j]+(1^g[i-1][j]))/2)+(j and(v[i][j-1]+g[i][j-1])/2)
i=j=0
while i<h and j<w:f=g[i][j]^v[i][j]&1;j+=f;i+=1^f
print i,j

Original, ungolfed version:
h, w, n = map(int, raw_input().split())
grid = [map(int, raw_input().split()) for i in xrange(h)]

# Determine the number of times each cell was visited in the first n-1 trips
visits = [[0]*w for i in xrange(h)]
visits[0][0] = n-1
for i in xrange(h):
    for j in xrange(w):
        if i:
            # Count visits from above cell
            visits[i][j] += (visits[i-1][j] + (not grid[i-1][j])) // 2
        if j:
            # Count visits from left cell
            visits[i][j] += (visits[i][j-1] + grid[i][j-1]) // 2

# Flip the bits corresponding to each cell visited an odd number of times
for i in xrange(h):
    for j in xrange(w):
        grid[i][j] ^= visits[i][j] & 1

# Figure out where the final trip ends
i = j = 0
while i < h and j < w:
    if grid[i][j]:
        j += 1
    else:
        i += 1

print i, j


Return the clock emoji closest to the current time when run I can have a large if/else condition for each 30 minutes but I'm looking for more math and Unicode based solution.

Here are clock emojis:
. If you lack proper rendering support, you can see them below (they're not in the same order and they may look different to what you see) or at the Unicode chart, page 4. They correspond to Unicode codepoints U+1F550 (CLOCK FACE ONE OCLOCK) through U+1F567 (CLOCK FACE TWELVE-THIRTY).

Your challenge is to write a program that outputs to STDOUT the closest clock face emoji to the current system time (AM and PM should be treated the same). For example if the time t is [5:15 < t < 5:45), you would display the 5:30 emoji .

This is code-golf, so shortest code in bytes wins. You may want to include a way to easily specify the time to test your code.

Edge test cases

Time   Output  Written
----------------------
11:48         12:00
3:15          3:30
9:45          10:00

Ruby — 61 54 bytes
Python 3 — 79 77 75 74 bytes
edit: Turns out this is much shorter in Ruby, because Time doesn't need to be imported and integer division is the default.
a=(Time.now.to_i/900-3)/2%24
puts""<<128336+a/2+a%2*12

Arithmetic:

Time.now.to_i: Seconds since epoch.
/900: Combine time into 15-minute segments.
-3: -4 because characters start at 1 o'clock, +1 so that rounding is done to nearest half hour, rather than downwards.
/2: Combine into half-hour segments.
%24: Get current half-hour segment out of 12 hours.
a/2 + a%2*12: Account for the fact that whole-hour characters come in a block before half-hour characters.

Local time version, 69 bytes:
n=Time.now
a=((n.to_i+n.gmtoff)/900-3)/2%24
puts""<<128336+a/2+a%2*12

Original Python 3 version:
import time
a=int((time.time()/900-3)/2%24)
print(chr(128336+a//2+a%2*12))

Prints the current time UTC. Python 2's chr only accepts 0-255, and unichr only 0-65535. In Python 3, / is always floating-point division and // is always integer division.


Pi Calculation Code Golf The Challenge

You must calculate pi in the shortest length you can. Any language is welcome to join and you can use any formula to calculate pi. It must be able to calculate pi to at least 5 decimal places. Shortest, would be measured in characters. Competition lasts for 48 hours. Begin.

Note: This similar question states that PI must be calculated using the series 4 * (1 – 1/3 + 1/5 – 1/7 + …). This question does not have this restriction, and in fact a lot of answers here (including the most likely to win) would be invalid in that other question. So, this is not a duplicate.

Python3, 7

Runs in the interactive shell

355/113

Output: 3.1415929203539825, correct to 6 decimal places

And finally I have a solution that beats APL!

Oh, and in case you are wondering, this ratio is called the 密率 (literally "precise ratio"), and is proposed by the Chinese mathematician Zu Chongzhi (429-500 AD). A related wikipedia article can be found  here. Zu also gave the ratio 22/7 as the "rough ratio", and he is known to be the first mathematician to propose that 3.1415926 <= pi <=3.1415927


Detect the character encoding of the input Your task is to golf a program that prints which character encoding, if any, the data read from the input represents. It should be able to detect the following encodings:

ASCII
ISO 8859-1
UTF-8
UTF-16

One of the above names of character encodings should be printed (in the same way) if it can be determined which is used. If the input is not ASCII, but it's ambiguous which of the other encodings is used, a ? should be printed. If none of the encodings can be valid, X must be printed.

Furthermore, the following should be taken into account:

If the input is valid ASCII, ASCII should be printed. Even though this means the other encodings are also valid. When the input is not ASCII, ? should printed in case of any ambiguity.
The UTF's are not required to start with a BOM.
UTF-16 can be either big or little endian. This means there are actually five different encodings to detect.
If UTF-8 or UTF-16 data encodes a number between 0 and 0x10FFFF you may consider it valid, even if it represents a Unicode code point that is technically not allowed in this encoding. Therefore you do not have to worry about unassigned code points and such.
ISO 8859-1 is considered invalid when any of its undefined bytes (positions 0-31 and 127-159, except 9, 10 and 13) are used.
This is code golf.

Happy golfing!

Tcl, 247

set i [read [open f rb]];foreach n\ d {ascii ASCII utf-8 UTF-8 unicode UTF-16 iso8859-1 ISO\ 8859-1} {if {[encoding convertt $n [encoding convertf $n $i]]eq$i&&($n!="iso8895-1"||[regexp {[\1-\10\13\14\16-\37\177-\237]} $i])} {puts $d;exit}};puts X

Reads the input from the file f in the current directory.

It works by decoding and re-encoding the input into the different charsets and check if the input and the re-encoded input is equal.

I believe that valid UTF-8 is also valid (but useless) ISO 8859-1, so I print UTF-8 then.


ASCII Airplane Banner Given two inputs -- one of them a non-empty printable ASCII string (including space, excluding newline), the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.) -- output an ASCII art airplane banner of the string, pointing either left or right. For consistency, I'll be using left and right throughout this challenge description.

The plane is either |-DI>-/ (left) or \-<ID-| (right). Since the banner is clear, it consists of the input string's characters separated by spaces, either left-to-right (left) or right-to-left (right), and surrounded by a box of the shape

    /--/
---<  <
    \--\

or

\--\
 >  >---
/--/

Note there must be one space between the beginning/end of the message and the >,< characters.

For example, here is the message HAPPY BIRTHDAY! and the direction left:

           /-------------------------------/
|-DI>-/---< H A P P Y   B I R T H D A Y ! <
           \-------------------------------\

Here is the message PPCG and the direction right. Note that the letters appear "backwards" when viewed from this side of the banner:

\---------\
 > G C P P >---\-<ID-|
/---------/

Rules

Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
If possible, please include a link to an online testing environment so other people can try out your code!
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.


Smallest positive number whose y-th power is divisible by x Task

Given integers x and y which are both at least 2, find the smallest positive number whose y-th power is divisible by x.

Example

Given x=96 and y=2, the output should be 24 since 24 is the smallest positive n satisfying n^2 is divisible by 96.

Testcases

x  y output
26 2 26
96 2 24
32 3 4
64 9 2
27 3 3

Scoring

This is code-golf. Solution with lowest byte-count wins.

References

y=2: OEIS A019554
y=3: OEIS A019555
y=4: OEIS A053166
y=5: OEIS A015052
y=6: OEIS A015054

Brachylog, 19 17 16 15 12 bytes
2 bytes saved thanks to @LeakyNun.
:[I:1]*$r=#>

Try it online!
Explanation
               Input = [X, Y]
:[I:1]*        Get a list [X*I, Y] (I being any integer at this point)
       $r=     Get the first integer which is the Yth root of X*I
          #>   This integer must be strictly positive
               This integer is the Output


Writing erasable code My phone number (which I will not be sharing here) has a neat property where there is a two digit number, which when iteratively removed from my phone number will eventually remove all the digits.  For example if my phone number were
abaababbab

Then by repeatedly removing ab we would eventually get nothing (I encluse the string I am removing in brackets to make it clear)
abaababb[ab]
abaab[ab]b
aba[ab]b
ab[ab]
[ab]

Now to generalize this property lets have any string.  A "minimal eraser" of that string will be the smallest substring such that if iteratively removed it will eventually make the string empty.
Some examples at the bottom.
Task and Scoring
Warning: This challenge is not code-golf.  Do not assume it is without reading the scoring
Your challenge will be to take a string as input and output a minimal eraser of that string.
Your answers will be scored by taking them as a string of bytes and calculating that string's minimal eraser.  The length in bytes of that eraser is your score, with lower being better.
Your answer must support strings containing all printable ascii plus any characters that appear in your program.
Test cases
abaababbab -> ab
baababbab -> baababbab
baababab -> baababab
echoecho -> echo
ototoo -> oto
ibiibibii -> ibi
aabaabaa -> abaa / aaba

Python 3, score ... 48 29  20
+1,eval(bytes([57]))

A completely different approach from the last 2 versions (and also result in manageable generated program). Check out the revision history for some (possibly) interesting ideas.

Given an arbitrary Python program:
print(1)

it can be transformed, without changing the behavior:
exec("print(1)")

eval(rb'exec("print(1)")')

eval(bytes([101, 120, 101, 99, 40, 34, 112, 114, 105, 110, 116, 40, 49, 41]))

The number list is getting long, so I'll use a shorter list for demonstration. Note that only printable ASCII characters can appear in the string representation and the first character is e, so the first number is 101 and all numbers are at least 32.
eval(bytes([101, 32, 32]))

Rewrite the first number to 57+1+1+1+...+1+1+1, the rest into 9+1+1+...+1; then add some ,9 at the end of the list. This is always possible because of the conditions mentioned before, and the program's behavior is unchanged because the byte 9 is \t, a whitespace character.
eval(bytes([57+1+1+...+1, 9+1+1+...+1+1, 9+1+1+...+1, 9, 9,..., 9]))

The number of ,9 added must satisfy that the total number of 9s is equal to the number of +1.
Then replace all the 9 with eval(bytes([57]), and prepend +1,.
+1,eval(bytes([57+1+1+...+1,eval(bytes([57])+1+1+...+1+1,eval(bytes([57])+1+1+...+1,eval(bytes([57]),eval(bytes([57]),...,eval(bytes([57])]))

Done! It's easy to see that this string has the eraser string +1,eval(bytes([57]).

It's trivial to see that there exists a Python snippet that solves the given problem.

g=lambda s, e: not s or any(
	s[i:].startswith(e) and g(s[:i]+s[i+len(e):], e)
	for i in range(len(s)-len(e)+1))
f=lambda s: min((s[i:j] for j in range(len(s)+1) for i in range(j) if g(s, s[i:j])), key=len)
print(f(input()))

Try it online!


Solve a mathematical expression from alternating sides Create a program that solves a mathematical expression using the elements from alternating sides of the expression. The way it’s done is, instead of reading from left to right, you read the first character, then the last, then the second, then the second to last etc. This will give you a new expression that you must evaluate and output.

a*b/c+d-e
135798642  <-- Order you read the expression in
ae*-bd/+c  <-- Order of operation.

Example:

1*3/2+4-5
15*-34/+2 = -255

If the expression doesn’t «work», a 1 must be inserted in the necessary positions to make it work.

A few examples will probably illustrate it better:

Input: 1+1+1+1+1
Result: 23     // Because 1+1+1+1+1 -> 11++11++1 -> 23

Input: 1+2-3+12-5
Result: -19    // Because 1+2-3+12-5 -> 15+-22-13+ -> 15+-22-13+1 -> -19
               //                                 |
               //                                 Not valid expression

Input: 2*2*2*2*2
Result: 968    // Because 2*2*2*2*2 -> 22**22**2 -> 22*1*22*1*2 -> 968
               //                        ||  ||
               //                        Not valid, 1 must be inserted

Input: 17/2
Output: 127    // Because 17/2 = 127/ -> 127/1 -> 127

The operators that must be supported are + - * /. There won't be parentheses. Normal math rules and "syntax" is used, so for instance ** does not mean exponentiation. a++++1 is equivalent to a+1 (i.e. MATLAB style, not C++).

In case there's any doubt, some valid operations are:

-a
+a
a++b
a+-b
a*-b
a*+b
a*++b
a/b
a/-b
a/+b
-a/--b

While all of the following are not valid. It's shown what they should be substituted with:

a+      | a+1
a-      | a-1
a++++   | a++++1   (This is equivalent to a+1)
a*+++   | a*+++1   (This is equivalent to a*1)
a**b    | a*1*b
a*/b    | a*1/b
a/*b    | a/1*b
a*      | a*1
*a      | 1*a
***a    | 1*1*1*a

Rules:

The code can be a function or a full program
The input can be STDIN or function argument
The input must be a valid mathematical expression, without quotation marks, '' or "".
The output should be the answer to the new expression, as an integer, decimal or a simplified fraction.
At least three digits after the decimal point must be supported. So 1/3 = 0.333, not 0.33. 0.333333333 is accepted.
ans = ... is accepted.
Leading and trailing newlines and spaces are accepted.
The input will only be integers
Division by zero can result in an error, NaN, Inf etc. Outputting a number is not accepted.

As always, the shortest code in bytes win. A winner will be selected one week from the day the challenge was posted. Answers posted later may still win if it's shorter than the current leader.


Rebuild a rectangular array from a corner I once had a beautiful rectangular array. It was very symmetrical, but unfortunately it has fallen apart and now I only have the top left corner. Your task will be to rebuild the original array.

Your program will receive a 2 dimensional array of integers. For ease of parsing, you may assume they are all between 1 and 9. Your task is to reverse the array's columns, its rows, and both, stitch together the resulting corners, and return the resulting array.

You can assume the array dimensions will be at least 1x1.

Test cases:

Input:
1 2 3
4 5 6

Output:
1 2 3 3 2 1
4 5 6 6 5 4
4 5 6 6 5 4
1 2 3 3 2 1

Input:
1

Output:
1 1
1 1

Input:
9
9
9

Output:
9 9
9 9
9 9
9 9
9 9
9 9

This is code-golf, fewest bytes wins!

Canvas, 1 byte

╬

Try it here!

Outputs as a multiline string


Shortest code to post a string to WebServer In bash, this code posts String to post to http://www.example.com/target:

curl -d "String to post" "http://www.example.com/target"

NOTE: You should use http://www.example.com/target as the URL to POST to, without any change.

I think all other languages that I have knowledge in need a lot more code than this. I'm not blaming other languages. Let's see the interesting answers that reduce the effort.

Your task is to write the shortest code possible to send a POST request to a sample server, http://www.example.com/target, and the request data should be the string String to post.

Bash: 90 characters

No external tools, just pure bash.

echo 'POST /target HTTP/1.0
Content-length:14

String to post'>/dev/tcp/www.example.com/80


Non-overlapping Matrix Sum Given \$k\$ arrays of length \$n\$, output the maximum sum possible using one element from each array such that no two elements are from the same index. It is guaranteed that \$k\le n\$.
Input
A nonempty list of nonempty arrays of integers.
Output
An integer that represents the maximum sum.
Examples
Input -> Output
[[1]] -> 1
[[1, 3], [1, 3]] -> 4
[[1, 4, 2], [5, 6, 1]] -> 9
[[-2, -21],[18, 2]] -> 0
[[1, 2, 3], [4, 5, 6], [7, 8, 9]] -> 15
[[1, 2, 3, 4], [5, 4, 3, 2], [6, 2, 7, 1]] -> 16
[[-2, -1], [-1, -2]] -> -2

Jelly, 10 6 bytes

ZŒ!ÆṭṀ

Try it online!

(4 bytes saved by @Dennis, who pointed out that Jelly had a "sum of main diagonal" builtin. I was not expecting it to have one of those; the previous solution implemented the operation without using the builtin. The operation in question, Æṭ, is defined as "trace", but the trace is only defined for square matrices; Jelly implements a generalisation to rectangular matrices too.)

The improvement over the other answers is mostly from a simpler (thus terser to express) algorithm; this program was originally written in Brachylog v2 ({\p\iᶠ∋₎ᵐ+}ᶠot), but Jelly has some builtins for parts of the program that have to be spelled out in Brachylog, so this came out shorter.

Explanation

ZŒ!ÆṭṀ
Z            Swap rows and columns
 Œ!          Find all permutations of rows (thus columns of the original)
   Æṭ        {For each permutation}, take the sum of the main diagonal
     Ṁ       Take the maximum

It should be clear that for any solution to the problem, we can permute the columns of the original matrix to put that solution onto the main diagonal. So this solution simply reverses that, finding all possible main diagonals of permutations.

Note that the "permute the columns" operation is done as "transpose, permute the rows" without bothering to transpose back; the rest of the algorithm happens to be symmetrical about the main diagonal, so we don't need to undo the transpose and thus can save a byte.


We're all unique in our own way This is an answer-chaining challenge where every part of your answer should aim to be unique from every other answer.
This question will work in the following way:

I will post the first answer. The next answer will stem from that, and all other answers will originate from it.
In this answer I will include a program and specify three things:

The language the program is written in
The integer it outputs
The bytes the next program must use

The next user will then write an answer, and specify the same three things - the language they used, the integer they output and the bytes the next program must use
And so on, until the chain ends.

Each answer will do the following:

It will include a program, written in a language that hasn't been used by any previous answer.

The program outputs an integer, through one of our standard I/O formats, that no previous answer in the chain has outputted before. This integer must be deterministic and consistent between executions, and may be positive, negative or \$0\$.

It will take either no input, or an empty input if necessary, and will output nothing more than the integer to a standard output method (STDOUT, function return, Javascript's alert etc.)

It only uses the bytes allowed to it by the previous answer. It may use each byte as many times as it likes, but each byte must be used at least once.

The answer will specify a set of bytes (containing no duplicates) that the next answer must use. This set of bytes may not have been used by any previous answer, and can be any subset of the integers between \$0\$ and \$255\$. There must be a minimum of 1 and a maximum of 256 bytes in this subset, and the number of bytes must be unique of all existing answers (i.e. if one answer allows the next to use 120 bytes, no other answer may allow 120 bytes).

Through this, each new answer will determine how difficult (or easy) the next answer is; only allowing a small subset of bytes will make it substantially more difficult than if allowing a larger set. "Bytes" means that you may use languages with non-UTF-8 encodings, by simply taking the characters those bytes represent in that code page.
For the sake of fairness, the first answer (which I'll post) will have all 256 bytes available to it, so that the answers truly are unique in all the specified ways.
Scoring
Your score is the number of answers you have in the chain, with a higher score being better.
Formatting
Please format your answer in the following way:
# [N]. [Language], [# of bytes available] available bytes

    [program]

This outputs [output]

This uses the characters [characters/bytes], allowed by [previous answer](link)

The next answer may use the following bytes:

    [list of bytes]

Rules

You must wait an hour between posting two answers
You may not post two answers in a row
So long as they're unique, the language, integer and bytes are up to your choice
You are under no obligation to golf your code
You may submit either a full program or function
Different versions of languages (e.g Python 2 and Python 3) are not considered separate languages. As a general rule, if the only way the language names differ is by a version number, or if the languages are usually thought of as versions of each other, they are considered the same language.
You may use any language that wasn't specifically invented to answer this challenge
The chain ends when 14 days pass with no new answers being posted or after 256 answers have been posted (as no new byte sets will be available).

Good luck!

5. Retina 0.8.2 -m, 8 available bytes
The code is given as three separate files. Here are their hexdumps:
00000000: 002a 0f2a 062a 092a 042a 142a            .*.*.*.*.*.*
00000000: 4545 4545 4545                           EEEEEE
00000000: 45                                       E

This outputs 6. Try it online!
The first file uses bytes 0, 15, 6, 9, 4, 20, and 42, and the other two files consist entirely of E (byte 69), covering the list specified by the previous answer.

Normally, Retina takes patterns and replacements in a single file separated by newlines, but we don't have newlines available. Fortunately, Retina 0.8.2 still makes available the language's original multi-file code format.* This program has two stages, a replacement stage and a count stage:

Find all regex matches of _*_*_*_*_*_* in the input, where _ represents the various unprintable characters. Since the input is empty, this matches once. Replace that match with EEEEEE.
In the resulting string, count the number of matches of E (six).

* IIRC, Retina was originally designed this way to take advantage of a PPCG scoring loophole. Now I'm using it to take advantage of a different kind of loophole. Seems appropriate.

The next answer may use the 54 bytes whose codepoints are prime numbers:
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,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251


Build a Simple Roguelike This challenge is based on one proposed on the usenet group rec.games.roguelike.development a few years ago.  I can't find the original newsgroup post, but you can have a look a the Github repo of solutions.  It was only golfed in a couple of languages and I'd love to see some more!

Objective

The aim is to build a program that presents a top-down view of a dungeon using ascii characters.  There will be an @ sign representing the player that can be moved through the free space in the dungeon (represented by ), though it cannot pass through the walls (represented by #).

The map of the dungeon must look like this:

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

The player must begin at location {2,2}, where {0,0} is the top left-hand corner.

Interface

The user needs to be able to move the player in the four cardinal directions using the arrow keys on the keyboard.

There needs to be some way for the user to exit the program.  It does not need to be a graceful exit (for example, it doesn't matter if an exception is printed).

The map and player need to be drawn before any input has been taken, and the player needs to be updated after each input.

Libraries

Feel free to use established libraries for console input or output, such as Curses.  Just mention in your answer what you are using.

Scoring

This is code golf, shortest code wins!

C, 257 253 222 220

Uses system("cls") instead of curses (use system("clear") for Linux systems) and a clever algorithm to fit the map into an 8-digit number. Non-extended keys end the program, e.g. escape.

EDIT: Now also shows your hero below the map by using a<230 instead of a<132:

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

Code:

a,p=14,w=11,X,Y;m(I){X=I%w-1,Y=I/w;return 70313263>>(Y>5?w-Y:Y)*5+(X>4?9-X:X)&1;}main(){do{system("cls");a=a&4?1:a&2?-1:a&8?-w:w;p+=!m(p+a)*a;for(a=0;++a<230;)putch(a%w?a-p?m(a)*35:64:10);}while(a=getch()>>7?getch():0);}


Are there brackets in disguise? Someone's given us a string, but all bracket-like characters have been changed into normal ones, and we don't know which, or even how many there were. All we know is that if L1,L2,L3,...,LN were different kinds of left brackets and R1,R2,R3,...,RN were different corresponding kinds of right brackets, all being distinct (2N distinct bracket characters), a string would be valid iff it is one of (+ is normal string concatenation):

L1+X+R1,L2+X+R2,...,LN+X+RN, where X is a valid string,
X+Y, where X and Y are valid strings,
Any single character that is not a bracket character.
The empty string

We know they started out with a valid string before they changed the brackets, and they didn't change them into any characters that already existed in the string. At least one pair existed for each bracket as well. Can you reconstruct which characters were originally left and right bracket pairs (find the Li and Ri following the given conditions)?

Output the pairs of characters that were brackets. For example, if (){}[] were actually bracket characters, you might output (){}[] or {}[]() or [](){}, etc. There may be multiple ways to do this for a string, you only need to return one such that there is no bracket assignment with more pairs (see examples). Note that the output string should always have an even length.

Examples:

abcc - c cannot be a bracket, since there is no other character with two occurrences, but ab can be a bracket pair, so you would output exactly ab.

fffff - any string with at most one character cannot have brackets, so you would return the empty string or output nothing.

aedbedebdcecdec - this string cannot have any brackets because there is 1 a, 2 bs, 3 cs, 4 ds, and 5 es, so no two characters occur the same number of times, which is a requirement to have brackets.

abcd -  possible assignments are ab, cd, abcd, cdab, adbc, bcad, ac, ad, bc and bd, (as well as the empty assignment, which all of them have) but you must return one of the longest assignments, so you must return abcd, cdab, adbc, or bcad.

aabbcc,abc - these both have ab, ac, and bc as valid pairs. You must return one of these pairs, doesn't matter which.

abbac - a and b have the same character count,  but they can't actually work, since one of them occurs to both the left and right of all occurrences of the other. Return nothing.

aabcdb - cd and ab are the exact two bracket pairs, so output either cdab or abcd.

abcdacbd - only one pair can be achieved at once, but ab,ac,bd,cd, and ad are all of the possible pairs you can return. No matter which pair you choose, it has an instance where a single other character is within it, which prohibits any other pairs, except in the case of ad, where the other pairs bc and cb are not possible alone either, and so can't be possible with ad.

This is code golf, so shortest code in bytes wins. Input is from STDIN if possible for your language. If it isn't possible, indicate the input method in your answer.

Ruby, 373 bytes

i=gets.chomp
b=[*(i.chars.group_by{|x|x}.group_by{|x,y|y.size}.map{|x|s=x[1].size
x[1][0...s-s%2].map{|x|x[0]}*''}*'').chars.each_slice(2)]
puts [*[*b.size.downto(1).map{|n|b.combination(n).map{|t|[t*'',(h=Hash[t]
s=[]
o=1
i.each_char{|c|s.push(c)if h.keys.include?c
(o=false if s.empty?||!h[s.pop].eql?(c))if h.values.include?c}
o ?s.empty?: o)]}}.find{|x|x[0][1]}][0]][0]

This uses a golfed version of the stack parser here.

It can probably be simplified further, but I don't think my brain can handle any more.

All test cases: http://ideone.com/gcqDkK

With whitespace: http://ideone.com/pLrsHg

Ungolfed (mostly): http://ideone.com/oM5gKX


Program which behaves differently in/out of a debugger The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.

For example, the program may output something when being debugged but not output anything when not being debugged. Or output something different in each case. Or it may crash when being debugged but not crash when not being debugged. Or vice-versa.

Caveats and clarifications:

Timing differences do not count.
Interpreted languages are permitted.
To emphasize determinism: the behaviour must be exactly reproducible both in and out of debugging context.
The presence of the debugger itself should the only difference between the two cases.

Telling the debugger to add inputs (stdin or argv ENV or whatever) is cheating, the debugger should run the program "as-is".
Changing the environment (e.g. running in a virtual machine or different OS, or changing OS settings such as memory limits) between debug and non-debug runs is not permitted.

Shortest code wins. I may award a bounty which reveals something interesting about how debuggers work.

x86 and x64_64 machine language on Linux and OSX, 1 byte

0x0:  CC    int3

Try it online!

int 3 throws a SIGTRAP which will cause a debugger to stop as if it encountered a breakpoint. Outside of a debugger, the kernel terminates the process (thanks to @Ruslan for the correction).

C (gcc) (x86 Linux and OSX), 14 11 9 bytes

main=204;

Try it online!

The integer 204 corresponds to the int 3 instruction; the TIO link is the same as above.


Zeroes at end of \$n!\$ in base \$m\$ Related: Zeroes at the end of a factorial
Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$.
Or in other words: For given integers \$n\$, and, \$m\$. Calculate the integer \$p\$ which is the highest power of \$m\$ dividing \$n!\$: \$p \in \mathbb{N}_0\$ which holds \$ \left( m^p \mid n! \right) \land \left( m^{p+1} \nmid n! \right) \$. Here, \$n!\$ is the factorial of \$n\$ which equals to the product of all positive integers less than or equal to \$n\$. The value of \$0!\$ is \$1\$.
Input / Output

Two integers \$n\$, \$m\$.
One integer: How many zeroes at end of \$n!\$ in base \$m\$.

Rules

As code-golf, the shortest codes in bytes win.
Your program is required to support \$0\le n\le 1{,}000{,}000\$; \$2\le m\le 1{,}000\$ at least. The program should be able to output correct results for any inputs in above range with reasonable resource (typically, <1 minutes on a normal laptop).
As this question is only talking about integers. No floating point errors may allowed in your output. You may, however, output 3.0 when 3 is required. But 2.9999999999999996 is certainly not allowed.

Testcases
      n,    m -> output
      0,    2 -> 0
      1,    2 -> 0
      2,    2 -> 1
      3,    2 -> 1
      4,    2 -> 3
      9,    6 -> 4
     10,  100 -> 1
     80,  100 -> 9
      4,    8 -> 1
     15,   12 -> 5
     16,   12 -> 6
     39,   45 -> 8
    100,    2 -> 97
    100,    3 -> 48
    100,    4 -> 48
    100,    5 -> 24
    100,    6 -> 48
    100,    7 -> 16
    100,    8 -> 32
    100,    9 -> 24
    100,   10 -> 24
    100,   13 -> 7
    100,   36 -> 24
    100,   42 -> 16
    100,   97 -> 1
    100,  100 -> 12
1000000,    2 -> 999993
1000000,    3 -> 499993
1000000,    4 -> 499996
1000000,    6 -> 499993
1000000,    7 -> 166664
1000000,    8 -> 333331
1000000,    9 -> 249996
1000000,  999 -> 27776
1000000, 1000 -> 83332

Above \$n\$ is written in base 10. You are allowed to receive \$n\$ as an array of integers in base \$m\$ if you want.
Related OEIS
It is interesting that this question involve at least 14 sequences on OEIS. Maybe you can find out some helpful formula to solve this problem on it.
OEIS includes sequences for every \$2 \le m \le 16\$:

2: A011371
3, 6: A054861
4: A090616
5, 10, 15: A027868
7, 14: A054896
8: A090617
9: A090618
11: A064458
12: A090619
13: A090620
16: A090621

Also, by treating above sequences as a matrix, there are other related sequences:

A090622: Square array read by antidiagonals of highest power of k dividing n! (with n,k>1).
A098094: T(n,k) = greatest e such that k^e divides n!, 2<=k<=n (triangle read by rows).
A011776: a(1) = 1; for n > 1, a(n) is defined by the property that n^a(n) divides n! but n^(a(n)+1) does not.

Wolfram Language (Mathematica), 22 bytes
#!~IntegerExponent~#2&

Try it online!


Tips for golfing in Husk Husk is a quite new golfing language, created by PPCG users Leo and Zgarb. It has begun being more and more competitive, often staying close or even beating languages known to be very terse, such as Jelly and 05AB1E.

Let's list some of the golfing techniques that are somewhat specific to Husk. As always, please post one tip per answer.

Use the return value from predicates

In Husk, functions that test their inputs for some property will usually return a meaningful result in truthy cases, as any positive integer is truthy.

Examples:

≠  Numbers: Absolute difference
   Chars:   Absolute difference of code points
   Lists:   First Index where the differ

Comparisons <, >, ≤, ≥:

For strict comparisons:
Numbers,Chars:  max 0 (the appropriate difference¹)
Lists: The first index where the comparison between the two lists is true

For non-strict comparisons:
Numbers,Chars: max 0 (the appropriate difference + 1)
Lists: Either the result of the strict comparison or, if they are equal,
       the length of the list + 1

ṗ  Index into the list of prime numbers

V  The index of the first element for which the condition is true

€  The first index of that element/substring in the list

£  Works like €

&  Given two arguments of the same type will return the second argument if false,
   otherwise will return the first argument

|  Given two arguments of the same type will return the second argument if true,
   otherwise will return the first argument

¦  Return the quotient if divisibility holds

Λ,E,Ë  Will all return length+1 in truthy cases

Char predicates:
□,±,√,D,½  will each return the codepoint of its argument on truthy cases

¹ appropriate difference means difference of code points for chars. It also refers to the argument order. i.e For <x y, would be x-y


Search for files on your computer Task
Write some code that will walk through the entire file-system tree and collect details from file-names, folder-names, text files etc to form a tag-group. This tag group, when searched in (user input) should point to the folders they are located in.
Rules

Any Language (standard libraries only).
Any kind of output (should be legible).
You may extend your code by reading more file-types and their metadata.
Regex is allowed

You'll win

+14 points for the shortest code (will be taken away when some else beats the record)
+6 for each added functionality (anything you could possibly claim).
-2 for each byte exceeding 1024 byte mark.

Example
Python (using os module - os.walk)

input
Enter search term below
>>> *camp*

output
Total results for *camp* = 2
-------------------------------
Camping.avi       - "C:\Users\Amelia\Videos\Summer Camping"
Campus party.avi  - "C:\Users\Public\Campus"

BASH, 14 + 6*18 = 122

Cheap, but a win.

locate

Example:

boothby@not ~ $ locate camp
/home/boothby/Desktop/kodak/Pictures/camp.jpg
/home/boothby/Desktop/kodak/Pictures/camp2.jpg
/home/boothby/Downloads/sage-5.12/local/share/doc/networkx-1.7.dev_20131124172629/examples/graph/napoleon_russian_campaign.py
/usr/src/linux-headers-3.8.0-19/arch/arm/plat-samsung/include/plat/camport.h
/usr/src/linux-headers-3.8.0-33/arch/arm/plat-samsung/include/plat/camport.h

Feature: this is super efficient since it caches the file information in a database.  The above runs on my computer in 0.187s.

... and 17 additional features:

   -b, --basename
          Match only the base name against the specified  patterns.   This
          is the opposite of --wholename.

   -c, --count
          Instead of writing file names on standard output, write the num‐
          ber of matching entries only.

   -d, --database DBPATH
          Replace the default database with DBPATH.  DBPATH is  a  :-sepa‐
          rated  list of database file names.  If more than one --database
          option is specified, the resulting path is  a  concatenation  of
          the separate paths.

          An empty database file name is replaced by the default database.
          A database file name - refers to the standard input.  Note  that
          a database can be read from the standard input only once.

   -e, --existing
          Print  only  entries  that  refer  to files existing at the time
          locate is run.

   -L, --follow
          When checking whether files exist (if the --existing  option  is
          specified),  follow trailing symbolic links.  This causes broken
          symbolic links to be omitted from the output.

          This is the default behavior.  The  opposite  can  be  specified
          using --nofollow.

   -h, --help
          Write  a summary of the available options to standard output and
          exit successfully.

   -i, --ignore-case
          Ignore case distinctions when matching patterns.

   -l, --limit, -n LIMIT
          Exit successfully after finding LIMIT entries.  If  the  --count
          option  is  specified,  the  resulting  count is also limited to
          LIMIT.

   -m, --mmap
          Ignored, for compatibility with BSD and GNU locate.

   -P, --nofollow, -H
          When checking whether files exist (if the --existing  option  is
          specified),  do not follow trailing symbolic links.  This causes
          broken symbolic links to be reported like other files.

          This is the opposite of --follow.

   -0, --null
          Separate the entries on output using  the  ASCII  NUL  character
          instead  of  writing each entry on a separate line.  This option
          is designed for interoperability with the --null option  of  GNU
          xargs(1).

   -S, --statistics
          Write  statistics  about  each  read database to standard output
          instead of searching for files and exit successfully.

   -q, --quiet
          Write no messages about errors  encountered  while  reading  and
          processing databases.

   -r, --regexp REGEXP
          Search  for  a  basic regexp REGEXP.  No PATTERNs are allowed if
          this option is used, but this option can be  specified  multiple
          times.

   --regex
          Interpret all PATTERNs as extended regexps.

   -V, --version
          Write  information  about  the  version and license of locate on
          standard output and exit successfully.

   -w, --wholename
          Match only the whole path name against the specified patterns.

          This is the default behavior.  The  opposite  can  be  specified
          using --basename.


Multiply without multiplying, without loops either Make a function, method, program or routine that will accept two interger parameters (say x and y) and the total of the two values multiplied. Except straight multiplication is not allowed so you must not simply do something like:

int multiply (int x, int y) {
    return x*y;
}

Also you must not use a for () loop, like this:

int multiply (int x, int y) {
    int z = 0;
    for (int i = 0;i < y; i++){
        z += x;
    }
    return z;
}

Everything else is up to you. A winner is you with the most compact solution.

Mathematica, 12 bytes

Exp@*Tr@*Log

Pure function taking a list of numbers (even complex numbers) as input and returning a number. Takes the logarithm of all the numbers in the list, adds them together, and exponentiates the result. Rules of exponents and logarithms ftw! (And because Mathematica calculates Log[0] as -∞ and can subsequently manipulate that symbolically, it arrives at the correct answer if one input number equals 0.)

Mathematica, 24 bytes

Tr[1^Flatten@Array[,#]]&

Pure function taking a list of nonnegative (unfortunately) integers as input and returning their product. Simply creates an array of the appropriate dimensions and counts the number of entries (using Tr[1^...] as a golfy shorthand for Length@...). Since we don't care what's actually in the array, we can fill it with Nulls using Array[,#], which doesn't cost any bytes for the first argument.


Laplace transform of a polynomial Your goal is to write a program that will print out the Laplace transform of a polynomial function with integer coefficients \$f(x)\$. The Laplace transform of \$f(x)\$ is defined as \$\int_0^\infty f(x) e^{-sx} dx\$.
The standard input for the polynomial function will be
a+bx+cx^2+dx^3+...

If the coefficient is zero, that term is omitted. It can be taken in from any standard type of input.
This is valid input: 1+x^2-5x^4+20x^5
These aren't:
0
1+0x
1+x^1
x^0+x

You may output from any standard type of output, in any readable order. Trailing newline is permitted.
No using built in evaluation functions.
Examples:
Input: 1
Output: 1/s

Input: 3-x
Output: 3/s-1/s^2

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

CJam, 57 bytes

l_"+-":Pf&sN+\PSerS/.{'^-'x/2We]"11".e|:~~:Em!*"/s^"E)+@}

Try it online in the CJam interpreter.


Fruit bagging factory Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags.
Each bag has to weight at least a certain amount, but any excess is lost profit since that weight could be used to fill another bag. Your bagging machine has always a lookahead of n fruits from the queue and may only choose to add any of these n fruits to the (single) bag that is being processed. It cannot look beyond the n first elements in the queue. The program always knows exactly how much weight there already is in the bag.
Another way to visualize this is having a conveyor belt with a loading area of size n at the end, from where a fruit has to be taken before a new fruit arrives. Any leftover fruit and a non-full bag at the end are discarded.

Inputs

List/array of weights of fruits in queue (positive integers)
Minimum total weight for bags (positive integer)
Lookahead n (positive integer)

Output
Your algorithm should return for all bags the weights of the fruits in them, by whatever means is convenient for you and your language, be that stdin or a return value or something else. You should be able to run the program and calculate your score in one minute on your computer.
Example
Total weight 1000, lookahead of 3 and fruit queue:
[171,163,172,196,156,175,162,176,155,182,189,142,161,160,152,162,174,172,191,185]

One possible output (indented to show how the lookahead affects the bagging):
[171,163,172,    156,175,    176]
                        [162,    155,182,189,    161,160]
                                                        [152,162,174,172,191,185]

Scoring
Your algorithm will be tested on six runs on a batch of 10000 oranges I have prepared for you, on lookaheads ranging from 2 to 7, inclusive on both ends. You shall pack them into bags weighing at least 1000 units. The oranges are normally distributed with a mean weight of 170 and a standard deviation of 13, if that is of any help.
Your score will be the sum of number of bags from the six runs. The highest score wins. Standard loopholes are disallowed.
Simple example implementation and test suite boilerplate in Haskell

Python 3, 9796 bags

Building on Jonathan's answer:

import itertools as it

def powerset(iterable):
    s = list(iterable)
    return it.chain.from_iterable(it.combinations(s, r) for r in range(len(s)+1))

def f(a,m,l):
 r=[];b=[]
 while a:
  c =  min(list(powerset(a[:l])),key=lambda w: abs(sum(b)+sum(w)-m))
  if sum(c)==0:
   c = a[:l]
  b+=[a.pop(a.index(min(c,key=lambda w: abs(sum(b)+w-m))))]
  if sum(b)>=m:r+=[b];b=[]
 return r

This relies on powerset from itertool's cookbook. First finds optimal subset of the buffer based on minimizing difference from target weight for all subsets, and then picks an element out of this subset based on same criterion. If no optimal subset selects from the whole buffer.


Railroad switch network Introduction

Suppose we have a network of railroads.
Each junction in the network is controlled by a switch, which determines whether an incoming train turns left or right.
The switches are configured so that each time a train passes, the switch changes direction: if it was pointing left, it now points right, and vice versa.
Given the structure of the network and the initial positions of the switches, your task is to determine whether a train can eventually pass through it.

This challenge was inspired by this article.

Input

Your input is a non-empty list S of pairs S[i] = (L, R), where each of L and R is an index of S (either 0-based or 1-based), in any reasonable format.
This includes a 2 × N matrix, an N × 2 matrix, two lists of length N, or a list of length 2N.

Each pair represents a junction of the network, and L and R point to the junctions that are reached by turning left and right from the junction.
They may be equal and/or point back to the junction i.
All junctions initially point left.

Output

A train is placed on the first junction S[0].
On each "tick", it travels to the junction that its current switch points to, and that switch is then flipped to point to the other direction.
Your output shall be a truthy value if the train eventually reaches the last junction S[length(S)-1], and a falsy value if is doesn't.

Example

Consider this network:

This corresponds to the input [(1,2),(0,3),(2,0),(2,0)]
The train travels the following route:

[0] -L-> [1] -L-> [0] -R-> [2] -L-> [2] -R-> [0] -L-> [1] -R-> [3]

Since the train reached its destination, the last junction, the correct output is truthy.

For the input [(1,2),(0,3),(2,2),(2,0)] we have the following route:

[0] -L-> [1] -L-> [0] -R-> [2] -L-> [2] -R-> [2] -L-> [2] -R-> ...

This time, the train got stuck in the junction 2, and will never reach the destination.
The correct output is thus falsy.

Rules and scoring

You can write a full program or a function, and the lowest byte count wins.
Consider skimming the article, as it may contain useful info for writing a solution.

Test cases

These have 0-based indexing.

[(0,0)] -> True
[(0,1),(0,0)] -> True
[(0,0),(1,0)] -> False
[(1,2),(0,3),(2,0),(1,2)] -> True
[(1,2),(0,3),(2,2),(1,2)] -> False
[(1,2),(3,0),(2,2),(1,2)] -> True
[(1,2),(2,0),(0,2),(1,2)] -> False
[(0,2),(4,3),(0,4),(1,2),(4,1)] -> True
[(4,0),(3,0),(4,0),(2,0),(0,4)] -> True
[(1,4),(3,2),(1,4),(5,3),(1,0),(5,2)] -> True
[(3,1),(3,2),(1,5),(5,4),(1,5),(3,2)] -> True
[(1,2),(5,0),(3,2),(2,4),(2,3),(1,6),(1,2)] -> False
[(4,9),(7,3),(5,2),(6,4),(6,5),(5,4),(3,2),(6,8),(8,9),(9,1)] -> False
[(2,7),(1,5),(0,8),(9,7),(5,2),(0,4),(7,6),(8,3),(7,0),(4,2)] -> True
[(4,9),(7,3),(3,2),(8,3),(1,2),(1,1),(7,7),(1,1),(7,3),(1,9)] -> False
[(0,13),(3,6),(9,11),(6,12),(14,11),(11,13),(3,8),(8,9),(12,1),(5,7),(2,12),(9,0),(2,1),(5,2),(6,4)] -> False
[(6,0),(1,2),(14,1),(13,14),(8,7),(6,4),(6,10),(9,10),(10,5),(10,9),(8,12),(14,9),(4,6),(11,10),(2,6)] -> False
[(1,3),(9,17),(5,1),(13,6),(2,11),(17,16),(6,12),(0,8),(13,8),(10,2),(0,3),(12,0),(3,5),(4,19),(0,15),(9,2),(9,14),(13,3),(16,11),(16,19)] -> True

CJam, 30 29 bytes

0l~_,m!{_2$=(@@2$+3$\t}*,(])&

Uses 0-based inputs and prints the index of the terminal node if the terminal node is ever reached.

This is super inefficient. You wouldn't want to test this on inputs with more than 10 nodes. The test link below uses 2\# instead of m! which isn't quite enough for all possible inputs, but it passes all test cases in a few seconds (and one would have try fairly hard to find a test case that doesn't pass).

Try it online!

Explanation

This doesn't have any loop or terminal detection. Instead we simply iterate the system often enough that we know we've hit a loop, recording the history, and then we check whether we've reached the terminal node at any point.

If we don't visit the terminal node, we only modify the states of N-1 nodes (if N is the total number of nodes). Each of the nodes has two different states, and the train can be on any one of those nodes (thanks to ais523 for pointing this out), so there are 2(N-1)*(N-1) different states we can visit before entering a loop or reaching the terminal node. Since we start from one of these states we know that after 2(N-1)*(N-1) transitions, we've either entered a loop or reached the terminal node.

That's a fairly lengthy expression. However, N! is almost never less than 2(N-1)*(N-1). In fact, the only N for which that's the case is 3, where the number of possible states is 8 and N! gives only 6. That said, it's not necessarily the case that it's possible to reach all theoretical states in any of the possible inputs. It's fairly easy to check this exhaustively: the neighbours of the last node are always irrelevant, so we can simply consider all inputs of the form [[a b] [c d] [0 0]] where at least one of abcd contains 2 (otherwise, the terminal state is guaranteed to be unreachable). There are only 65 of these states, and I ran them through a slightly modified program, which finds the first transition after which the terminal state is reached (or -1 if it's unreachable). As it turns out, it's impossible to construct an input which requires more than 6 transitions to reach the terminal state, just what we need. Hence, I'm using N! as the upper bound of iterations.

0      e# Push a zero. This is the initial node index of the train.
l~     e# Read and evaluate the input.
_,m!   e# Compute the factorial of N.
{      e# Run this block N! times.
  _    e#   Copy the list of LR pairs.
  2$=  e#   Copy the current node index and extract the corresponding pair.
  (    e#   Pull off the first neighbour - this is where the train moves next.
  @@   e#   Pull list of pairs and the list with the other neighbour on top.
  2$+  e#   Copy the first neighbour and append it. This effectively, reverses
       e#   the pair so that next time the other destination from the current
       e#   node is picked.
  3$   e#   Copy the current node again.
  \    e#   Swap it with the reversed pair.
  t    e#   Write the reversed pair back into the full list of pairs.
       e#   In summary, one iteration extracts the first neighbour of the
       e#   current node and leaves it on the stack, and swaps the neighbours
       e#   of that node for future visits.
}*     e# At the end, we've got all the reachable nodes on the stack, and
       e# the list of all pairs still on top.
,(     e# Compute N-1 from the list of pairs.
])     e# Wrap everything in a list and remove N-1 from it.
&      e# Compute the set intersection all reachable nodes with N-1.


Randomize the scalars of an array You must fill an array with every number from 0-n inclusive. No numbers should repeat. However they must be in a random order.
Rules
All standard code-golf rules and standard loopholes are banned
The array must be generated pseudo-randomly. Every possible permutation should have a equal probability.
Input
n in any way allowed in the I/O post on meta.
Output
The array of numbers scrambled from 0-n inclusive.

Perl 6, 14 bytes

{pick *,0..$_}

Try it

Expanded:

{           # bare block lambda with implicit parameter ｢$_｣

  pick      # choose randomly without repeats
    *,      # Whatever (all)
    0 .. $_ # Range from 0, to the input (inclusive)
}


Shortest, lexicographically smallest generating string A string x generates a string y if y is a substring of an infinite repeat of x.  For example abc generates bcabcab.

Write a program to find the shortest, lexicographically smallest string that will generate the input.  You are given on standard input a single line of text.  You should print the generating string to standard output.  For example:

input

bcabcabca

output

abc

Shortest code wins.  You may assume the input contains only the characters a-z (and a trailing newline if you want).

Ruby 1.9, 40 characters

gets;a=?a;a.next!until(a*~/$/)[$_];$><<a

Assumes the input is not terminated by a newline. Also it's probably ridiculously slow for larger results.

$ echo -n "bcabcabca" | ruby genlex.rb
abc
$ echo -n "barfoobarfoobarfoo" | ruby1.9 genlex.rb
arfoob


Tips For Golfing In Groovy As I have seen many questions asking tips for golfing in their interested language, I decided to ask for my favorite language: Groovy. People can give some tips and tricks that will be used in golfing with Groovy.

I'm new to this whole golfing thing, this is what I got so far:

Use Closures not functions:

def a(b){print b}

is longer than

a={print it}

You can use a negative index in arrays and lists as an alias for size()-

c = "abc"
d = ["a", "b", "c"]

assert c[c.size()-1] == c[-1]
assert c[c.size()-2] == c[-2]
assert d[d.size()-1] == d[-1]
assert d.last() == d[-1]

The spread operator is a shortcut for collect:

assert d*.size() == d.collect{it.size()}

For sorting use the spaceship operator:

e = [54,5,12]
assert e.sort{a,b->a<=>b}==e.sort{a,b->a<b?-1:+1}
assert e.sort{a,b->a<=>b}==e.sort{a,b->if (a>b) {return(-1)} else {return(+1)}}

Edit Conversions:

assert "123" as int == "123".toInteger()


What's my Body Mass Index? Problem:
Your task is to write a program that takes as input a height (in meters) and weight (in kilograms), and outputs the corresponding BMI category.
BMI is a measure of the ratio of your weight to your height. It's dated and inaccurate for many people, but that doesn't matter here!
BMI can be calculated using the following equation:
BMI = (mass in kilograms) / (height in meters)^2

The categories will be defined as follows:

BMI < 18.5: "Underweight"

18.5 <= BMI < 25: "Normal"

25 <= BMI: "Overweight"

For the sake of the challenge, I'm ignoring all the "extreme" categories. Also, since some numbers like "25" sit between 2 categories, I adjusted the bounds slightly so there's a definite answer.
You can write either a function, or a full program.
Input:
Input can be in any reasonable form. Two numbers (or strings), either as 2 separate arguments, or as a single string. An array/list of 2 numbers, a dictionary with "weight" and "height" keys... Decimal values should be supported. You can assume the input will always be valid (no negative values, and height will never be 0).
Output:
Output will be a string containing the case-insensitive category names. The strings must match the category names exactly as above, ignoring case. It can be output to the stdout, returned (in the case of a function), or written to file.
Test Cases (weight, height => result):
80, 1 =>   "Overweight"
80, 2 =>   "Normal"
80, 3 =>   "Underweight"

50, 1 =>   "Overweight"
50, 1.5 => "Normal"
50, 2 =>   "Underweight"

Edge Cases:

41, 1.5 => "Underweight" (18.2 BMI)
42, 1.5 => "Normal" (18.667 BMI)

56, 1.5 => "Normal" (24.889 BMI)
57, 1.5 => "Overweight" (25.3 BMI)

73, 2 =>   "Underweight" (18.25 BMI)
74, 2 =>   "Normal" (18.5 BMI)

99, 2 =>  "Normal" (24.75 BMI)
100, 2 => "Overweight" (25 BMI)

Here's some pseudocode that shows an example implementation:
function bmi_category(weight, height):
    var bmi = (weight / (height**2))

    if (bmi < 18.5):
        return "Underweight"

    if (18.5 <= bmi < 25):
        return "Normal"

    if (25 <= bmi):
        return "Overweight"

This is code-golf, so the fewest number of bytes wins.
(Yes, this task is exceedingly trivial in most languages. Most of the challenges lately seem to be harder than normal, so I thought I'd post a more accessible one).

NOTE! An hour after I posted this challenge, I had to modify the ranges slightly since the ranges as stated had "holes" as pointed out in the comments. Please see the new ranges.

Python, 69 bytes

lambda w,h:["UOnvd"[w/h/h>20::2]+"erweight","Normal"][18.5<=w/h/h<25]

Try it online!

Compare to 72 bytes:

lambda w,h:"Underweight"*(w/h/h<18.5)or"Normal"*(w/h/h<25)or"Overweight"


How can I shorten this python code? Here is the code which I want to shorten.

n=input()
while n:
 s=raw_input()
 x,r,g,b=(int(x) for x in s.split())
 a=x/r%2
 c=x/g%2
 d=x/b%2
 r=((a*10+c)*10)+d
 if r==0:e="black"
 elif r==100:e="red"
 elif r==1:e="blue"
 elif r==10:e="green"
 elif r==101:e="magenta"
 elif r==11:e="cyan"
 elif r==110:e="yellow"
 else:e="white"
 print(e)
 n-=1

Input:
3

4643 5913 4827 9752
5583 5357 5120 9400
2025 5475 4339 8392

Output:

black
yellow
black

Instead of ((a*10+c)*10)+d we can use ((a*2+c)*2)+d to distinguish the colors.

 r=((a*2+c)*2)+d
 if r==0:e="black"
 elif r==4:e="red"
 elif r==1:e="blue"
 elif r==2:e="green"
 elif r==5:e="magenta"
 elif r==3:e="cyan"
 elif r==6:e="yellow"
 else:e="white"

Ah, but now we're just distinguishing between values from 0 to 7, so we can index into an array instead!

 r=a*4+c*2+d
 e=["black","blue","green","cyan","red","magenta","yellow","white"][r]
 # or even shorter:
 e="black blue green cyan red magenta yellow white".split()[r]

Combining with Uriel's changes we get down to 136 bytes (164 bytes saved).

exec'x,r,g,b=map(int,raw_input().split());print"black blue green cyan red magenta yellow white".split()[x/r%2*4+x/g%2*2+x/b%2];'*input()

Try it online!


Print Triangle Wave of Numbers Given the amplitude and period for a wave, print the wave. See sample output for more details. The total number of wave forms equals the period, and the height of each wave equals the amplitude. Amplitude and Period are less than 10. You can ignore the trailing spaces but not the leading spaces.

Sample Input
3 2

Sample Output
  3           3
 232         232
12321 12321 12321 12321
       232         232
        3           3

Dyalog APL, 43 40 bytes
{⍉⊃⍪/⍺⍴⊂(⌽⍪⊢)(n,1-n←2×⍵)↑↑b⍴¨⍕¨b←a,1↓⌽a←⍳⍵}
{⍉⊃⍪/⍺⍴⊂(⌽⍪⊢)n(1-n←2×⍵)↑↑⍴∘⍕¨⍨a,1↓⌽a←⍳⍵} (Thanks, Moris Zucca)
This is a dyadic function with the amplitude as the right argument (⍵) and the period as the left argument (⍺).  A program that reads user input would take the same number of characters.
Drawing some inspiration from Martin Büttner's CJam answer:
{⍉⊃⍪/⍺⍴⊂(⌽⍪⊢)n(1-n←2×⍵)↑↑⍴∘⍕¨⍨a,1↓⌽a←⍳⍵}
                                   a←⍳⍵ ⍝ numbers 1 2 3, call them "a"
                                  ⌽     ⍝ reverse them: 3 2 1
                                1↓      ⍝ drop one: 2 1
                              a,        ⍝ prepend "a": 1 2 3 2 1
                         ⍴∘⍕¨⍨          ⍝ format a[i] and repeat it a[i] times:
                                        ⍝     (,'1') '22' '333' '22' (,'1')
                        ↑               ⍝ mix, i.e. obtain a character matrix:
                                        ⍝    ┌───┐
                                        ⍝    │1  │
                                        ⍝    │22 │
                                        ⍝    │333│
                                        ⍝    │22 │
                                        ⍝    │1  │
                                        ⍝    └───┘
             n(1-n←2×⍵)↑                ⍝ take a 2×⍵ by 1-2×⍵ matrix
                                        ⍝ (negative length extends backwards):
                                        ⍝    ┌─────┐
                                        ⍝    │  1  │
                                        ⍝    │  22 │
                                        ⍝    │  333│
                                        ⍝    │  22 │
                                        ⍝    │  1  │
                                        ⍝    │     │
                                        ⍝    └─────┘
        (⌽⍪⊢)                           ⍝ the reverse of it, vertically joined with it
                                        ⍝    ┌─────┐
                                        ⍝    │  1  │
                                        ⍝    │ 22  │
                                        ⍝    │333  │
                                        ⍝    │ 22  │
                                        ⍝    │  1  │
                                        ⍝    │     │
                                        ⍝    │  1  │
                                        ⍝    │  22 │
                                        ⍝    │  333│
                                        ⍝    │  22 │
                                        ⍝    │  1  │
                                        ⍝    │     │
                                        ⍝    └─────┘
     ⍺⍴⊂                                ⍝ take ⍺ copies
  ⊃⍪/                                   ⍝ join them vertically
 ⍉                                      ⍝ transpose


Make a base64 Quine! Your challenge is to output a Base64-encoded version of your source code, and optionally a line break. You must output the correct padding, if any. Standard quine rules apply, shortest answer wins.

It must be a valid RFC 4648 encoded base64 string, with no linebreaks (except optionally a trailing newline).

Test cases:

h -> aA==
PPCG! -> UFBDRyE=
Programming Puzzles and Code Golf -> UHJvZ3JhbW1pbmcgUHV6emxlcyBhbmQgQ29kZSBHb2xm

Base64 table

0   A   16  Q   32  g   48  w
1   B   17  R   33  h   49  x
2   C   18  S   34  i   50  y
3   D   19  T   35  j   51  z
4   E   20  U   36  k   52  0
5   F   21  V   37  l   53  1
6   G   22  W   38  m   54  2
7   H   23  X   39  n   55  3
8   I   24  Y   40  o   56  4
9   J   25  Z   41  p   57  5
10  K   26  a   42  q   58  6
11  L   27  b   43  r   59  7
12  M   28  c   44  s   60  8
13  N   29  d   45  t   61  9
14  O   30  e   46  u   62  +
15  P   31  f   47  v   63  /

If you want to test your submission, try base64encode.org.

Bash, 27 bytes

trap -- 'trap|base64' EXIT

Based on this Bash quine. Note the trailing linefeed.

Try it online!


Test if a given number is a Vampire Number EDIT: In the interest of increasing the complexity, i've added more to the challenge.

  In mathematics, a vampire number (or
  true vampire number) is a composite
  natural number v, with an even number
  of digits n, that can be factored into
  two integers x and y each with n/2
  digits and not both with trailing
  zeroes, where v contains precisely all
  the digits from x and from y, in any
  order, counting multiplicity. x and y
  are called the fangs.

More about Vampire Number

Pseudovampire numbers

  Pseudovampire numbers are similar to
  vampire numbers, except that the fangs
  of an n-digit pseudovampire number
  need not be of length n/2 digits.
  Pseudovampire numbers can have an odd
  number of digits, for example 126 =
  6×21.

Input

Accept Numbers from command line or stdin

Output

"1260 = 21 * 60" (smaller fang first if the number is a Vampire.)
"1261 is not a Vampire Number." (if the number is not a Vampire number)
"126 = 6 * 21". (if the number is a Pseudovampire number)

EDIT: If the number has multiple fangs, display it so.

x = fang1a * fang1b = fang2a * fang2b

Python - 188 chars

Doesn't do Pseudovampire numbers
from itertools import*
n=input()
a=[]
for i in map("".join,permutations(`n`)):x,y=int(i[::2]),int(i[::-2]);a+=[(x,y)]*(x*y==n)
print n,a and"=%s*%s"%min(a)or"is not a Vampire Number"


Output nearby primes Write a program which takes an input (which may or may not be prime), and lists the immediate prime following and preceding it.

Example input:

1259

Example output:

1249 1277

Shortest program wins. Must execute within 10 seconds on a modern desktop PC. Inputs will be limited to 10,000 maximum.


Output a text that doesn't output any of the characters used in the instructions to output the text Main objective

The main objective is to output a text, it doesn't mind which text or where the text gets its output (it can be on a browser window, the default console etc).

It just requires the condition that what is output must be indeed "real chars" (the ones in UNICODE for example), it's not considered valid to display graphics that simulate chars.

Condition to program

Now into the conditions to program:

None of the characters that appear in the code must appear in the output.

The created string cannot be infinite (continuosly being created in a loop without end)

Test cases

So let's say that you code  is

abcdef

If that displayed

ghijk

The code would be valid, but if this displayed:

chiij

Then it would not be valid

Obviously something like

print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

That displays

 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

would be invalid.

Challenge

Write a code that displays a text as defined.

Scoring

In this code-challenge, your answer is scored by the ratio between string length and number of bytes in code (string length / code length), where the highest score wins.

Good luck!

Jelly, 0 bytes, score: 1/0 = ∞

Try it online!
That's right, the empty program in Jelly prints 0.
Jelly, 5 bytes, score: 1000.6
⁶³ȷ³x

Try it online!
Jelly, 2 bytes, score: 95 / 2 = 47.5
ØṖ

Try it online!
This yields the set of all printable ASCII: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ and a space (95 bytes)


Construct a word ladder Given a list of at least two words (made only of lowercase letters), construct and display an ASCII ladder of the words by alternating the direction of writing first to the right, then to the left, relatively to the initial direction from left to right.

When you finish writing a word, change the direction and only then start writing the next word.

If your language doesn't support lists of words, or it's more convenient for you, you can take the input as a string of words, separated by a single space.

Leading and trailing whitespaces are allowed.

["hello", "world"] or "hello world"

hello
    w
    o
    r
    l
    d

Here we start by writing hello and when we come to the next word (or in the case of the input as a string - a space is found), we change the relative direction to the right and continue to write world

Test cases:

["another", "test", "string"] or "another test string" ->

another
      t
      e
      s
      tstring

["programming", "puzzles", "and", "code", "golf"] or "programming puzzles and code golf" ->

programming
          p
          u
          z
          z
          l
          e
          sand
             c
             o
             d
             egolf

["a", "single", "a"] or "a single a" ->

a
s
i
n
g
l
ea

Wining criteria

The shortest code in bytes in every language wins. Don't let be discouraged by the golfing languages!

Sandbox

Charcoal, 9 bytes

Ｆ⮌Ａ«↑⮌ι‖↗

Try it online! Link is to verbose version of code. Explanation: Works by drawing the text backwards, transposing the canvas after every word. 10 bytes for string input:

Ｆ⮌Ｓ≡ι ‖↗←ι

Try it online! Link is to verbose version of code. Explanation: Draws the text backwards, transposing the canvas for spaces.


Ah, why is there a bug in my program? This challenge is inspired by @LuisMendo's MATL answer to my "binary multiples" challenge.

Task

Pick a code-golf challenge that is open and that has been posted before this one; let me call it the "linked challenge". The linked challenge must be a challenge whose task involves producing output.

Write the shortest code possible that satisfies the following restrictions:

Your code must contain the characters b, u and g in your program, in this order and consecutively (case-insensitive, so "bug", "BUG", "Bug", "bUg", ... are all fair game.);
Your code must not contain the letters b, u and g more than once (case-insensitive);
Your code should be a valid submission for the linked challenge;
When any subset of the (case-insensitive) characters bug are removed, your program no longer fulfils the task of the linked challenge. This may happen because your program now produces the wrong output (i.e. fails test cases), because it halted with an error, because it runs indefinitely and never returns (if this is the case, be prepared to prove your program runs indefinitely), etc.
Your code should not be an integral copy - nor a trivial modification* - of a submission that already exists in the linked challenge (for example, you may not copy @LuisMendo's MATL answer to my "binary multiples" challenge);

Input

Your program takes input as per the specs of the linked challenge you choose.

Output

Your program, in its correct state (i.e. with a bug**), must abide by the output specs of the linked challenge you choose.

* This is subjective so I appeal to your common sense; any imaginative modification should be fair game, even if in retrospective it is "trivial". This "no trivial modifications" rule will be "enforced" by me downvoting answers I think disrespect this...

** Sit down, take a moment to let this sink in. Your program has a bug. And yet your program is correct.

Posting an answer

When you post your answer, please provide a link to your linked challenge.

This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it! If you dislike this challenge, please give me your written feedback. Happy golfing!

Japt, 4 bytes
Challenge: Output with the same length as the code
BUG³

Test it
Explanation
B, U, and G are variables for 11, the input, and 16 respectively.
When applied to a number, ³ brings it to the third power.
In Japt, only the last expression is outputted, so only \$16^3 = 4096\$ is outputted, which is the same length as the code (4).
Since B and U are ignored, removing them have no effect on the output. However, their removal changes the length of the program, making it invalid. Removing G raises either the input (U) or 11 (B) to the third power. While \$11^3 = 1331\$ is 4 bytes, the program B³ is only two bytes, making the output invalid. The variable U defaults to 0 when there is no input given, and \$0^3 = 0\$, which is only one byte long.


Finding Not-Quite-Prime Numbers Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria:

The integer itself is a prime number OR
Either of its neighbor integers are prime

For example:
An input of 7 would return True.
An input of 8 would also return True.
An input of 15 would return False.  (Neither 14, 15, or 16 are prime)

The input must be able to return correctly for numbers between 2^0 and 2^20 inclusive, so there's no need to worry about sign issues or integer overflows.

J, 17

*/<:$&q:(<:,],>:)

Returns booleans encoded as process return codes: zero for true, nonzero for false.  Sample use:

   */<:$&q:(<:,],>:) 7
0
   */<:$&q:(<:,],>:) 8
0
   */<:$&q:(<:,],>:) 15
3