Can you hear me now? Background

You are a rich executive of a software empire. Your time is worth a lot of money. As such, you must always travel in the most efficient route possible. However, as an executive, you spend a lot of time participating in important phone calls. It is paramount that you never drop calls, so you must never travel through areas which don't have cell service!

The Challenge

You'll be given a list of three-tuples, each of which represents the location and power of a cell tower. As an example, [50, 25, 16] would represent a cell tower located at <x,y> = <50, 25> with a circle of radius 16 representing its circle of influence. With this list in mind, you must travel from your starting position at <0, 0> to your destination at <511, 511>, in the shortest distance possible without losing cell service. This is code-golf, so shortest code wins!

Input / Output

You are free to manipulate the input into a form that makes it easy to read, such as in a file, or as a nested array through STDIN using eval, etc. You may hardcode the input, so long as your code works for other inputs as well. The exact characters used to hardcode the input will not be counted, but the variable name and assignment characters will. You should not assume that the input is in any specific order, or that every cell tower is relevant to the problem. If you have any questions please leave a comment and I will try to clarify it.

The output is to be a list of coordinates, marking points that when connected in order form a path to the exit. The accuracy need only be rounded to the nearest integer, and if you are 1-2 units off of what I have in me output example, that is fine. I have included images below to clarify this.

Best of luck!

Examples

input:
[ 32,  42,  64]
[112,  99,  59]
[141, 171,  34]
[157, 191,  28]
[177, 187,  35]
[244, 168,  57]
[289, 119,  20]
[299, 112,  27]
[354,  59,  58]
[402,  98,  23]
[429,  96,  29]
[424, 145,  34]
[435, 146,  20]
[455, 204,  57]
[430, 283,  37]
[432, 306,  48]
[445, 349,  52]
[424, 409,  59]
[507, 468,  64]

output:
0 0
154 139
169 152
189 153
325 110
381 110
400 120
511 511

input2
[ 32,  42,  64]
[112,  99,  59]
[141, 171,  34]
[157, 191,  28]
[177, 187,  35]
[244, 168,  57]
[289, 119,  20]
[299, 112,  27]
[354,  59,  58]
[402,  98,  23]
[429,  96,  29]
[424, 145,  34]
[435, 146,  20]
[455, 204,  57]
[430, 283,  37]
[432, 306,  48]
[445, 349,  52]
[424, 409,  59]
[507, 468,  64]
[180, 230,  39]
[162, 231,  39]
[157, 281,  23]
[189, 301,  53]
[216, 308,  27]
[213, 317,  35]
[219, 362,  61]
[242, 365,  42]
[288, 374,  64]
[314, 390,  53]
[378, 377,  30]
[393, 386,  34]

output2:
0 0
247 308
511 511

The previous path is highlighted in blue, but you can see the addition of more towers allows a more optimal route.

Python, 1,291 1,271 1,225 bytes

As Martin noted, this problem can be largely reduced to his excellent rubber band challenge.
Using that challenge's terminology, we can take as the second set of nails the points of intersection between the circles on the boundary of the enclosed area:

As the rubber band we can take any path P between the two endpoints that runs inside the enclosed area.
We can then invoke a solution to the rubber-band problem to produce a (locally) minimal path.
The challenge is, of course, to find such a path P, or more precisely, to find enough paths so that at least one of them produces the globally minimal path (note that in the first test-case we need at least one path to cover all possibilities, and in the second test-case at least two.)

A naive approach would be to just try all possible paths:
For every sequence of adjacent (i.e. intersecting) circles that connects the two endpoints, take the path along their centers (when two circles intersect, the segment between their centers is always within their union.)
Though this approach is technically correct, it can lead to a ridiculously large number of paths.
While I was able to solve the first test-case using this approach within a few seconds, the second one took forever.
Still, we can take this method as a starting point and try to minimize the number of paths we have to test.
This is what follows.

We construct our paths by basically performing a depth-first search on the graph of circles.
We're looking for a way to eliminate potential search directions at each step of the search.

Suppose that at some point we're at a circle A, that has two adjacent circles B and C, which are also adjacent to each other.
We can get from A to C by visiting B (and vice versa,) so we might think that visiting both B and C directly from A is unnecessary.
Unfortunately, this is wrong, as this illustration shows:

If the points in the illustration are the two endpoints, we can see that by going from A to C through B we get a longer path.

How about this one: if we're testing both the moves A→B and A→C, then it's unnecessary to test A→B→C or A→C→B, since they can't result in shorter paths.
Wrong again:

The point is that using purely adjacency-based arguments is not going to cut it; we have to use the geometry of the problem as well.
What the two above examples have in common (as well as the second test-case on a larger scale,) is that there's a "hole" in the enclosed area.
It manifests itself in the fact that some of the points-of-intersection on the boundary—our "nails"—are within the triangle △ABC whose vertices are the circles' centers:

When this happens, there's a chance that going from A to B and from A to C will result in different paths.
More importantly, when it doesn't happen (i.e. if there wasn't a gap between A, B and C) then it's guaranteed that all paths starting with A→B→C and with A→C and which are otherwise equivalent will result in the same locally minimal path, hence if we visit B we don't need to also visit C directly from A.

This leads us to our elimination method:
When we're at a circle A, we keep a list H of the adjacent circles we've visited.
This list is initially empty.
We visit an adjacent circle B if there are any "nails" in all the triangles formed by the centers of A, B and any of the circles in H adjacent to B.
This method dramatically drops the number of paths we have to test to just 1 in the first test-case and 10 in the second one.

A few more notes:

It's possible to decrease the number of paths we test even further, but this method is good enough for the scale of this problem.
I used the algorithm from my solution to the rubber-band challenge.
Since this algorithm is incremental it can be pretty easily integrated into the path-finding process, so that we minimize the path as we go along.
Since many paths share a starting-segment, this can significantly improve performance when we have lots of paths.
It can also hurt performance if there are much more dead-ends than valid paths.
Either way, for the given test-cases performing the algorithm for each path separately is good enough.
There's one edge-case where this solution may fail:
If any of the points on the boundary is the point of intersection of two tangent circles then under some conditions the result can be wrong.
This is due to the way rubber-band algorithm works.
With some modifications it's possible to handle these cases as well, but, hell, it's already long enough.

# First test case
I={((32.,42.),64.),((112.,99.),59.),((141.,171.),34.),((157.,191.),28.),((177.,187.),35.),((244.,168.),57.),((289.,119.),20.),((299.,112.),27.),((354.,59.),58.),((402.,98.),23.),((429.,96.),29.),((424.,145.),34.),((435.,146.),20.),((455.,204.),57.),((430.,283.),37.),((432.,306.),48.),((445.,349.),52.),((424.,409.),59.),((507.,468.),64.)}
# Second test case
#I={((32.,42.),64.),((112.,99.),59.),((141.,171.),34.),((157.,191.),28.),((177.,187.),35.),((244.,168.),57.),((289.,119.),20.),((299.,112.),27.),((354.,59.),58.),((402.,98.),23.),((429.,96.),29.),((424.,145.),34.),((435.,146.),20.),((455.,204.),57.),((430.,283.),37.),((432.,306.),48.),((445.,349.),52.),((424.,409.),59.),((507.,468.),64.),((180.,230.),39.),((162.,231.),39.),((157.,281.),23.),((189.,301.),53.),((216.,308.),27.),((213.,317.),35.),((219.,362.),61.),((242.,365.),42.),((288.,374.),64.),((314.,390.),53.),((378.,377.),30.),((393.,386.),34.)}

from numpy import*
V=array;X=lambda u,v:u[0]*v[1]-u[1]*v[0];L=lambda v:dot(v,v)
e=V([511]*2)
N=set()
for c,r in I:
 for C,R in I:
  v=V(C)-c;d=L(v)
  if d:
    a=(r*r-R*R+d)/2/d;q=r*r/d-a*a
    if q>=0:w=V(c)+a*v;W=V([-v[1],v[0]])*q**.5;N|={tuple(t)for t in[w+W,w-W]if all([L(t-T)>=s**2-1e-9 for T,s in I])}
N=map(V,N)
def T(a,b,c,p):H=[X(p-a,b-a),X(p-b,c-b),X(p-c,a-c)];return min(H)*max(H)>=0
def E(a,c,b):
 try:d=max((X(n-a,b-a)**2,id(n),n)for n in N if T(a,b,c,n)*X(n-b,c-b)*X(n-c,a-c))[2];A=E(a,c,d);B=E(d,c,b);return[A[0]+[d]+B[0],A[1]+[sign(X(c-a,b-c))]+B[1]]
 except:return[[]]*2
def P(I,c,r,A):
 H=[];M=[""]
 if L(c-e)>r*r:
    for C,R in I:
     if L(C-c)<=L(r+R)and all([L(h-C)>L(R+s)or any([T(c,C,h,p)for p in N])for h,s in H]):v=V(C);H+=[(v,R)];M=min(M,P(I-{(C,R)},v,R,A+[v]))
    return M
 A+=[e]*2;W=[.5]*len(A)
 try:
  while 1:
    i=[w%1*2or w==0for w in W[2:-2]].index(1);u,a,c,b,v=A[i:i+5];A[i+2:i+3],W[i+2:i+3]=t,_=E(a,c,b);t=[a]+t+[b]
    for p,q,j,k in(u,a,1,i+1),(v,b,-2,i+len(t)):x=X(q-p,c-q);y=X(q-p,t[j]-q);z=X(c-q,t[j]-q);d=sign(j*z);W[k]+=(x*y<=0)*(x*z<0 or y*z>0)*(x!=0 or d*W[k]<=0)*(y!=0 or d*W[k]>=0)*d
 except:return[sum(L(A[i+1]-A[i])**.5for i in range(len(A)-1)),id(A),A]
print V(P(I,e*0,0,[e*0]*2)[2][1:-1])

Input is given through the variable I as a set of tuples ((x, y), r) where (x, y) is the center of the circle and r is its radius.
The values must be floats, not ints.
The result is printed to STDOUT.

Example

# First test case
I={((32.,42.),64.),((112.,99.),59.),((141.,171.),34.),((157.,191.),28.),((177.,187.),35.),((244.,168.),57.),((289.,119.),20.),((299.,112.),27.),((354.,59.),58.),((402.,98.),23.),((429.,96.),29.),((424.,145.),34.),((435.,146.),20.),((455.,204.),57.),((430.,283.),37.),((432.,306.),48.),((445.,349.),52.),((424.,409.),59.),((507.,468.),64.)}

[[   0.            0.        ]
 [ 154.58723733  139.8329183 ]
 [ 169.69950891  152.76985495]
 [ 188.7391093   154.02738541]
 [ 325.90536774  109.74141936]
 [ 382.19108518  109.68789517]
 [ 400.00362897  120.91319495]
 [ 511.          511.        ]]


Decode a 7-segment display You probably all know the 7-segment display which can display among other things all digits from \$0\dots 9\$:

Challenge

We only consider the segments \$\texttt{A}\dots\texttt{G}\$, your task is to decode a single digit given which segments are turned on.

This can be encoded as an 8-bit integer, here's a table of each digit with their binary representation and the corresponding little-endian and big-endian values:

$$
\begin{array}{c|c|rr|rr}
\text{Digit} & \texttt{.ABCDEFG} & \text{Little-endian} && \text{Big-endian} & \\ \hline
0 & \texttt{01111110} & 126 & \texttt{0x7E} & 126 & \texttt{0x7E} \\
1 & \texttt{00110000} &  48 & \texttt{0x30} &  12 & \texttt{0x0C} \\
2 & \texttt{01101101} & 109 & \texttt{0x6D} & 182 & \texttt{0xB6} \\
3 & \texttt{01111001} & 121 & \texttt{0x79} & 158 & \texttt{0x9E} \\
4 & \texttt{00110011} &  51 & \texttt{0x33} & 204 & \texttt{0xCC} \\
5 & \texttt{01011011} &  91 & \texttt{0x5B} & 218 & \texttt{0xDA} \\
6 & \texttt{01011111} &  95 & \texttt{0x5F} & 250 & \texttt{0xFA} \\
7 & \texttt{01110000} & 112 & \texttt{0x70} &  14 & \texttt{0x0E} \\
8 & \texttt{01111111} & 127 & \texttt{0x7F} & 254 & \texttt{0xFE} \\
9 & \texttt{01111011} & 123 & \texttt{0x7B} & 222 & \texttt{0xDE}
\end{array}
$$

Rules & I/O

Input will be one of

single integer (like in the table above one of the two given orders)
a list/array/.. of bits
a string consisting of characters ABCDEFG (you may assume it's sorted, as an example ABC encodes \$7\$), their case is your choice (not mixed-case)

Output will be the digit it encodes
You may assume no invalid inputs (invalid means that there is no corresponding digit)

Tests

Since this challenge allows multiple representations, please refer to the table.

JavaScript (ES6), 26 bytes
Takes input in little Endian.

n=>'0958634172'[n*3%77%10]

Try it online!


Smoothing out a list You should write a program or function which takes a non-negative integer k and a sorted integer list Las input and outputs or returns a smoothed list M.

M is created from the ascending list L by inserting at most k integer elements while keeping the list sorted. The inserted integers should be chosen in a way that the maximum forward difference of M will be as small as possible. We will call this smallest value "smoothness".

The forward differences of the list -1 3 8 11 15 are 4 5 3 4 and the maximum forward difference is 5.

With 2 insertions the smoothness of 2 10 15 is 4 and a possible output is 2 6 10 11 15 with forward differences 4 4 1 4.

Input

A non-negative integer k.
An ascending integer list L with at least 2 elements.

Output

The ascending integer list M.
If multiple correct answers exists output exactly one of them (any one is sufficient).
Your solution has to solve any example test case under a minute on my computer (I will only test close cases. I have a below-average PC.).

Examples

Input (k, L) => A possible output and the maximum forward difference (which is not part of the output) in parentheses

0, 10 20 => 10 20 (10)

2, 1 10 => 1 4 7 10 (3)

2, 2 10 15 => 2 6 10 11 15 (4)

3, 2 10 15 => 2 5 8 10 12 15 (3)

5, 1 21 46 => 1 8 15 21 27 33 39 46 (7)

5, 10 20 25 33 => 10 14 18 20 24 25 29 33 (4)

3, 4 4 6 9 11 11 15 16 25 28 36 37 51 61 => 4 4 6 9 11 11 15 16 22 25 28 36 37 45 51 59 61 (8)

15, 156 888 2015 => 156 269 382 495 608 721 834 888 1001 1114 1227 1340 1453 1566 1679 1792 1905 2015 (113)

8, -399 -35 -13 56 157 => -399 -347 -295 -243 -191 -139 -87 -35 -13 39 56 108 157 (52)

5, 3 3 3 => 3 3 3 3 (0)

This is code-golf so the shortest entry wins.

Python 2, 104

def f(L,k,d=1):
 M=[];p=L[0]
 for x in L:M+=range(p+d,x,d);p=x
 return M[k:]and f(L,k,d+1)or sorted(L+M)

Tries different maximum increments d, starting from 1 and counting up. Fills in gaps of each pair (p,x) of successive elements by taking every d'th number in the gap. If M is longer than the quota allows, recurses to try a higher d. Otherwise, returns a list of the added and original elements, sorted.

This does all the test cases without delay on my machine.


Implement the Thanos sorting algorithm The sorting algorithm goes like this:

While the list is not sorted, snap half of all items (remove them from the list). Continue until the list is sorted or only one item remains (which is sorted by default). This sorting algorithm may give different results based on implementation.

The item removal procedure is up to the implementation to decide, but the list should be half as long as before after one pass of the item removal procedure. Your algorithm may decide to remove either the first half or the list, the last half of the list, all odd items, all even items, one at a time until the list is half as long, or any not mentioned.

The input list can contain an arbitrary amount of items (within reason, let’s say up to 1000 items), not only perfectly divisible lists of 2^n items. You will have to either remove (n+1)/2 or (n-1)/2 items if the list is odd, either hardcoded or decided randomly during runtime. Decide for yourself: what would Thanos do if the universe contained an odd amount of living things?

The list is sorted if no item is smaller than any previous item. Duplicates may occur in the input, and may occur in the output.

Your program should take in an array of integers (via stdin or as parameters, either individual items or an array parameter), and return the sorted array (or print it to stdout).

Examples:

// A sorted list remains sorted
[1, 2, 3, 4, 5] -> [1, 2, 3, 4, 5]

// A list with duplicates may keep duplicates in the result
[1, 2, 3, 4, 3] -> [1, 3, 3] // Removing every second item
[1, 2, 3, 4, 3] -> [3, 4, 3] -> [4, 3] -> [3] // Removing the first half
[1, 2, 3, 4, 3] -> [1, 2] // Removing the last half

[1, 2, 4, 3, 5] could give different results:

// Removing every second item:
[1, 2, 4, 3, 5] -> [1, 4, 5]

or:

// Removing the first half of the list
[1, 2, 4, 3, 5] -> [3, 5] // With (n+1)/2 items removed
[1, 2, 4, 3, 5] -> [4, 3, 5] -> [3, 5] // With (n-1)/2 items removed

or:

// Removing the last half of the list
[1, 2, 4, 3, 5] -> [1, 2] // With (n+1)/2 items removed
[1, 2, 4, 3, 5] -> [1, 2, 4] // With (n-1)/2 items removed

or:

// Taking random items away until half (in this case (n-1)/2) of the items remain
[1, 2, 4, 3, 5] -> [1, 4, 3] -> [4, 3] -> [4]

Python 3, 38  42 39 bytes

q=lambda t:t>sorted(t)and q(t[::2])or t

Try it online!

-3 bytes thanks to @JoKing and @Quuxplusone


Implement glob Matcher Implement a function of pattern and string to be matched, return true if the pattern matches the WHOLE string, otherwise false.

Our glob pattern syntax is:

? matches any one character
+ matches one or more characters
* matches zero or more characters
\ escapes

Rules:

No eval, no converting into regular expression, no calling a system glob function.
I/O are not required: you can just write a function
Shortest wins

Examples:

glob('abc', 'abc') => true
glob('abc', 'abcdef') => false IMPORTANT!
glob('a??', 'aww') => true
glob('a*b', 'ab') => true
glob('a*b', 'agwijgwbgioeb') => true
glob('a*?', 'a') => false
glob('?*', 'def') => true
glob('5+', '5ggggg') => true
glob('+', '') => false
glob('a\*b', 'a*b') => true

Here is a tip to get started: http://en.wikipedia.org/wiki/Backtracking

Haskell, 141 characters

c('\\':a:z)s=a&s>>=c z
c(a:z)s=a%s>>=c z
c[]s=[null s]
p&(a:z)|a==p=[z]
_&_=[]
'?'%(a:z)=[z]
'*'%a=a:'+'%a
'+'%(a:z)='*'%z
l%a=l&a
g=(or.).c

Works for all input, both patterns and strings to match against. Handles trailing backslash in the pattern as a literal match (behavior was unspecified.)

This can be run with the following test driver:

main = do
    globtest "abc" "abc"    True
    globtest "abc" "abcdef" False
    globtest "a??" "aww"    True
    globtest "a*b" "ab"     True
    globtest "a*b" "agwijgwbgioeb" True
    globtest "a*?" "a"      False
    globtest "?*" "def"     True
    globtest "5+" "5ggggg"  True
    globtest "+" ""         False
    globtest "a\\*b" "a*b"  True
  where
    globtest p s e =
      if g p s == e
        then putStrLn "pass"
        else putStrLn$"fail: g " ++ show p ++ " " ++ show s ++ " /= " ++ show e

Update: I wrote a blog post about this particular answer, as I think it shows off well how Haskell so easily encodes the problem.

Edit: (181 -> 174) replaced d and m with operators
Edit: (174 -> 151) inlined r into c
Edit: (151 -> 149) removed an unnecessarily generated option in the + case
Edit: (149 -> 141) removed an unnecessary clause for %, which was handled by &


Spell out the Revu'a Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator.

Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first two characters of s, ... the first n–2 characters of s, the first n–1 characters of s, the entire s.

The string will only consist of Unicode (any encoding you want) characters that have strong directionality and are found in the range 0x0000 through 0xFFFF. However, no directionality control characters will occur. All characters in any given string will have the same directionality.

You may return in array notation ["t","te","tes","test"], as a space-separated string "t te tes test", as multi-line textttetestest, a pre-formatted arrayt
te
tes
test, or anything similar. Amounts of leading, separating, and trailing spacing is not important, and neither are trailing newline. Ask if in doubt.

Right-to-Left input must result in Right-to-Left output in proper order:

Input: "נחמן"

Output: "נ  נח  נחמ  נחמן" orנ
נח
נחמ
נחמן
, or ["נ","נח","נחמ","נחמן"]. Among invalid results are "נחמן  נחמ  נח  נ" ,"ן  מן  חמן  נחמן", and "נחמן  חמן  מן  ן".

Dyalog APL, 2 bytes
,\

Cumulative reduce by concatenate. Try it here.
The formatting of the output is nicer when you prefix a ⍕, but it clearly shows the correct order without.


Test if a Gray code is Beckett Background
An \$n\$-bit Gray code is an ordering of \$2^n\$ binary sequences so that adjacent sequences always differ by exactly one bit.
A Beckett-Gray code is a special kind of Gray code. In addition to being a Gray code, it has the following characteristics:

It is cyclic: the last bit pattern has one bit difference with the first pattern.  (Your input is guaranteed to be cyclic)
The first pattern is all zeros.    (Your input is guaranteed to start with 0)
Whenever a bit turns from 1 to 0, that bit is the one which has been 1 for the longest time (consecutively).  (You need to verify this)

It is known that a Beckett-Gray code exists for \$n=2, 5, 6, 7, 8\$, but does not exist for \$n=3\$ and \$4\$. It is not known if any such code exists for \$n \ge 9\$, and no constructive methods to build such a code are known.
One example for \$n=5\$ is as follows (copied from this paper, 1-0 transition marked):
00000, 00001, 00011, 00010, 00110, 00111, 00101, 01101,
                         ^                   ^
01001, 01000, 01010, 01011, 11011, 10011, 10111, 10101,
  ^        ^                        ^               ^
10100, 00100, 01100, 11100, 11000, 11010, 10010, 10110,
    ^  ^                      ^            ^
11110, 01110, 01111, 11111, 11101, 11001, 10001, 10000
       ^                       ^     ^     ^         ^

Task
Given a cyclic Gray code starting with an all-zero pattern, determine if it is a Beckett-Gray code.
You may take input as a sequence of boolean arrays (possibly transposed), a sequence of strings, or a sequence of equivalent integers. Also, you may optionally take the value of \$n\$ as the second input.
For output, you can choose to

output truthy/falsy using your language's convention (swapping is allowed), or
use two distinct values to represent true (affirmative) or false (negative) respectively.

Standard code-golf rules apply. Shortest code in bytes wins.
Test cases
Each test case is separated with an empty line.
Truthy (Beckett)
0, 1

00, 01, 11, 10

00, 10, 11, 01

00000, 00001, 00011, 00010, 00110, 00111, 00101, 01101,
01001, 01000, 01010, 01011, 11011, 10011, 10111, 10101,
10100, 00100, 01100, 11100, 11000, 11010, 10010, 10110,
11110, 01110, 01111, 11111, 11101, 11001, 10001, 10000

00000, 01000, 01001, 00001, 00011, 01011, 01010, 11010,
11000, 10000, 10001, 11001, 11101, 01101, 01111, 01110,
00110, 00010, 10010, 10110, 10100, 10101, 00101, 00111,
10111, 10011, 11011, 11111, 11110, 11100, 01100, 00100

Falsy (Not Beckett)
000, 001, 011, 010, 110, 111, 101, 100

0000, 1000, 1100, 1110, 1111, 1101, 0101, 0001,
1001, 1011, 1010, 0010, 0011, 0111, 0110, 0100

00000, 00001, 00011, 00010, 00110, 00111, 00101, 00100,
01100, 01101, 01111, 01110, 01010, 01011, 01001, 01000,
11000, 11001, 11011, 11010, 11110, 11111, 11101, 11100,
10100, 10101, 10111, 10110, 10010, 10011, 10001, 10000

Husk, 9 bytes
Λ≡½hÖ▼Ẋz-

Try it online! (Version with formatting header to allow pasting testcases: Try it online!)
Explanation
If we compute differences from each binary sequence to the next with an element-by-element subtraction, we will get a series of results each containing a single -1/+1 on the flipped bit and a 0 on all other bits. In order for this Gray code to be Beckett, the subsequence of -1 lists must be identical to the subsequence of +1 lists (except for the sign).
As noted by Unrelated String we don't need to check the last element against the first, since it will always consist of a single 1 turning into a 0.
 Λ≡½hÖ▼Ẋz-    Input: list of binary sequences
       Ẋ      For each pair of adjacent sequences:
        z-       subtract the first from the second element by element
     Ö▼       Sort by the minimum (in place): all the -1 sequences move to the beginning
    h         Discard the last (would match the final sequence turning into the first)
   ½          Group the sequences into two lists of equal length
                (the first will contain the -1s, the second the +1s)
 Λ            Check that the two elements
  ≡           Have the same distribution of zeros/nonzeros


Type-check an expression Given an infix expression, determine whether all constants are of the same type.

Operators will consist only of these dyadic operators: +-/*

Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value otherwise.

The expression will consist solely of constants, and may contain any of the following types:

String, of the form "String" (Always double quotes, can be empty, no escape characters, may contain any ASCII text)
Integer, of the form 14 (Always positive or zero)
Float, of the form 7.3f (Always positive or zero, always has a decimal component, eg 14.0f)
Byte, of the form 0x42 (0-255, Always 2 hexadecimal characters)
Boolean, of the form true (true or false, case insensitive)

The expression will not contain parentheses, as order of operation doesn't affect type when no type coercion is present.

A lone constant with no operators is a valid expression.

An empty expression is not a valid expression.

You may assume that the expression string contains no whitespace outside of string literals.
Note: Alternatively you may assume that there will always be spaces between constants and operators, as seen in the testcases. If you make this assumption, please specify as such in your answer

You do not have to handle invalid expressions such as 1 +.

Scoring

This is code-golf, so fewest bytes wins!

Test cases

(Whitespace added for readability)

2 + 3
True

"Hello" / "World"
True

true * false
True

"Hello" + 4
False

"Hello" + "4"
True

3 + 2.4f / 8
False

0xff * 0xff
True

0xff + 2
False

6
True

" " + ""
True

"4 + false" + "word"
True

JavaScript (ES6),  79 77  75 bytes
Saved 2 bytes thanks to @ExpiredData
Expects whitespace around operators. Returns a Boolean value.

s=>![/".*?"/g,/0x../g,/\S+f/g,/\d/,/e/i].filter(e=>s!=(s=s.split(e)+''))[1]

Try it online!
How?

We remove all strings, using /".*?"/g
We remove all bytes, using /0x../g
We remove all floats, using /\S+f/g
We look for a remaining digit with /\d/; if we do find one, there must be at least one integer
We look for a remaining "e" or "E" with /e/i; if we do find one, there must be at least one Boolean value

All removed expressions are actually replaced with a comma, which is harmless.
We filter out the regular expressions causing no change to the input string and test whether less than two of them remain at the end of the process.


Justify a text by adding spaces Given this text

  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

write the shortest program that produces the same text justified at 80 character. The above text must look exactly as:

Lorem ipsum dolor sit amet,  consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut  labore et  dolore magna aliqua.  Ut  enim ad  minim veniam,  quis
nostrud exercitation ullamco laboris nisi ut  aliquip ex  ea  commodo consequat.
Duis aute irure dolor in  reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.  Excepteur sint occaecat cupidatat non proident,  sunt in
culpa qui officia deserunt mollit anim id est laborum.

Rules:

words must not be cut
extra spaces must be added

after a dot.
after a comma
after the shortest word (from left to right)
the result must not have more than 2 consecutive spaces

last line is not justified.
lines must not begin with comma or dot.
provide the output of your program

winner: The shortest program.

note: The input string is provided on STDIN as one line (no line feed or carriage return)

update:

The input string can be any text with word length reasonnable (ie. not more than 20~25 char) such as:

  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna. Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.

Perl, 94 chars
for(/(.{0,80}\s)/g){$i=1;$i+=!s/^(.*?\.|.*?,|(.*? )??\S{$i}) \b/$1  /until/
|.{81}/;chop;say}

Run with perl -nM5.01.  (The n is included in the character count.)
The code above is the shortest I could make that could handle any curveballs I threw at it (such as one-letter words at the beginning of a line, input lines exactly 80 chars long, etc.) exactly according to spec:
Lorem ipsum dolor sit amet,  consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut  labore et  dolore magna aliqua.  Ut  enim ad  minim veniam,  quis
nostrud exercitation ullamco laboris nisi ut  aliquip ex  ea  commodo consequat.
Duis aute irure dolor in  reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.  Excepteur sint occaecat cupidatat non proident,  sunt in
culpa qui officia deserunt mollit anim id est laborum.

I'm  tempted to  provide a  php  program which consists of  the output text. ;-)
Seriously though,  the spaces on the second line of the output text seem to have
been added to  the spaces at  random? Is  there some pattern to  it that I'm not
seeing,  and if  not,  how can we be expected to produce exactly that output for
the given input?

(With apologies to Gareth for using his comment as additional test input.)
The following 75-char version works well enough to produce the sample output from the sample input, but can fail for other inputs.  Also, it leaves an extra space character at the end of each the output line.
for(/(.{0,80}\s)/g){s/(.*?\.|.*?,|.*? ..) \b/$1  /until/.{81}/||s/
//;say}

Both versions will loop forever if they encounter input that they can't justify correctly.  (In the longer version, replacing until with until$i>80|| would fix that at the cost of seven extra chars.)


Find a fraction's position in the Stern-Brocot tree The Stern-Brocot tree is a binary tree of fractions where each fraction is acquired by adding the numerators and denominators of the two fractions neighbouring it in the levels above.

It is generated by starting with 0/1 and 1/0 as "endpoint fractions", and from there, iterating by placing one fraction between each consecutive pair of fractions by adding the numerators and denominators of those fractions together, like so:

0.  0/1                                                             1/0
1.  0/1                             1/1                             1/0
2.  0/1             1/2             1/1             2/1             1/0
3.  0/1     1/3     1/2     2/3     1/1     3/2     2/1     3/1     1/0
4.  0/1 1/4 1/3 2/5 1/2 3/5 2/3 3/4 1/1 4/3 3/2 5/3 2/1 5/2 3/1 4/1 1/0

In each iteration of the Stern-Brocot tree (the nth iteration), there are 2^n + 1 elements in the sequence, to which we can ascribe a fraction from 0/2^n to 2^n/2^n. Each new iteration simply inserts one fraction "halfway" between each pair of consecutive fractions.

This makes the Stern-Brocot tree a one-to-one mapping between the positive rational numbers and the binary fractions between 0 and 1, thereby also serving as a proof that the two sets have the same cardinality.

Your task is to write a program or function that, given the numerator and denominator of a positive rational number in lowest terms, determines the binary fraction that corresponds to that fraction's position in the Stern-Brocot tree.

Examples of inputs and outputs are provided below:

2/3 -> 3/8   (4th number in iteration 3)
4/7 -> 9/32  (between 1/2 and 3/5 in the chart above)
1/1 -> 1/2   (middle number in the first iteration)

Inputs you don't need to support, but are included for reference:

0/1 -> 0/1   (0/1 is considered the left number)
1/0 -> 1/1   (1/0 is considered the rightmost number)

The shortest program in any language to achieve this goal wins.


Count arrays of periods The period of a string is the shortest non-zero shift so that the string matches itself, ignoring any parts that overhang. So for example, abcabcab has period 3. By convention we say that if there is no such shift then a string has period equal to its length. So the period of abcde is 5 and the period of a is 1.

In more formal terms, the period of a string S is the minimum i > 0 so that S[1,n-i] == S[i+1,n] (indexing from 1).

For a given string S of power of two length, we will compute the period of all its prefixes of power of two length.  For example, consider S = abcabcab.  The periods we will compute are:

'a', 1
'ab', 2
'abca', 3
'abcabcab', 3

We will in fact just output the array of periods, that is [1, 2, 3, 3].

For a given  positive power of two n, consider all possible binary strings S.   Recall that a binary string is simply a string of 1s and 0s so there are exactly 2^n such strings (that is 2 to the power n). For each one we can compute this array of periods.

  The challenge is to write code that takes n (a power of two)  as input and computes how many distinct such arrays there are.

The answers for n = 1, 2, 4, 8, 16, 32, 64, 128 are:

1, 2, 6, 32, 320, 6025, 216854, 15128807

The full set of distinct period arrays for n = 4 is:

1, 1, 1
1, 1, 3
1, 1, 4
1, 2, 2
1, 2, 3
1, 2, 4

Score

I will run your code on my computer running Ubuntu for 10 minutes. Your score is the largest n for which your code terminates in that time. In the case of a tie, the answer that completes the joint largest n fastest wins. In  the case that there is a tie within 1 second on timings, the first answer posted wins.

Languages and libraries

You can use any available language and libraries you like. Please include a full explanation for how to run/compile your code in Linux if at all possible.`

Your code should actually compute the answers and not, for example, just output precomputed values.

Leading entries

2 minutes and 21 seconds for n = 128 in C# by Peter Taylor
9 seconds for n = 32 in Rust by isaacg

C#, n=128 in about 2:40

using System;
using System.Collections.Generic;
using System.Linq;

namespace Sandbox
{
    class PPCG137436
    {
        public static void Main(string[] args)
        {
            if (args.Length == 0) args = new string[] { "1", "2", "4", "8", "16", "32", "64", "128" };

            foreach (string arg in args)
            {
                Console.WriteLine(Count(new int[(int)(0.5 + Math.Log(int.Parse(arg)) / Math.Log(2))], 0));
            }
        }

        static int Count(int[] periods, int idx)
        {
            if (idx == periods.Length)
            {
                //Console.WriteLine(string.Join(", ", periods));
                return 1;
            }

            int count = 0;
            int p = idx == 0 ? 1 : periods[idx - 1];
            for (int q = p; q <= 1 << (idx + 1); q++)
            {
                periods[idx] = q;
                if (q == p || q > 1 << idx || p + q - Gcd(p, q) > 1 << idx && UnificationPasses(periods, idx, q)) count += Count(periods, idx + 1);
            }

            return count;
        }

        private static int Gcd(int a, int b)
        {
            while (a > 0) { int tmp = a; a = b % a; b = tmp; }
            return b;
        }

        private static bool UnificationPasses(int[] periods, int idx, int q)
        {
            UnionSet union = new UnionSet(1 << idx);
            for (int i = 0; i <= idx; i++)
            {
                for (int j = 0; j + periods[i] < Math.Min(2 << i, 1 << idx); j++) union.Unify(j, j + periods[i]);
            }

            IDictionary<int, long> rev = new Dictionary<int, long>();
            for (int k = 0; k < 1 << idx; k++) rev[union.Find(k)] = 0L;
            for (int k = 0; k < 1 << idx; k++) rev[union.Find(k)] |= 1L << k;

            long zeroes = rev[union.Find(0)]; // wlog the value at position 0 is 0

            ISet<int> onesIndex = new HashSet<int>();

            // This can be seen as the special case of the next loop where j == -1.
            for (int i = 0; i < idx; i++)
            {
                if (periods[i] == 2 << i) onesIndex.Add((2 << i) - 1);
            }
            for (int j = 0; j < idx - 1 && periods[j] == 2 << j; j++)
            {
                for (int i = j + 1; i < idx; i++)
                {
                    if (periods[i] == 2 << i)
                    {
                        for (int k = (1 << j) + 1; k <= 2 << j; k++) onesIndex.Add((2 << i) - k);
                    }
                }
            }

            for (int i = 1; i < idx; i++)
            {
                if (periods[i] == 1) continue;

                int d = (2 << i) - periods[i];
                long dmask = (1L << d) - 1;
                if (((zeroes >> 1) & (zeroes >> periods[i]) & dmask) == dmask) onesIndex.Add(periods[i] - 1);
            }

            long ones = 0L;
            foreach (var key in onesIndex) ones |= rev[union.Find(key)];

            if ((zeroes & ones) != 0) return false; // Definite contradiction!

            rev.Remove(union.Find(0));
            foreach (var key in onesIndex) rev.Remove(key);

            long[] masks = System.Linq.Enumerable.ToArray(rev.Values);

            int numFilteredMasks = 0;
            long set = 0;
            long M = 0;
            for (int i = 1; i <= idx; i++)
            {
                if (periods[i - 1] == 1) continue;

                // Sort the relevant masks to the start
                if (i == idx) numFilteredMasks = masks.Length; // Minor optimisation: skip the filter because we know we need all the masks
                long filter = (1L << (1 << i)) - 1;
                for (int j = numFilteredMasks; j < masks.Length; j++)
                {
                    if ((masks[j] & filter) != 0)
                    {
                        var tmp = masks[j];
                        masks[j] = masks[numFilteredMasks];
                        masks[numFilteredMasks++] = tmp;
                    }
                }

                // Search for a successful assignment, using the information from the previous search to skip a few initial values in this one.
                set |= (1L << numFilteredMasks) - 1 - M;
                M = (1L << numFilteredMasks) - 1;
                while (true)
                {
                    if (TestAssignment(periods, i, ones, masks, set)) break;
                    if (set == 0) return false; // No suitable assignment found

                    // Gosper's hack with variant to reduce the number of bits on overflow
                    long c = set & -set;
                    long r = set + c;
                    set = (((r ^ set) >> 2) / c) | (r & M);
                }
            }

            return true;
        }

        private static bool TestAssignment(int[] periods, int idx, long ones, long[] masks, long assignment)
        {
            for (int j = 0; j < masks.Length; j++, assignment >>= 1) ones |= masks[j] & -(assignment & 1);
            for (int i = idx - 1; i > 0; i--) // i == 0 is already handled in the unification process.
            {
                if (Period(ones, 2 << i, periods[i - 1]) < periods[i]) return false;
            }

            return true;
        }

        private static int Period(long arr, int n, int min)
        {
            for (int p = min; p <= n; p++)
            {
                // If the bottom n bits have period p then the bottom (n-p) bits equal the bottom (n-p) bits of the integer shifted right p
                long mask = (1L << (n - p)) - 1L;
                if ((arr & mask) == ((arr >> p) & mask)) return p;
            }

            throw new Exception("Unreachable");
        }

        class UnionSet
        {
            private int[] _Lookup;

            public UnionSet(int size)
            {
                _Lookup = new int[size];
                for (int k = 0; k < size; k++) _Lookup[k] = k;
            }

            public int Find(int key)
            {
                var l = _Lookup[key];
                if (l != key) _Lookup[key] = l = Find(l);
                return l;
            }

            public void Unify(int key1, int key2)
            {
                int root1 = Find(key1);
                int root2 = Find(key2);

                if (root1 < root2) _Lookup[root2] = root1;
                else _Lookup[root1] = root2;
            }
        }
    }
}

Extending to n=256 would require switching to BigInteger for the masks, which probably kills the performance too much for n=128 to pass without new ideas, let alone n=256.

Under Linux, compile with mono-csc and execute with mono.

Basic explanation

I'm not going to do a line-by-line dissection, just an overview of the concepts.

As a rule of thumb, I'm happy to iterate through on the order of 250 elements in a brute-force combinatoric program. To get to n=128 it is therefore necessary to use an approach which doesn't analyse every bitstring. So rather than working forwards from bit strings to period sequences, I work backwards: given a period sequence, is there a bitstring which realises it? For n=2x there's an easy upper bound of 2x(x+1)/2 period sequences (vs 22x bitstrings).

Some of the arguments use the string periodicity lemma:

  Let p and q be two periods of a string of length n. If p + q ≤ n + gcd(p, q) then gcd(p, q) is also a period of the string.

Wlog I will assume that all of the bitstrings under consideration start with 0.

Given a period sequence [p1 p2 ... pk] where pi is the period of the prefix of length 2i (p0 = 1 always), there are some easy observations about possible values of pk+1:

pk+1 ≥ pk since a period of a string S is also a period of any prefix of S.
pk+1 = pk is always a possible extension: just repeat the same primitive string for twice as many characters.
2k < pk+1 ≤ 2k+1 is always a possible extension. It suffices to show this for pk+1 = 2k+1 because an aperiodic string of length L can be extended to an aperiodic string of length L+1 by appending any letter which isn't its first letter.

Take a string Sx of length 2k whose period is pk and consider the string SxyS of length 2k+1. Clearly SxyS has a period 2k+1. Suppose its period q is smaller.

Then 2k+1 + q ≤ 2k+1+1 ≤ 2k+1 + gcd(2k+1, q) so by the periodicity lemma gcd(2k+1, q) is also a period of SxyS, and since the greatest divisor is less than or equal to its arguments and q is the smallest period, we require q to be a proper factor of 2k+1. Since its quotient cannot be 2, we have q ≤ (2k+1)/3.

Now, since q ≤ 2k is a period of SxyS it must be a period of Sx. But the period of Sx is pk. We have two cases:

gcd(pk, q) = pk, or equivalently pk divides exactly into q.
pk + q > 2k + gcd(pk, q) so that the periodicity lemma doesn't force a smaller period.

Consider first the second case. pk > 2k + gcd(pk, q) - q ≥ 2k+1 - q ≥ 2k+1 - (2k+1)/3 ≥ 2q, contradicting the definition of pk as the period of Sx. Therefore we are forced into the conclusion that pk is a factor of q.

But since q is a period of Sx and pk is the period of Sx, the prefix of length q is just q/pk copies of the prefix of length pk, so we see that pk is also a period of SxyS.

Therefore the period of SxyS is either pk or 2k+1. But we have two options for y! At most one choice of y will give period pk, so at least one will give period 2k+1. QED.
The periodicity lemma allows us to reject some of the remaining possible extensions.
Any extension which hasn't passed a quick-accept or a quick-reject test needs to be tested constructively.

The construction of a bitstring given a period sequence is essentially a satisifiability problem, but it has a lot of structure. There are 2k - pk simple equality constraints implied by each prefix period, so I use a union set data structure to combine bits into independent clusters. This was enough to tackle n=64, but for n=128 it was necessary to go further. I employ two useful lines of argument:

If the prefix of length M is 01M-1 and the prefix of length L > M has period L then the prefix of length L must end in 1M. This is most powerful precisely in the cases which would otherwise have most independent clusters, which is convenient.
If the prefix of length M is 0M and the prefix of length L > M has period L - d with d < M and ends in 0d then it must in fact end in 10d. This is most powerful at the opposite extreme, when the period sequence starts with a lot of ones.

If we don't get an immediate contradiction by forcing the cluster with the first bit (assumed to be zero) to be one then we brute force (with some micro-optimisations) over the possible values for the unforced clusters. Note that the order is in descending number of ones because if the ith bit is a one then the period cannot be i and we want to avoid periods which are shorter than the ones which are already enforced by the clustering. Going down increases the chances of finding a valid assignment early.


Print the ASCII table The task is to display n characters of the ASCII table.

You may write a function (or a program that takes the argument as a parameter, STDIN is allowed as well) that takes a parameter n, which will be the index of the last character to print.

The task is quite simple, so as an example here's a possible implementation in Python 2.7:

(lambda n:map(chr, range(n)))(256)

As I said it's a simple task. So this is code-golf and the shortest codes wins!

EDIT

As some of you pointed out this code doesn't print the result. It's just an example since I might struggle explaining the problem in english ;-).

EDIT2

Feel free to post the answer in any programming language, even if it's not the shortest code. Maybe there are some interesting implementations out there!

EDIT3

Fixed the example so it prints the result.

brainfuck - 169 146 142 bytes
-[+>+[+<]>+]>+>>,[>,]<[<]<[->>[->]<[<]<]>>>[[<[-<+<+<+>>>]+++++++++[<[-<+>]<<[-<+>>>+<<]<[->+<]>>>>-]]<,<<,>[->>>+<<<]>>>---------->]<-[->.+<]

Limitations:

EOF must be 0
Requires 8-bit wrapping cells
Because of ^, mods input by 256

Not the shortest answer here, but hey, brainfuck! This would be a really, really good brainfuck challenge, except for the fact that it requires human readable input without guaranteeing the number of digits. I could have required input to have leading zeroes to make it 3 characters long, but what fun is that? :D One major problem with taking input this way is that brainfuck's only branching or looping structure checks if the current cell is zero or not. When the input can contain zeroes, it can cause your code to take branches it shouldn't be taking. To solve this problem, I store each digit of input plus 1, then subtract the excess at the last possible second. That way, I always know where my zeroes are.
I did say that this would have been a great brainfuck challenge without having to parse input. Why is that? Well, let's pretend that we don't take a numeric input. We'll say the challenge is "Given a byte of input, output all ASCII characters below that byte". Here's what my answer would be:

brainfuck - 8 bytes
,[->.+<]

It's quite a difference! The real program uses 135 instructions to collect the input (over 95% of the program!), just because it's a human typing it. Store the number as a byte and give that to me, and it only takes one.
(Fun fact: If you understood the hypothetical program, then congratulations! You understand brainfuck in its entirety. The whole language has only eight commands, and that program happens to use each one exactly once.)
Explanation
-[+>+[+<]>+]>+               abuse 8 bit wrapping to put 47 in cell 4

>>,[>,]                      starting in cell 6; get each character of input

<[<]<[->>[->]<[<]<]          subtract the value of cell 4 from each input character
                             '0' has an ascii value of 47 so subtracting 47 from each
                             digit gives you that digit's value plus 1

>>>[                         if the number is in more than one cell
                             (when the program first starts this means "if the input has
                             more than one digit")

[<[-<+<+<+>>>]               copy first input cell to 3 new cells

+++++++++[<[-<+>]<<          do some fancy addition magic to multiply that value by 10
[-<+>>>+<<]<[->+<]>>>>-]]

<,<<,>                       clean up a bit (abusing comma to set cells to 0)

[->>>+<<<]>>>                add the value to the next cell of input

----------                   because we multiplied (the digit plus 1) by 10; the answer
                             is 10 too high; so subtract 10

>]                           if the input is still in multiple cells; do the song and
                             dance again (multiply by 10; add to next cell; subtract 10)

<-                           we never got a chance to fix the final digit; so it's still 1
                             too high

               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
               ;;         we have now finished processing input         ;;
               ;;     the tape is empty except for the current cell     ;;
               ;;  the current cell contains the number that was input  ;;
               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[                            while the cell containing input != 0

-                            subtract 1 from it

>.+                          go a cell to the right; output that cell; then add 1

<]                           repeat


Gravitational Force Between Numbers The gravitational force is a force that attracts any two objects with mass. In this challenge our objects will be Numbers and their mass will be their value. To do so, we don't care about the strength of the force but the direction of it.

Imagine this set of numbers

[1 6 9 4 6 9 7 6 4 4 9 8 7]

Each of them creates a force between itself and it's adjacent numbers. Under some conditions, this will cause another number to be attracted (moved) toward a number. When the number is bigger than the adjacent, it attracts it. Lets take a look at our previous example:

[1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]

The number 1 is not big enough to move 6, but the number 6 is, etc... Basically, numbers are moved to the biggest adjacent number (also bigger than the number itself). If both of the adjacent numbers are equal it is not attracted then. It also happens when the number and it adjacent are equal.

This is only to show the attraction, but what happens after? Numbers that collide due to attraction are summed up:

[20 32 28]

So basically the challenge is, Given a set of numbers, output the result of the attracted set of numbers.

Example 1

Input  => [10 15 20 10 20 10 10]
          [10 → 15 → 20 10 20 ← 10 10]
Output => [45 10 30 10]

Example 2

Input  => [9 9 9 9 8 1 8]
          [9 9 9 9 ← 8 1 8]
Output => [9 9 9 17 1 8]

Example 3

Input  => [1 6 9 4 6 9 7 6 4 4 9 8 7]
          [1 → 6 → 9 ← 4 6 → 9 ← 7 ← 6 ← 4 4 → 9 ← 8 ← 7]
Output => [20 32 28]

Example 4

Input  => [1 2 3 2 1]
          [1 → 2 → 3 ← 2 ← 1]
Output => [9]

Example 5

Input  => [1]
Output => [1]

Example 6

Input  => [1 1]
Output => [1 1]

Example 7

Input  => [2 1 4]
Output => [2 5]

Notes

Attraction only happens once
Numbers are not attracted to non-adjacent Numbers
The set of numbers will only contain positive integers

JavaScript (ES6),  106 104  100 bytes
Saved 2 bytes thanks to @Shaggy

a=>a.filter(n=>n,[...a].map((v,i)=>a[a[p>v&(n=~~a[i+1])<p?k:i+(k=i,n>v&p<n)]+=x=a[i],p=v,i]-=x,p=0))

Try it online!
Commented
We first update the original input array a[] by iterating on a copy of it. During this step, all values 'attracted' by other ones are set to \$0\$.
Because the array is parsed from left to right, we can just add \$a_i\$ to \$a_{i+1}\$ whenever a value is attracted by its right neighbor.
Example: \$4\rightarrow5\rightarrow6\$ is turned into \$[0,\color{red}9,6]\$ and then \$[0,0,\color{red}{15}]\$.
But when several values in a row are attracted by their left neighbor, we need to add \$a_i\$ to the first attractor \$a_k\$ of this sequence (with \$k<i\$) rather than simply \$a_{i-1}\$.
Example: \$6\leftarrow5\leftarrow4\$ is turned into \$[\color{red}{11},0,4]\$ and then \$[\color{red}{15},0,0]\$.
[...a]                 // create a copy of a[]
.map((v, i) =>         // for each value v in a[] at position i:
  a[                   //   this statement updates a[i]:
    a[                 //     this statement updates either a[i] or an adjacent value:
      p > v &          //       if the previous value p is greater than v
      (n = ~~a[i + 1]) //       and the next value n
      < p ?            //       is less than p (attraction to the left):
        k              //         use k (k is initially undefined, but this code cannot
                       //         be triggered during the first iteration)
      :                //       else:
        i + (          //         use either i or i + 1:
          k = i,       //           set k to i
          n > v &      //           use i + 1 if n is greater than v
          p < n        //           and p is less than n (attraction to the right)
        )              //
    ] += x = a[i],     //     add x = a[i] to the entry defined above
    p = v,             //     update the previous value to v
    i                  //     actual index to update a[i]
  ] -= x,              //   subtract x from a[i]
  p = 0                //   start with p = 0
)                      // end of map()

We then filter out all entries equal to \$0\$.
a.filter(n => n)


Print the missing primes The Task

Write a program or function that, when passed a numerical input x, prints or returns the primes beneath the square root of x1 that are not factors of x.

Examples

Let f(x) be the function called:

>>> f(4)
[]

>>> f(5)
[2]

>>> f(20)
[3]

>>> f(60)
[7]

>>> f(100)
[3, 7]

>>> f(10000)
[3, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Bonus Rules

You may use any builtins that your language provides.
Your program must support an x input as high as the upper bound defined by your language.

1 Using the square root as only primes below the square root can actually be involved within the factors of x. Without making this restriction, larger numbers would have a lot of excess printed numbers.

Jelly, 6 bytes in Jelly's codepage

½ÆRḟÆf

Try it online!

Explanation:

½ÆRḟÆf
 ÆR    All primes less than or equal to
½      the square root of the input
   ḟ   but with the following removed:
    Æf All prime factors of {the input, by default}


Hexasweep (part 1): The Solver (This is part 1 in a two-part challenge.)

Your task is to solve a Hexasweep puzzle.

A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so:

         _____
        /\    \
  _____/ X\____\_____
 /\    \  / XX /\    \
/X \____\/____/X \____\
\ X/ XX /\    \ X/    /
 \/____/  \____\/____/
 /\    \  / X  /\    \
/  \____\/____/  \____\
\  / XX /\    \  / XX /
 \/____/  \____\/____/
       \ X/    /
        \/____/

The above image is composed of 7 hexagons (21 diamonds), and is thus a Hexasweep puzzle of size 2.

If you want to expand it, cover the current Hexasweep puzzle with more hexagons (so that there are 19 hexagons - that will make a Hexasweep puzzle of size 3).
The same goes for the other direction - to make a Hexasweep puzzle of size 1, remove the outermost layer of hexagons (so that there's 1 hexagon).

Each diamond can contain 0, 1 or 2 "bombs", with bombs depicted as X above. With bombs filled out, this is the final solution.

Numbers are marked on "intersection points", to show how many bombs are on the diamonds which are touching those intersection points - the intersection points of this grid are shown below using O.

         _____
        /\    \
  _____/  OO___\_____
 /\    \  OO   /\    \
/  OO___OO___OO  OO___\
\  OO   OO   OO  OO   /
 \/___OO  OO___OO____/
 /\   OO  OO   OO    \
/  OO___OO___OO  OO___\
\  OO   OO   OO  OO   /
 \/____/  OO___\/____/
       \  OO   /
        \/____/

As you can see, there are two "types" of intersection points - those with 3 diamonds touching it, and those with 6 (the one that are touching the edge of the board aren't counted):

  _____
 /\  XX\
/X OO___\
\ XOO   /
 \/____/

       /\
 _____/X \_____
 \ XX \ X/    /
  \____OO____/
  / XX OO  X \
 /____/  \____\
      \ X/
       \/

The two intersections would be marked with 4 and 8 respectively.

In the original Hexasweep puzzle above, the intersection numbers would be:

   3
4 5 4 2
 2 1 3
2 4 1 2
   1

Which would be condensed to:

3,4,5,4,2,2,1,3,2,4,1,2,1

Given an input in this "condensed form", you must output the original puzzle, in "condensed form" (see above).

The solved image (the first one, with the crosses) - which would be formed from the puzzle - would be read from top to bottom, starting from the left:

2,0,0,2,0,2,1,0,1,0,2,0,1,0,0,2,0,0,0,0,2

That is now the "condensed form" of the puzzle.

If there is more than 1 answer (as in the condensed form above), the output must be N.

Examples:

0,0,4,3,1,3,4,7,1,4,3,6,1 -> 0,0,0,0,1,0,0,2,0,0,0,2,0,1,0,1,2,0,0,2,2 (size 2 Hexasweep)
6 -> 2,2,2 (size 1 Hexasweep)
0,1,5,3,1,4,4,7,2,5,3,6,1 -> N (multiple solutions)

Specs:

Any delimiter for the "condensed form" as input are allowed (it doesn't have to be , separating the numbers).
You may output a list, or a string with any delimiter.
Your program must be generalised: it must be able to solve Hexasweep puzzles of any size (at least from size 1 to size 4).

This is code-golf, so lowest amount of bytes wins!


Simulate a (gravity-based) billiard-ball-type computer The Machine

A billiard-ball type machine is composed of only the symbols \ _ / along with upper- and lower-case letters, spaces, and the number 1.

\ and / are ramps. A ball coming from above will be deflected to either the right or left side, respectively. For both ramps, if a ball comes from either side, it will be deflected downward.

_ is a logic element. The logic performed by it is the most un-billiard-like part of the computer. First, a ball coming from the left or right continues in the same direction. A ball coming from above will be stopped. Then, after the end of its execution (see Running the Machine below), if the number of balls crossing/landing on it is positive even number, then a single ball is released from the bottom of the element.

A space does nothing. Any balls coming from any direction fall straight down due to gravity.

Lowercase letters are inputs. All inputs will either be a single 1 or 0.

Uppercase letters are outputs. The number outputted will be the number of billiard balls that hit its location.

The number 1 releases a extra billiard-ball at that location. It represents a logical 1.

All characters besides \_/ cause any ball coming from any direction to fall straight down due to gravity.

Balls never combine, split, or collide. They are only created when released from an input, a _, or a 1. They are only destroyed when they fall straight down onto a _.

Example machine-

1 a
\_/ b
  \_/
 \/
 /\ /
_  _
A  B

There will never be any blank lines in a machine, but the _'s may make it appear that there is a blank line.

Running the Machine

A machine is run in layers, or rows. All billiard-ball movement on the top layer is performed before anything happens on the second layer.

The machine

ab
\_A
 C

is run as follows:

First, it prompts for the input a in the form a:. The user will then input a 1 or 0 (followed by enter). It repeats this for the input b. This is the end of the first layer. I am going to assume that the user entered a 1 for both inputs.

It then traces out the path of the first ball (from a), which goes along the \, across the _, into the A, and falls down to the spot under the A. It then traces out the path for the second ball (from b), which goes straight down onto the _ and terminates. This is the end of the second layer.

Now, before the third layer, since the _ has had two balls cross over it, it releases one ball. The output A has had one ball cross over it, so it outputs A:1.

For the third layer, it traces the path of the first ball (from the _), which goes though the C and falls straight down. The second ball (which fell through the A) also falls straight down.

Now, before the fourth layer, since the output C had one ball travel over it, it outputs C:1.

Since the fourth layer is blank, the program terminates.

The total result should look like

a:1     (the user entered the one)
b:1     (same here)
A:1
C:1

The Goal

Your goal is to take a machine from STDIN and simulate it by taking inputs and printing output as needed to STDOUT. The first part of the input to your program will consist of the machine to be run, followed by a blank line. Any input letters encountered should cause your program to prompt for input in the form of the input name followed by a colon. Any output should be shown in the form of the output name, followed by a colon, followed by the number of balls passing over that spot.

This is golf.

Examples

A wire crossing

ab
\/
AB

An XOR gate

ab1
\_/
 C

A full adder

1 a
\_/ b
  \_/
 \/
 /\
_ __/
 \_/
  \/c
 \\_/
  _S1
\  \/
 __/
  /
 _
\__
 C

JavaScript (392 423)

Assumes machine is set in a variable called m, then alerts the final output.

l=m.split(q='\n');o='';for(r=Array(z=l[i=0].length);i<l.length;i++){L=l[i];n=Array(z);for(c=0;c<z;n[c]=N,r[c++]=R){C=L[c];N=~~n[c];R=~~r[c];if(C>'`'){N+=x=~~prompt(C);R+=x;o+=C+': '+x+q}else if(C=='\\'||C=='/'){for(d=c+(g=C=='/'?-1:1);L[d]=='_';r[d]+=R,d+=g);if(L[d]>'@'&L[d]<'[')r[d]+=r[c];n[d]=~~n[d]+R}else if(C<'2')N+=R+=~~C;else if(C!='_')o+=C+': '+R+q}for(c=0;c<z;c++)if(L[c]=='_')n[c]+=(r[c]%2)?0:r[c]>0;r=n}alert(o)

Sample source (runs adder machine, see history for less golfed sources): http://jsfiddle.net/96yLj/12/

Spoilers:

   - r tracks the # of balls across current row, n tracks # of balls across next row.
 - Algorithm: process each row character by character, but process _'s last.
 - Algorithm: \ -> follow _ and increase r until non-_. Same for / but in reverse direction.  At the end increase n for gravity pulling balls down. g holds direction.
 - if(L[d]>'@'&L[d]<'[')r[d]+=r[c]; is for the bug mentioned in Edit 1.  The reason we can't just say r[d]+=r[c]; is because \_/ will double-count balls when processing /
 - else if(C<'2') handles both cases '1' and ' ', which ~~C turns into 1 and 0, respectively.

Edit 1: Fix bug with ball running over _ not included in A for sample code.


Evaluate the aspect ratio of a triangle Given three sidelengths of a triangle, evaluate its aspect ratio AR given the following formula:

where

The closer to equilaterality a triangle is, the closer to 1 its aspect ratio is. The aspect ratio is bigger or equal to 1 for valid triangles.

Inputs

The input is three real positive numbers which can be encapsulated in a list or anything similar if need be.

Your program must output the same value no matter what the order in which the three sidelengths are inputted is.

Those three numbers will always be valid sidelengths of a triangle (degenerate triangles like one with sidelengths 1, 1 and 2 will not be given as input). You need not worry about floating point inaccuracies when values become extremely close to a degenerate triangle (e.g. it is acceptable that your program would error division by 0 for input [1, 1, 1.9999999999999999]).

The input can be given through STDIN, as a function argument, or anything similar.

Outputs

The output is a real number bigger or equal to 1 with the standard accuracy that is acceptable in your language.

The output may be printed to STDOUT, returned from a function, or anything similar.

Test cases

Inputs                   Output

  1      1      1         1
  3      4      5         1.25
 42     42   3.14         ≈ 6.9476
 14      6     12         1.575
  6     12     14         1.575
0.5    0.6    0.7         ≈ 1.09375

Scoring

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

Jelly, 7 bytes

SH_÷@HP

Try it online!

Explanation

Let’s read this chain:

The implicit argument is a list [a, b, c].
First we read S. This takes the sum: a + b + c.
Then, we read H. This halves it: (a + b + c)/2. (This is s.)
Then, we read a dyad _ (subtract), followed by another dyad. This is a hook: it lacks a right argument, so it receives the argument to this chain, [a, b, c], giving us [s-a, s-b, s-c]. (This is the fifth chain pattern in the table here.)
Then, we read the dyad-monad pair ÷@H. This is a fork: ÷@ is division with the arguments flipped, and H is halve, so our working value gets Half the argument to this chain ÷’d by it. This vectorizes; we’re left with [(a/2)/(s-a), (b/2)/(s-b), (c/2)/(s-c)]. (This is the second chain pattern in the table here.)
Finally, we take the product with P, getting us abc/(8(s-a)(s-b)(s-c)).

View a tree-like graph of how the links fit together.


It's time to make a histogram Your task is to make a histogram given a sample of arbitrary size.

Input

A float array or any other reasonable form of input with an arbitrary number of elements.

Output

The histogram; more to follow.

How to make a histogram

We'll use the sample: [1.1, 3, 5, 13, 15.5, 21, 29.7, 63, 16, 5, 5.1, 5.01, 51, 61, 13]

To make a histogram, you first separate your observations into classes. The ideal number of classes is the lowest k such that 2^k > n, where k is the number of classes, and n is the number of observations. In our case, k = 4. The number of bars is not final. This k value's purpose is only to find the width of each class.

The width of each class is the range of your data set divided by the number of classes. The range of our data set is 63 - 1.1 = 61.9, so the width of each class is 15.475. This means that the first class is [1.1, 16.575), the second is [16.575, 32.05) and so on. The last class is [63.0, 78.475). The second value of the last class (b in [a,b)) must be greater than the max value of the set.

Now we rearrange our data into the classes; for us:

[1.1, 16.575): [1.1, 3, 5, 5, 5.01, 5.1, 13, 13, 15.5, 16]
[16.575, 32.05): [21, 29.7]
[32.05, 47.525): []
[47.525, 63.0): [51, 61]
[63.0, 78.475): [63]

And finally, we graph!

For our purposes, a bar will be a ▉ stacked for the number of observations in the class (because I think that looks good). You can count the ▉ as one byte in your source code. There should be no space between bars (unless there is an empty bar), nor do you need to label axes or any of that fancy stuff. There can be trailing whitespace at the end of your output. In our case, that would be:

▉
▉
▉
▉
▉
▉
▉▉
▉▉ ▉
▉▉ ▉▉

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

Python 3, 139
Generates histogram with numpy, takes on account the strange last column rule and prints.
from numpy import*
def f(l):
 h,_=histogram(l,'fd');h[-1]-=1
 for i in zip(*((max(h)-i)*' '+i*'▉'for i in append(h,1))):print(''.join(i))


House of cards (version 1) Version 2 here.

Simple challenge: given an integer, draw a house of cards with the given number of stories. If the number is negative, draw the house upside-down. Examples:

Input: 2
Output:

 /\
 --
/\/\

Input: 5
Output:

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

Input: 0
Output: <empty, whitespace or newline>

Input: -3
Output:

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

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

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

Python 2, 97 95 94 92 bytes

-2 bytes thanks to Luka
This version produces an exception  on n=0,but without printing anything

n=input()*2
m=abs(n)
for i in range(2,m+1)[::n/m]:print(i/2*'/-\-'[i%2::2][::n/m]).center(m)

Try it online!

Non-error version, Python 2, 94 bytes

n=input()*2
x=n>0 or-1
for i in range(2,x*n+1)[::x]:print(i/2*'/-\-'[i%2::2][::x]).center(n*x)

Try it online!


Display a Digital Clock Display a Digital Clock

(I see there are many clock challenges, I have tried to read them all, I'm pretty sure this is unique)

Write some code that continuously updates a digital clock displayed in the format h:m:s where h, m, and s can occupy 1 or 2 characters each. The restrictions in simple terms as @BlueEyedBeast put it, I basically want it to replace the time shown.

Newlines are not allowed
Trailing spaces are allowed
Other trailing characters are not allowed
No seconds should be missed (57 -> 59 is not allowed)
Numbers beginning with "0" are allowed, as long as they don't occupy more than 2 characters
The code must not accept any input
If your language can't get the current time without input, you may use for input up to 8 bytes in a standardly allowed way
Output must be to stdout
This is codegolf so the shortest answer wins!

Example

I'm working on a language named *><> (starfish) because programs like this aren't possible in ><> (just wait for file i/o) . Here's a working digital clock program in it (ungolfed). This program is written in *><>:

s":"m":"hnonon"   "ooo88888888888ooooooooooo1S

Note: Everything is identical to ><> in this except, s = second, m = minute, h = hour, S = sleep(100ms*x)

This outputs:

14:44:31

Updating every 100ms until terminated.

Disallowed Examples

The following are not allowed:

1:

14:44:3114:44:32

2:

14:44:31 14:44:32

3:

14:44:31
14:44:32

The time must remain on the first line it was outputted with no visible trailing characters. Clearing the terminal though, would be allowed as that still wouldn't have any trailing characters.

HTML + JS (ES6), 8 + 60 = 68 bytes

Tested in Chrome.

setInterval`a.innerHTML=new Date().toLocaleTimeString('fr')`

-1 byte (@ETHProductions): Use French time format instead of .toTimeString().slice(0,8)

HTML + JS (ES6), 8 + 62 = 70 bytes

This will work in FireFox.

setInterval('a.innerHTML=new Date().toLocaleTimeString`fr`',0)

-3 bytes (@ETHProductions): Use French time format instead of .toTimeString().slice(0,8)


Very Simple Grid Marks Write a program or function that takes in three positive integers, W, H, and N. Print or return a W×H grid of .'s where every Nth . in normal English reading order is replaced with an X.

For example, given W = 7, H = 3, N = 3, the grid is 7 characters wide and 3 high, and every third character reading from the top left is an X:

..X..X.
.X..X..
X..X..X

Similarly, if the input is W = 10, H = 4, N = 5, the output would be:

....X....X
....X....X
....X....X
....X....X

Notes

"Normal English reading order" means going left to right on each line, from the top line to the bottom.
When N is 1 then all the .'s will become X's.
You may use any two distinct printable ASCII characters in place of . and X.

If you use space ( ) then trailing spaces are not required when the result would be visually the same. (Empty lines are still required.)
You may not using something else in place of the newlines that shape the grid.

The exact input format and order of W, H, and N is not super important. Things like [H,W,N] or N\nW,H are alright.
A trailing newline in the output is fine.
The shortest code in bytes wins!

Examples

W = 5, H = 3, N = 1
XXXXX
XXXXX
XXXXX

W = 5, H = 3, N = 2
.X.X.
X.X.X
.X.X.

W = 5, H = 3, N = 3
..X..
X..X.
.X..X

W = 5, H = 3, N = 4
...X.
..X..
.X...

W = 5, H = 3, N = 5
....X
....X
....X

W = 5, H = 3, N = 6
.....
X....
.X...

W = 5, H = 3, N = 7
.....
.X...
...X.

W = 5, H = 3, N = 15
.....
.....
....X

W = 5, H = 3, N = 16 (or more)
.....
.....
.....

W = 1, H = 1, N = 1
X

W = 1, H = 1, N = 2 (or more)
.

W = 8, H = 6, N = 2
.X.X.X.X
.X.X.X.X
.X.X.X.X
.X.X.X.X
.X.X.X.X
.X.X.X.X

W = 8, H = 6, N = 3
..X..X..
X..X..X.
.X..X..X
..X..X..
X..X..X.
.X..X..X

W = 8, H = 6, N = 4
...X...X
...X...X
...X...X
...X...X
...X...X
...X...X

W = 8, H = 6, N = 7
......X.
.....X..
....X...
...X....
..X.....
.X......

W = 8, H = 6, N = 16
........
.......X
........
.......X
........
.......X

W = 37, H = 1, N = 4
...X...X...X...X...X...X...X...X...X.

W = 1, H = 10, N = 8
.
.
.
.
.
.
.
X
.
.

J, 9 5 bytes

$":&1

Uses spaces and 1's and expects input in the form H W f N

Explanation:

$":&1
   &1 bonds the fixed right argument 1 to ":
 ":   formats the right argument number (1) to take up left argument (N) number of cells
      padding with spaces, resulting  in "  1"
$     reshape to H-by-W with repeating the string if necessary

Usage:

   3 7 ($":&1) 3
  1  1
 1  1
1  1  1

Try it online here.


Offset in split text content You will be given an ASCII text. This text may have zero, one or many appearances of a split a character (let's assume it will be the space character )
You will also be given an offset integer value (zero based) anywhere between zero and the length of the text.

You should calculate the relative offset inside the one split text, which contains the absolute offset, as well as the index of that very split text.
If the given offset is at the split character the last split should have the offset

It's hard to describe (comments welcome), so here are some examples

text: Lorem ipsum dolor sit amet
offset: 20

Lorem ipsum dolor sit amet
enter code here
--------------------^
000000000011111111112
012345678901234567890

Result: 2, 3
Explanation: If we split the text along the space characters, the split text, where the offset is in, is the fragment `sit` which is the 3rd split (count starts at zero) and the offset inside this fragment is 2
sit
--^
012

Some more examples

Text                           Offset        Result
Lorem ipsum dolor sit amet     0             0, 0
^
Lorem ipsum dolor sit amet     1             1, 0
-^
Lorem ipsum dolor sit amet     2             2, 0
--^
Lorem ipsum dolor sit amet     3             3, 0
---^
Lorem ipsum dolor sit amet     4             4, 0
----^
Lorem ipsum dolor sit amet     5             5, 0
-----^
Lorem ipsum dolor sit amet     6             0, 1
------^
Lorem ipsum dolor sit amet     7             1, 1
-------^
Lorem ipsum dolor sit amet     8             2, 1
--------^
Lorem ipsum dolor sit amet     9             3, 1
---------^
Lorem ipsum dolor sit amet     10            4, 1
----------^
Lorem ipsum dolor sit amet     11            5, 1
-----------^
Lorem ipsum dolor sit amet     12            0, 2
------------^
Lorem ipsum dolor sit amet     13            1, 2
-------------^
Lorem ipsum dolor sit amet     14            2, 2
--------------^
Lorem ipsum dolor sit amet     15            3, 2
---------------^
Lorem ipsum dolor sit amet     16            4, 2
----------------^
Lorem ipsum dolor sit amet     17            5, 2
-----------------^
Lorem ipsum dolor sit amet     18            0, 3
------------------^
Lorem ipsum dolor sit amet     19            1, 3
-------------------^
Lorem ipsum dolor sit amet     20            2, 3
--------------------^
Lorem ipsum dolor sit amet     21            3, 3
---------------------^
Lorem ipsum dolor sit amet     22            0, 4
----------------------^
Lorem ipsum dolor sit amet     23            1, 4
-----------------------^
Lorem ipsum dolor sit amet     24            2, 4
------------------------^
Lorem ipsum dolor sit amet     25            3, 4
-------------------------^
Lorem ipsum dolor sit amet     26            4, 4
--------------------------^

Python 3.8, 56 bytes
lambda a,b:(x:=a[:b].split(' '))and[len(x[-1]),len(x)-1]

Try it online!


Parse ascii art math! The task

Given a multiline string with ascii art operators and numbers, parse the expression!

Possible symbols

Numbers: (3x4)

 /
/|
 |
---

___
 _|
|
---

___
 _|
  |
---

| |
|_|
  |
  |

___
|_
  |
---

___
|_
| |
---

___
  /
 /
|

___
|_|
| |
---

___
|_|
  |
---

___
| |
| |
---

Operators: (3x3)

 |
-+-
 |

---

\ /
 x
/ \

 .
---
 .

Braces: (1x4)

/
|
|
\

\
|
|
/

Input

A multiline string with ascii art operators and numbers. Examples in the test cases.

Output

The string of the parsed expression.

Test cases

Input:

/ ___     ___ \     ___
|  _|  |    / |  .   _|
| |   -+-  /  | ---   |
\ ---  |  |   /  .  ---

Output: (2+7)/3

Input:

___      /      ___
|_|     /|  \ / |_
  | ---  |   x    |
---     --- / \ ---

Output: 9-1*5

Rules

Numbers will always be single-digit
Since operators are one symbol shorter than numbers, they are placed one symbol lower than numbers, leaving whitespace on top.
All symbols have a column of whitespace between them
This is a code-golf challenge, so lowest byte count wins!

APL (Dyalog Unicode), 46 44 bytes

'/(80-)63+92145*7'[16|43|25⊥¨(×⊆⊢)2⊥' .\'⍳⎕]

Try it online!

⎕ evaluated input, must be a character matrix

' .\'⍳ replace spaces with 0, .s with 1, \s with 2, and everything else with 3

2⊥ base-2 decode the columns

(×⊆⊢) split on zeroes

25⊥¨ base-25 decode each group

16|43| mod 43, mod 16

'/(80-)63+92145*7'[ ] use as indices in the given string


Total resistance from unit resistors This problem is based on, A337517, the most recent OEIS sequence with the keyword "nice".

\$a(n)\$ is the number of distinct resistances that can be produced from a circuit with exactly \$n\$ unit resistors.

The sequence begins 1, 2, 4, 9, 23, 57, 151, 427, 1263, 3823, 11724, 36048, 110953, 342079.
The goal of this challenge is to write a program that takes a positive integer n and outputs the possible resistances that can be formed with \$n\$ unit resistors, written as fractions (or floats, ordered pairs representing fractions, or in another essentially similar format) as in the following:
f(3) = [3/1, 3/2, 2/3, 1/3]
     = [(3,1), (3,2), (2,3), (1,3)]
     = [[3,1], [3,2], [2,3], [1,3]]

This is a code-golf challenge, so shortest code wins. Your program needs to be able to handle inputs up to \$n = 6\$ on TIO.
Examples

With \$n = 1\$ resistor, the only possibility is a circuit with \$1 \Omega\$ total resistance.
With \$n = 2\$ resistors, there are only \$a(2) = 2\$ possibilities:

Resistors in sequence resulting in \$2 \Omega\$ total resistance.
Resistors in parallel resulting in \$\frac 12 \Omega\$ total resistance.

With \$n = 3\$ resistors, there are \$a(3) = 4\$ possibilities with resistances \$3 \Omega, \frac 32 \Omega, \frac 23 \Omega\$, and \$\frac 13 \Omega\$:

Python 2, 734 bytes

import fractions as F,itertools as I
r=range
s=set
P=lambda G,p=[0]:[x for a,b in G if(p[-1]==a)*(1-(b in p))for x in(P(G,p+[b])if b-1else[p+[b]])]
def R(G):
 G+=tuple((b,a)for a,b in G);B=s(b for a,b in G);n=1+max(B)
 if s(G)-s(x for p in P(G)for e in zip(p,p[1:])for x in[e,e[::-1]])or len(B)-n:return 0
 M=[[0]*(n+1)for _ in B];M[0][0],M[0][n],M[1][1]=[F.Fraction(1)]*3
 for a,b in G:M[a][a]+=a>1;M[a][b]-=a>1
 for i in r(n):
	for j in r(i,n):
	 if M[j][i]:break
	M[i],M[j]=M[j],M[i];M[i]=[x/M[i][i]for x in M[i]]
	for j in r(n):M[j]=[a-(j!=i)*b*M[j][i]for a,b in zip(M[j],M[i])]
 return 1/sum(M[a][n]-M[b][n]for a,b in G if a==0)
f=lambda n:s(map(R,I.combinations_with_replacement([(a,b)for a in r(n)for b in r(a,n+1)],n)))-s([0])

Try it online!
I probably missed a bunch of golfing opportunities, but it's under 1000 bytes at least! I could have used SymPy for row reduction but went for a pure python answer instead.
Graphs are represented as lists of edges.
P generates all paths from vertex 0 to 1, used to determine if any resistors are unused (if they don't appear in any path).
R accepts a graph and returns the resistance between vertex 0 and 1, or 0 if the graph is invalid (it has unused edges/resistors or unused vertices). It does this by solving a system of linear equations of the voltages at each vertex.
f enumerates all graphs and generates the distinct resistances as a set. 0 from invalid graphs is removed.
Here are the results for 1 to 6 (as output by the footer in TIO):
f(1) = set([Fraction(1, 1)])
f(2) = set([Fraction(1, 2), Fraction(2, 1)])
f(3) = set([Fraction(3, 2), Fraction(3, 1), Fraction(1, 3), Fraction(2, 3)])
f(4) = set([Fraction(1, 4), Fraction(3, 4), Fraction(4, 1), Fraction(5, 2), Fraction(1, 1), Fraction(4, 3), Fraction(2, 5), Fraction(3, 5), Fraction(5, 3)])
f(5) = set([Fraction(3, 8), Fraction(7, 4), Fraction(4, 7), Fraction(5, 1), Fraction(5, 8), Fraction(7, 3), Fraction(5, 6), Fraction(2, 1), Fraction(3, 7), Fraction(8, 5), Fraction(1, 2), Fraction(6, 7), Fraction(7, 6), Fraction(1, 5), Fraction(1, 1), Fraction(5, 4), Fraction(4, 5), Fraction(7, 5), Fraction(6, 5), Fraction(7, 2), Fraction(2, 7), Fraction(8, 3), Fraction(5, 7)])
f(6) = set([Fraction(1, 2), Fraction(5, 9), Fraction(2, 1), Fraction(1, 3), Fraction(8, 13), Fraction(6, 1), Fraction(1, 1), Fraction(7, 12), Fraction(3, 11), Fraction(13, 5), Fraction(12, 5), Fraction(3, 1), Fraction(1, 6), Fraction(7, 11), Fraction(10, 3), Fraction(3, 4), Fraction(11, 13), Fraction(11, 10), Fraction(4, 9), Fraction(2, 9), Fraction(11, 5), Fraction(10, 7), Fraction(3, 10), Fraction(5, 6), Fraction(3, 2), Fraction(13, 7), Fraction(13, 11), Fraction(7, 10), Fraction(7, 9), Fraction(13, 8), Fraction(10, 9), Fraction(5, 4), Fraction(11, 8), Fraction(5, 11), Fraction(4, 5), Fraction(8, 11), Fraction(6, 11), Fraction(5, 13), Fraction(9, 10), Fraction(2, 3), Fraction(11, 4), Fraction(6, 5), Fraction(9, 4), Fraction(11, 7), Fraction(7, 13), Fraction(13, 6), Fraction(11, 3), Fraction(4, 3), Fraction(6, 13), Fraction(12, 7), Fraction(9, 5), Fraction(10, 11), Fraction(9, 7), Fraction(9, 2), Fraction(5, 12), Fraction(11, 6), Fraction(4, 11)])


I used to solve code golf puzzles like you, but then I took an arrow in the knee Getting hit in the knee with arrows seems to be the injury of choice right now. As such, I propose the following golf challenge.

You have an adventurer that looks like this:

  O
 /|\
/ | \
  |
  |
 / \
/   \

Given a text file that contains one bow (drawn as a } symbol), a set of walls (drawn as # symbols) and one adventurer, write the smallest code that calculates the angle and initial velocity at which you should fire an arrow in order to hit him in the knee.

Assume the following:

Each character in the file is 0.5 x 0.5 meters.
The arrow is fired from the center of the }, i.e. an offset of 0.25m, 0.25m
Gravity is 10ms^-2
Arrow weighs 0.1kg
Arrow is a point, i.e. collisions only occur when the arrow's coordinate enters one of the blocks.
Maximum initial velocity is 50m/s
Angle may be between 0 (straight up) and 180 (straight down)
Hitting any part of the adventurer's leg is considered a hit to the knee.
A wall (# character) takes up one entire 0.5m x 0.5m block.
The arrow can travel over the "top" of the file, but there's nothing to stop the input from starting with a ceiling of # characters.
You can't penetrate walls with arrows.
Hitting any other part of the adventurer is not allowed!
You should display an error if hitting him in the knee is impossible.

Example input:

                                 #
}                                                     O
                        #                            /|\
                                                    / | \
            #                                         |
                            #                         |
                                                     / \
                                                    /   \

Feel free to ask questions if you need to :)

Python, 599 chars

import os,sys
from math import*
I=os.read(0,999)
O=[]
h=v=0
for i in I:
 if'#'==i:O+=[(h,v,h+1,v+1),(h+1,v,h,v+1)]
 if'O'==i:O+=[(h,v+1,h-2,v+3)];T=(h,v+5,h-2,v+7)
 if'}'==i:e=h+.5;c=v+.5
 h+=1
 if'\n'==i:v+=1;h=0

def X(K,L):
 A,B,C=K;p=L[0];q=L[2]-p;r=L[1];s=L[3]-r;A,B,C=A*q*q,2*A*p*q+B*q-s,A*p*p+B*p+C-r;d=B*B-4*A*C
 return 0 if d<0 else any(0<x<1 for x in[(sqrt(d)-B)/2/A,(-sqrt(d)-B)/2/A])

R=range(1,999)
for v in R:
 for z in R:
  z*=pi/999;d=v*sin(z)/10;b=-v*cos(z)/10
  K=20/d/d,b/d-40*e/d/d,c+20*e*e/d/d-b*e/d
  if X(K,T)and not any(X(K,x)for x in O):print v/2,z;sys.exit(0)
print'ERROR'

The X(K,L) routine takes a parabola K=(a,b,c) representing y=ax^2+bx+c and a line segment L=(a,b,c,d) representing the segment between (a,b) and (c,d).  Both obstacles (O) and the target (T) are repesented as line segments.  All distances are scaled by a factor of 2.

The example input gives the following trajectory (by default, the minimum velocity one):

  --                             #          --
--                                            -       O
                        #                      -     /|\
                                                -   / | \
            #                                    -    |
                            #                     -   |
                                                   - / \
                                                    -   \

you can reverse R to get the maximum velocity path:

                                 #
-------------                                         O
             -----------#                            /|\
                        --------                    / | \
            #                   -------               |
                            #          -----          |
                                            -----    / \
                                                 -----  \


SPOF Picture Hanging Objective

I have a nice picture that I want to hang on my wall. And I want it to hang there in a spectacular way, so I chose to hang it on n nails where n is any positive integer.

But I'm also indecisive, so if I change my mind, I don't want a lot of trouble taking the picture down. Therefore, removing any one of the n nails should make the picture fall down. Did I mention that there is no friction in my house?

Can you help me?

Rules

Your program must read the number n from stdin and print to stdout (or your language's equivalents).
The output must be the solution according to the output specification without any other trailing or leading characters. However, trailing whitespace and/or newlines is acceptable.
You must use exactly n nails.
Assuming a friction-less world, your solution must fulfill the following conditions:

Hanging the picture as described by your solution, the picture must not fall down.
If any one of the nails is removed, the picture must fall down.

Standard loopholes apply. In particular, you may not make requests to, e.g., the verification program to brute-force solutions.

Note that 4.2 already implies that all n nails must be involved.

Output Specification

All nails are named from left to right with the position they are in, starting at 1.
There are two fundamental ways to put the string around a nail: clockwise and counter-clockwise. We denote a clockwise step with > and a counter-clockwise step with <.
Everytime the string is put around a nail, it comes out on top of the nails, so skipping nails means the string will go across the top of the intermediate nails.
Every solution must start on nail 1 and end on nail n.
The output must consist of a sequence of steps wherein a step is a combination fo the nail's name and the direction in which to put the string around it.

Example Output

Here is an example output for n=5 and n=3:

1>4<3<2>4>5<          # n=5, incorrect solution
1>2<1<2>3<2<1>2>1<3>  # n=3, correct solution

And here is a visual representation of the incorrect solution for n=5 (awsumz gimp skillz)

The correct solution for n=1 is simply 1> or 1<. For multiple nails, there can be different solutions. You must only output one since this is part of your score.

Verification

You can verify whether a solution is correct here: www.airblader.de/verify.php.

It uses a GET request, so you can call it directly if you want. For example, if foo is a file containing a solution on each line, you can use

cat foo | while read line; do echo `wget -qO- "www.airblader.de/verify.php?solution=$line" | grep "Passed" | wc -l`; done

If you believe a solution is correct but the verifier marks it as incorrect, please let me know!

Edit: And if your output is so long that a GET request won't cut it, let me know and I'll make a POST request version. :)

Scoring

This is code-golf. The score is the number of bytes of your source-code in UTF-8 encoding, e.g., use this tool. However, there is a potential bonus for every submission:

Run your program for all n in the range [1..20] and add the length of all outputs up to determine your output score. Subtract your output score from 6291370 to get the number of bonus points that you may deduct from your byte count to get your overall score. There is no penalty if your output score is higher than this number.

The submission with the lowest overall score wins. In the unlikely case of a tie, the tie breakers are in this order: higher bonus points, lower byte count, earlier submission date.

Please post both the individual parts (byte count, bonus points) of the score and the final score, e.g., "LOLCODE (44 - 5 = 39)".


Circumference of an ellipse Challenge
Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the circumference of an ellipse is hard.
Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see the image below, from Wikipedia), calculate its circumference.
By definition, you can assume \$0 < b \le a\$ for input values. The output value must be within \$10^{-6}\$ relative error from the expected answer for the given test cases.

Standard code-golf rules apply. The shortest code in bytes wins.
Formulas
Relevant information can be found on Wikipedia and MathWorld. \$C\$ is the value of the circumference; \$e\$ and \$h\$ are helper values. The last two are Ramanujan's approximations, the first of which (the crossed-out one) does not meet the error requirements. The second approximation formula (Equation 5) barely does (verification) for up to \$a=5b\$ (which is also the upper limit of the test cases, so you can use it for your answer).
$$
\require{enclose} \\
\begin{align}
e &= \sqrt{1-\frac{b^2}{a^2}} \\
C &= 4aE(e) = 4a\int^{\pi/2}_{0}{\sqrt{1-e^2 \sin^2 \theta} \;d\theta} \tag{1} \\
C &= 2 \pi a \left(1-\sum^{\infty}_{n=1}{\left(\frac{(2n-1)!!}{(2n)!!}\right)^2 \frac{e^{2n}}{2n-1}}\right) \tag{2} \\
h &= \frac{(a-b)^2}{(a+b)^2} \\
C &= \pi (a + b) \left( 1 + \sum^{\infty}_{n=1} { \left( \frac{(2n-1)!!}{2^n n!} \right)^2 \frac{h^n}{(2n-1)^2} } \right) \tag{3} \\
C &= \pi (a + b) \sum^{\infty}_{n=0} { \binom{1/2}{n}^2 h^n } \tag{4} \\
\enclose{horizontalstrike}{C} &\enclose{horizontalstrike}{\approx \pi \left( 3(a+b) - \sqrt{(3a+b)(a+3b)} \right)} \\
C &\approx \pi (a+b) \left( 1+ \frac{3h}{10 + \sqrt{4-3h}} \right) \tag{5}
\end{align}
$$
Test cases
All the values for C (circumference) are calculated using Equation 4 with 1000 terms, and presented with 10 significant figures.
a     b     C
1     1     6.283185307
1.2   1     6.925791195
1.5   1     7.932719795
2     1     9.688448220
3     1     13.36489322
5     1     21.01004454
20    10    96.88448220
123   45    556.6359936

Wolfram Language (Mathematica), 20 bytes
Perimeter[#~Disk~#]&

Try it online!
-2 bytes from @Roman (see comments)


Create another empty string in .NET? I apologize if this isn't fit for this site but it is a puzzle, not all that practical, so I thought it would fit.

Take this code:

string s = "";
Console.WriteLine(ReferenceEquals(s, string.Empty));

This will print out true because "" is interned by the JITter at some early point and literals are reused from the interning cache.

The question and puzzle is this:

  How can you initialize s such that
  1. s.Length == 0
  2. ReferenceEquals(s, string.Empty) == false

I've tried the following:

string s = "test".Substring(0, 0); // any arbitrary legal start offset tried
string s = new string(' ', 0);
string s = new string(new char[0]);
string s = CallSomeMethodThatWontBeInlined() + CallSomeMethodThatWontBeInlined();

These three all end up being equal to string.Empty.

Bonus if you can explain the above behavior with regards to new string(...). I have my thoughts about it but no solid evidence one way or another.

I can understand that all methods that concatenate or take substrings of existing strings special-case the result that will end up with length zero, but how new string(...) actually doesn't create a new object I don't know.

Note! I'm asking for legal C#. I'm not asking for a p/invoke or assembly code call that just manually constructs the bytes of an empty string object in memory and stuffs a pointer to it into a string variable.

Any method or path through existing classes in .NET or using operators of strings or whatnot that would end up with the required results are legal. As such, take the Substring example above, if that returned a new empty string that isn't the same as the existing one, then that would be a/the answer to this puzzle.

Reflection is boundary, at the very least it has to be reflection that can run in untrusted scenarios.

My own "conclusion" is that this may indeed be impossible because the actual C# code that would end up constructing such a string would end up with one of the new string(...) overloads, or using one of the operators which all seem to handle this cases. As such, the end-point of any such code may be the one that handles this case and since it does, it may not be possible.

So, I'll take the easy way:

string s = "";

So, s.Length is now 0, so far so good. But how can we get ReferenceEquals(s, string.Empty) to false.

Piece of cake, just put that into your class:

public static new bool ReferenceEquals(object a, object b) => false;

and the above call will result in false.

I will look for some more sneaky methods, so.


Sum of Fibonacci numbers -- speed contest Write a program that print sum of as many Fibonacci numbers as possible.
There is a limit in that your program should not run more than 10s on 2GHz single core PC. (equivalents are acceptable, for instance you have twice as many time on 1GHz PC).
Memory consumption is not limited, but provide details, if you exceed normal values.

Your program has to work with different input values.
Output can be calculated modulo 10^i, but i has to be at least 9 digits.
Other types of results are also welcome as long as they are presented with 9 digits and are not trivially calculated.

Post source, language input value and result.

Python, 7 chars

It turns out that the period of G(i)=F(i) mod 10^9 is 1.5e9 exactly.  So when adding them up, we can group them into groups of size 1.5e9, each of which will have the same sum (mod 10^9).  Turns out, that sum is 0.  So if we take N to be any multiple of 1.5e9, the sum of the first N fibonacci numbers is 0.  So:

print 0

will, given an argument i, print the sum of the first i * 1.5e9 Fibonacci numbers.  Super fast and works for an arbitrarily large i.