Determining vertical slices Given an image, output the [width in pixels of a full vertical section]1 (if one exists). If no vertical section exists, output 0.

Input may be provided as a local file or a nested array. If you choose to take input as a nested array, white pixels should be represented by a truthy value while non-white pixels should be represented by a falsey value.

1. the number of contiguous, all-white columns

You can assume that

no image will be larger than 1000 square pixels
there will be no more than one full vertical section per image

Examples

Inputs:

Outputs:

50
57
0
0

Here are the first two examples, highlighted (in yellow) to show their sections:

Jelly, 2 bytes

PS

Try it here!

If I encode an image like so:

0000111111111100000
0000000111111111000
0000000001111100000
0000000011111000000
0001111111111111100
0000001111110000000
0000000111111110000
0000111111111100000

Into a nested array like this:

[[0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0],...]

Then P takes the element-wise product of all of the row vectors, and S sums all of the ones in the result, yielding the length of the vertical slice. (This works only because there’s guaranteed to be only one contiguous slice.) In our case, the answer is 3.


Generate Keyboard Friendly Numbers Most common computer keyboard layouts have the decimal digit keys

1234567890

running along at their top, above the keys for letters.

Let a decimal digit's neighborhood be the set of digits from its own digit key and from the digit keys immediately to the left and right, if they exist.

For example, the neighborhood of 0 is {0, 9}, and the neighborhood of 5 is {4, 5, 6}.

Now, define a keyboard friendly number as a positive integer (in decimal form with no leading zeros) that can be typed on the layout above such that every consecutive digit in the number after the first digit is in the neighborhood of the preceding digit.

All single digit numbers (1-9) are trivially keyboard friendly.
A number such as 22321 is keyboard friendly because every digit (not counting the first) is in the neighborhood of the digit just before.
A number such as 1245 is not keyboard friendly because 4 is not in the neighborhood of 2 (nor vice versa).
A number such as 109 is not keyboard friendly because 0 is not in the neighborhood of 1. The ends do not loop around.

By putting the keyboard friendly numbers in order from smallest to largest, we can create an integer sequence.

Here are the first 200 terms of the keyboard friendly numbers sequence:

N KFN(N)
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 11
11 12
12 21
13 22
14 23
15 32
16 33
17 34
18 43
19 44
20 45
21 54
22 55
23 56
24 65
25 66
26 67
27 76
28 77
29 78
30 87
31 88
32 89
33 90
34 98
35 99
36 111
37 112
38 121
39 122
40 123
41 211
42 212
43 221
44 222
45 223
46 232
47 233
48 234
49 321
50 322
51 323
52 332
53 333
54 334
55 343
56 344
57 345
58 432
59 433
60 434
61 443
62 444
63 445
64 454
65 455
66 456
67 543
68 544
69 545
70 554
71 555
72 556
73 565
74 566
75 567
76 654
77 655
78 656
79 665
80 666
81 667
82 676
83 677
84 678
85 765
86 766
87 767
88 776
89 777
90 778
91 787
92 788
93 789
94 876
95 877
96 878
97 887
98 888
99 889
100 890
101 898
102 899
103 900
104 909
105 987
106 988
107 989
108 990
109 998
110 999
111 1111
112 1112
113 1121
114 1122
115 1123
116 1211
117 1212
118 1221
119 1222
120 1223
121 1232
122 1233
123 1234
124 2111
125 2112
126 2121
127 2122
128 2123
129 2211
130 2212
131 2221
132 2222
133 2223
134 2232
135 2233
136 2234
137 2321
138 2322
139 2323
140 2332
141 2333
142 2334
143 2343
144 2344
145 2345
146 3211
147 3212
148 3221
149 3222
150 3223
151 3232
152 3233
153 3234
154 3321
155 3322
156 3323
157 3332
158 3333
159 3334
160 3343
161 3344
162 3345
163 3432
164 3433
165 3434
166 3443
167 3444
168 3445
169 3454
170 3455
171 3456
172 4321
173 4322
174 4323
175 4332
176 4333
177 4334
178 4343
179 4344
180 4345
181 4432
182 4433
183 4434
184 4443
185 4444
186 4445
187 4454
188 4455
189 4456
190 4543
191 4544
192 4545
193 4554
194 4555
195 4556
196 4565
197 4566
198 4567
199 5432
200 5433

Challenge

Write a program or function that takes a positive integer N (via stdin/command line/function arg) and prints (to stdout) or returns the Nth term in the keyboard friendly numbers sequence.

For example, if the input is 191, the output should be 4544.

The output may optionally have a single trailing newline.

The shortest submission in bytes wins.

Pyth, 27 24 bytes

uf!f/h-FY3.:metsd`T2hGQ0

Demonstration.

Improvements to the original:

Using metd, instead of .r ... _UJ: 2 less bytes. 1 direct, 1 for not having to use J.
Using s and `T instead of JT10: 1 less byte.

We start with the string representation of a number: `T.

Then, we convert the string to a list of digits, and rotate the digits digits backwards by one, (9876543210) with metsd. Then, we take the 2 element subsequences with .: ... 2. These subsequences are filtered on /h-FY3. This expression corresponds to ((a-b)+1)/3, which is zero if and only if the difference between a and b is at most 1. Thus, the filtered list will be empty if and only if the number is keyboard friendly. With !, the result is true only if the number is keyboard friendly.

f ... hG filters upwards from G+1 until the result is true, giving the first keyboard friendly number at G+1 or above. u ... Q0 applies this function to its own output Q times, starting from 0, where Q is the input. This gives the Qth Keyboard Friendly Number, as desired.


Greatest greatest common divisor Find the greatest gcd of the numbers \$n^m + k\$ and \$(n+1)^m + k\$ for given m and k.
For example, for m=3, k=1 we have:

\$n = 1\$: \$\gcd(1^3 + 1, 2^3 + 1) = 1\$
\$n = 2\$: \$\gcd(2^3 + 1, 3^3 + 1) = 1\$

\$\vdots\$

\$n = 5\$: \$\gcd(5^3 + 1, 6^3 + 1) = 7\$ (max)

\$\vdots\$

\$n \to \infty\$

Input/Output
Input is L lines through file or stdin, EOF terminated. Each line contains two integers: m and k separated by a space.
Output is L integers separated by any pattern of whitespace characters (tabs, spaces, newlines etc).
Examples
Input
2 4
2 7
3 1
4 1
3 2
5 4
10 5

Output
17
29
7
17
109
810001
3282561

Update
I can't find a proof that the solution is bounded for all n given some m and k, so you only have to find the GGCD for \$n < 10,000,000\$.

Update:

GGCD for given m and k is good defined.

This is table of GGCD tested for n up to 500000.

m/k      1       2       3       4       5       6       7       8       9      10
2        5       9      13      17      21      25      29      33      37      41
3        7     109      61     433     169     973     331    1729     547    2701
4       17      33      49      65      81      97     113     129     145    2093
5      341   52501  258751  810001       1  131371       1       1  501311 2846591
6       65     129     193     257   21507     385     449   22059     577     641
7     3683  235747       1       1      71  438299  940507   33461     757  110503
8     4369     513     769   13325    1281  149089  202609    2049  975937  617201
9   359233  232537  202927  470983  123019  708589  241117 5601589  398581   19783
10   62525  514299  183757  807517 1094187 16856405  97477    8193  377897 25919971

For m==2 or 4 it looks quite good :-)

It seems that if p_in_i is gcd for some n, where p_i is a prime, than every combination of products of p_i's with exponents <= n_i is also gcd for some n. E.g. for m=8,k=2, 3^3 and 19 are gcd of type p_in_i, also 57, 171 and 513 are gcd's.

Some theory background: If g = gcd(n) > 1 for some n, and d > 1 and d divide g (it can be d=g) than d divide gcd(n±d). It is easy to prove. That means:

If you find some g = gcd(n) > 1 for some n, than gcd(n±d) > 1. So, it is enough to jump for found prime number of steps while iterating n.
If prime p divide some gcd() than there is n <= p where p divide gcd(n). Prime p will 'appear' in gcd(n) for some n <= p.

These properties can speed up search, but still there is a question is GGCD good defined.


Alternating bit smearing Introduction

This challenge requires you to set the trailing zeros of an integers binary representation to 010101…, this is best explained with an example:

Given the integer 400, the first step is to convert it to binary:

110010000

As we can see the fifth bit is the least significant 1 bit, so starting from there we replace the lower zeros by 0101:

110010101

Finally we convert that back to decimal: 405

Challenge

Given a positive integer return/output the corresponding resulting value of the above defined process.

Rules

This sequence is only defined for integers with at least one 1 bit, so the input will always be ≥ 1
You may take input as a string, list of digits (decimal) instead
You don't have to handle invalid inputs

Testcases

Here are some more testcases with the intermediary steps (you don't have to print/return these):

In -> … -> … -> Out
1 -> 1 -> 1 -> 1
2 -> 10 -> 10 -> 2
3 -> 11 -> 11 -> 3
4 -> 100 -> 101 -> 5
24 -> 11000 -> 11010 -> 26
29 -> 11101 -> 11101 -> 29
32 -> 100000 -> 101010 -> 42
192 -> 11000000 -> 11010101 -> 213
400 -> 110010000 -> 110010101 -> 405
298 -> 100101010 -> 100101010 -> 298

Python 3, 20 bytes

lambda n:(n&-n)//3+n

Try it online!

Explanation

Take 192 as an example. Its binary form is 11000000, and we need to convert it to 11010101.

We note that we need to add 10101 to the number. This is a geometric series (4^0 + 4^1 + 4^2), which has a closed form as (4^3-1)/(4-1). This is the same as 4^3//3 where // denotes integer division.

If it were 101010, then it would still be a geometric series (2×4^0 + 2×4^1 + 2×4^2), which is 2×4^3//3 for the reasons above.

Anyway, 4^3 and 2×4^3 would just be the least significant bit, which we obtain by n&-n:

We notice that the complement of n is 00111111. If we add one, it becomes 01000000, and it only overlaps with n=11000000 at the least significant digit. Note that "complement and add one" is just negation.


Generate Gmail Dot-Aliases Background
You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place!
This is a great way to have multiple different emails addresses for things like signing up for free trails, or filtering mail from different website. We will refer to gmail address aliases created in this way as dot-aliases.
The Task
Write a program to generate all possible dot-aliases of a given Gmail address.
Input
A Gmail address as a string. You may choose whether or not the "@gmail.com" part is included in the input. The maximum length of a Gmail ID (the part before the '@') is 30 characters (not including dots). The minimum is 6 characters. You may assume the input will not already include any dots.
For more details on gmail ID requirements: https://support.google.com/mail/answer/9211434?hl=en
Output
All of the dot-aliases, in any order, with no duplicates. This can mean printing them to stdout, writing to a file, returning them in a container, returning a iterator, etc. The output must contain the "@gmail.com" suffix. You may choose whether or not to include the original input address in the output.
Scoring
Code Golf here, solution with fewest bytes wins. In the event of a tie, the code who's least common character has the highest number of occurrences wins. In the event of a double tie, earliest timestamp wins.
Example:
Input:
abcabc@gmail.com
or
abcabc
(you pick)

Output:
a.bc.a.bc@gmail.com
a.b.cab.c@gmail.com
abc.ab.c@gmail.com
ab.cabc@gmail.com
a.b.cabc@gmail.com
ab.c.abc@gmail.com
a.b.c.abc@gmail.com
abc.a.bc@gmail.com
a.b.ca.b.c@gmail.com
abc.a.b.c@gmail.com
a.bc.a.b.c@gmail.com
a.bcabc@gmail.com
ab.c.a.b.c@gmail.com
a.b.c.a.b.c@gmail.com
a.b.c.ab.c@gmail.com
ab.c.a.bc@gmail.com
a.b.c.a.bc@gmail.com
abcab.c@gmail.com
a.bcab.c@gmail.com
ab.cab.c@gmail.com
a.bc.ab.c@gmail.com
ab.c.ab.c@gmail.com
abca.b.c@gmail.com
a.bca.b.c@gmail.com
ab.ca.b.c@gmail.com
abca.bc@gmail.com
a.bca.bc@gmail.com
ab.ca.bc@gmail.com
a.b.ca.bc@gmail.com
abc.abc@gmail.com
a.bc.abc@gmail.com
abcabc@gmail.com (optional)

-8% Byte Bonus: Even though the longest Gmail ID is 30 characters, the maximum length for any valid email address prefix is 64 characters. Make your program work for input up to 64 characters before the '@', but ensure output is also limited to 64 characters before the '@'.

Python 3, 72 69 bytes

-3 bytes thanks to Jitse!

Input includes @gmail.com.

f=lambda s:s[11:]and[s[0]+w+x for x in f(s[1:])for w in('.','')]or[s]

Try it online!


Decompose Polynomials Given an integral polynomial of degree strictly greater than one, completely decompose it into a composition of integral polynomials of degree strictly greater than one.
Details

An integral polynomial is a polynomial with only integers as coefficients.
Given two polynomials p and q the composition is defined by (p∘q)(x):=p(q(x)).
The decomposition of an integral polynomial p is a finite ordered sequence of integral polynomials q1,q2,...,qn where deg qi > 1 for all 1 ≤ i ≤ n and p(x) = q1(q2(...qn(x)...)), and all qi are not further decomposable. The decomposition is not necessarily unique.
You can use e.g. lists of coefficients or built in polynomial types as input and output.
Note that many builtins for this task actually decompose the polynomials over a given field and not necessarily integers, while this challenge requires a decomposition integer polynomials. (Some integer polynomials might  admit decomposition into integer polynomials as well as decomposition that contain rational polynomials.)

Examples
x^2 + 1
[x^2 + 1] (all polynomials of degree 2 or less are not decomposable)
x^6 - 6x^5 + 15x^4 - 20x^3 + 15x^2 - 6 x - 1
[x^3 - 2, x^2 - 2x + 1]
x^4 - 8x^3 + 18x^2 - 8x + 2
[x^2 + 1, x^2 - 4x + 1]
x^6 + x^2 + 1
[x^3 + x + 1, x^2]
x^6
[x^2, x^3]
x^8 + 4x^6 + 6x^4 + 4x^2 + 4 = (x^2 + 1)^4 + 3
[x^2 + 3, x^2, x^2 + 1]
x^6 + 6x^4 + x^3 + 9x^2 + 3x - 5
[x^2 + x - 5, x^3 + 3*x], [x^2 + 5*x + 1, x^3 + 3*x - 2]

Use Maxima for generating examples: Try it online!
Some decomposition algorithms can be found here and here.

Pari/GP, 84 bytes
f(p)=[if(q'',[f(q),r],p)|r<-x*divisors(p\x),r''&&p==subst(q=substpol(p,r,x),x,r)][1]

Based on the algorithm described here.
Try it online!


Display a bézier curve in the browser The goal is to display a bézier curve in any classical browser (except maybe old IE versions, because... are they really browsers?) client side.

Rules:

You must provide one or more files (or their content). These files must contain all the code.
The code must work offline, no imports from a remote source. No installation should be needed on the computer (except a vanilla browser).
This is a Javascript contest. A very simple way would be to use SVG files that can be read with browsers. Don't!
No need to pass the W3C validator test, you can omit the doctype and the surrounding tags (html, head, body, ...)
The input can take any form: GET, POST, written in the code, etc.
The quadratic bézier must be implemented. (2nd degree bézier: starting point, ending point and 1 intermediate point). It means 3 points (= 6 coordinates) must be given in whatever format you prefer (XML, JSON, ...).
If you don't know what a bézier curve is, you should! Check on Wikipedia to know about it.

Scoring:

In his great kindness, OP offers you 10'000 point just by posting a valid answer.
The sum of the sizes of the files in bytes will give negative points. 1 byte = -1 point*.
Implementing the cubic bézier curve instead of the quadratic multiplies your points by 120%.
Implementing n-th degree bézier curve instead of the quadratic or cubic double your points. (Which means implementing both the cubic and the n-th degree is useless, pointless and very dumb).
Implementing filled bézier (with inner color) will double your points again.
There is no limit in the number of files or libraries you use, just remember adding jQuery, for example, already gives you about -26'000 points.

The contestant with the highest score wins. (duh!)

*A 10'000 characters answer gives you 0 points.

39240 points (190 chars)

<script>P='<svg><path stroke=red d=M'+X[n]+','+Y[n]
for(t=N=99;t--;P+='L'+x+','+y)for(x=y=i=0,z=Math.pow(1-t/N,n);i<=n;z*=t/(N-t)*(n-i)/++i)x+=z*X[i],y+=z*Y[i]
document.write(P+'>')</script>

Input is supplied in three variables: X and Y hold the coordinates, and n holds the degree of the polynomial. If more coordinates are supplied than are needed, the surplus ones are ignored. The line is stroked in red and filled in black.

This example draws substantially from the existing ones, but with an improvement of 40% in character count over the current best character count I think it's worth a separate answer.

Demo: http://jsfiddle.net/MBCGJ/7/

This is stretching the flexibility of the rules too far IMO, but three characters can be saved by making N a "fineness" parameter which must be initialised along with the input coordinates and degree.

Also, Chrome at least doesn't care about closing the path element at all, which allows saving the 4 chars +'>', so if that works cross-platform and the fineness parameter abuse is allowed this can go down to 183 chars.

The preferred way of rendering Bézier curves is, of course, adaptive subdivision using the de Casteljau algorithm. Unfortunately this uses more characters because it's necessary to do a test to decide whether to subdivide and then to do a moderate amount of work for the subdivision itself. Currently I'm at 371 chars, although I think this could be reduced with an explicit stack.

<script>P='<svg><path stroke=red d=M'+X[0]+','+Y[0]
function Z(A,B,E,F){function d(p,q){return(t=A[p]-A[q])*t+(t=B[p]-B[q])*t}for(e=i=0;++i<n;e|=b+c-d(n,0)+Math.sqrt(3.9*b*c)>0)b=d(i,0),c=d(n,i)
for(E=[],F=[i=-1];e?i++<n||Z(E,F)|Z(A,B):0;)for(E[i]=A[0],F[i]=B[j=0];j<n-i;B[j]=(B[j]+B[++j])/2)A[j]=(A[j]+A[j+1])/2
P+='L'+A[n]+','+B[n]}Z(X,Y)
document.write(P+'>')</script>

The figure 3.9 in the middle there is the quality parameter, which must be less than 4 to avoid infinite recursion. The closer it gets to 4, the better the quality.

http://jsfiddle.net/FrJLn/2/


May the 4th be with you! In honor of Star Wars day, write a program to display the following text, scrolling like the Star Wars opening crawl:

It  is  a  period  of  civil war.  Rebel
spaceships,   striking  from   a  hidden
base,  have   won  their  first  victory
against the evil Galactic Empire.

During  the battle,  Rebel spies managed
to  steal  secret  plans to the Empire's
ultimate   weapon,  the  Death Star,  an
armored   space  station   with   enough
power to destroy an entire planet.

Pursued by the Empire's sinister agents,
Princess  Leia  races  home  aboard  her
starship,  custodian of the stolen plans
that  can save  her people  and  restore
freedom to the galaxy...

You may output an animated GIF or have your program display it. The output must show the following:

The text must start from the bottom of the image/display
It must scroll upwards until it reaches the top. It must take at least 30 seconds for a piece of text to reach the top. The animation must continue until all the text reaches the top.
In this distance, the text must get smaller until it is less than 1/3 the size (length and font)
The text must be slanted to follow this angle.
The text must be left and right justified. The text given is already justified for monospaced fonts, however, you may remove the extra spaces (not newlines) and justify it yourself.
The text must be yellow
The background must be black

This video shows the opening crawl.

Good luck, and May the fourth be with you!

HTML/CSS, 1047
I could golf this a lot more by deleting the -webkit prefixes etc., but this will do for the time being:

It is a period of civil
war. Rebel spaceships, striking from a hidden base, have won their first victory
against the evil Galactic Empire.

During the battle, Rebel spies managed to
steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored
space station with enough power to destroy an entire planet.

Pursued by
the Empire's sinister agents, Princess Leia races home aboard her starship,
custodian of the stolen plans that can save her people and restore freedom to
the galaxy...

Live demo


The dragon Curve sequence The dragon curve sequence (or the regular paper folding sequence) is a binary sequence.  a(n) is given by negation of the bit left of the least significant 1 of n.  For example to calculate a(2136) we first convert to binary:

100001011000

We find our least significant bit

100001011000
        ^

Take the bit to its left

100001011000
       ^

And return its negation

0

Task

Given a positive integer as input, output a(n). (You may output by integer or by boolean).  You should aim to make your code as small as possible as measured by bytes.

Test Cases

Here are the first 100 entries in order

1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 0 1

Mathematica 25 Bytes

1/2+JacobiSymbol[-1,#]/2&

Other ways of doing this:

56 bytes

(v:=1-IntegerDigits[#,2,i][[1]];For[i=1,v>0,i++];i++;v)&

58 bytes

1-Nest[Join[#,{0},Reverse[1-#]]&,{0},Floor@Log[2,#]][[#]]&


Simulate Rocket League Quick Chat In Rocket League, there are controls assigned to quick chat. For PC, they are
1, 2, 3, and 4. To use a quick chat, you must press two controls. For example, the first option would be 1, 1.
You will be simulating the Rocket League client. You will be given a non-empty list composed only of four characters of your choosing. The length of the list will always be even and <= 8. I will be using 1, 2, 3, 4 for the examples. If you modify the input domain, you must specify how your input maps to 1, 2, 3, 4.
The first character in each couplet specifies the section, the second the item in the section. Below are all sections, with their default chat:
1
 1 I got it!
 2 Need boost!
 3 Take the shot!
 4 Defending...

2
 1 Nice shot!
 2 Great pass!
 3 Thanks!
 4 What a save!

3
 1 OMG!
 2 Noooo!
 3 Wow!
 4 Close one!

4
 1 $#@%!
 2 No problem.
 3 Whoops...
 4 Sorry!

The above are case sensitive. So, 1 1 would be I got it!, and 3 3 would be Wow!.
In addition, after three quick chats come through rapidly, the game shots you down. You get a message back: Chat disabled for 2 seconds.. If you continue trying, you get one more chance, and then Chat disabled for 4 seconds.. Our challenge will not deal with time, or any further chats.
However, after three chats (6 input characters), you must output Chat disabled for 2 seconds.. After four chats (8 input characters), you must output Chat disabled for 4 seconds.. Since 8 is the maximum input length, that would be your final output, if they are 8 input characters.
Input
First, chose your four characters, and map them to 1, 2, 3, 4.
Your input will be non-empty, contain an even number of items, and only contain up to eight items.
Output
You will output the matching quick chats in order, plus any chat disabled warnings (in the correct location). Output is case sensitive. It must be delimited - suggested delimiters are \n (pretty delimiter) or ,, and you cannot use any delimiters in any of the possible outputs.
Test Cases
In these, input is in the form of a JSON list and can be 1, 2, 3, 4, and the output delimiter is ,.
[1, 1, 1, 1] => I got it!,I got it!
[2, 4, 4, 4] => What a save!,Sorry!
[3, 3] => Wow!
[1, 4, 2, 3, 4, 1, 4, 4] => Defending...,Thanks!,$#@%!,Chat disabled for 2 seconds.,Sorry!,Chat disabled for 4 seconds.

Invalid (out of scope) inputs:
[] //empty
[1, 3, 1] //odd length
[5, 4] //character out of input domain
[1, 2, 3, 4, 1, 2, 3, 4, 1] //length > 8

To ensure the point is made: you are not taking these in real time, like in the game. You are just receiving a (short) list of numbers.

JavaScript, 264 bytes

f=([x,y,...z],n=.5)=>"I got it!,Need boost!,Take the shot!,Defending...,Nice shot!,Great pass!,Thanks!,What a save!,OMG!,Noooo!,Wow!,Close one!,$#@%!,No problem.,Whoops...,Sorry!".split`,`[x*4+y-5]+(n>1?`,Chat disabled for ${n} seconds.`:'')+(z[0]?','+f(z,n*2):'')


The Lehmer-Comtet sequence The Lehmer-Comtet sequence is a sequence such that a(n) is the nth derivative of f(x) = xx with respect to x as evaluated at x = 1.

Task

Take a non-negative integer as input and output the nth term of the  Lehmer-Comtet sequence.

This is code-golf so you should minimize the file size of your source code.

Test Cases

OEIS 5727

Here are the first couple terms in order (copied from the OEIS)

1, 1, 2, 3, 8, 10, 54, -42, 944, -5112, 47160, -419760, 4297512, -47607144, 575023344, -7500202920, 105180931200, -1578296510400, 25238664189504, -428528786243904, 7700297625889920, -146004847062359040, 2913398154375730560, -61031188196889482880

Haskell, 77 75 bytes, no differentiation builtins

x@(a:b)&y@(c:d)=a*c:zipWith(+)(b&y)(x&d)
s=1:s&(1:scanl(*)1[-1,-2..])
(s!!)

Try it online!
How it works
We represent a function as its infinite list of Taylor series coefficients about \$x = 1\$:
$$
f(x) = \sum_{n=0}^\infty \frac{f^{(n)}(1)}{n!} (x - 1)^n
$$
is represented by \$[f(1), f'(1), f''(1), ...]\$.
The & operator multiplies two such functions using the product rule.  This lets us recursively define the function \$s(x) = x^x\$ in terms of itself using the differential equation
$$
s(1) = 1, \\
s'(x) = s(x) \cdot (1 + \ln x),
$$
where
$$
\ln x = \sum_{n=1}^\infty \frac{(-1)^{n-1}(n - 1)!}{n!}(x - 1)^n.
$$


Is this platform game level winnable? Given a level from a simple platform game, your task is to make a program or function to determine if a level is winnable. Platform game levels are 4 characters tall and any number of characters wide. There is exactly one platform for each horizontal space in a level:

           =======    =
==    =           =
   ===                 =====
  =    ====        ===

The game consists of jumps. Jumps start from the space above the platform which is being jumped from, and end in the space above the platform which is being jumped to (these can be above the 4 platform height levels). To complete a jump, it must be possible to move from the start point to the end point in four or less (including the start/end points) up, down, left, and right moves which do not pass through a platform. Here are some examples (marked with A for start platform and B for end platform):

 >>>
 ^ B
=A
  =

 >>>>
=A  B=

>>
^B
A

Horizontal moves along a platform are just jumps which only move in one direction:

  >>
==AB===

The player would start on the leftmost platform, and wins by standing on the rightmost one (marked with vs):

v  === v
===   ==

Test cases

Winnable:

 ===      ==
=    =====
    =

    ==

=         ==
 ===  ====

   ==== =
===
       =
         ===

  ==  ==  =

=
 =  ==  == =

Unwinnable:

      ======

======

 =======   =
=         =
         =
        =

           =
   =
=     =
 == == ====

Rules

Your program should output one distinct value if a level is winnable, and a different one if it isn't. It can take input in any reasonable form, such as an ASCII art with any two distinct characters, a matrix, or a 2d array.

Code golf, so shortest answer per language wins.

Jelly, 23 22 bytes

ŒṪạþ`§<4NA1¦A»/T$¦ÐLṪṀ

Try it online!

New version, which now efficiently handles moves backwards. Takes input as a boolean matrix (row major). Returns 1 for winnable and 0 for not.

Thanks to @AZTECCO for first suggesting using the indices of platforms, and @tsh for a test case that made me rethink my approach.

Explanation

ŒṪ                     | Multidimensional truthy indices of each
  ạþ`                  | Outer table using absolute difference and with the same argument on both sides:
     §                 | Sum innermost lists
      <4               | - Less than 4
        N              | Negate
         A1¦           | Absolute top row
                  ÐL   | Apply the following until no changes:
            A   $¦     | Absolute the rows indicated by the following:
             »/        | - Max of each column
               T       | - Truthy indices (i.e. where there’s a 1 in the column)
                    Ṫ  | Finally take the last row
                     Ṁ | Max

Step b step

(each matrix shown collapsed as a grid, with - = -1):

1. Input

0010
0001
1000
0010
0001
1000

2.ŒṪ

Multidimensional indices.

[[1, 3], [2, 4], [3, 1], [4, 3], [5, 4], [6, 1]]

3. ạþ`§<4N

Convert to initial outer table with -1 for possible moves between columns and 0 where no move possible.

--0-00
--0--0
00--0-
-----0
0-0--0
00-00-

4. A1¦A»/T$¦ÐL

Absolute first row, then iteratively take each column with at least one 1 in it, and absolute the rows at those indices; results after each iteration shown.

Absolute row 1 ->

110100
--0--0
00--0-
-----0
0-0--0
00-00-

-> Absolute rows 1, 2, 4 ->

110100
110110
00--0-
111110
0-0--0
00-00-

-> Absolute rows 1, 2, 3, 4, 5 ->

110100
110110
001101
111110
010110
00-00-

-> Absolute rows 1, 2, 3, 4, 5, 6 ->

110100
110110
001101
111110
010110
001001

5. ṪṀ

Finally, take the max of the last row

1

My previous 61 byte version has explanation in the edit history; thanks to @JonathanAllan for golfing 3 bytes off that one!


Golf a Numerical Growing Braid Braid Description

In this braid, when a strand crosses over the top of another strand it adds the other strand's value to itself and all other strand values pass through. The braid has three strands and each strand begins at 1. The first crossover is the leftmost strand crossing over the middle strand. The next crossover is the rightmost strand crossing over the new middle strand (previously the leftmost strand). These two steps of crossovers repeat. In other words, the first crossover is [a, b, c] -> [b, a+b, c] and the second is [a, b, c] -> [a, b+c, b]. Using these rules here are the first six levels of the braid:

1,1,1
1,2,1
1,3,2
3,4,2
3,6,4
6,9,4

Your task

Write a golfed program or function that accepts an integer as the braid level and outputs the three values for that level of the braid. You must indicate if your levels are zero- or one-based. Input and output may come in any reasonable format and trailing white space is allowed.

Test Cases (1-based)

1 -> 1,1,1

2 -> 1,2,1

5 -> 3,6,4

10 -> 28,41,19

MATL, 18 17 16 bytes
7Bi:"2:4PB@EX!Y*

Input is 0-based.
Try it online! Or verify all test cases.
Explanation
Given a row vector [a b c], the next vector is obtained post-matrix-multiplying it by either
[1 0 0;
 0 1 1;
 0 1 0]

or
[0 1 0;
 1 1 0;
 0 0 1]

depending on whether the iteration index is odd or even. For example, the matrix product [1 3 2]*[0 1 0; 1 1 0; 0 0 1] gives [3 4 2]. Then [3,4,2]*[1 0 0; 0 1 1; 0 1 0] gives [3 6 4], and so on.
Note also that the second matrix equals the first rotated 180 degrees, which can be exploited to save a few bytes.
7        % Push 7
B        % Convert to binary. Gives [1 1 1]. This is the initial level
i        % Take input n
:        % Push range [1 2 ... n]
"        % For each
  5      %   Push 5
  I:     %   Push range [1 2 3]
  -      %   Subtract, element-wise: gives [4 3 2]
  B      %   Convert to binary. This gives the matrix [1 0 0; 0 1 1; 0 1 0]
  @      %   Push current iteration index
  E      %   Multiply by 2. Gives 2 in the firt iteration, 4 in the second etc
  X!     %   Rotate matrix 90 degrees either 2 or 0 times
  Y*     %   Matrix multiply
         % End. Implicitly display


PHP golfing tips: Reading/writing files and the CLI I have been participating in a number of PHP code golf challenges recently and some of the techniques that are used to read data from a file such as fopen() and fread() or file_get_contents() really give my code a beating on the char count. Especially the methods provided for reading in command line input.

My question is, what is the fastest way (least keystrokes) to read and write to the contents of a file, and what is the fastest way (least keystrokes) to read a line from the prompt?

(Note: As this is code golf, I can't use any external libraries.)

You can read a line from STDIN in 13 characters:

fgets(STDIN);

as seen here.

Reading from a file:

file('filename')

returns an array of lines of the file.

Using fputs instead of fwrite will save a character on writing, but I can't think of a shorter way than:

fputs(fopen('filename','w')); //use 'a' if you're appending to a file instead of overwriting

which is marginally shorter than:

file_put_contents('filename');


Infer geometric sequences Haskell has this neat(-looking) feature where you can give it three numbers and it can infer an arithmetic sequence from them. For example, [1, 3..27] is equivalent to [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27].

That's cool and all but arithmetic sequences are fairly limiting. Addition, pfft. Multiplication's where it's at. Wouldn't it be cooler if it did geometric sequences like [1, 3..27] returning [1, 3, 9, 27]?

Challenge

Write a program/function that takes three positive integers a, b, and c and outputs [a, b, b × (b ÷ a), b × (b ÷ a)2, ..., x] where x is the greatest integer ≤ c that can be represented as b × (b ÷ a)n where n is a positive integer.

That is, the output should be r, such that:

r0 = a
r1 = b
rn = b × (b ÷ a)n-1
rlast = greatest integer ≤ c that can be represented as b × (b ÷ a)n
         where n is a positive integer

Specifications

Standard I/O rules apply.
Standard loopholes are forbidden.
b will always be divisible by a.
a < b ≤ c
This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
Built-in functions (Mathematica might have one :P) that compute this sequence are allowed but including a solution that doesn't rely on a built-in is encouraged.
Explanations, even for "practical" languages, are encouraged.

Test cases

a   b   c     r

1   2   11    [1, 2, 4, 8]
2   6   100   [2, 6, 18, 54]
3   12  57    [3, 12, 48]
4   20  253   [4, 20, 100]
5   25  625   [5, 25, 125, 625]
6   42  42    [6, 42]

In a few better formats:

1 2 11
2 6 100
3 12 57
4 20 253
5 25 625
6 42 42

1, 2, 11
2, 6, 100
3, 12, 57
4, 20, 253
5, 25, 625
6, 42, 42

Husk, 8 bytes

~↑≤Ṡ¡o//

Input is in order b, c, a.
Try it online!

Explanation

~↑≤Ṡ¡o//  Implicit inputs.
       /  a/b as exact rational number.
     o/   Divide by a/b (so multiply by b/a).
    ¡     Iterate that function
   Ṡ      on a. Result is the infinite list [a, b, b^2/a, b^3/a^2, ..
 ↑        Take elements from it while
~ ≤       they are at most c.

The control flow in this program is a bit hard to follow.
First, b is fed to the rightmost /, producing a function /b that divides by b.
Next, ~ splits the remaining program into three parts: ~(↑)(≤)(Ṡ¡o//b).
This feeds c to ≤ and a to Ṡ¡o//b, and combines the results with ↑.
The result of ≤c is a function that checks if its argument is at most c, and ↑≤c takes the longest prefix of elements for which this holds.

It remains to show how (Ṡ¡o//b)a evaluates to the desired infinite list.
The part in parentheses is split into Ṡ(¡)(o//b).
Then Ṡ feeds a to o//b, feeds the result to ¡, and then gives a to its second argument.
The expression (o//b)a gives a function that takes a number and divides it by a/b, and ¡ iterates this function on its second argument, which is a.

Here is a series of transformations that visualize the explanation:

  (~↑≤Ṡ¡o//) b c a
= (~↑≤Ṡ¡o/(/b)) c a
= ~(↑)(≤)(Ṡ¡o/(/b)) c a
= ↑(≤c)((Ṡ¡o/(/b)) a)
= ↑(≤c)(Ṡ(¡)(o/(/b)) a)
= ↑(≤c)(¡(o/(/b)a) a)
= ↑(≤c)(¡(/(/ba))a)
Last line in English: takeWhile (atMost c) (iterate (divideBy (divideBy b a)) a)

Alternative solution using explicit variables in order a, b, c:

↑≤⁰¡*/⁵²


Generate an RSA key pair Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits.

The RSA key generation algorithm is as follows:

Choose an \$N\$-bit semiprime \$n\$. Let the prime factors of \$n\$ be \$p\$ and \$q\$.
Compute \$\lambda(n) = LCM(p-1, q-1)\$.
Choose an integer \$e\$ such that \$1 < e < \lambda(n)\$ and \$GCD(e, \lambda(n)) = 1\$.
Compute \$d \equiv e^{−1} \pmod {\lambda(n)}\$.

The public key is composed of \$n\$ and \$e\$. The private key is \$d\$.

Rules

You may assume that there exists at least one semiprime \$n\$ with bit length \$N\$.
Output may be in any consistent and unambiguous format.
\$e\$ and \$n\$ must be chosen from discrete uniform distributions.
You may assume that \$N\$ is less than or equal to the maximum number of bits for integers representable in your language, if your language has such a restriction.

JavaScript (ES7), 190 bytes
Returns [n,e,d].

f=N=>(R=Math.random,g=d=>d&&p%--d?g(d):d)(p=g(p=n=R()*2**N|0))<2&n>1&(L=(q=n/p-1)*--p/(G=(a,b)=>b?G(b,a%b):a)(p,q))>2?(g=_=>G(L,e=R()*(L-2)+2|0)<2?(h=d=>d*e%L<2?[n,e,d]:h(-~d))():g())():f(N)

Try it online!
Because of the limited size of the call stack, this may fail for \$N>13\$.
Commented
f = N =>
  (
    R = Math.random,
    // helper function returning the highest divisor of p
    g = d => d && p % --d ? g(d) : d
  )(
    // choose n and compute its highest divisor p
    p = g(p = n = R() * 2 ** N | 0)
  )
  // make sure that p is prime
  < 2 &
  // and that n is greater than 1
  n > 1 &
  // compute L = λ(n) = LCM(p - 1, q - 1) = (p - 1) * (q - 1) / GCD(p - 1, q - 1),
  // using the helper function G that returns GCD(a, b)
  (L = (q = n / p - 1) * --p / (G = (a, b) => b ? G(b, a % b) : a)(p, q))
  // make sure that L > 2
  > 2 ?
    // helper function to choose e such that GCD(e, L) = 1
    (g = _ => G(L, e = R() * (L - 2) + 2 | 0) < 2 ?
      // helper function to compute d such that d * e mod L = 1
      (h = d => d * e % L < 2 ? [n, e, d] : h(-~d))()
    :
      g()
    )()
  :
    f(N)


Guess my password (robbers' thread) Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here.
Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to the cop's program, the flag should be outputted.
Robber rules

When the cop's program is given the password you guess, it should output the flag.
Your password does not have to be the same as the cop's password.
You are allowed to take advantage of ambiguous descriptions of the flag by cops.

Cop answers will be safe if they haven't been cracked for two weeks.
Example
Cop:
Scala, 4 bytes
x=>x

Flag: Yay, you cracked it! (an object of type String is returned from the lambda above)
Try it online!
Robber:
Password: the string "Yay, you cracked it!"
Try it online!

Sisyphus, PHP
Password:
A string golf with 1,000,000 leading whitespaces and 1,000,000 trailing whitespaces
Output: golf
Reason: 1,000,000 is the default backtracking limit of PCRE (which you can get by var_dump(ini_get('pcre.backtrack_limit'));). And preg_match will return FALSE other than 0 or 1 when this limit is breaked.
Try it online!


1, 2, 3, 4, 5, Shaggy This is my first code golf exercise for you:
Your input is two integers n and k. You can assume n >= 1 and k >= 1
You have to output all numbers from 1 to n (inclusively) and replace every element that is a multiple of k or that contains k with "Shaggy".

you can take the input in any convenient form and output it in a human readable form (seperators can be whitespaces, commas or whatever)

Standard loop holes are forbidden. Functions or programs are acceptable. Shortest code in byte wins!

This is different from the "Bzzt"-game, as this takes a variable "Bzzt" parameter, which, for values>=10, may increase the difficulty in some languages.

Examples:

Input: 20 6
Output: 1 2 3 4 5 Shaggy 7 8 9 10 11 Shaggy 13 14 15 Shaggy 17 Shaggy 19 20

Input: 21 4
Output: 1 2 3 Shaggy 5 6 7 Shaggy 9 10 11 Shaggy 13 Shaggy 15 Shaggy 17 18 19 Shaggy 21

Input: 212 11
Output: 1 2 3 4 5 6 7 8 9 10 Shaggy 12 13 14 15 16 17 18 19 20 21 Shaggy 23 24 25 26 27 28 29 30 31 32 Shaggy 34 35 36 37 38 39 40 41 42 43 Shaggy 45 46 47 48 49 50 51 52 53 54 Shaggy 56 57 58 59 60 61 62 63 64 65 Shaggy 67 68 69 70 71 72 73 74 75 76 Shaggy 78 79 80 81 82 83 84 85 86 87 Shaggy 89 90 91 92 93 94 95 96 97 98 Shaggy 100 101 102 103 104 105 106 107 108 109 Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy 120 Shaggy 122 123 124 125 126 127 128 129 130 131 Shaggy 133 134 135 136 137 138 139 140 141 142 Shaggy 144 145 146 147 148 149 150 151 152 153 Shaggy 155 156 157 158 159 160 161 162 163 164 Shaggy 166 167 168 169 170 171 172 173 174 175 Shaggy 177 178 179 180 181 182 183 184 185 186 Shaggy 188 189 190 191 192 193 194 195 196 197 Shaggy 199 200 201 202 203 204 205 206 207 208 Shaggy 210 Shaggy 212

Python 2, 64 63 bytes
Anonymous function with arguments n and k, returns the list to output.
lambda n,k:[[i,'Shaggy'][i%k<1or`k`in`i`]for i in range(1,n+1)]

Alternatively, a function which prints to STDOUT for the same bytecount:
def f(n,k,i=1):exec"print[i,'Shaggy'][i%k<1or`k`in`i`];i+=1;"*n


Leonhard loves labyrinths The background

My son Leonhard (4 years old) loves labyrinths. I don't know where he knows labyrinths from, but he paints them and knows quite well how they work:

Recently, he started making a game from his paintings. These are his rules:

a black square denotes the starting point.
a hook denotes the exit of the labyrinth (that's where you get pulled out).
you can collect crowns.
you can collect gold nuggets (the round things).
you can go a way forth and back, but not more than that.
arrows may guide you to the exit. (If he paints a labyrinth for me to solve, they are often misleading).

Annotated version:

blue: starting point
orange: crowns
yellow: area with gold nuggets
green: hook (exit)
pink: arrows (mostly misleading)

The Task

Maybe you know, at the age of 4, kids start telling porky-pies and sometimes he does not follow his own rules, especially if he finds out that he cannot reach the end of the maze any more.

That's where you come into play: since I'm looking for games for kids anyway, you turn his idea into a game where cheating is not possible.

Well, we need some more definitions I'd say:

the playing field is a n*m rectangle of equally sized squares.
a square can have 0 to 4 walls, one on each side.
a crown is worth 50 points.
a gold nugget is worth 20 points.
walking on a square that has already been walked subtracts 1 point.
squares are marked in a way to identify how often the player walked on it (0, 1 or 2 times)
the player can walk in 4 directions, except if there is a wall.
Input device can be anything. Please consider keyboard support.
The labyrinth must be solvable. I.e. it must be possible to reach the hook from the starting point and it must be possible to collect all the valuables (even if that does not result in the highest possible score).
If the player gets stuck, the game ends.
The player must not die by falling off the board. You may put a wall around the complete maze or wrap around edges, whatever you like.
the program takes an word (0-65535) argument as input. This is the seed for the random number generator. Calling the program with the same seed again results in the same labyrinth.

Bonus:

calculate the maximum points that can be collected. Consider that due to -1 points it might be better to not collect all items.
Show the best solution (shortest way to get maximum points)

The Rules

This is a popularity contest, since I want to be able to read and understand the code and perhaps adapt to new ideas of my son. Sorry, code golfers, maybe you want to create a copy of this question with rules more suitable for golfing, e.g. a console version with all the characters defined.

The most popular game on 3rd of May will become the accepted answer. And, hey, why not publish it in an app store?

JavaScript
Work in progress. Unfortunately the maze is not always solvable - the limit on back-forward is the real hurdle.
Edit 1 Cosmetic
Edit 2 Better gameplay, but the big problem is still there

var rows, columns, rowOfs, maze, plPos, points, playing

$('#BNEW').on('click', function() {
    NewMaze();
});
$('#BREP').on('click', function() {
    Start();
});

$(document).on('keydown', function(e) {
    var ok, move, pxy, mz, $td
    switch (e.which)
    {
    case 37:
        (move = -1, ok = maze[plPos+move] < 9 && maze[plPos+move*2] < 9);
        break;
    case 39:
        (move = 1, ok = maze[plPos+move] < 9 && maze[plPos+move*2] < 9);
        break;
    case 38:
        (move = -rowOfs, ok = maze[plPos+move] < 9 && maze[plPos+move*2] < 9);
        break;
    case 40:
        (move = rowOfs, ok = maze[plPos+move] < 9 && maze[plPos+move*2] < 9);
        break;
    }
    if (playing && ok)
    {
        pxy = getXY(plPos)
        mz = maze[plPos] < 8 ? 8 : 9;
        $td = $('#Field table tr').eq(pxy.y).find('td').eq(pxy.x)
        $td.addClass("m"+mz);
        maze[plPos] = mz;
        maze[plPos+move] = mz;
        plPos += move*2;
        mz = maze[plPos];
        PTS.value = mz==7 ? points += 20 : mz==6 ? points += 50 : mz == 8 ? points -= 1 : points;

        pxy = getXY(plPos)
        $td = $('#Field table tr').eq(pxy.y).find('td').eq(pxy.x)
        $td.removeClass("m6 m7")
        $('#Player').finish().animate(playerCss(pxy.x,pxy.y));
        CheckEndGame();
    }
    return !move
});

function CheckEndGame()
{
  var msg = ''
  if (maze[plPos] == 5)
  {
      msg = "Maze completed!";
  }
  else if (maze[plPos+1]==9 && maze[plPos-1]==9
        && maze[plPos+rowOfs]==9 && maze[plPos-rowOfs]==9)
  {
      msg = "You are stuck, try again!";
  }
  if (msg) {
    $("#Msg").text(msg).show();
    playing=false
  }
}

function seed(s) {
    return function() {
        s = Math.sin(s) * 10000; return s - Math.floor(s);
    };
};

function Build()
{
    var i
    var Fill = function(p)
    {
        var d=[rowOfs,-rowOfs,1,-1], i, s, l
        maze[p] = 1
        while(d[0])
        {
            i = random()*d.length|0
            s = d[i]
            if (s != (l=d.pop())) d[i]=l
            if (maze[p+s+s]>8) {
                maze[p+s] = 1, Fill(p+s+s)
            }
        }
    }
    rowOfs = (columns + 1) * 2
    maze = Array(rowOfs * (rows*2+1))
    for (i=0; i < maze.length; i++)
        maze[i] = i % rowOfs? 9 : 0
    Fill(rowOfs+2)
}

function NewMaze()
{
    SEED.value = Math.random()*65536 | 0
    Start()
}

function Start()
{
    var sd = SEED.value || 1
    columns = COLS.value |0 || 18
    rows = ROWS.value | 0 || 12
    COLS.value = columns
    ROWS.value = rows
    random = seed(sd)
    PTS.value = points = 0
    $("#Msg").hide();

    Build()

    plx = random()*columns|0;
    ply = random()*rows|0;
    setPlayer(plx,ply);
    plPos = getPos(plx,ply);
    BlockTriples(plPos);
    AddItems(plPos);
    Draw();
    playing = true;

}

function AddItems(p)
{
    var d=[rowOfs,-rowOfs,1,-1]
    var cells=[]
    // scan all reachable cells and calc distance from start
    var Go = function(p,l)
    {
        var i,t,mark,r
        ++l
        cells.push([p,l])

        maze[p] = 8;
        for(i=0; d[i]; i++)
        {
            t = d[i]
            if (maze[p+t]<2 && maze[p+t+t]<2)
            {
                Go(p+t+t, l)
            }
        }
        maze[p] = 0;
    }
    Go(p,0)
    cells.sort(function(a,b){return a[1]-b[1]})
    cells=cells.slice(10) // cut the shortest distances
    r = random()*10|0; //exit
    r = cells.length-r-1
    maze[cells[r][0]] = 5;
    console.log(r)
    cells = cells.slice(0,r)
    var ncr = rows, nnu = columns
    for(i = ncr+nnu; i; i--)
    {
        r = random()*cells.length|0
        maze[cells[r][0]] = (i > ncr ? 7 : 6);
        cells[r] = cells.pop();
    }

}

function BlockTriples(p)
{
    var d=[rowOfs,-rowOfs,1,-1]
    var Go = function(p)
    {
        var i,t,size=[0,0,0,0],s=1,nw=0,min,minp
        maze[p] = 8
        for(i=0; d[i]; i++)
        {
            t = d[i]
            if (maze[p+t]<9 && maze[p+t+t]<8)
            {
                ++nw
                s += size[i] = Go(p+t+t)
            }
        }
        if (nw > 2) // triple way, block the smallest
        {
            for(i=0,min=1e6; d[i]; i++)
                size[i] && size[i] < min && (min = size[minp = i])
            maze[p + d[minp]] = 5;
        }
        maze[p]=0
        return s
    }
    Go(p)
}

function Draw()
{
    var q=[], i, x, y;
    for(i = rowOfs+2, y = 0; y < rows; y++)
    {
        q.push('
')
        for (x = 0; x < columns; i += 2, x++)
        {
            tcl = 'm'+(maze[i]|0)
            maze[i-1]>8 && (tcl += ' wl')
            maze[i+1]>8 && (tcl += ' wr')
            maze[i-rowOfs]>8 && (tcl += ' wu')
            maze[i+rowOfs]>8 && (tcl += ' wb')
            q.push('	')
        }
        q.push('
')
        i += rowOfs+2
    }
    $("#TOUT").html(q.join(''));
    $("#Field").show();
}

function setPlayer(posx, posy)
{
    $('#Player').css(playerCss(posx, posy));
}

function getXY(pos)
{
    return { x: (plPos % rowOfs)/2-1, y: plPos / rowOfs / 2 | 0}
}

function getPos(x, y)
{
   return (x+y*rowOfs)*2 + rowOfs+2;
}

function playerCss(posx, posy)
{
    return{ left: 6+posx*21, top: posy*21+2};
}
input { width: 3em; margin-right:1em }
table {
  border: 2px solid #000;
  border-collapse: collapse;
  font-size: 8px }
#Field {
  margin: 10px;
  position: relative;
  display: none;
}
td {
    width: 19px; height: 19px;
    padding: 0; margin: 0;
    text-align: center;
}
td.wl { border-left: 2px solid #444; background: #fff }
td.wr { border-right: 2px solid #444; background: #fff }
td.wt { border-top: 2px solid #444;; background: #fff }
td.wb { border-bottom: 2px solid #444; background: #fff }
td.m7 { background: #ffd url(http://i.stack.imgur.com/QUInh.png) -21px 0}
td.m6 { background: #efe url(http://i.stack.imgur.com/QUInh.png) -1px 0}
td.m5 { background: #ddf url(http://i.stack.imgur.com/QUInh.png) -40px 0}
td.m8 { background: #eed }
td.m9 { background: #f55 }
#Player { position: absolute; top:0; left:0; color: #007; background: #fcb; font-size:12px }
#Msg { color: red; font-size:40px; display:none;  }

ID:<input id=SEED>
Rows:<input id=ROWS>
Columns:<input id=COLS>
<button id=BNEW>New</button>
<button id=BREP>Replay</button>

⛄

Score: <input readonly id=PTS>


Floating point addition, without floats! Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed.

Format

The format for the numbers are strings containing 1's and 0's which represent the binary value of a IEEE 754 32-bit float. For example the number 2.54 would be represented by the string "01000000001000101000111101011100".

Goal

You program should input two numbers in the above mentioned format, add them together, and output the result in the same format. The shortest answer in any language wins!

Rules

Absolutly no floating point, decimal, or any kind of non-integer maths functions are allowed.

You can assume that the input is clean (i.e. contains only 1's and 0's).

You can assume that the inputs are numbers, and not Inf, -Inf, or NaN or subnormal. However, if the result is greater than the max value or smaller than the min value, you should return Inf and -Inf respectively. A subnormal (denormal) result may be flushed to 0.

You do not have to handle rounding properly. Don't worry if your results are a few bits out.

Tests

To test your programs, you can convert between decimal and floating point binary numbers using this tool.

1000 + 0.5 = 1000.5

01000100011110100000000000000000 + 00111111000000000000000000000000 = 01000100011110100010000000000000

float.MaxValue + float.MaxValue = Infinity

01111111011111111111111111111111 + 01111111011111111111111111111111 = 01111111100000000000000000000000

321.123 + -123.321 = 197.802

01000011101000001000111110111110 + 11000010111101101010010001011010= 01000011010001011100110101010000

Good luck!

Python, 224 chars

This code converts a floating point input f to the integer f*2^150, does the addition using python native big integers, then converts back.

V=lambda x:((-1)**int(x[0])<<int(x[1:9],2))*int('1'+x[9:],2)
B=lambda x,n:B(x/2,n-1)+'01'[x&1]if n else''
def A(x,y):
 v=V(x)+V(y)
 s=e=0
 if v<0:s=1;v=-v
 while v>=1<<24:v/=2;e+=1
 if e>254:v=0
 return'%d'%s+B(e,8)+B(v,23)


I like Pythagorean trees ...so this is a challenge to make me a tree.

Produce a program or function called tree which takes a single integer argument, N and draws a Pythagorean Tree N levels deep, where level 0 is just the trunk.

Each junction of the tree should place the vertex of the triangle at a random point on the perimeter (this point should be uniformly distributed over at least 5 equally spaced points, or uniformly over the whole semicircle).

Optionally your tree may be 3d, be colourful, or be lit according to the time of day. However, this is code-golf, so the smallest file wins.

EDIT: I'll shut the contest and accept the smallest answer when it's a week old

CFDG, 134 characters

This one isn't exactly valid, because you cannot limit the recursion depth. But the problem just calls for a solution in this one. :)

startshape t
c(q)=cos(q/2)^2
d(q)=1+sin(q)/2
p=acos(-1)
shape t{w=rand(p)
SQUARE[x .5 .5]t[trans 0 1 c(w) d(w)]t[trans c(w) d(w) 1 1]}

The results look something like this

For another 46 characters (180 characters in total), you can even colour it in:

startshape t
c(q)=cos(q/2)^2
d(q)=1+sin(q)/2
p=acos(-1)
shape t{w=rand(p)
SQUARE[x .5 .5 h 25 sat 1 b .2]t[trans 0 1 c(w) d(w) b .08 .8 h 2.2]t[trans c(w) d(w) 1 1 b .08 .8 h 2.2]}


Do the circles intersect? This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal

Input is two x, y coordinates for the circle centres and two radius lengths, as either 6 floats or ints, in any order, and output a boolean value, (you may print True or False if you choose)

test cases are in format (x1, y1 x2, y2, r1, r2):

these inputs should output true:

0 0 2 2 2 2
1 1 1 5 2 2
0.55 0.57 1.97 2.24 1.97 2.12

these should output false:

0 0 0 1 5 3
0 0 5 5 2 2
1.57 3.29 4.45 6.67 1.09 3.25

Mathematica 67 bytes
This checks whether the area of the intersection of two disks is positive.
RegionMeasure@RegionIntersection[{#,#2}~Disk~#3,{#4,#5}~Disk~#6]>0&


Summing intertwined terms of an array I'm recieving 2-dimensional positions of two objects as a string with this format: x1,y1,x2,y2. The string is recieved from a readline call (replaced in the snippet with a prompt).

In order to get the horizontal and vertical position differentials, I'm writing the following code:

[x1,y1,x2,y2]=prompt("Please enter the positions separated by commas").split`,`
dx=+x2-x1
dy=+y2-y1
console.log(dx,dy)

Is there a way to get dx and dy using less characters since I don't really need the positions? I suppose the main problem could be in the variable assignment which can probably be done in one step. I can use ECMAScript 6.

I don't really know if I have to precise it but removing the text in the prompt or giving variables 1-char names doesn't count, I have written them on purpose to clarify my question. The console.log is not part of the code golf either since the variables are supposed to be used after in the program.

I'm not sure exactly what you're looking for, but perhaps something like this?

[x1,y1,dx,dy]=prompt("Please enter the positions separated by commas").split`,`
dx-=x1
dy-=y1
console.log(dx,dy)

Reusing x2 and y2 as dx and dy, respectively, lets you use the -= operator to shorten it a bit.


convert decimal to duodecimal The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed.

The input number can be positive and negative, can be integer or rational. The decimal and duodecimal representations will have a finite number of digits after the (duo)decimal point.

The digits for duodecimal should be 0-9, a, b.

The output should not contain trailing zeroes after the duodecimal point and no leading zeroes before the duodecimal point. The duodecimal point should only be printed if the number is non-integer.

examples

input 400 -> output 294

input 14 -> output 12

input 1498 -> output a4a

input -11 -> output -b

input 11.875 -> output b.a6

counter examples

not okay are outputs like "-001a", "00b.300", "1.050".

EDIT: additional assumptions

the number can be represented exactly as float
there are overall less than 7 digits (excluding a minus and a duodecimal point) needed to represent the result.

Japt, 2 bytes
I feel I must be missing something ...
sC

Try it


Ruby, 79
->n{1.upto(n*=3){|i|puts (' '*(n-i)).ljust(n+i,'/__\_\/\ \__/_/\/ '[i%3*6,6])}}

A. (-4 bytes, -1 +1) changed from 0-indexed (.times) to 1-indexed (1.upto)
B. (-5 bytes) changed from array of three 6-char strings to selection of 6-char substring of 18-char string.
C. (-1 byte) m=n*3 -> n*=3
D. (-5 bytes) reduced all five double backslashes to single backslashes (partly made possible by reordering of string required for point A)
Ruby, 94
->n{(m=n*3).times{|i|puts (' '*(m-i-1)).ljust(m+i+1,[ '/\\ \\__','/_/\\/ ','/__\\_\\'][i%3])}}

explanation
The basic unit is a 3x6 diamond as follows (last character on each row duplicated for clarity:)
    /\ \__/
   /_/\/ /
  /__\_\/

All we need to do is display a suitable window of this pattern. Ruby's ljust allows you to pad with any string, not just spaces. Normally ljust would be used to pad a string of printable characters by adding spaces at the end, but here we use it in reverse: to pad a string of spaces by adding printable characters at the end.
ungolfed in test program
f=->n{
  (m=n*3).times{|i|                  #for each line of the triangle
    puts (' '*(m-i-1)).              #print m-i-1 spaces,
      ljust(m+i+1,[ '/\\ \\__',      #left justified and padded to total length m+i+1
                   '/_/\\/ ',        #by one of these three strings
                  '/__\\_\\'][i%3])
  }
}

f[gets.to_i]


Generate Skolem sequences Skolem sequences

A Skolem sequence is a sequence of 2n numbers where every number i between 1 and n occurs exactly twice, and the distance between the two occurrences of i is exactly i steps.
Here are some examples of Skolem sequences:

1 1
1 1 4 2 3 2 4 3
16 13 15 12 14 4 7 3 11 4 3 9 10 7 13 12 16 15 14 11 9 8 10 2 6 2 5 1 1 8 6 5

The following sequences are not Skolem sequences:

1 2 1 2      (The distance between the 1's is 2, not 1)
3 1 1 3      (The number 2 is missing)
1 1 2 1 1 2  (There are four 1's)

Objective

Write a program, function, or expression to count the number of all Skolem sequences of a given length.
More explicitly, your input is an integer n, and your output is the number of Skolem sequences of length 2n.
This sequence has an OEIS entry.
For n = 0, you may return either 0 or 1.
The first few values, starting from 0, are

0, 1, 0, 0, 6, 10, 0, 0, 504, 2656, 0, 0, 455936, 3040560, 0, 0, 1400156768

Rules and scoring

This is code golf.
Output format is lax within reason.

GolfScript, 48 46 characters
:b,1,{)2\?){{.2$&!{.2$|@@}*.+.4b?<}do;;}+%}@/,

The faster version (try online) - runs reasonable fast, e.g. n=8 takes about two seconds. And the chosen approach takes really few characters.
This version also works with bitmasks. It builts the possible result array from 1 upwards, i.e. for n=3:
1: 000011        000110 001100 011000 110000
2: 010111 101011 101110        011101 110101 111010

While some results (like 000011) have two possible continuations, others (i.e. 001100) have none and are removed from the result array.
Explanation of the code:
:b           # save the input into variable b for later use
,            # make the list 0..b-1 (the outer loop)
1,           # puts the list [0] on top of the stack - initially the only possible
             # combination
{)           # {...}@/ does the outer loop counting from i=1 to b
  2\?)       # computes the smalles possible bit mask m=2^i+1 with two bits set
             # and distance of those equal to i (i.e. i=1: 11, i=2: 101, ...)
  {          # the next loop starts with this bitmask (prepended to code via
             # concatination {...}+
             # the loop itself iterates the top of the stack, i.e. at this point
             # the result array
             # stack here contains item of result array (e.g. 00000011)
             # and bitmask (e.g. 00000101)
    {        # the inner-most loop tries all masks with the current item in the result set
      .2$&!  # do item and result set share not single bit? then - {...}*
      {
        .2$| # then generate the new entry by or-ing those two
        @@   # push it down on the stack (i.e. put working items to top)
      }*
      .+     # shift the bit mask left by one
      .4b?<  # if still in the range loop further
    }do;;    # removes the remainders of the loop (i.e. item processed and mask)
  }+%        # stack now contains the new result array
}@/
,            # length of result array, i.e. the number of Skolem sequences


How small can it get? Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater than 1.
Example #1
The expected output for N = 230 is N' = 23:

Example #2
The expected output for N = 129528 is N' = 257:

Beware of non-optimal paths!
We could start with 129528 / 9 = 14392, but that would not lead to the smallest possible result. The best we can do if we first divide by 9 is:

Rules

Input can be taken in any reasonable format (integer, string, array of digits, ...).
This is code-golf, so the shortest answer in bytes wins!

Test cases
1         --> 1
7         --> 1
10        --> 10
24        --> 1
230       --> 23
234       --> 78
10800     --> 1
10801     --> 10801
50976     --> 118
129500    --> 37
129528    --> 257
8377128   --> 38783
655294464 --> 1111

Haskell, 67 61 bytes

f n=minimum$n:[f$div n d|d<-read.pure<$>show n,d>1,mod n d<1]

Try it online!
Explanation:

read.pure<$>show n transforms the input integer n into a list of digits.
For each digit d from this list, we check d>1 and mod n d<1, that is whether d divides n.
If the checks are successful, we divide n by d and recursively apply f: f$div n d.
Altogether, this yields a list of the minimal integers from all sub-trees of n.
As the list might be empty, we append n to it and return the minimum of the list.


Maximum Area of a Polygon with Vertices of a Polygon Rules
Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon satisfies:

is simple (not self-intersecting).
has all the coordinates of its n vertices in the list l.
has no three consecutive collinear vertices.

Note that the polygon given in the input should comply to the three points above as well.
Test Cases
Here are a few test cases:
[(0,0), (0,-1), (-1,-1), (-1,0)], 3 -> 0.5
[(0,0), (1,0), (2,1), (2,2), (1,3), (0,3), (-1,2), (-1,1)], 3 -> 3
[(0,0), (1,0), (2,1), (2,2), (1,3), (0,3), (-1,2), (-1,1)], 5 -> 5.5
[(0,0), (1,0), (2,1), (2,2), (1,3), (0,3), (-1,2), (-1,1)], 6 -> 6

You can try any test cases you like here.
Make your code as short as possible.

Python 2, 172 bytes

-1 byte thanks to J843136028

bug fix thanks to Jonathan Frech

from itertools import*
def f(l,n,L=()):
 for p in combinations(l,n):
  r=0;j=-1
  for i in range(n):r+=(p[j][0]+p[i][0])*(p[j][1]-p[i][1]);j=i
  L+=abs(r/2.),
 print max(L)

Try it online!


Non-crossing X's and crossing non-X's You should write a program or function which given a text as input outputs or returns the sum of the following three integers:

Number of lowercase x's which are not part of a cross-formation.
Number of uppercase X's which are not part of a cross-formation.
Number of cross-formations which are made of neither x nor X.

A cross-formation is 5 copy of the same character positioned to each other in the following manner:

  A A
   A
  A A

Cross-formations can overlap with each other.

Detailed example

Input:
x-x+x+X++
-x-x+x++asd
x-x+x+X+

Info:
There is 1 x and 2 X's not in cross-formation and
there are 2 cross-formations of +'s as shown here:
   + +X+
    +x+
   + +X+

Output:
5

Input

A string containing only printable ascii characters (codepoint 32-126) and newlines.
The string will contain at least one printable character.

Output

A single positive integer, the sum of the number of occurrences for the three property.

Examples

After each output the values of the 3 properties (x's, X's and crosses) are provided in parens but note that those are not part of the output.

Input:
a
Output:
0 (0,0,0)

Input:
x xxx
 X x
x xxx
Output:
5 (4,1,0)

Input:
########
#####
########
Output:
4 (0,0,4)

Input:
a-a-a
0a0a
a-a-axXxX
0a0a
a-a-a
Output:
9 (2,2,5)

Input:
a c efghi
ab defgh
a c e ghij
abcd fgh
abc e g
Output:
2 (0,0,2)

Input:
/\/\/\/\/\/\/\
\/\/\/\/\/\/\/
#####x-x+x+X++
#####-x-x+x++###XX
#####x-x+x+X+
/\/\/\/\/\/\/\
\/\/\/\/\/\/\/
Output:
10 (1,4,5)

Input:
xxxxxxxxxx
xxxxxxxXX
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxx
Output:
5 (3,2,0)

This is code-golf so the shortest entry wins.

JavaScript (ES6) 234 246

Longer than I expected ...

Run snippet to test (in Firefox)

// Golfed

F=t=>t.split('\n').map((r,j,t)=>(
  [...r].map((c,i)=>(
    f=c==r[i+2]&c==u[i+1]&c==v[i]&c==v[i+2],
    c!='x'&c!='X'?z+=f
    :(++z,f?k[j+[,i]]=k[2+j+[,i]]=k[1+j+[,i+1]]=k[j+[,i+2]]=k[2+j+[,i+2]]=1:0)
  )),v=u,u=r),
k={},u=v=z=0)&&z-Object.keys(k).length

// Ungolfed

U=t=>{
  var k={}, u=0,v=0,z=0, t=t.split('\n')
  t.forEach((r,j)=> {
    [...r].forEach((c,i)=> {
      x = c=='x'|c=='X' // is any X
      f = c==r[i+2] & c==u[i+1] & c==v[i] & c==v[i+2] // is in a formation
      if (x)
      {
        ++z
        if (f)
        { // remember the position of X involved in a formation, avoid counting duplicates more tha once
          k[j+[,i]]=k[2+j+[,i]]=k[1+j+[,i+1]]=k[j+[,i+2]]=k[2+j+[,i+2]]=1
        }
      }
      else
      {
        z+=f
      }
    })
    v=u,u=r
  })
  return z-Object.keys(k).length
}

// TEST

Out=s=>OUT.innerHTML=OUT.innerHTML + s;

['a','a a\n a\na a','x xxx\n X x\nx xxx', 'x-x+x+X++\n-x-x+x++asd\nx-x+x+X+'
,'########\n#####\n########','a-a-a\n0a0a\na-a-axXxX\n0a0a\na-a-a'
,'a c efghi\nab defgh\na c e ghij\nabcd fgh\nabc e g'
,'/\\/\\/\\/\\/\\/\\/\\\n\\/\\/\\/\\/\\/\\/\\/\n#####x-x+x+X++\n#####-x-x+x++###XX\n#####x-x+x+X+\n/\\/\\/\\/\\/\\/\\/\\\n\\/\\/\\/\\/\\/\\/\\/'
,'xxxxxxxxxx\nxxxxxxxXX\nxxxxxxxxxx\nxxxxxxxxxx\nxxxxxxxxxx\nxxxxxxxx']
.forEach(t=>Out(t+'\n'+F(t)+'\n\n'))
b { color: #00f }


Is it a chess cycle? Inspired by a discussion from the Esolangs.org unofficial Discord Server.
Instructions
A chess cycle is an arrangement of a chess board where each piece must attack one other piece, and only one other piece, and each piece is attacked exactly once.
The effective idea to to "connect" pieces with each other, forming a single cyclic chain. Here is a board example:

You will only be given boards with Knights, Rooks and Bishops.
Your submission must take a chess board in any valid format(string, list of strings, 2D array, list of piece positions, FEN, ...) and output a truthy or falsy value for whether the board represents a valid cycle or not.
Testcases
To create your own testcases, create your board here, copy the FEN box contents, and use as input here.
FEN: 8/2B5/8/1N6/5N2/3B4/8/8, lichess
Board:
........
..B.....
........
.N......
.....N..
...B....
........
........

Output: True (In the illustration)

FEN: 8/8/8/3R4/8/8/8/8, lichess
Board:
........
........
........
...R....
........
........
........
........

Output: False (Rook cannot attack self)

FEN: 1R4B1/3N4/3N4/3N1B2/8/2B2N2/4R1BB/R1N5, lichess
Board:
.R....B.
...N....
...N....
...N.B..
........
..B..N..
....R.BB
R.N.....

Output: True

FEN: 6B1/4N2N/5B2/8/8/6B1/4N2N/5B2, lichess
Board:
......B.
....N..N
.....B..
........
........
......B.
....N..N
.....B..

Output: False (Multiple Cycles)

FEN: 8/6R1/8/5R1N/3N4/8/5BB1/7N, lichess
Board:
........
......R.
........
.....R.N
...N....
........
.....BB.
.......N

Output: False (Rook on f5 attacks two pieces)

FEN: 8/8/8/8/8/8/8/8, lichess(tsh)
Board:
........
........
........
........
........
........
........
........

Output: False (No pieces for a cycle)

FEN: 8/8/8/2R2R2/8/8/8/8, lichess(tsh)
Board:
........
........
........
..R..R..
........
........
........
........

Output: True (Two connected rooks, single cycle)

FEN: 8/8/8/1R3B2/8/3R2N1/8/8, lichess(Robin Ryder)
Board:
........
........
........
.R...B..
........
...R..N.
........
........

Output: False
Other Info

You may represent the pieces and empty squares as any number or character, as long as it is consistent.
Given boards will always be 8x8 and valid i.e. not containing any invalid characters.

Wolfram Language, 259 bytes
o=DirectedEdges->True
i|->RelationGraph[(d=Abs[#1[[2]]-#2[[2]]];#1!=#2&&NoneTrue[i,RegionMember[Line[p={#1[[2]],#2[[2]]}]~RegionDifference~Point@p]@*Last]&&Switch[#1[[1]],r,Times@@d==0,b,Equal@@d,n,Sort@d=={1,2}])&,i,o]~IsomorphicGraphQ~CycleGraph[Length@i,o]

Try it online!
(uses \[Function] rather than |->, as TIO doesn't have the most recent version of the language)
Defines a function that takes in a list of piece positions as input, each in the form {piece, {row, column}} where piece is one of r, b, or n.
Un-golfed explanation:
i|->
IsomorphicGraphQ[                (*check if the following graphs are equivalent*)
  CycleGraph[Length[i], DirectedEdges -> True],
                                 (*cyclic graph with length of input*)
  RelationGraph[                 (*graph defined by a functional relation*)
    (d = Abs[#1[[2]] - #2[[2]]]; (*set `d` to absolute difference in coordinates*)
    #1 != #2 &&                  (*no pieces attack themselves*)
    NoneTrue[i,                  (*no other pieces are...*)
      RegionMember[RegionDifference[Line[p = {#1[[2]], #2[[2]]}], Point[p]]] @* Last
    ] &&                         (*between these two pieces*)
    Switch[First @ #1,           (*switch by attacking piece*)
      r, Times @@ d == 0,        (*rooks attack when one coordinate offset is zero*)
      b, Equal @@ d,             (*bishops attack when both offsets are equal*)
      n, Sort[d] == {1, 2}]      (*knights attack when one offset is 1 and the other is 2*)
    )&, i, DirectedEdges->True], (*apply to list of pieces*)
]&


Mixed Base Conversion Background

Most people on here should be familiar with several base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, the number 1234516 would represent

1*16^4 + 2*16^3 + 3*16^2 + 4*16^1 + 5*16^0

Note that we're usually not expecting the base (here, 16) to change from digit to digit.

A generalisation of these usual positional systems allows you to use a different numerical base for each digit. E.g. if we were alternating between decimal and binary system (starting with base 10 in the least significant digit), the number 190315[2,10] would represent

1*10*2*10*2*10 + 9*2*10*2*10 + 0*10*2*10 + 3*2*10 + 1*10 + 5 = 7675

We denote this base as [2,10]. The right-most base corresponds to the least significant digit. Then you go through the bases (to the left) as you go through the digits (to the left), wrapping around if there are more digits than bases.

For further reading, see Wikipedia.

The Challenge

Write a program or function which, given a list of digits D an input base I and an output base O, converts the integer represented by D from base I to base O. You may take input via STDIN, ARGV or function argument and either return the result or print it to STDOUT.

You may assume:

that the numbers in I and O are all greater than 1.
the I and O are non-empty.
that the input number is valid in the given base (i.e., no digit larger than its base).

D could be empty (representing 0) or could have leading zeroes. Your output should not contain leading zeroes. In particular, a result representing 0 should be returned as an empty list.

You must not use any built-in or 3rd-party base conversion functions.

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

Examples

D               I                  O        Result
[1,0,0]         [10]               [2]      [1,1,0,0,1,0,0]
[1,0,0]         [2]                [10]     [4]
[1,9,0,3,1,5]   [2,10]             [10]     [7,6,7,5]
[1,9,0,3,1,5]   [2,10]             [4,3,2]  [2,0,1,1,0,1,3,0,1]
[52,0,0,0,0]    [100,7,24,60,60]   [10]     [3,1,4,4,9,6,0,0]
[0,2,10]        [2,4,8,16]         [42]     [1,0]
[]              [123,456]          [13]     []
[0,0]           [123,456]          [13]     []

CJam, 45

q~_,@m>0@{@(:T+@T*@+}/\;La{\)_@+@@md@@j@+}jp;

Finally I found a good use of j.

How it works

Long ArrayList Block j executes the block which takes an integer as the parameter, and Long j will call this block recursively in the block. It will also store the values returned by the block in an internal array, which is initialized by the array parameter. It will not execute the block if the input is already in the array, and the value in the array is returned instead.

So if I initialize it with an array of an empty array, the empty array will be returned for input 0, and the block will be executed for any other input.

q~_,@m>0@{@(:T+@T*@+}/\;     " See below. Stack: O decoded-D ";
La                           " Initialized the value with input 0 as empty list. ";
{
  \)_@+@@md@@                " See below. Stack: remainder O quotient ";
  j                          " Call this block recursively except when the same quotient has
                               appeared before, which is impossible except the 0.
                               Stack: remainder O returned_list ";
  @+                         " Append the remainder to the list. ";
}j
p;                           " Format and output, and discard O. ";

CJam, 49 48

q~_,@m>0@{@(:T+@T*@+}/\;{\)_@+@@md@@}h;;_{}?]W%`

Input should be O I D.

Examples:

$ while read; do <<<$REPLY ./cjam-0.6.2.jar <(echo 'q~_,@m>0@{@(:T+@T*@+}/\;{\)_@+@@md@@}h;;_{}?]W%`');echo; done
[2] [10] [1 0 0]
[10] [2] [1 0 0]
[10] [2 10] [1 9 0 3 1 5]
[4 3 2] [2 10] [1 9 0 3 1 5]
[10] [100 7 24 60 60] [52 0 0 0 0]
[42] [2 4 8 16] [0 2 10]
[13] [123 456] []
[13] [123 456] [0 0]
[1 1 0 0 1 0 0]
[4]
[7 6 7 5]
[2 0 1 1 0 1 3 0 1]
[3 1 4 4 9 6 0 0]
[1 0]
""
""

How it works

q~           “ Read the input and evaluate. ";
_,@m>        " Rotate I to the right by the length of D. ";
0@{          " For each item in D, with the result initialized to 0: ";
  @(:T+      " Rotate I to the left, and set the original first item to T. ";
  @T*@+      " Calculate result * T + current. ";
}/
\;           " Discard I. ";
{            " Do: ";
  \)_@+      " Rotate O to the right, and get a copy of the original last item. ";
  @@md       " Calculate divmod. ";
  @@         " Move O and the quotient to the top of the stack. ";
}h           " ...while the quotient is not 0. ";
;;           " Discard O and the last 0. ";
_{}?         " If the last item is still 0, discard it. ";
]W%          " Collect into an array and reverse. ";
`            " Turn the array into its string representation. ";


Calculate cell-phone keypresses Your task is to calculate the total number of key-presses required to enter a given text on an old cellphone.

The keymaps are:

1:1
2:abcABC2
3:defDEF3
4:ghiGHI4
5:jklJKL5
6:mnoMNO6
7:pqrsPQRS7
8:tuvTUV8
9:wxyzWXYZ9
0:<space><newline>0

To type exaMPle TExt 01 , you would press 33 99 2 6666 77777 555 33 0 8888 33333 99 8 0 <a 1-sec pause here in real life but we'll ignore it>000 1 for a total of 37 keypresses.

The * key brings up a map of special characters:

.,'?!
"-()@
/:_;+
&%*=<
>£€$¥
¤[]{}
\~^¡¿
§#|`

with the first one (.) highlighted. You can move to highlight the required character using rectangular navigation keys and it takes another keypress to select.

So to insert $, you would press *↓↓↓↓→→→<select> i.e. a total of 9 key-presses.

Input will be from a file called source placed in the current directory/directory of your program.
EDIT: Per requests in comments, I'm adding STDIN as a valid input method.  Apologies for changing the spec after receiving answers.
You must output Total key presses <total_keypresses>
If the input file contains any character not in the given keymap, then your program must output Invalid character <character> in source and exit.

In short, the input and output of your program must resemble that of this(ungolfed) python script:

# This Python file uses the following encoding: utf-8
from __future__ import print_function
import sys

general_dict = { '1':1,
                 'a':1, 'b':2, 'c':3, 'A':4, 'B':5, 'C':6, '2':7,
                 'd':1, 'e':2, 'f':3, 'D':4, 'E':5, 'F':6, '3':7,
                 'g':1, 'h':2, 'i':3, 'G':4, 'H':5, 'I':6, '4':7,
                 'j':1, 'k':2, 'l':3, 'J':4, 'K':5, 'L':6, '5':7,
                 'm':1, 'n':2, 'o':3, 'M':4, 'N':5, 'O':6, '6':7,
                 'p':1, 'q':2, 'r':3, 's':4, 'P':5, 'Q':6, 'R':7, 'S':8, '7':9,
                 't':1, 'u':2, 'v':3, 'T':4, 'U':5, 'V':6, '8':7,
                 'w':1, 'x':2, 'y':3, 'z':4, 'W':5, 'X':6, 'Y':7, 'Z':8, '9':9,
                 ' ':1, '\n':2, '0':3
                }

special_chars = ['.',',',"'",'?','!','"','-','(',')','@','/',':','_',';','+','&','%','*','=','<','>','£','€','$','¥','¤','[',']','{','}','\\','~','^','¡','¿','§','#','|','`']
for x in special_chars:
    general_dict[x]=(special_chars.index(x)/5) + (special_chars.index(x)%5) + 2

key_press_total = 0
with open('source') as f: # or # with sys.stdin as f:
    for line in f:
        for character in line:
            if character in general_dict:
                key_press_total+=general_dict[character]
            else:
                print('Invalid character',character,'in source')
                sys.exit(1)

print('Total key presses',key_press_total)

This is code-golf, shortest program in bytes wins.

Shameless disclaimer: I made this challenge to have translations of the above python script in different languages which will be used to score this challenge in the sandbox.

GolfScript, 219 characters
Basic approach using a lookup table:
"Total key presses "0@1/{"1adgjmptw °behknqux\n.°cfilorvy0,\"°ADGJMsTz'-/°BEHKNPUW?(:&°CFILOQVX!)_%>°23456R8Y@;*£¤°SZ+=€[~°79<$]^§°¥{¡#°}¿|°`°".2$?)\1$<"°"/,{"Invalid character  in source"18/*puts'"#{''exit}"'+~}if\;+}/

Try here.


Human Friendly Filename Detection Introduction
File names can be wildly varying things, ranging from a simple blah.txt to 303549020150514101638190-MSP0.txt. The former is usually human generated, while the latter is often machine generated. Wouldn't it be nice to have a simple function to make educated guesses on whether or not a file might be considered "human-friendly"?
Inspired by a post by Eduard Florinescu that has since been deleted. His idea was good, but just needed a little fleshing out.
Challenge
Write a program or function in the language of your choice that can take an string, and determine if it is considered "human-friendly", as defined by this challenge.
Some further details and rules are as follows:

Input will be a string consisting of the 95 printable ascii characters.
"human-friendly" shall be defined thusly:

Exclude the extension in the consideration. An extension is defined as the final period followed by a series of alpha-numeric characters (as few as 1, as many as 6).
No more than half of the string by length (excluding extension) may consist of the following defined groupings of characters (combined):

Decimal characters longer than 8 in a row.
Hexadecimal characters (upper xor lower case) of at least 16 in a row (must consist of letters and numbers, and of which at least a third of the characters are numbers).
Base64 characters (using %+= as the special characters) of at least 12 in a row (must consist of letters and numbers, be mixed case, and of which at least a third of the characters are uppercase letters).

If any of the above groupings overlap in definition (such as one that qualifies as base64, but has 8 digits in a row), choose the longest of them to be excluded.

Output should be a truthy or falsy value, depending on if the string is considered "human-friendly" or not.
Assume that only valid input will be used. Don't worry about error handling.

The winner will be determined by the shortest program/function. They will be selected in at least 7 days, or if/when there have been enough submissions. In the event of a tie, the answer that came earlier wins.
Examples
Here's a few examples of input and output that your code should be able to handle:
"results_for__michael_greer.txt.zip" => true

"Georg Feuerstein - Connecting the Dots.pdf" => true

"M People - Search for the Hero-ntuqTuc6HxM.mp4" => true

"index.html?v=QTR4WGVTUzFsV3d8NHxvcmlnaW5hbHx8MTExMTAxBHxodHRwOi8vLCwsLHRyLDcsMA%3D%3D.html" => false

"ol2DCE0SIyQC(173).pdf" => false

"d41d8cd98f00b204e9800998ecf8427e.md5" => false

"12792331_807918856008495_7076645197310150318_o.jpg" => false

Javascript, 466 bytes

s=>(s=s.split(/\.[a-z\d]{1,6}$/i)[j=d=0],h=s[l='length']/2|0,m=[],g=r=>(++j,m=m.concat((s[n='match'](r)||[]).map(x=>[x,j]))),p='replace',g(/\d{9,}/g),g(/[\da-f]{16,}/ig),g(/[\da-z%+=]{12,}/ig),m.sort((x,y)=>y[0][l]-x[0][l]).every(x=>x[1]-1?x[1]-2?s=s[p](x[0],y=>y[n](/[a-z]/)&&y[n](/\d/)&&(y+'A')[n](/[A-Z]/g)[l]>y[l]/3|0?(d+=y[l],''):y):s=s[p](x[0],y=>!!y[n](/[A-F]/)^!!y[n](/[a-f]/)&&(y+'0')[n](/\d/g)[l]>y[l]/3|0?(d+=y[l],''):y):(s=s[p](z=x[0],''),d+=z[l])),d<=h)

Explaining:

f=s=>(                                 // f: take string s (filename) as input
    s=s.split(/\.[a-z\d]{1,6}$/i)[j=d=0],  // s: input without extension
                                           // d: combined rules' sum
                                           // j: combined rule-number step
    h=s[l='length']/2|0,                   // h: half string
                                           // l: length
    m=[],                                  // m: matches
    g=r=>(++j,                             // j: next combined rule number
        m=m.concat(                            // m: join
            (s[n='match'](r)||[]).map(             // new (r)egex-matches
            x=>[x,j])                              // mapped with its rule number
    )),p='replace',                        // p: replace
    g(/\d{9,}/g),                          // combined rules §1
    g(/[\da-f]{16,}/ig),                   // combined rules §2
    g(/[\da-z%+=]{12,}/ig),                // combined rules $3
    m.sort((x,y)=>y[0][l]-x[0][l])         // matches ordered by length
        .every(x=>x[1]-1?                      // for combined rule §1
            x[1]-2?                                // for combined rule §2
                s=s[p](x[0],y=>                        // for combined rule §3
                    y[n](/[a-z]/)&&y[n](/\d/)&&            // if lower and digit and
                    (y+'A')[n](/[A-Z]/g)[l]>y[l]/3|0?      // upper at least `total/3`
                (d+=y[l],''):y)                        // replace by empty and sum up `d`
            :s=s[p](x[0],y=>                       // replace if
                !!y[n](/[A-F]/)^!!y[n](/[a-f]/)&&      // (upper xor lower case) and
                (y+'0')[n](/\d/g)[l]>y[l]/3|0?         // digits: at least `total/3`
            (d+=y[l],''):y)                        // by empty and sum up `d`
        :(s=s[p](z=x[0],''),d+=z[l]))          // no treatment
    ,d<=h                                  // output if "no more than half of string"
);

["results_for__michael_greer.txt.zip",
"Georg Feuerstein - Connecting the Dots.pdf",
"M People - Search for the Hero-ntuqTuc6HxM.mp4",
"index.html?v=QTR4WGVTUzFsV3d8NHxvcmlnaW5hbHx8MTExMTAxBHxodHRwOi8vLCwsLHRyLDcsMA%3D%3D.html",
"ol2DCE0SIyQC(173).pdf",
"d41d8cd98f00b204e9800998ecf8427e.md5",
"12792331_807918856008495_7076645197310150318_o.jpg"]
.forEach(x=>document.body.innerHTML+='<pre>"'+x+'" => '+f(x)+'</pre>')


What is the fastest safe way down a mountain? Intro

Help! I'm stuck on a snow-covered mountain and I need to get down as fast as possible, preferably without dying. I have a map showing how high each part of the mountain is above the normal ground.

I am a novice skier, which means I like to stick to slopes that aren't too steep. I'm willing to go down just two moderately steep sections, however - but not back to back!

Rules

Your program's job is to, given a n x m matrix of height values, navigate from the skier's current position (the top left corner) to the base (the bottom right corner). Height values will be given as integers between 0 and 25, with 25 being the highest possible point and 0 being the base of the mountain. It should be noted the mountain does not have to start at 25 units high, but will always finish at the 0 in the bottom right corner.

There are a few constraints:

The skier can move up, down, left, or right on the map. No diagonals.
The skier is usually only comfortable on slopes that bring him down 2 units or less.
The only exception to the above rule is that the skier can go down a maximum of two sections that will bring him down 3 or 4 units.
The skier can move upwards if necessary, but only one unit at a time. The skier also cannot go upwards or flat then immediately thereafter go down a steep slope of 3 or 4 units, he must already be headed downwards before taking a steep slope. Also, his first move cannot be to go down a steep slope, and he cannot do two steep slopes back to back.
It is possible for the skier to visit a location twice (as seen in the fourth example - this is due to the fact that the skier cannot go down two steep slopes in a row)

Input

As mentioned above, the map will be given by a matrix containing integer values from 0 to 25, with a 0 in the bottom left corner (there could be zeroes in other places on the map). These maps will always have at lease one best solution but could have several worse solutions. These matrices will always have spaces and line breaks as separators - double spaces will be used if the integer is just one character (see examples below)

Output

Your program is to output a sequence of moves (the format of this sequence does not matter so long as it is coherent) that shows the best way down the mountain - meaning fewest moves on the map. These moves can be represented by any strings, numbers, or characters you like, so long as they are distinct and are described in your solution. A sample output might look like RRDDRRRURRDDDDRR, where R means right, D means down, U means up, and L means left.

Test cases

Input 1:

10 13 13 13 13
8  9  11 13 25
0  7  11 12 23
6  5  2  2  0

Sample output 1:

DRDDRRR

Input 2:

16 12 12 10 8 6
14 12 6  8  0 4
10 20 4  2  1 2
8  20 10 8  4 0
9  8  9  25 2 0

Sample output 2:

DDDDRRURRDR or DRURRRRDDDD

Input 3:

20 19 15 11 0  9  15 6
18 20 13 12 11 9  18 12
16 25 9  7  6  2  1  1
12 20 10 4  4  4  3  2
13 12 13 0  0  0  0  0

Sample output 3:

RRDDRRDRRRD

Input 4:

20 18 10 11 12 0
19 11 1  4  5  0
18 16 3  3  3  3
19 8  7  17 19 3
18 20 11 12 13 3
17 17 16 16 14 2
20 21 11 14 11 0

Sample output 4:

DDDDDRRRRULLULRURRRDDDD

Scoring:

This is code-golf. Shortest answer wins - get creative!

JavaScript (ES6),  223 ... 205  199 bytes

f=(m,x=o=0,y=0,n=2,V,s,p='',r=m[y]||0,v=r[x],h=V%32-v%32|0)=>63>>h+1&v<64&!p[o.length-1]?h<3||s*n--?1+r[x+!m[y+1]]?[...'LURD'].map((c,d)=>r[f(m,x+--d%2,y+~-d%2,n,r[x]+=32,6>>h&1,p+c),x]=v)&&o:o=p:0:0

Try it online!
Commented
The 5 least significant bits of the cells are left unchanged. The upper bits are used to count the number of times a cell has been visited in a given path.
We need quite a lot of variables to fully describe the skier status at any given time, notably the possibility to do a big steep slope.
Header
f = (                      // a recursive function taking:
  m,                       //   m[] = input matrix
  x =                      //   (x, y) = current position, starting at (0, 0)
  o = 0,                   //   o = output string, initialized to a numerical value
  y = 0,                   //
  n = 2,                   //   n = remaining number of big steep slopes
  V,                       //   V = value of the previous cell
  s,                       //   s = a flag that is set if a big steep slope is allowed
                           //       for this turn
  p = '',                  //   p = current path string
  r = m[y] || 0,           //   r[] = current row (using 0 as a fallback)
  v = r[x],                //   v = value of the current cell (or undefined)
  h = V % 32 - v % 32 | 0  //   h = height between the previous and the current cell
) =>                       //       (0 if V is undefined)
  (...)                    //

Tests
63 >> h + 1 &              // if the height is greater than or equal to -1 and less
                           // than or equal to 4 and
v < 64 &                   // v is defined and less than 64 and
!p[o.length - 1] ?         // the current path is shorter than the best solution or
                           // we don't have a solution yet (in which case o.length - 1
                           // is NaN):
  h < 3 ||                 //   if the height is less than 3 or
  s * n-- ?                //   a big steep slope is allowed and we can still do one:
    1 + r[x + !m[y + 1]] ? //     if we haven't reached the bottom-right cell,
                           //     i.e. m[y + 1] is defined or 1 + r[x + 1] is not NaN:
      (...)                //       process the recursive calls
    :                      //     else:
      o = p                //       update the solution to this path
  :                        //   else:
    0                      //     do nothing
:                          // else:
  0                        //   do nothing

Recursive calls
[...'LURD'].map((c, d) =>  // for each direction character c at index d:
  r[                       //   we will eventually restore r[x]
    f(                     //     recursive call:
      m,                   //       m[] is unchanged
      x + --d % 2,         //       add dx to x
      y + ~-d % 2,         //       add dy to y
      n,                   //       n is unchanged
      r[x] += 32,          //       add 32 to the current cell
      6 >> h & 1,          //       set s if h is either 1 or 2
      p + c                //       append c to the path
    ),                     //     end of recursive call
    x                      //     restore r[x] to ...
  ] = v                    //   ... v
) && o                     // end of map(); yield o


Create an Accurate How-To Article Here is an easy-intermediate challenge for anyone interested!
What is that?
A thing me and brother do a bit too often is this:
One of us has a problem and asks the other to explain how to do certain stuff. The other just says the following carelessly:
How to <verb> in <n> easy steps!
                                   (Newline mandatory)
Step 1 - Do not <verb>.
Step 2 - Do not <verb>.
Step 3 - Do not <verb>.
.
.
.
Step <n> - <verb>.                 (Capitalised)

For example, if my brother could not find a pen to write with (Do not ask me why) and asked How do I find a pen?, I would probably answer:
How to find a pen in 10 easy steps!

Step 1 - Do not find a pen.
Step 2 - Do not find a pen.
Step 3 - Do not find a pen.
Step 4 - Do not find a pen.
Step 5 - Do not find a pen.
Step 6 - Do not find a pen.
Step 7 - Do not find a pen.
Step 8 - Do not find a pen.
Step 9 - Do not find a pen.
Step 10 - Find a pen.

Sarcasm alert!Now isn't that so accurate and helpful!
<verb> is the problem one of us wants to achieve.
<n> is a random number that we choose (for your information, we mostly use 10 as <n>, but that is not important for this challenge).
So what?
Your challenge is to write a usual program or function using standard I/O and golfing rules that takes in a string formatted with "How do I <v>?" as input, and then print or return the (accurate) how-to article specified according to the rules displayed above, where <verb> is <v> from the input, and <n> is any random natural number from the range 1 to 10 (inclusive) generated by your program. When <n> is 1, remove the ending s in ...steps!.
Standard loopholes are not allowed!

Note: There might be some cases where sentences will be illogical, like in the case of How do I find my pen?. Outputting How to find my pen in <n> easy steps is fine!

Here is another example for further clarity:
Input -
How do I make coffee?

Example output -
How to make coffee in 3 easy steps!

Step 1 - Do not make coffee.
Step 2 - Do not make coffee.
Step 3 - Make coffee.

Good luck!

LaTeX, 269 bytes
\input tikz.tex\let\s\pgfmathsetmacro\pgfmathsetseed{\number\pdfrandomseed}\def\u#1{\uppercase{#1}}\def\f
How do I #1?{\s\n{random(0,9)}\s\m{int(\n+1)}How to #1 in \m~easy
step\ifnum\m>1s!\\\\\foreach\i in{1,...,\n}{Step \i~- Do not #1.\\}\else!\\\\\fi
Step \m~- \u#1.}

Random numbers aren't very nice to handle in LaTeX.
Example output:


Find the Interwoven Source Codes (Robbers) This is the robbers' thread. For the cops' thread, go here.
Introduction
For this Cops/Robbers challenge, the cops will write output-producing programs and interweave them together. It is the robber's job to pick apart the cops' programs to produce the desired outputs.
Robber rules
Robbers will try to find the different programs that people post in submissions to the cops' thread (linked above). If a robber solves a cop's code, they must post the separated programs and match them with their outputs in an answer here and post that they have cracked the code on the cop's answer.
Scoring
There are two components that are added together when scoring a cracked submission.

2 to the power of the number of different programs used in the cop's answer
Round the number of bytes in the interweaving down to the nearest power of 2.

For example, if a robber cracks TIliGoEnR as being TIGER and lion, then the robber receives 2^2+8=12 points.
The winner of the robbers' challenge will be the person with the most points after a sufficient period of time for people to participate.

(Who wants to help with a snippet?)

Vitsy, 12 points

'o'2\I/NO

Try it online!

a5F\aZ

Try it online!

The NaN in NaNo was a dead giveaway.

The obvious way to push NaN would be to divide 0 by itself, 2\I pushes the input length (0) twice, / performs division, and N prints a float.

We're left with printing o, and 'o' is a string literal that O prints.

Whatever characters were left had to belong to the other program. In fact, a pushes a linefeed, 5F the factorial of 5 (120), \a turns that into 120 linefeeds, and Z prints the entire stack.