Shortest Sorted Hello World Write a program that takes no input and prints Hello, World! to stdout or your language's closest alternative. The catch is that each line in your program must only contain printable ASCII characters and it must be in lexicographical order, a.k.a. sorted.

Here are all 95 printable ASCII characters in order:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

So, for example, the line !!A0~ would be invalid because the A and 0 are out of order. The line !!0A~ would be valid.

Each line in your program may be any length and there may be any number of lines. Empty lines are considered sorted. Each of the newlines in your program must be the same (no mixing \n and \r\n). Tabs and other non-printable ASCII characters are forbidden.

Due to popular demand, the win condition has been switched around:
The submission with the fewest lines wins. Tiebreaker goes to the shortest program (newlines count as single characters).

Only Hello, World! and an optional trailing newline should be output. Note that HQ9+ is invalid since it outputs hello, world. I may forbid languages similar to HQ9+ that have one character "Hello, World!" commands due to their triviality.

Hint:

   This is definitely possible in Unary and Lenguage, though not very concisely.

///, 7 lines, 22 bytes

/
//Hello
,
 Wor
l
d
!

A rare chance for /// to be competitive (well as long as no one starts with Unary and Lenguage...).

The code first encounters a /, and parses the

/
//

as a substitution instruction which removes all newlines from the remainder of the program. Afterwards, the program merely reads

Hello, World!

which is printed verbatim as it doesn't contain any further slashes.


Design a One Instruction Set Computer! Notice: I'm willing to give a bounty to any answer that I find interesting.

Your challenge is to design a Turing-complete one instruction set computer (OISC):

  An OISC is an abstract machine that uses only one instruction – obviating the need for a machine language opcode. With a judicious choice for the single instruction and given infinite resources, an OISC is capable of being a universal computer in the same manner as traditional computers that have multiple instructions.

Here are some examples of single commands that make a Turing-complete OISC.

Rules:

You must provide an interpretation or proof thereof

You must provide an interpreter for your language. This interpreter should only be restricted by memory/time (e.g. must have no user-imposed restrictions). If you do not provide an interpreter for your language (for whatever reason other than laziness) you must prove that it is possible for one to be written. An interpreter must be possible.

You must prove its Turing-completeness

You must include a formal proof that your language is Turing-complete. A simple way to do this is by proving that it can interpret or have the same behavior as another Turing-complete language. The most basic language to interpret would be Brainf**k.

For example, a normal language that has all the same commands as Brainf**k (and the same lack of user-imposed memory restrictions) is Turing-complete because anything that can be implemented in Brainf**k can be implemented in the language.

Here is a list of very simple-to-implement Turing-complete languages.

Additional OISC requirements

This OISC should only have one instruction - it cannot have multiple instructions with one of them making it Turing-complete.
Your OISC may use any syntax you like. You should define in your answer what is instruction, what is data, and what is a no-op (e.g. whitespace). Be creative!
Arguments do not just need to be integers. For example, /// is a beautiful example of a Turing-complete OISC.
How and if input and output are taken and given are left up to you. Most OISCs implement I/O via specific memory locations, but there may be other ways to do so, and you are encouraged to find one.
A valid answer must provide some example code in your OISC, either by including it in the post or linking to a simple challenge solved in the language.

Voting

Voters, please remember not to upvote boring submissions. Examples:

Lenguage-equivalents
An implementation of an existing OISC (answerers, please create your own!)
An "OISC" in which the first argument specifies a command to call (example)

However, you should upvote interesting, creative submissions, such as:

An OISC based off of a mathematical equation
A Turing-complete ZISC based on a neural network
An OISC in which output I/O happens in other ways than certain memory locations

Winning

As with popularity-contest, the answer with the most votes wins! Good luck!

XOISC

This OISC is based on Fokker's X-combinator which is defined as follows:

$$ X = \lambda f\ . f\ (\lambda g\ h\ x\ . g\ x\ (h\ x))\ (\lambda a\ b\ c\ . a) $$

If we acknowledge the fact that the SKI-calculus is Turing complete the above \$X\$-combinator is Turing complete as well. This is because \$S\$, \$K\$ and \$I\$ can be written in terms of \$X\$, like this:

$$
  \begin{align}
      S &= X\ (X\ X) \\
      K &= X\ X \\
      I = S\ K\ K &= X\ (X\ X)\ (X\ X)\ (X\ X)
  \end{align}
$$

How XOISC works

Internally XOISC has an (initially empty) stack, from there the instruction taking \$n\$ as an argument does the following:

Pop \$n\$ elements (functions \$ f_1 \dots f_N\$) from the stack, push \$f_1\ (f_2\ (\dots (f_N\ X) \dots ))\$

Once there are no more instructions left XOISC will push all command-line arguments (if any) to the stack, for example:

$$
  [ \underbrace{s_1, \dots,\ s_M}_{\text{stack before}}
  ,\ \underbrace{a_1, \dots,\ a_N}_{\text{arguments}}
  ]
$$

The final computation will be \$(\dots ((\dots (s_1\ s_2) \dots)\ s_M)\ a_1) \dots) a_N \$.

Since the one instruction in XOISC takes only one argument (memory offset) there is no reason to even use a name for that instruction. So a valid source file will constitute solely of integers separated by newlines or whitespaces, like for example:

0 0 2 0 1 0 1

Try it online!

Example

Let's take the above example (stack growing to the right):

$$
  \begin{align}
& \texttt{0} & \text{pop 0 and apply (ie. push single } X \text{)}:
  & \quad [X] \\
& \texttt{0} & \text{again simply push } X:
  & \quad [X,\ X] \\
& \texttt{2} & \text{pop 2 (} a,b \text{) and push } a\ (b\ X):
  & \quad [X\ (X\ X)] \\
& \texttt{0} & \text{simply push } X:
  & \quad [X\ (X\ X),\ X] \\
& \texttt{1} & \text{pop 1 (} a \text{) and push } a\ X:
  & \quad [X\ (X\ X),\ X\ X] \\
& \texttt{0} & \text{simply push } X:
  & \quad [X\ (X\ X),\ X\ X,\ X] \\
& \texttt{1} & \text{pop 1 (} a \text{) and push } a\ X:
  & \quad [X\ (X\ X),\ X\ X,\ X\ X]
  \end{align}
$$

Finally evaluate the stack: \$((X\ (X\ X))\ (X\ X))\ (X\ X)\$ or with less parentheses \$X\ (X\ X)\ (X\ X)\ (X\ X)\$ which we recognize as the good old \$S\ K\ K\$ identity function.

Turing completeness

Proof idea

For XOISC to be Turing complete we need to be able to translate any (valid) interleaving of parentheses and \$X\$ combinators. This is possible because when popping, applying and pushing it does so in a right-associative manner (function application is left-associative).

To translate any such \$X\$ expression there is an easy way to do so: Always pop as many elements such that from the beginning of the current level of parentheses there will only be one element left.

As an example, the previously used expression: \$((X\ (X\ X))\ (X\ X))\ (X\ X)\$

to get \$X\$, we simply need a 0
next we're in a new level of parentheses, so we again only need a 0
now two parentheses close, so we need to pop 2 elements: 2
again we're in a new level of parentheses, so we need a 0
two parentheses, close so again a 2
and the same again

So we end up with a different (yet semantically equivalent) XOISC-program:

0 0 2 0 2 0 2  Try it online!

If we stay with this strategy we can easily transform any expression consisting of \$X\$ combinators to an XOISC program which only leaves a single function on the stack.

Formal proof

Given that the SKI-calculus is Turing complete, we need to show two things:

the \$X\$-combinator is a basis for the SKI-calculus
XOISC is able to represent any expression formed with the \$X\$ combinator

The first part - proving the three equalities in the introduction - is very tedious and space consuming, it's also not very interesting. So instead of putting it in this post, you can find here*.

The second part can be proven by structural induction, though it's easier to prove a slightly stronger statement: Namely, for any expression formed by \$X\$-combinators there is a program that will leave that expression as a single expression on the stack:

There are two ways of constructing such an \$X\$ expression, either it's \$X\$ itself or it's \$f\ g\$ for some expressions \$f\$ and \$g\$:

The former one is trivial as 0 will leave \$X\$ on the stack as a single expression. Now we suppose that there are two programs (\$\texttt{F}_1 \dots \texttt{F}_N\$ and \$\texttt{G}_1 … \texttt{G}_K\$) that will leave \$f\$ and \$g\$ as a single expression on the stack and prove that the statement holds for \$f\ g\$ as well:

The program \$\texttt{F}_1 \dots \texttt{F}_N\ \texttt{G}_1 \dots \texttt{G}_{K-1}\ (\texttt{G}_K + 1)\$ will first generate \$f\$ on the stack and then it will generate \$g\$ but instead of only popping parts of \$g\$ it will also pop \$f\$ and apply it, such that it leaves the single expression \$f\ g\$ on the stack. ∎

Interpreter

Inputs

Since the untyped lambda calculus requires us to define our own data types for everything we want and this is cumbersome the interpreter is aware of Church numerals - this means when you supply inputs it will automatically transform numbers to their corresponding Church numeral.

As an example here's a program that multiplies two numbers: Try it online!

You can also supply functions as arguments by using De Bruijn indices, for example the S combinator \\\(3 1 (2 1)) (or λλλ(3 1 (2 1))). However it also recognizes the S, K, I and of course X combinator.

Output

By default the interpreter checks if the output encodes an integer, if it does it will output the corresponding number (in addition to the result). For convenience there's the -b flag which tells the interpreter to try matching a boolean instead (see the last example).

Assembler

Of course any low-level language needs an assembler that converts a high-level language to it, you can simply use any input (see above) and translate it to a XOISC-program by using the -a flag, try it online!**

* In case the link is down, there's a copy as HTML comment in this post.

** This results in a program that tests for primality, try it online!


Print a shuffled deck of cards Input

None

Output

52 cards. No duplicates. Cards are represented as their unicode characters, e.g. .

The Unicode codepoints follow the following format:

The first three digits are 1F0.
The next digit is A, B, C, or D for spades, hearts, diamonds, and clubs respectively.
The next digit is 1 through C and E for the various numbers/face cards. 1 is ace, 2-A are the number cards, and B, D,  and E are the jack, queen, and king respectively. (C is the knight, which isn't in most decks.)

Example output:

Rules:

This is code-golf. Shortest answer wins.
Forbidden loopholes are forbidden.
Your deck must be actually randomized. If run 20 times, 20 random (and most likely unique) outputs must be generated.

Note

If you only see boxes, install the DejaVu fonts.


Check if a string is entirely made of the same substring This is taken from this question (with permission ofcourse). I'll quote:

  Create a function which takes a string, and it should return true or
  false based on whether the input consists of only a repeated character
  sequence. The length of given string is always greater than 1 and the
  character sequence must have at least one repetition.

Some examples:

'aa' //true
'aaa' //true
'abcabcabc' //true
'aba' //false
'ababa' //false
'weqweqweqweqweqw' // false

Specifically, the check for a string strictly composed of repeating substrings (Update) can output any true or false representation, but no error output please. Strictly alphhanumeric strings. Otherwise standard code golf rules. This is Code Golf, so shortest answer in bytes for each language wins.

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!

Without a regular expression,  33  29 bytes

Returns either null (falsy) or an object (truthy).

s=>(s+s).slice(1,-1).match(s)

Try it online!

NB: Technically, \$s\$ is converted to a regular expression for match(), so the above title is a lie.


Shortest C \ C++ function to generate -1, 0 ,1 Let a function receive two integers i and j between 0 and 3, it should return the value in position (i,j) in the following 2D array:

1, 0, -1, 0
   1, 0, -1, 0
   0, 1, 0, -1
   0, -1, 0, 1

Shortest code in any variant of C / C++ wins.


Counting polyominoes on (hyper-)cubes This challenge like some of my previous challenges will have you counting free polyforms, which are generalizations of Tetris pieces.
This code-golf challenge will have you count polyomino-like polyforms on hypercubes. In particular, this challenge is to write a program that takes in three parameters:

n, which represents an \$n\$-dimensional hypercube,
m, which represents \$m\$-dimensional faces of the hypercube, and
k, which represents the number of cells in the polyform,

and outputs the number of ways to choose \$k\$ (\$m\$-dimensional) faces on the \$n\$-cube such that the \$m\$-faces are connected at \$(m-1)\$-faces. These polyforms are "free" which means they should be counted up to the rotations/reflections of the \$n\$-cube.
Again, this is a code-golf challenge, so shortest code wins.

Example 1
Okay, this is all very abstract, so this warrants an example.
When n=3, we're talking about the \$3\$-dimensional (ordinary) cube. When m=2 this means we're talking about the \$2\$-dimensional (square) faces. And we're talking about k of these, joined along \$1\$-dimensional faces (edges).
When k=3, there are two such polyforms (on the left) up to rotations/reflections of the cube. When k=4 there are also two polyforms (on the right).

Example 2
In this second example, n=3 still, so we're again talking about the \$3\$-dimensional (ordinary) cube. When m=1 this means we're talking about the \$1\$-dimensional faces (edges). And we're talking about k of these, joined along \$0\$-dimensional faces (corners).
When k=4 there are four such polyforms.

Data
n | m | k | f(n,m,k)
--+---+---+---------
3 | 2 | 3 | 2       (Example 1, left)
3 | 2 | 4 | 2       (Example 1, right)
3 | 1 | 4 | 4       (Example 2)
2 | 1 | 2 | 1
3 | 0 | 0 | 1
3 | 0 | 1 | 1
3 | 0 | 2 | 0
3 | 1 | 3 | 3
3 | 1 | 5 | 9
3 | 1 | 6 | 14
3 | 1 | 7 | 19
3 | 1 | 8 | 16
3 | 1 | 9 | 9
3 | 3 | 0 | 1
3 | 3 | 1 | 1
3 | 3 | 2 | 0
4 | 1 | 4 | 7
4 | 1 | 5 | 21
4 | 1 | 6 | 72
4 | 1 | 7 | 269
4 | 1 | 8 | 994
4 | 1 | 9 | 3615
4 | 2 | 3 | 5
4 | 2 | 4 | 12
4 | 2 | 5 | 47
5 | 1 | 4 | 7
5 | 1 | 5 | 27
5 | 2 | 0 | 1
5 | 2 | 1 | 1
5 | 2 | 2 | 1
5 | 2 | 3 | 5
5 | 2 | 4 | 20
5 | 3 | 4 | 16
5 | 3 | 5 | 73
5 | 4 | 4 | 3
6 | 1 | 6 | 121

Python 3, 389

import itertools as I
S=sorted
P=I.product
def C(n,m,k):
 Q=[((-1,)*(n-m)+(0,)*m,)]
 for i in' '*(k-1):Q=set(tuple(S(q+(v,)))for q in Q for v in P(*[(-1,0,1)]*n)if sum(map(abs,v))==n-m if not v in q and any(sum((a!=b)*(1+2*a*b)for a,b in zip(v,u))==2for u in q))
 return sum(all(S(q)<=S(zip(*r))for X in I.permutations(zip(*q))for r in P(*((p,tuple(-x for x in p)) for p in X)))for q in Q)

Try it online!

Basically just finds all connected polyominos, and discards ones which can be rotated into a lexicographically smaller polyomino, with rotations being brute-forced.

Can definitely be improved but it's my bedtime.


Write a program that reverses the name of its source file In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects.

Any way of achieving this is fine. It only matters that once the program is run the only lasting change is that its file name has been reversed. e.g. no new files should be in the directory.

Running the program again should reverse the name back. Indeed, the program should be able to be run arbitrarily many times.

For the purposes of this challenge:

You may assume filenames are always strings of lowercase letters (a-z) between 1 and 127 characters long. (If your language requires files to have extensions to run then just reverse the part before the extension, e.g. mycode.bat → edocym.bat.)
You may assume the code file is in a directory by itself so it will not have naming conflicts (except with itself).
You may not assume the filename is not a palindrome, i.e. the same when reversed. Filenames that are palindromes should work just as well as those that aren't.
You may read your file's contents or metadata. There are no quine restrictions here.
You may assume your program will be run on a particular, modern, commonplace operating system (e.g. Windows/Linux), since not all shells have the same command set.

  As a concrete example, say you have a Python program in a file called
  mycode in its own directory. Running

python mycode

  in the terminal should result in the filename being reversed to
  edocym. The file edocym should be alone in its directory - no file
  named mycode should exist anymore. Running

python edocym

  will reverse the name back to mycode, at which point the process can
  be repeated indefinitely.

  If the same Python file was renamed racecar (without changing the code) and then run

python racecar

  nothing should visibly change since "racecar" is a palindrome.
  That same goes if the filename were, say, a or xx.

The shortest code in bytes wins. Tiebreaker is higher voted answer.

Bash + common linux utils, 13 bytes

My method is similar to @DigitalTrauma's but a bit shorter due to the pipe with ls:

mv * `ls|rev`


I before E, except after C You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words.
Quoting Wikipedia:

If one is not sure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in which case it is ei.

It is well known that this rule is not always correct (e.g. weird, leisure, ancient). That is why you will be asked to write an algorithm which accurately determines the spelling of these words.
Task
The following wordlist (found here) consists of 2967 valid words, each of which contains either ei or ie as a substring.
The input is a single word \$ w \$ from the wordlist, but the ies and eis may be flipped (all occurrences of ie are replaced with ei, and vice versa). You are to output a boolean value indicating whether \$ w \$ was flipped. The values do not need to be True and False, so long as they are consistent. Your program must work correctly for all words, including their flipped counterparts (for a total of 5934 cases to consider). Here I've provided of a list of all possible test cases.
Note that you are not given this list as input. You must find a way to determine, for any word in the list, whether or not it is flipped but you cannot take the list itself as input.
Just to clarify, no word in the wordlist contains iei or eie as a substring, nor do a word and its flipped version both exist in the wordlist. As such, these ambiguous cases do not need to be considered. However, words such as friendlier or eighties which contain more than one occurrence of ei or ie do exist in the wordlist, in which case both occurrences are flipped (friendlier -> freindleir, eighties -> ieghteis).
Since this is code-golf, the shortest code in bytes wins.
As a side note, simply applying the "I before E, except after C" rule will be correct for 4954/5934 of the cases.

JavaScript (ES6), 338 bytes
A regex-based solution. This can probably be optimized some more.
Returns 0 (not flipped) or 1 (flipped).
w=>/dief|egh|etei|it?ei/.test(w)|/^(a?th0[rs]|d0st|r?0|h0r?[1s]|w0r)|b0[gt]|c0(l|t[es1]|v)|cl01|d0(f|n[1es]|ra|tie|ty)|0([aijop]|c1|[df]o|g[hln]|na?[fgor]|rlo|[rs]u|s[ahims]|tf|tm)|f0n?[at]|g0g|h0(fe|k|n|re)|ip01|k0n|n0t|no?th0|o0s|r0n1|rel01|rg0st|s0(l|ne|z)|t0n[es1]|u0n|un01|v0(l|n[1es])|yth0/.test(w.replace(/ei|ie/,0)+1)^/ei/.test(w)

Try it online!
(The total number of errors is reported in the Debug section of TIO, so you can collapse the Footer and Output sections if you just want to see that.)
How?
We first get rid of a few edge cases with the following regular expression:
/dief|egh|etei|it?ei/

which matches these flipped inputs (for which it's especially hard to tell that they are indeed flipped):
diefeid, diefeis, ieghteis, ieghteith, inhomogenieteis, pompiei, soceiteis,
wieghteir, wieghteist

Otherwise, we replace the first occurrence of either ei or ie in the input word with 0 and append a trailing 1:
w.replace(/ei|ie/, 0) + 1

We test whether the resulting string is matched by a large regular expression consisting of 23 patterns which are associated to words for which 0 must be ei.
Examples:

ath0stically1 is matched by ^(a?th0[rs]|d0st|r?0|h0r?[1s]|w0r)
rec0ved1 is matched by c0(l|t[1es]|v)
mad0ra1 is matched by d0(f|n[1ens]|ra|tie|ty)
ineffic0ncy1 is not matched by any expression


Stepping Through Time Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01.

That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this is true. Time can be considered to wrap around. For example, 23:55 and 00:05 are only 10 minutes apart.

Input

Input can be in any reasonable form which represents all four digits of a 24 hour time. E.x. a string, "20:48" (colon optional), a list of integers, [2, 0, 4, 8], or a single integer 2048.
Leading zeros are optional for input. Use whatever is most convenient.
You can assume the input will always represent a valid 24 hour time.

Output

You must output four integers which represent a valid 24 hour time. The individual integers can be represented in whatever form is most convenient. E.x. [2, 1, 0, 1] or "2101".
Leading zeros are not optional for output. E.x. you can't output 1:23 instead of 01:23.
You may optionally output a separator between the hours and minutes. This can be a colon, period, space, newline, or some other junk that saves you a byte. Whatever separator you choose, it must be consistent from one output to another.
If there are two equally close times to the input which satisfy the requirements, you may output either.
Note there are only 16 possible outputs: 01:01, 01:21, 01:23, 10:10, 10:12, 12:10, 12:12, 12:32, 12:34, 21:01, 21:21, 21:23, 23:21, 23:23, 23:43, and 23:45.

Test cases

00:10 -> 23:45
01:23 -> 01:23
05:46 -> 01:23
05:47 -> 10:10
12:00 -> 12:10
16:47 -> 12:34
16:48 -> 21:01
20:48 -> 21:01
21:22 -> 21:23 or 21:21

Python 3 reference implementation.

Score

This is code golf, so the shortest program in bytes wins. The standard loopholes are forbidden.

JavaScript (ES7),  136  132 bytes
Takes a single integer as input and returns a string.
s=>(V=g=(d,t=s,k=0)=>k>V?R:[...S=([1e3]+t).slice(-4)].some(p=c=>(p-(p=c))**2-1)?g(d,t=(t-~d)%2400,k+=t%100<60):(V=k,R=S))()&&g(2398)

Try it online!
How?
The only valid hour prefixes are 01, 10, 12, 21 and 23. It means that any invalid minute count starting with a digit greater than 5 will be rejected by the test on the absolute difference between two consecutive digits.
So there's no need to explicitly handle the wrapping of minutes modulo 60. Instead, we can just make sure that the distance k is not incremented on invalid minutes:
k += t % 100 < 60

JavaScript (Node.js),  148  146 bytes
Takes a single integer as input and returns a string.
This version picks the answer from a hardcoded table.
t=>0x60553BCD48A3CE4F56D818FDC473FC726398E907D3A9n.toString(6).substr([22,85,9,423,462,x=98,x,9,9,413,461,9,x,x,9,9].findIndex(d=>(t-=d+2)<0)*4,4)

Try it online!
How?
Once converted to base-6, the integer 0x60553BCD48A3CE4F56D818FDC473FC726398E907D3A9n is turned into the following string, which holds all possible valid answers:
"23450101012101231010101212101212123212342101212121232321232323432345"

The correct answer is selected according to the interval in which the input time falls:
 answer | input interval
--------+----------------
 "2345" | 00:00 - 00:23
 "0101" | 00:24 - 01:10
 "0121" | 01:11 - 01:21
 "0123" | 01:22 - 05:46
 "1010" | 05:47 - 10:10
 "1012" | 10:11 - 11:10
 "1210" | 11:11 - 12:10
 "1212" | 12:11 - 12:21
 "1232" | 12:22 - 12:32
 "1234" | 12:33 - 16:47
 "2101" | 16:48 - 21:10
 "2121" | 21:11 - 21:21
 "2123" | 21:22 - 22:21
 "2321" | 22:22 - 23:21
 "2323" | 23:22 - 23:32
 "2343" | 23:33 - 23:43
 "2345" | 23:44 - 23:59

The lengths of the intervals in minutes (minus 2) are stored in an array.


Thwarting the Fry King Setting

The Fry King is a small criminal mastermind from the western european nation of Belgium, more specifically Flanders. He has acquired every single fastfood restaurant in a large part of Belgium and set them out on a 101X49 grid (102 intersections horizontally, 50 vertically, including the borders), 5100 restaurants in total located on the intersections. The next step in his diabolical plan is to orchestrate the closing hours of these restaurants so that on any one day of the year (bar 2 explained later), only 1 corner of each square will have an open restaurant.

Example with a 6X2 grid:

1---2---3---4---1---2
|   |   |   |   |   |
3---4---1---2---3---4

A year has 365 days. On the first Monday of the year, only the restaurants with number 1 will be open. On the next day, Tuesday, only those with the number 2. On the next day, Wednesday, only those with number 3. On the next day, Thursday, only those with number 4. after that, it starts again at 1. The days before the first Monday count back. For example, if the first Monday falls on January 3rd, the Sunday before the 4s will be open. This might mean that when the year changes, a store might be open twice or might be skipped in the rotation.

There are 2 exceptions: the 21st of July is the national holiday. All restaurants are open. Another is the 29th of February. Because this is the Fry King's birthday, all restaurants are also open. These exceptions replace a normal day, so if the 20th is for the restaurant with number 1, the 22nd is for the joints with number 3.

Assignment

You are a vigilante coder who has setup a toll-free texting number. It accepts 3 values, delimited by an *: A number between 1 and 101 denoting the column value you're in, a number between 1 and 49 to denote the row number you're in (these 2 determine which joints are eligible) and a date in the format of DD/MM/YYYY (day/month/year). The number returns 2 letters indicating which corner of your square contains today's open restaurant (NW-NE-SE-SW). If there are multiple options, it returns the first eligible one from the previous series.

Example:

Input

1*1*06/01/2014

Output

NW

Input:

2*1*20/01/2014

Output

NE

Calculation is code golf. Shortest code in bytes wins. There are no special bonuses to win or limitations involved, apart from 1: no external resources.

Python 2 (228 209 208 207)

(not counting the last newline)

import time
s=time.strptime
f=raw_input().split('*')
t=s(f[2],"%d/%m/%Y")
if t[1:3]in[(2,29),(7,21)]:t=s("%s%s"%(t[0],t[7]-1),"%Y%j")
print"NNSSWEWE"[(t[7]+s(str(t[0]),"%Y")[6]-int(f[0])-int(f[1])*2+3)%4::4]

Edits:

substituted variables that were used only once, further golfed the print statement.
Removed the space after print as isaacg suggested.
Changed from time import*;s=strptime to import time;s=time.strptime to shave off one extra byte


Range interval insert which should split into unique ranges Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.

The goal is to create an insertInterval(intervals, newInterval) function which returns a new interval list if there are any changes.

Pre-condition:
Interval range is sorted smallest to larger [[0, 1], [3, 5]].

Examples:
Input and output:

assert.deepEqual(
  insertIntervalSec([[1,5],[10,15],[20,25]], [12,27]),
  [[1,5],[10,15],[15,20],[20,25],[25, 27]]
);

assert.deepEqual(
  insertIntervalSec([[1,5],[10,15],[20,25]], [-3,0]),
  [[-3,0],[1,5],[10,15],[20,25]]
);

assert.deepEqual(
  insertIntervalSec([[1,5],[10,15],[20,25]], [-3,3]),
  [[-3,1],[1,5],[10,15],[20,25]]
);

assert.deepEqual(
  insertIntervalSec([[0,5],[10,15],[20,25]], [15,15]),
  [[0,5],[10,15],[20,25]]
);
assert.deepEqual(
  insertIntervalSec([[0,5],[10,15],[20,25]], [20,21]),
  [[0,5],[10,15],[20,25]]
);
assert.deepEqual(
  insertIntervalSec([[0,5],[10,15],[20,25]], [26,27]),
  [[0,5],[10,15],[20,25],[26, 27]]
);
assert.deepEqual(
  insertIntervalSec([[0,5],[10,15],[20,25]], [25,27]),
  [[0,5],[10,15],[20,25],[25,27]]
);
assert.deepEqual(insertIntervalSec([], [25,27]), [[25,27]]);
assert.deepEqual(insertIntervalSec([[1,1]], [1,1]), [[1,1]]);
assert.deepEqual(insertIntervalSec([[1,1]], [1,3]), [[1, 1], [1, 3]]);
assert.deepEqual(insertIntervalSec([[2,2]], [1,3]), [[1, 2], [2, 2], [2, 3]]);

All programming languages are welcome.

Japt, 44 bytes

rò
íU c ò@Vc øX ©X¥YÃke@V®ròÃc øXÃ®gJõ0ÃcV n

Try it online!

Reworked it, at the cost of 1 byte.
Now handles the [[2,2]],[1,3] test case properly.

Explanation:

rò                                           #Turn the second input into a range
íU c                                         #Duplicate each item in that range
     ò@      ©X¥YÃ                           #Split in the middle of the duplicates that:
       Vc øX                                 # Appear in the first input
                  k                          #Remove the segments where:
                   e@       øXÃ              # Every item in the segment is in...
                     V®ròÃc                  # A range from the first input
                               ®    Ã        #For the remaining segments:
                                gJõ0         # Get the first and last items
                                     cV      #Add those pairs to the first input
                                        n    #Sort the whole thing

Worked Example:

Input: [[2,2],[5,7]],[1,8]

Second input as a range: [1,2,3,4,5,6,7,8]

Duplicate each item: [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]

Numbers that appear in the first input: [2,5,7]

After splitting: [[1,1,2],[2,3,3,4,4,5],[5,6,6,7],[7,8,8]]

Numbers within the first input's ranges: [2,5,6,7]

Segments using only those numbers:[[5,6,6,7]]

Remaining segments after those are removed: [[1,1,2],[2,3,3,4,4,5],[7,8,8]]

First and last item of each: [[1,2],[2,5],[7,8]]

Merge with the first input: [[1,2],[2,5],[7,8],[2,2],[5,7]]

Sort it: [[1,2],[2,2],[2,5],[5,7],[7,8]]

Which matches the actual output of the code


Parse a C++14 integer literal According to http://en.cppreference.com/w/cpp/language/integer_literal, integer literals consist of a decimal/hex/octal/binary literal and a optional integer suffix, that is obviously completely unnecessary, wastes precious bytes and is not used in this challenge.

A decimal literal is a non-zero decimal digit (1, 2, 3, 4, 5, 6, 7, 8, 9), followed by zero or more decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).

A octal literal is the digit zero (0) followed by zero or more octal digits (0, 1, 2, 3, 4, 5, 6, 7).

A hexadecimal literal is the character sequence 0x or the character sequence 0X followed by one or more hexadecimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, A, b, B, c, C, d, D, e, E, f, F) (note the case-insensitivity of abcdefx).

A binary literal is the character sequence 0b or the character sequence 0B followed by one or more binary digits (0, 1).

Additionally, there may optionally be some 's as a digit separator. They have no meaning and can be ignored.

Input

A string that represents a C++14 integer literal or an array of its charcodes.

Output

The number represented by the input string in base 10, with an optional trailing newline. The correct output never will exceed 2*10^9

Winning criteria

The GCC contributors need over 500 lines of code to do this, therefore our code must be as short as possible!

Test cases:

0                       ->    0
1                       ->    1
12345                   ->    12345
12345'67890             ->    1234567890
0xFF                    ->    255
0XfF                    ->    255
0xAbCdEf                ->    11259375
0xa'bCd'eF              ->    11259375
0b1111'0000             ->    240
0b0                     ->    0
0B1'0                   ->    2
0b1                     ->    1
00                      ->    0
01                      ->    1
012345                  ->    5349
0'123'4'5               ->    5349

x86 (32-bit) machine code, 59 57 bytes

This function takes esi as a pointer to a null-terminated string and returns the value in edx.  (Listing below is GAS input in AT&T syntax.)

        .globl parse_cxx14_int
        .text
parse_cxx14_int:
        push $10
        pop %ecx                # store 10 as base
        xor %eax,%eax           # initialize high bits of digit reader
        cdq                     # also initialize result accumulator edx to 0
        lodsb                   # fetch first character
        cmp $'0', %al
        jne .Lparseloop2
        lodsb
        and $~32, %al           # uppercase letters (and as side effect,
                                # digits are translated to N+16)
        jz .Lend                # "0" string
        cmp $'B', %al           # after '0' have either digit, apostrophe,
                                # 'b'/'B' or 'x'/'X'
        je .Lbin
        jg .Lhex
        dec %ecx
        dec %ecx                # update base to 8
        jmp .Lprocessdigit      # process octal digit that we just read (or
                                # skip ' if that is what we just read)
.Lbin:
        sub $14, %ecx           # with below will update base to 2
.Lhex:
        add $6, %ecx            # update base to 16
.Lparseloop:
        lodsb                   # fetch next character
.Lparseloop2:
        and $~32, %al           # uppercase letters (and as side effect,
                                # digits are translated to N+16)
        jz .Lend
.Lprocessdigit:
        cmp $7, %al             # skip ' (ASCII 39 which would have been
                                # translated to 7 above)
        je .Lparseloop
        test $64, %al           # distinguish letters and numbers
        jz .Lnum
        sub $39, %al            # with below will subtract 55 so e.g. 'A'==65
                                # will become 10
.Lnum:
        sub $16, %al            # translate digits to numerical value
        imul %ecx, %edx
#        movzbl %al, %eax
        add %eax, %edx          # accum = accum * base + newdigit
        jmp .Lparseloop
.Lend:
        ret

And a disassembly with byte counts - in Intel format this time, in case you prefer that one.

Disassembly of section .text:

00000000 <parse_cxx14_int>:
   0:   6a 0a                   push   0xa
   2:   59                      pop    ecx
   3:   31 c0                   xor    eax,eax
   5:   99                      cdq
   6:   ac                      lods   al,BYTE PTR ds:[esi]
   7:   3c 30                   cmp    al,0x30
   9:   75 16                   jne    21 <parse_cxx14_int+0x21>
   b:   ac                      lods   al,BYTE PTR ds:[esi]
   c:   24 df                   and    al,0xdf
   e:   74 28                   je     38 <parse_cxx14_int+0x38>
  10:   3c 42                   cmp    al,0x42
  12:   74 06                   je     1a <parse_cxx14_int+0x1a>
  14:   7f 07                   jg     1d <parse_cxx14_int+0x1d>
  16:   49                      dec    ecx
  17:   49                      dec    ecx
  18:   eb 0b                   jmp    25 <parse_cxx14_int+0x25>
  1a:   83 e9 0e                sub    ecx,0xe
  1d:   83 c1 06                add    ecx,0x6
  20:   ac                      lods   al,BYTE PTR ds:[esi]
  21:   24 df                   and    al,0xdf
  23:   74 13                   je     38 <parse_cxx14_int+0x38>
  25:   3c 07                   cmp    al,0x7
  27:   74 f7                   je     20 <parse_cxx14_int+0x20>
  29:   a8 40                   test   al,0x40
  2b:   74 02                   je     2f <parse_cxx14_int+0x2f>
  2d:   2c 27                   sub    al,0x27
  2f:   2c 10                   sub    al,0x10
  31:   0f af d1                imul   edx,ecx
  34:   01 c2                   add    edx,eax
  36:   eb e8                   jmp    20 <parse_cxx14_int+0x20>
  38:   c3                      ret

And in case you want to try it, here is the C++ test driver code that I linked with it (including the calling convention specification in GCC asm syntax):

#include <cstdio>
#include <string>
#include <iostream>

inline int parse_cxx14_int_wrap(const char *s) {
    int result;
    const char* end;
    __asm__("call parse_cxx14_int" :
            "=d"(result), "=S"(end) :
            "1"(s) :
            "eax", "ecx", "cc");
    return result;
}

int main(int argc, char* argv[]) {
    std::string s;
    while (std::getline(std::cin, s))
        std::printf("%-16s -> %d\n", s.c_str(), parse_cxx14_int_wrap(s.c_str()));
    return 0;
}

-1 byte due to comment by Peter Cordes

-1 byte from updating to use two decrements to change 10 to 8


Printing criss cross of two strings Given a set of two strings guaranteed to be the same length, print their criss cross.

The criss cross of two strings is obtained as follows.

Yield the second character of the second string, then the first character of the first string.
Yield the first character of the second string, then the second character of the first string.
Discard the first character of each string.
If the strings have more than one character each, go back to step 1.

For example, if the two strings are

Truck
Tower

the criss cross is

oTTrwroueuwcrcek

as illustrated in the following diagram.

Each color represents a different iteration of criss-crossing. The numbers show the corresponding character's indices in the output.


File access redirection This one ought to be a little more of a challenge than your normal "compute these numbers" or "print this sequence of text" puzzles:

Write a program that launches another program and when that other program tries to access a certain file the program causes it to open a different file.

Example:

The program launches Notepad.
Notepad attempts to open "orange.txt"
The program detects it and makes notepad open "green.txt" instead.

Rules:
WinAPI is allowed, but your code will stand out better if you can get this some other way.
You can use any language, but it must be able to run on either Windows or Linux

gdb, 108 chars

star
b open if !(int)strcmp(((char**)$esp)[1],"orange.txt")
comm
set((char**)$esp)[1]="green.txt"
c
end
c
q

Save as the file redirect and run like this:

gdb -x redirect <program you want to redirect>

Works on x86 (linux at least, and probably Windows/Mac also).  Here's what the lines do:

star = start gets to the beginning of main (needed so open is defined for the next step).

b open if... = break if we're calling open on orange.txt

comm = command the code up to the next end is executed when the breakpoint fires.

set ((char*))... = replace the open argument with green.txt

c=continue

q=quit


Sabotage a Train to Make It Run Late "I want to go to the Araby bazaar to buy a present for the one I have fallen in love with. However, if I arrive too late all the stores will be closed and I won't be able to buy anything. Can you help me?"

Goal: Get the boy to Araby from North Richmond Street before all the stores close.
Actual Goal: Make sure the boy doesn't arrive in Araby before the stores close.

Your program will take in input in the following format:

<time> <map>

where

<time> is the maximum time the boy can spend travelling, in minutes. It is a positive integer.
<map> is a graph of the routes the train can take.

Here is how the format for the graph works:

Each statement is ended with a semicolon.
Nodes in the map (which represent switches) are represented using single lower case letters.
A path between nodes is represented with the syntax a,X,b, where X is an integer representing the weight of the path. The weight of the path is the time, in minutes, the train takes to go through those two nodes.
Araby is represented with a, and North Richmond Street is represented with an n.
All paths are bidirectional.

For instance, this graph (pretend the paths are bidirectional):

Image by Artyom Kalinin, via Wikimedia Commons. Used under the CC BY-SA 3.0 licence.

would be recorded in the graph notation as:

a,4,b;a,2,c;b,5,c;b,10,d;c,3,e;e,4,d;d,11,f;

Note that this input doesn't have an n, so it's an invalid input. Your program may do anything if given an invalid input.

Here is an example input:

21 n,4,b;n,2,c;b,5,c;b,10,d;c,3,e;e,4,d;d,11,a;

(It's just the same graph as the image above with a replaced by n and f replaced by a).

The boy must get from n to a within 21 minutes. If he takes the route n --> c --> e --> d --> a, he gets there in 20 minutes, which is in time. We could represent that route as a comma separated list of nodes:

n,c,e,d,a

On the other hand, the route n --> b --> c --> e --> d --> a will cause the boy to take 27 minutes, which is not in time. We could represent that route like this:

n,b,c,e,d,a

Another possible route that will cause the boy to not make it in time is:

n,b,c,b,c,b,c,b,c,b,c,b,c,b,c,b,c,b,c,e,d,a

Your program should take in the input as described above, and at first glance appear to output a route that will cause the boy to make it in time, but actually outputs a route that causes the boy to not make it in time. For any given input there will always exist a route, without backtracking, that causes the boy to not make it in time.

This is an underhanded popularity contest, so the entry with the most votes wins. Votes are awarded for ingenuity in hiding the bug - the less obvious it is the better.

Here are some sample graphs to test your program with.

Input:

12 a,2,c;a,2,e;b,5,c;b,4,d;b,11,e;d,7,n;e,4,n;

A visual representation (this visual representation is only for clarity and does not constitute part of the challenge):

A possible output:

n,d,b,e,a

Input:

10 a,8,b;a,12,d;b,1,n;d,11,n;a,1,n;

Here is a visual image of the graph:

A possible output:

n,d,a

Python 3 (not 2)

Edit: I'll ungolf this in the morning, oops.

It's a perfectly normal A-star search. Right? Riiiiiiight?
Seems to work for all test cases.

def a(b,c,d):
    e,f,g=[],{},{}
    f[c]=0
    while f:
        h=sorted(f.keys(),key=lambda z:-f[z],reverse=True)[-1]
        if h==d:break
        e.append(h)
        for z in b[h]:
            if z in e:continue
            if z in f and f[z]>f[h]+b[z][h]:continue
            g[z]=h
            f[z]=f[h]+b[z][h]
        del f[h]
    i=[]
    j=d
    q=0
    while j!=c:
        i.append(j)
        q+=b[j][g[j]]
        j=g[j]
    return q,(i+[c])[::-1]
t,q=input().split(" ")
t=int(t)
q=q[:-1]
q=[i.split(",")for i in q.split(";")]
g={a:{}for a in __import__("functools").reduce(lambda zz,zy:zz+zy,[[v[0],v[2]]for v in q])}
for l in q:g[l[0]][l[2]]=g[l[2]][l[0]]=int(l[1])

r=a(g,'n','a')
print("time-good: %d, time-ours: %d" % (t, r[0]))
print("path: %s" % " -> ".join(r[1]))


Real Chebyshev Rotation This is a challenge inspired by Chebyshev Rotation. I suggest looking at answers there to get inspiration for this challenge.

Given a point on the plane there is a unique square (a rectangle with equal sides) that is centered on the origin and intersects that point (interactive demo):

Given a point p and a distance d, return the point obtained by moving distance d from p, counter-clockwise (and clockwise for negative  d), along the perimeter of the square centered on the origin that intersects p. Your answer must be accurate to at least 4 decimal digits.

Testcases:

(0, 0), 100 -> (0, 0)
(1, 1), 81.42 -> (-0.4200, 1.0000)
(42.234, 234.12), 2303.34 -> (-234.1200, 80.0940)
(-23, -39.234), -234.3 -> (39.2340, -21.8960)

The following test cases are from the original challenge by Martin Ender, and all are with d = 1:

(0, 0)       -> (0, 0)
(1, 0)       -> (1, 1)
(1, 1)       -> (0, 1)
(0, 1)       -> (-1, 1)
(-1, 1)      -> (-1, 0)
(-1, 0)      -> (-1, -1)
(-1, -1)     -> (0, -1)
(0, -1)      -> (1, -1)
(1, -1)      -> (1, 0)
(95, -12)    -> (95, -11)
(127, 127)   -> (126, 127)
(-2, 101)    -> (-3, 101)
(-65, 65)    -> (-65, 64)
(-127, 42)   -> (-127, 41)
(-9, -9)     -> (-8, -9)
(126, -127)  -> (127, -127)
(105, -105)  -> (105, -104)

Python 2, 363 335 296 266 262 258 256 233 Bytes

Woo, 130 bytes lost! Thanks to Neil for saving 4 bytes, Nathan Merrill for saving 2 bytes, and xnor for saving a ridiculous 23 bytes!

The general idea is this: We can reduce the distance traveled by taking it's the modulus of it against the perimeter of the square. The perimeter is defined as 8 times the largest of the two coordinates, since the point must rest on it. Then, after modulus is taken we are guaranteed to have no overlap. It also guarantees we only ever have to move counter-clockwise, since modulus gives a positive result.

From there, I simply use what we know from the given x and y-coordinates to figure out where we are: top, bottom, left, right, or in a corner, and determine the direction, which can be one of 0, 1, 2, 3:

0 --> we are on the 'top', moving 'left'
1 --> we are on the 'left', moving 'down'
2 --> we are on the 'bottom', moving 'right'
3 --> we are on the 'right', moving 'up'

After this, it is as simple as looping while we still have distance to travel, and based on the direction we subtract or add to the appropriate coordinate, and tell the loop which direction we are going next.

p,d=input()
x,y=p
s=max(x,y,-x,-y)
d=d%(s*8or 1)
r=[(y<s)*[2,[3,x>-s][x<s]][y>-s],[2*(y<0),3*(y<=0)][x>0]][y*y==x*x]
while s>0<d:f=1-2*(r<2);m=abs(f*s-p[r%2]);j=d>m;p[r%2]=[p[r%2]+f*d,f*s][j];r=-~r%4;d=(d-m)*j
print"%.4f "*2%tuple(p)

While quite long, it certainly works. Here's some example I/O:

[0, 0], 100 --> 0.0000 0.0000
[1, 1], 81.42 --> -0.4200 1.0000
[42.234, 234.12], 2303.34 --> -234.1200 80.0940
[-23, -39.234], -234.3 --> 39.2340 -21.8960

Try it online or run test cases.


Project Euler's "Harshad Numbers" Project Euler Problem 387 states:

  A Harshad or Niven number is a number that is divisible by the sum of its digits.
  201 is a Harshad number because it is divisible by 3 (the sum of its digits.)
  When we truncate the last digit from 201, we get 20, which is a Harshad number.
  When we truncate the last digit from 20, we get 2, which is also a Harshad number.
  Let's call a Harshad number that, while recursively truncating the last digit, always results in a Harshad number a right truncatable Harshad number.

  Also:
  201/3=67 which is prime.
  Let's call a Harshad number that, when divided by the sum of its digits, results in a prime a strong Harshad number.

  Now take the number 2011 which is prime.
  When we truncate the last digit from it we get 201, a strong Harshad number that is also right truncatable.
  Let's call such primes strong, right truncatable Harshad primes.

Given a number n, determine the first n strong, right truncatable Harshad primes.

Input: An integer, n, where n<50. (This means your program will need to be somewhat efficient.)

Output: The first n strong, right truncatable Harshad primes, with some form of whitespace in between each value.

Reference Table:
The first 20 strong, right truncatable Harshad primes are:
1-10:181 211 271 277 421 457 631 2011 2017 2099
11-20:2473 2477 4021 4027 4073 4079 4231 4813 4817 6037 8011

Shortest code wins. Good luck!

Python 188 bytes

r=range(10)
h=zip(r,r)
w=input()
p=lambda n:all(n%~i for i in range(1,int(n**.5)))%n
while w:
 n,s=h.pop(1)
 for i in r:
    d=s+i;i+=10*n
    if i%d<1:h+=[(i,d)]
    if p(n/s)and p(i):print i;w-=1

This could be made shorter, but my primary concern was efficiency. This code maintains a list of the 'right truncable harshad numbers', as well as the their digital sum, and then uses this list to extend itself by one digit iteratively, allowing only new truncable numbers. I don't see any way to obtain the efficiency required without maintaining such a list. Runtime for n<=50 is less than one second.

A less efficient version, which calculates everthing as it goes (139 bytes, has an acceptable runtime for n<=31):

s=9
w=input()
while w:
 n=s=s+2;x=2;f=0
 while n>9:n/=10;z=sum(map(int,`n`));x-=n%z;f=f or(n/z<3)+n/z
 if(1<<s)%s==(1<<f)%f==x:print s;w-=1


LED Numbers and Letters The program must print the following block of text of LED numbers exactly.

+-----------------------------------------------------------------+
|                                                                 |
| 000   1 222 333 4 4 555 666 777 888 999 AAA B   CCC   D EEE FFF |
| 0 0   1   2   3 4 4 5   6     7 8 8 9 9 A A B   C     D E   F   |
| 0 0   1 222 333 444 555 666   7 888 999 AAA BBB C   DDD EEE FFF |
| 0 0   1 2     3   4   5 6 6   7 8 8   9 A A B B C   D D E   F   |
| 000   1 222 333   4 555 666   7 888 999 A A BBB CCC DDD EEE F   |
|                                                                 |
+-----------------------------------------------------------------+

Notice the 1-char padding inside the borders.
The trailing newlines, and the types of the newlines are not significant.
However, the whitespaces are the spaces you get when you press spacebars (ASCII 32).

Shortest code wins. Using data encoding (base64, gzip), or compressing with other Unicode characters is discouraged. You cannot use programs like cat or gzip since they are not programming languages.

The character count must be less than 600 to qualify.

Golfscript, 142 137 chars

Unfortunately some of the characters are control codes, so I'm going to have to post a hexdump and a link rather than a direct copy of the source:

00000000  27 2b 27 3a 28 27 2d 27  36 35 2a 3a 5e 28 6e 27  |'+':('-'65*:^(n'|
00000010  7c 27 3a 29 27 20 27 3a  7c 36 34 2a 3a 40 27 20  ||':)' ':|64*:@' |
00000020  7c 0a 7c 20 27 3a 76 5b  27 77 12 5d 5b 3a 6b 6f  ||.| ':v['w.][:ko|
00000030  52 7f 7b 7e 2f 65 1f 6d  6c 27 7b 7d 2f 5d 3a 24  |R.{~/e.ml'{}/]:$|
00000040  2c 2c 7b 3a 78 3b 5b 27  60 40 50 20 00 10 2c 08  |,,{:x;['`@P ..,.|
00000050  1a 04 00 02 05 01 03 27  7b 7d 2f 5d 7b 24 78 3d  |.......'{}/]{$x=|
00000060  26 21 5b 34 38 78 2e 31  30 2f 37 2a 2b 2b 5d 7c  |&![48x.10/7*++]||
00000070  2b 3d 7d 25 33 2f 7d 25  7a 69 70 7b 7c 2a 7d 25  |+=}%3/}%zip{|*}%|
00000080  76 2a 76 40 29 6e 28 5e  28                       |v*v@)n(^(|

leds.gs

Note that all of the characters are 7-bit values and legal Unicode code points, so the number of characters is the same as the number of bytes in UTF-8.

Basically there are two hard-coded arrays. The first is a 15-element bitmap indicating which of the 7 segments control each grid cell. The second is the 7-segment encoding of the 16 characters. Then it's just a case of using bitwise and to work out which segments are turned on and doing some string manipulation.


Radio station hopping Introduction
You are listening to a car radio. You are pressing seek up/down, moving you to the next frequency some radio station broadcasts on, to avoid all this pointless music and listen to all the ads, or vice versa. If you try to go below the lowest frequency radio can handle, it jumps to the highest (and vice versa). Possible frequency range of a car radio is about 80-110 MHz with 2 decimals of precision.
But there is a tendency of these broadcasts to have your radio jump to another frequency, where signal of that radio station is stronger. So, suppose this radio station A broadcasts at 99, 100 and 101 MHz with 100 MHz having the strongest signal at your place. The moment you reach 101 MHz, radio will jump to 100 MHz.
Because of that, you can get trapped. Suppose there is one extra radio station B, broadcasting only at 102 MHz. The moment you are stuck at the station A, you can never listen to station B again - if you try going with frequency down, you will hit 99 and jump to 100, if you go up you reach 101 and jump to 100 again... never escaping that trap and radio station.
But if there is yet another station C at 99.5 and 98.5 MHz with latter being the strongest, you can listen to all 3 radios again - starting from B you get down to A, then down to C, then pressing down loops you back again to the highest frequency and station B.
So, you start wondering - given a list of radio stations, can I listen to all radio stations at least once if I start at the correct frequency? And will I be able to endlessly cycle through all of them, or listen to all just once before getting cut off some stations?
Your task:
Get a list of radio stations, along with a designation of which has the strongest signal, in any reasonable format (1). Return one of three options to distinguish whether you can cycle through all stations indefinitely, you can cycle through all stations once or you cannot reach all stations from any starting point. Again in any reasonable format (2). Standard loophole rules apply.
(1) Test cases have different radio stations separated by semicolon. For each radio station, the strongest broadcast for the station is first, other entries separated by comma. You can pick anything else as your input format, along with any reasonable extra information you would like - for example number of radio stations, number of channels each station broadcasts at etc. Two stations won't share frequency. Frequencies can be assumed to be in typical car-like frequency range of say 80.00 to 110.00 MHz (or 8000 to 11000 if you prefer working with integers).
(2) Test cases have output as 1 - cycle all, 2 - cycle once, 3 - cannot reach all stations even once. You can return anything reasonable to distinguish these three options, as long as you return/print the value.  For example, another possible output might be T meaning cycle all is true, FT meaning cycle all is false, cycle once is true, and FF meaning cycle all and cycle once are both false (= you can't reach all stations even once). Limitation: You must return everything in the same way, eg if your code outputs "cycle all" by crashing due to recursion depth, your "cycle once" and "cannot cycle" must also output by crashing.
Test cases:
input: 102; 100, 99, 101 output: 2
input: 102; 100, 99, 101; 98.5, 99.5 output: 1
input: 100, 99, 101; 103, 102, 104 output: 3
input: 100, 99, 101; 103, 102, 104; 101.5, 99.5, 103.5 output: 1
input: 100, 99; 99.5, 100.5; 102, 103; 102.5, 101.5 output: 3
May the shortest code win.

JavaScript (ES10),  179  155 bytes
Expects an array of arrays of frequencies, with the strongest broadcast in first position for each station.
Returns \$1\$ for cycle once, \$0\$ for cycle all, or \$3\$ if there's no solution at all.

a=>a.some(h=A=>a[(g=([x],C=q=>a.find(d=>d.includes(b[(b.indexOf(x)+q)%n])))=>!g[x]&&g(C(g[x]=1))-~g(C(n-1)))(A)],b=a.flat().sort(),n=b.length)|2*a.every(h)

Try it online!
How?
We first create an array b[] holding all frequencies sorted in lexicographical order. It means that the 80-99Mhz range will be put after the 100-110MHz range. But because the frequencies are wrapping around anyway, it doesn't matter. We also put the total number of frequencies in n.
b = a.flat().sort(), n = b.length

The helper function C takes a direction q and returns the sub-list corresponding to the station that is reached by moving towards q from the current leading frequency x.
C = q => a.find(d => d.includes(b[(b.indexOf(x) + q) % n]))

The callback function h takes the sub-list A of a station and walks through all connected stations, keeping track of the count (let's call it N). We use q = 1 to seek up and q = n - 1 to seek down. We eventually test a[N] to figure out whether all stations were reached.
h = A => a[(g = ([x], C = ...) => !g[x] && g(C(g[x] = 1)) - ~g(C(n - 1)))(A)]

This uses the helper function C described above and another recursive function g whose underlying object is also used to keep track of the stations that were already reached, using the leading frequency as the key.
We invoke h twice: once within a some() to detect cycle once and once within an every() to detect cycle all.


Cover up zeroes in a list Inspired by this SO question

As input you will be given a non-empty list of integers, where the first value is guaranteed to be non-zero. To construct the output, walk from the start of the list, outputting each non-zero value along the way. When you encounter a zero, instead repeat the value you most recently added to the output.

You may write a program or function, and have input/output take any convenient format which does not encode extra information, as long as is still an ordered sequence of integers. If outputting from a program, you may print a trailing newline. Except for this trailing newline, your output should be an acceptable input for your submission.

The shortest code in bytes wins.

Test Cases

[1, 0, 2, 0, 7, 7, 7, 0, 5, 0, 0, 0, 9] -> [1, 1, 2, 2, 7, 7, 7, 7, 5, 5, 5, 5, 9]
[1, 0, 0, 0, 0, 0] -> [1, 1, 1, 1, 1, 1]
[-1, 0, 5, 0, 0, -7] -> [-1, -1, 5, 5, 5, -7]
[23, 0, 0, -42, 0, 0, 0] -> [23, 23, 23, -42, -42, -42, -42]
[1, 2, 3, 4] -> [1, 2, 3, 4]
[-1234] -> [-1234]

Jelly, 3 bytes
o@\

Try it online!
How it works
o      Take the logical OR of its arguments.
 @     Reverse the argument order of the link to the left.
  \    Do a cumulative reduce, using the link to the left.


Write the shortest game of alak Alak was invented by the mathematician A. K.  Dewdney, and described in his 1984 book Planiverse. The rules of Alak are simple:

  Alak is a two-player game played on a one-dimensional board with eleven slots on it.  Each slot can hold at most one piece at a
  time.  There's two kinds of pieces, "x" and "o". x's belong to one player, o's to the other.
  The initial configuration of the board is:

      xxxx___oooo

  The players take turns moving.  At each turn, each player can move only one piece, once.  A player cannot pass up on his turn.  A player
  can move any one of his pieces to the next unoccupied slot to its right or left, which may involve jumping over occupied slots.  A
  player cannot move a piece off the side of the board.

  If a move creates a pattern where the opponent's pieces are surrounded, on both sides, by two pieces of the mover's color (with no
  intervening unoccupied blank slot), then those surrounded pieces are removed from the board.

  The goal of the game is to remove all of your opponent's pieces, at which point the game ends.  Removing all-but-one ends the game
  as well, since the opponent can't surround you with one piece, and so will always lose within a few moves anyway.

I found this game online and was wondering: can it be golfed?

Rules of the golf

Your code must follow all the rules in the game, handling captures, proper moving, etc. (only exception is you don't have to add a bot, but you must have both players controlled somehow, and one player must be human).
Input must be move piece at tile X to tile Y, or quit. For example, you can use 1 4 to say 'move this piece at tile 1 to tile 4'. quit would end the program, although using Control-C would be acceptable. You also have to check if a move is invalid (by going outside the board or moving somewhere that you would have to cross over unoccupied spaces to get to or sending a message that is not a pair of tiles or quit).
Outputs for players winning and invalid must be P1 WINS, P2 WINS, and INVALID, respectively. (All of these are 7 characters.)
Output must show the board. That's all that's required.
It doesn't matter if you use any aids like numbered tiles or other pieces.
The challenge ends if:

One answer gets 50 votes
One answer remains the top-voted for 3 weeks, and no other answers were posted in that time

and the challenge has at least 3 answers (so there's some real competition).

Rules of the game

The player on the left must start first.
Only one piece occupies a square at a time. You move the piece left or right until it hits an unoccupied space. The board does not wrap, and you can't move through unoccupied areas. For example:

xoo__o. Here, the x moving right would change the board to _oox_o.
xxooo_. Here, the farthest-left x could move to yield _xooox, which captures the os, leaving _x___x.
x__oox. Here, the os are not captured (there is still a gap). Capture is not possible because you can't move through unoccupied spaces. The x on the left could only move one space, because there are no other pieces in between (leaving _x_oox).

Multiple adjacent pieces can be captured at once if the group is surrounded by the opponent's pieces. E.g. from x_oox to _xoox will capture both os and result in _x__x.
If after a move, you first capture the opponent's pieces, before checking if your own piece should be remove. Take two examples:

o_oxx to oxox_. First, the second o is captured, ox_x_, so the first x remains on the board.
o_oox to oxoo_. This time, none of the os are captured, so the x is captured instead.
If you have only one piece, the game ends, because you can't capture with just one piece.

Let the games begin! I look forward to seeing what you come up with.


Find the Fibonacci Patterns You are probably familiar with the Fibonacci sequence where the first two terms are 0, 1 (or sometimes 1, 1) and every term after that is the sum of the previous two. It starts like this:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Sometimes, the sequence contains numbers that have a particular pattern that I find interesting: the difference between any pair of adjacent digits is the same as any other pair. For instance, in the sequence starting with 0, 1, the 18th term is 987. 9-8=1 and 8-7=1. I am mildly satisfied.

Challenge

Given two initial values F(0) and F(1), output every number in the sequence generated by F(n) = F(n-1) + F(n-2) that meets the following criteria:

The difference between any pair of adjacent digits is the same as any other pair
It is as least three digits long (1 and 2 digit numbers are not interesting for this pattern)

Input

Two non-negative integers less than 10**10 (10 billion)

Output

All integers that are less than 10**10 and meet the criteria in the Challenge section
It is acceptable to output digits greater than 10**10 but it is not a requirement
Given that repeated digits meet the pattern (e.g. 777), it is possible that there are infinite numbers that meet the criteria but your program is not required to output forever
If no such integers exist, output whatever you want so long as it's not a number (nothing, null, empty array, error message, sad face, etc.)
If a number matching the pattern appears more than once in the sequence, you can output it once or as many times as it occurs
If any input meets the criteria, it should be included in the output

Rules

Input and Output can be in any standard format
Standard loopholes are forbidden
This is code-golf so the shortest code in bytes wins

Examples / Test Cases

Input , Output
[1,10] , []

[0,1] , [987]
[2,1] , [123]
[2,3] , [987]

[61,86] , [147]
[75,90] , [420]
[34,74] , [1234]
[59,81] , [2468]
[84,85] , [7531]

[19,46] , [111]
[60,81] , [222]
[41,42] , [333]
[13,81] , [444]
[31,50] , [555]
[15,42] , [666]
[94,99] , [777]
[72,66] , [888]
[3189,826] , [888888888]

[15,3] , [159,258]
[22,51] , [321,1357]
[74,85] , [159,4444]
[27,31] , [147,11111]

[123,0] , [123,123,123,246,369]
[111,0] , [111,111,111,222,333,555,888]
[111,222] , [111,222,333,555,888]

[33345,692] , [987654321]
[3894621507,5981921703] , [9876543210]
[765432099,111111111] , [111111111,876543210,987654321]

[1976,123] , [123, 2222, 4321, 6543, 45678]

MATL, 14 bytes
Thanks to Emigna for pointing out a mistake, now corrected
`yVdd~?yD]wy+T

Infinite loop that outputs the numbers as they are found.
Try it online! Note that in the online interpreter the results are displayed after the 1-minute time-out.
Explanation
Let F(n) and F(n+1) denote two generic consecutive terms of the Fibonacci sequence. Each iteration of the loop starts with the stack containing F(n), F(n+1) for some n.
`         % Do...while
  y       %   Duplicate from below. Takes the two inputs F(0), F(1) (implicitly)
          %   in the first iteration
          %   STACK: F(n), F(n+1), F(n)
  V       %   Convert to string. Let the digits of F(n) be '3579' for example
          %   STACK: F(n), F(n+1), '3579'
  d       %   Consecutive differences (of ASCII codes)
          %   STACK: F(n), F(n+1), [2 2 2]
  d       %   Consecutive differences
          %   STACK: F(n), F(n+1),  [0 0]
  ~       %   Logical negate, element-wise
          %   STACK: F(n), F(n+1), [1 1]
  ?       %   If top of the stack is non-empty and only contains non-zero entries
          %   (this is the case for digits '3579', but not for '3578' or '33')
          %   STACK: F(n), F(n+1)
    y     %     Duplicate from below
          %     STACK: F(n), F(n+1), F(n)
    D     %     Display immediately. This prints the copy of F(n)
          %     STACK: F(n), F(n+1)
  ]       %   End
  w       %   Swap
          %   STACK: F(n+1), F(n)
  y       %   Duplicate from below
          %   STACK: F(n+1), F(n), F(n+1)
  +       %   Add. Note that F(n)+F(n+1) is F(n+2)
          %   STACK: F(n+1), F(n+2)
  T       %   Push true. This will be used as loop condition
          %   STACK: F(n+1), F(n+2), true
          % End (implicit). The top of the stack is consumed as loop condition.
          % Since it is true, a new iteration will begin, with the stack
          % containing F(n+1), F(n+2)


Standardise a Phinary Number Background
Most people on here should be familiar with a few integer base systems: decimal, binary, hexadecimal, octal. E.g. in the hexadecimal system, a number \$abc.de_{16}\$ would represent
$$a\times16^2 + b\times16^1 + c\times16^0 + d\times16^{-1} + e\times16^{-2}$$
However, one can also use non-integer bases, like irrational numbers. Once such base uses the golden ratio \$φ = \frac{1+√5}2 ≈ 1.618...\$. These are defined analogously to integer bases. So a number \$abc.de_φ\$ (where \$a\$ to \$e\$ are integer digits) would represent
$$a\timesφ^2 + b\timesφ^1 + c\timesφ^0 + d\timesφ^{-1} + e\timesφ^{-2}$$
Note that in principle any of the digits could be negative (although we're not used to that) - we'll represent a negative digit with a leading \$\text{~}\$. For the purpose of this question we restrict ourselves to digits from \$\text{~}9\$ to \$9\$, so we can unambiguously write a number as one string (with tildes in between). So
$$-2\timesφ^2 + 9\timesφ^1 + 0\timesφ^0 + -4\timesφ^{-1} + 3\timesφ^{-2}$$
would be written as \$\text{~}290.\text{~}43\$. We call such a number a phinary number.
A phinary number can always be represented in standard form, which means that the representation uses only digits \$1\$ and \$0\$, without containing \$11\$ anywhere, and with an optional minus sign to indicate that the entire number is negative. (Interestingly, every integer has a unique finite representation in standard form.)
Representations which are not in standard form can always be converted into standard form using the following observations:

\$011_φ = 100_φ\$ (because \$φ^2 = φ + 1\$)
\$0200_φ = 1001_φ\$ (because \$φ^2 + \frac1φ = 2φ\$)
\$0\text{~}10_φ = \text{~}101_φ\$ (because \$φ - \frac1φ = 1\$)

In addition:

If the most significant digit is \$\text{~}1\$ (with the rest of the number being standard form), the number is negative, and we can convert it into standard form by swapping all \$1\$ and \$\text{~}1\$, prepending a minus sign, and applying the above three rules again until we obtain the standard form.

Here is an example of such a normalisation of \$1\text{~}3.2\text{~}1_φ\$ (I'm using additional spaces for positive digits, to keep each digit position aligned):

      1~3. 2~1φ         Rule:
=     0~2. 3~1φ         (3)
=    ~1~1. 4~1φ         (3)
=  ~1 0 0. 4~1φ         (3)
=  ~1 0 0. 3 0 1φ       (3)
=  ~1 0 1. 1 0 2φ       (2)
=  ~1 1 0. 0 0 2φ       (1)
=  ~1 1 0. 0 1 0 0 1φ   (2)
= - 1~1 0. 0~1 0 0~1φ   (4)
= - 0 0 1. 0~1 0 0~1φ   (3)
= - 0 0 1.~1 0 1 0~1φ   (3)
= - 0 0 0. 0 1 1 0~1φ   (3)
= - 0 0 0. 0 1 1~1 0 1φ (3)
= - 0 0 0. 0 1 0 0 1 1φ (3)
= - 0 0 0. 0 1 0 1 0 0φ (1)

Yielding \$-0.0101_φ\$.
For further reading, Wikipedia has a very informative article on the topic.
The Challenge
Hence, or otherwise, write a program or function which, given a string representing a phinary number (as described above), outputs its standard form, without leading or trailing zeroes. The input does not necessarily contain the phinary point, but will always contain the digit left of it (so no \$.123\$). The output must always include the phinary point and at least one digit to the left of it.
You may take input via STDIN, ARGV or function argument and either return the result or print it to STDOUT.
You may use a different algorithm than the above procedure as long as it is in principle correct and exact for arbitrary (valid) inputs - that is, the only limits which could potentially break your implementation should be technical limitations like the size of built-in data types or the available RAM. For instance, evaluating the input as a floating-point number and then picking digits greedily is not allowed, as one could find inputs for which floating-point inaccuracies would lead to incorrect results.
This is code golf, the shortest answer (in bytes) wins.
Test Cases
Input       Output

1           1.
9           10010.0101
1.618       10000.0000101
1~3.2~1     -0.0101
0.~1021     0. (or -0.)
105.~2      1010.0101
~31~5.~1    -100000.1001

Javascript (ES6) - 446 418 422 420 bytes

Minified:

F=s=>{D=[];z='000000000';N=t=n=i=e=0;s=(z+s.replace(/^([^.]*)$/,'$1.')+z).replace(/~/g,'-').replace(/-?\d/g,s=>((D[n++]=s/1),0));for(;i<n-3;i=j){if(p=D[j=i+1]){if(!e&&p<0){D=D.map(k=>-k);N=~N;p=-p}e=1}d=D[i];x=D[i+2];m=D[i+3];if(p<0){d--;p++;x++;e=j=0}if(p>1){d++;m++;p-=2;e=j=0}if(!d&&p*x==1){d=p;e=j=p=x=0}D[i]=d;D[i+1]=p;D[i+2]=x;D[i+3]=m}return(N?'-':'')+s.replace(/0/g,()=>D[t++]).replace(/^(0(?!\.))+|0+$/g,'')}

Expanded:

F = s => {
    D = [];
    z = '000000000';
    N = t = n = i = e = 0;
    s = (z + s.replace( /^([^.]*)$/, '$1.' ) + z).replace( /~/g, '-' ).
        replace( /-?\d/g, s => ((D[n++]=s/1),0) );

    for( ; i < n-3; i = j ) {
        if( p = D[j = i+1] ) {
            if( !e && p < 0 ) {
                D = D.map( k=>-k );
                N = ~N;
                p = -p;
            }
            e = 1;
        }
        d = D[i];
        x = D[i+2];
        m = D[i+3];

        if( p < 0 ) {
            d--;
            p++;
            x++;
            e = j = 0;
        }
        if( p > 1 ) {
            d++;
            m++;
            p-=2;
            e = j = 0;
        }
        if( !d && p*x == 1 ) {
            d = p;
            e = j = p = x = 0;
        }

        D[i] = d;
        D[i+1] = p;
        D[i+2] = x;
        D[i+3] = m;
    }

    return (N ? '-' : '') + s.replace( /0/g, ()=>D[t++] ).replace( /^(0(?!\.))+|0+$/g, '' );
}

The code produces a function F that performs the specified conversion.

It's a tough problem to golf. Numerous edge cases creep up that prevent simplification of the code. In particular, dealing with negatives is a pain, both in terms of parsing and in terms of logical handling.

I should note that the code only handles a "reasonable range" of inputs. To extend the domain of the function without bound, the number of zeros in z can be increased, and the constant bounding the while( c++ < 99 ) loop can be increased. The range currently supported is already overkill for the supplied test cases.

Sample Outputs

F('1')          1.
F('9')          10010.0101
F('1~3.2~1')    -0.0101
F('0.~1021')    -0.
F('105.~2')     1010.0101
F('~31~5.~1')   -100000.1001

The -0. isn't pretty, but the answer is still correct. I can fix it if necessary.


All you have to do is print the number 1! ...Twice Your task

In your language of choice: create a program that outputs 1

This 1 may either be a string or value equivalent to the number one.

The shifting catch

If you take the unicode codepoint (or whatever codepoint encoding your languages uses if not UTF) for each character in your program, and shift each of those values by the same non-zero amount, then the result will be another program (potentially executable in different language) that also outputs 1.

Find the unicode codepoint of a character: here.

E.g;

If your program looked like: X?$A, and somehow output 1, and it also miraculously outputs 1 after shifting all of it's Unicode indices up by, say, 10; then that process of shifting looks like this:

original program: X?$A

letter    codepoint  shift   new-codepoint   new-letter

X            88       +10        98          b
 ?           63                  73          I
  $          36                  46          .
   A         65                  75          K

new program: BI.K

Note: The Unicode codepoint will often be represented  in the form similar to U+0058. 58 is the hexadecimal codepoint . In decimal, that's 88. The link above will list 88 under the UTF (decimal) encoding section. That is the number you want to increment or decrement!

Examples of valid outputs

1
"1"
'1'
[1]
(1)
1.0
00000001
one

Note: If your language only supports the output of true as an equivalent to 1, that is acceptable. Exit-codes are also valid outputs.

Scoring

This is code-golf, so lowest bytes wins!
Brownie points for creativity & if the two programs are in separate languages.

Java, 62 bytes

interface M{static void main(String[]a){System.out.print(1);}}

Try it online.
05AB1E, 62 bytes
\agXeYTVXι@nfgTg\Vιib\Wι`T\a₂Fge\aZNPT₃nFlfgX`!bhg!ce\ag₂$₃.pp

Uses the 05AB1E encoding, with the codepoints all decreased by 13:

interface M{static void main(String[]a){System.out.print(1);}} has the codepoints [105,110,116,101,114,102,97,99,101,32,77,123,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,97,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,49,41,59,125,125]
\agXeYTVXι@nfgTg\Vιib\Wι`T\a₂Fge\aZNPT₃nFlfgX`!bhg!ce\ag₂$₃.pp has the codepoints [92,97,103,88,101,89,84,86,88,19,64,110,102,103,84,103,92,86,19,105,98,92,87,19,96,84,92,97,27,70,103,101,92,97,90,78,80,84,28,110,70,108,102,103,88,96,33,98,104,103,33,99,101,92,97,103,27,36,28,46,112,112].

Try it online.
Explanation:
Java:

interface M{                   // Full program:
  static void main(String[]a){ //  Mandatory main-method:
    System.out.print(          //   Print without trailing newline:
      1);}}                    //    Print 1

05AB1E:

\                  # Discard the top of the stack (no-op, since it's already empty)
                   #  STACK: []
 a                 # Check if it only consists of letters (resulting in falsey/0
                   # for an empty string "", which is used implicitly without input)
                   #  STACK: [0]
  g                # Push and push its length, which is 1
                   #  STACK: [1]
   X               # Push variable `X`, which is 1 by default
                   #  STACK: [1,1]
    e              # Push the number of permutations n!/(n-r)! with both 1s, which is 1
                   #  STACK: [1]
     Y             # Push variable `Y`, which is 2 by default
                   #  STACK: [1,2]
      T            # Push builtin 10
                   #  STACK: [1,2,10]
       V           # Pop and store it in variable `Y`
                   #  STACK: [1,2]
        X          # Push variable `X` again, which is 1 by default
                   #  STACK: [1,2,1]
         ι         # Uninterleave using the 2 and 1, resulting in ["2"]
                   #  STACK: [1,["2"]]
          @        # Check whether 1 is >= ["2"], resulting in [0]
                   #  STACK: [[0]]
           n       # Square it
                   #  STACK: [[0]]
            f      # Get a list of all prime factors (none for 0), which results in []
                   #  STACK: [[[]]]
             g     # Pop and push its length
                   #  STACK: [1]
              T    # Push builtin 10
                   #  STACK: [1,10]
               g   # Pop and push its length
                   #  STACK: [1,2]
                \  # Discard it
                   #  STACK: [1]
                 V # Pop and store it in variable `Y`
                   #  STACK: []

From here on out I can't really explain it anymore, since it does things I wasn't expecting:
ι                  # Uninterleave (would take either one or two arguments, but since the
                   # stack is empty, it somehow remembered the 1 that was previously on
                   # the stack and results in ["1"] -
                   # A program `ι` without input would result in an error instead..)
                   #  STACK: [["1"]]
 i                 # If-statement, which will be entered if the top is 1;
                   # since it's ["1"] instead of 1, it won't enter
                   #  STACK: []
  b\Wι`T\a₂Fge\aZNPT₃nFlfgX`!bhg!ce\ag₂$₃.pp
                   #  No-ops within the if-statement
                   # It again somehow remembers the previous ["1"] that was on the stack,
                   # which is output implicitly as result


How many Lynch-Bell numbers are there? Challenge

Given an integer, n, as input where 36 >= n >= 2, output how many Lynch-Bell numbers there are in base n.

The output must be in base 10.

Lynch-Bell Numbers

A number is a Lynch-Bell numbers if:

All of its digits are unique (no repetition of digits)
The number is divisible by each of its digits
It doesn't contain zero as one of its digits

Since, all of the digits have to be unique, and you have a finite set of single digit numbers in each base, there is a finite number of Lynch-Bell numbers.

For example, in base 2 there is only one Lynch-Bell number, 1, since all other numbers either repeat digits or contain a 0.

Examples

Input > Output
2 > 1
3 > 2
4 > 6
5 > 10
6 > 10
7 > 75
8 > 144
9 > 487
10 > 548

Mathematica Online ran out of memory above base 10. You can use the following code to generate your own:

Do[Print[i," > ",Count[Join@@Permutations/@Rest@Subsets@Range[#-1],x_/;And@@(x\[Divides]FromDigits[x,#])]&[i]],{i,10,36,1}]

Winning

Shortest code in bytes wins.

Jelly, 13 bytes

Q⁼g
*`Ṗ©bç"®S

Try it online!

Another O(nn) solution.

Explanation

Q⁼g  Helper link. Input: digits (LHS), integer (RHS)
Q    Unique (digits)
 ⁼   Match
  g  GCD between each digit and the integer

*`Ṗ©bç"®S  Main link. Input: integer n
*`         Compute n^n
  Ṗ        Pop, forms the range [1, n^n-1]
   ©       Store previous result in register
    b      Convert each integer to base n
     ç"    Call the helper link, vectorized, with
       ®   The register's value
        S  Sum


Single swaps of an array Inspired by Taken from a question at Stack Overflow.
The challenge
Given an integer n>1, output all arrays that can be obtained by swapping exactly two entries in the array [1, 2, ..., n].
The arrays can be produced in any order.
You can consistently use [0, 1, ..., n-1] (0-based) instead of [1, 2, ..., n] (1-based).
Additional rules

Input and output are flexible as usual.

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

Shortest code in bytes wins.

Test cases
Input 2 gives output (assumed 1-based)
2 1

Input 3 gives output (note that the three arrays could be in any order)
1 3 2
2 1 3
3 2 1

Input 4 gives output
1 2 4 3
1 3 2 4
1 4 3 2
2 1 3 4
3 2 1 4
4 2 3 1

Input 7 gives output
1 2 3 4 5 7 6
1 2 3 4 6 5 7
1 2 3 4 7 6 5
1 2 3 5 4 6 7
1 2 3 6 5 4 7
1 2 3 7 5 6 4
1 2 4 3 5 6 7
1 2 5 4 3 6 7
1 2 6 4 5 3 7
1 2 7 4 5 6 3
1 3 2 4 5 6 7
1 4 3 2 5 6 7
1 5 3 4 2 6 7
1 6 3 4 5 2 7
1 7 3 4 5 6 2
2 1 3 4 5 6 7
3 2 1 4 5 6 7
4 2 3 1 5 6 7
5 2 3 4 1 6 7
6 2 3 4 5 1 7
7 2 3 4 5 6 1

R, 54 bytes

function(n)combn(n,2,function(x){z=1:n
z[x]=rev(x)
z})

Try it online!

Returns a matrix where each column is a permutation.

combn(n,k) generates all combinations of size k from the list n, or from 1:n if n is a single integer. It also optionally takes a function FUN to be applied to the resultant combinations. So we write a function that performs the swap and returns the swapped list. The results are then all accumulated into an array, which is in this case 2-dimensional and hence a matrix.


Find the best period in which to have invested in a S&P500 index fund Here are the annual returns for a hypothetical S&P 500 stock index fund for each calendar year from 1928 to 2017, expressed as a multiplier. So in 1928 you might say "the index went up by 37.88%" which I've represented here by 1.3788.

1.3788, 0.8809, 0.7152, 0.5293, 0.8485, 1.4659, 0.9406, 1.4137, 1.2792, 0.6141,  1.2521, 0.9455, 0.8471, 0.8214, 1.1243,  1.1945, 1.138, 1.3072, 0.8813, 1,  0.9935, 1.1026, 1.2178, 1.1646, 1.1178,  0.9338, 1.4502, 1.264, 1.0262, 0.8569,  1.3806, 1.0848, 0.9703, 1.2313, 0.8819,  1.1889, 1.1297, 1.0906, 0.8691, 1.2009,  1.0766, 0.8864, 1.001, 1.1079, 1.1563,  0.8263, 0.7028, 1.3155, 1.1915, 0.885,  1.0106, 1.1231, 1.2577, 0.9027, 1.1476,  1.1727, 1.014, 1.2633, 1.1462, 1.0203,  1.124, 1.2725, 0.9344, 1.2631, 1.0446,  1.0706, 0.9846, 1.3411, 1.2026, 1.3101,  1.2667, 1.1953, 0.8986, 0.8696, 0.7663,  1.2638, 1.0899, 1.03, 1.1362, 1.0353,  0.6151, 1.2345, 1.1278, 1, 1.1341,  1.296, 1.1139, 0.9927, 1.0954, 1.1942

Source: https://www.macrotrends.net/2526/sp-500-historical-annual-returns

Challenge

Given as inputs:

the array of annual returns (but see Rule 2. below)
an array \$X\$ of \$1\le K \le 90\$ positive numbers (the amounts to invest in each year of the investment period)

write a program or function that outputs what would have been the "best" \$K\$ consecutive year period to have invested the amounts in \$X\$, where:

each amount is invested at the beginning of a year.
anything left after each year is reinvested at the beginning of each subsequent year.
"best" means the largest amount at the end of the \$K\$ year period.

Rules

This is code-golf, so the fewest bytes in each language wins. Standard rules apply. Explanations encouraged.
If you don't like the way I've represented the array of annual returns, you can change them to any other array of 90 numbers that you prefer.
You can output the best \$K\$ year period in any consistent manner (e.g. 0-indexed or 1-indexed, the first and/or the last year to have invested, etc.) but you need to say what your output represents if it isn't obvious.
In case of a tie, output any or all correct answers.

Example calculation

Suppose \$X = [ 10000, 20000, 30000 ]\$.

If you had invested these amounts in 1928, 1929, and 1930 (the 1-indices 1, 2, and 3) you would have ended up with 42743.10. Sad.

But if you had invested those amounts in 2014, 2015, and 2016 (the 1-indices 87, 88, and 89) you would have ended up with 66722.66. A bit better.

It turns out the best three year period to have invested these amounts would have been 1995, 1996, and 1997 (1-indices 68, 69, and 70), resulting in 91942.91. Nice.

Test cases

1-indexed, first year of optimal period

[ 1, 2, 3 ]                          ->  68
[ 1 ]                                ->   6
* any array of length 90 *           ->   1
[ 1, 1 ]                             ->  27
[ 1, 2 ]                             ->   8
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]  ->  62
[ 1, 2, 3, 4, 5, 4, 3, 2, 1 ]        ->  64
* 1 repeated 20 times *              ->  53

Jelly, 9 bytes

PÐƤ⁹L¤ƤḋM

A dyadic link which yields a list of all the maximal starting 1-based indices.

Try it online!

(or ṡL}PÐƤ€ḋM)

How?

PÐƤ⁹L¤ƤḋM - Link: list of returns, list of nominal investments
      Ƥ   - for infixes of (the returns)...
          - ...of length:
     ¤    -               nilad followed by links as a nilad:
   ⁹      -                 chain's right argument (nominals)
    L     -                 length
          - ...do:
 ÐƤ       -        for post-fixes:
P         -          product
       ḋ  - dot-product (each) with (the nominals)
        M - maximal indices


Recursive Steiner Chains Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images:

In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain will be the base circles of another iteration of chains:

Challenge
Write a program/function that accepts image dimensions and a list of integers denoting the level of circles in each successive iteration of chains, and output an image with the recursive Steiner chains drawn to it.
Input
Your program/function will accept 2 arguments:

s - width and height of image
ls - list of positive integers denoting the number of circles present in each successive iteration of chains, ordered from the top-most chain to the bottom-most chain

Output
Your program/function will output an image of dimension s x s displaying the recusive Steiner chain.

The top level base circle will be as large as the image with a diameter of s, centered inside the image
To make things easy, the 2 base circles of a Steiner chain will be concentric, that is, the centerpoints of the 2 baseline circles will be the same
Given an outer radius, R, and the number of circles in a chain, N, the formula for the inner radius R' is R' = (R-R*sin(pi/N))/(sin(pi/N)+1)
Circles of the chain as well as the inner base circle will be the outer base circles of the next iteration of chains
While recursing through the chain circles, the order of the next chain should correspond to the next value in ls
While recursing through the inner circle of a chain, the order should be the same as its parents order (example [5,2]):

All chains should end recursion at a depth of the length of ls
The rotation of the chains doesn't matter:

However, the rotations of recursive chains relative to their parents centerpoint should be the same:

All circles should be drawn with an outline or solid fill
Color choice is left to the implementation, save for loopholes (for example, filling everything with the same color)

Example Runs
In the following examples, color is determined by (depth of the recursion)^4.
You can find source here.
chain(600,[5,4,3])

chain(600,[11,1,1,1,1,1,1])

chain(600,[5,6,7,8,9])

Javascript ES6, 379 bytes

This solution was used to generate the example runs in the question.

f=(s,ls)=>{with(V=document.createElement`canvas`)with(getContext`2d`)with(Math)return(width=height=s,translate(s/=2,s),(S=(o,d=0,n=ls[d],i=(o-o*sin(PI/n))/(sin(PI/n)+1),r=0)=>{fillStyle=`rgba(0,0,0,${pow(d/ls.length,4)})`;beginPath(),arc(0,0,o,-PI,PI),fill();if(d++<ls.length){S(i,d,n);for(;r<n;++r){save();translate(0,(o+i)/2);S((o-i)/2,d);restore();rotate((2*PI)/n);}}})(s),V)}

Ungolfed:

f=(s,ls)=>{                                        // define function that accepts image dimensions and a list of orders
 with(V=document.createElement`canvas`)            // create canvas to draw on, bring its functions into current scope chain
 with(getContext`2d`)                              // bring graphics functions into current scope chain
 with(Math)return(                                 // bring Math functions into current scope chain
  width=height=s,                                  // set width and height of image
  translate(s/=2,s),                               // center the transform on image
   (S=(o,d=0,                                      // define recursive function that accepts outer radius, depth, and optionally order
       n=ls[d],                                    // default chain order to corresponding order in input list
       i=(o-o*sin(PI/n))/(sin(PI/n)+1),            // calculate inner base circle radius
       r=0)=>{                                     // initialize for loop var
    fillStyle=`rgba(0,0,0,${pow(d/ls.length,4)})`; // fill based on depth
    beginPath(),arc(0,0,o,-PI,PI),fill();          // draw circle
    if(d++<ls.length){                             // if within recursion limit
     S(i,d,n);                                     //   recurse on inner circle
     for(;r<n;++r){                                //   loop through all circles of the chain
      save();                                      //   save transform
      translate(0,(o+i)/2);                        //   translate origin to middle of the 2 base circles
      S((o-i)/2,d);                                //   recurse on chain circle
      restore();                                   //   restore transform
      rotate((2*PI)/n);                            //   rotate transform to next circle in chain
   }}})(s),                                        // begin the recursion
 V)}                                               // return the canvas

Note: f returns a canvas.

Example run (assumes there's a <body> to append to):

document.body.appendChild(f(600,[13,7,11,5,3]))

Should dump the following image to the page:


How much snow did you get? My apologies for the wordiness. We had fun with it at work in our internal golfing, but it required a few emails for clarification, so I hope I captured most of that the first time.

PROBLEM

Given a “simulated” snowfall snapshot (as a string, stdin or parameter to your function/method), report on 4 values: minimum depth, maximum depth, average depth, and duration.

Here’s a formatted example to illustrate the input:

* * **
** * ***
** *  *
*
--------

The ‘*’ is a snowflake and the ‘-‘ is the ground. Imagine all of those “snowflakes” falling toward the ground. This is the final “snapshot”:

*
*
** * **
********
--------

You need to report on:

Minimum depth - count the shortest “pile” (1, in example above)
Maximum depth - count the tallest “pile” (4, in example above)
Average depth - average count of all “piles” (1.9, in example above - rounding to tenths)
Duration - (each “fall” = 1 second) - time from the first snapshot to the last snapshot (3 seconds, in example above)

Another example for reference:

     *
   *   *
      *
*
--------

Final snapshot:

*  * ***
--------

INPUT

The starting “snapshot” will have 8 “rows”, 8 “columns”, and be pipe-delimited (the pipes separate the rows). For example (excluding quotes):

“        |        |        |        |     *  |   *   *|      * |*       |--------”

OUTPUT

The 4 values pipe-delimited on a single line: 0|1|.6|3 or 0|5|1|1

Python, 153 characters

s=raw_input()
R=range(8)
C=[s[i::9].count('*')for i in R]
print"%d|%d|%.1f|%d"%(min(C),max(C),sum(C)/8.,max(8-s[i::9].find('*')-C[i]for i in R if C[i]))


Build a staircase for my kid The other day, my son asked me to build him a staircase using Lego-ish blocks. And I came up with something like this:

Then my kid asked me for a program using the least number of bytes that generated a similar staircase in a computer screen. I am not that good at code-golf, so I need your help. I need a program that:

Receives a positive integer with the number of levels the staircase needs to have.
Outputs a drawing of a staircase, with the pattern you see in the image.

The output will be in text format but the bricks can be distinguished one from another. For instance, you may use the '█' character as half a block and paint it in any color you want, or just choose any character of your choice.

Restrictions:

Blocks need to be of three different colors, which will be used as long as possible (if input is 1 or 2 there are not enough blocks to use all three colors). If you want, you may use the '░▒▓' characters, for instance, or just select three different characters.
No two blocks of the same color or pattern can be side to side in a single row.

My son does not really care about trailing spaces or new lines as long as a staircase is drawn.

Examples (sorry for the bad choice of characters):

Input: 1
Output:
██

Input: 2
Output:
██
 ▓▓

Input: 3
Output:
██
 ▓▓
██░░

Input: 5
Output:
██
 ██
██░░
 ██░░
██░░▓▓

Python 2, 55 bytes

i=2
exec"print(i%2*' '+`2%i*1122`*i)[:i];i+=1;"*input()

Try it online!

Cycles between blocks of 22, 44, except the top row is 00. For example, on input 10, prints

00
 22
2244
 2244
224422
 224422
22442244
 22442244
2244224422
 2244224422

Prints rows of increasing length i=2,3,.. by creating a space for odd lengths, repeating the pattern i times, and trunctating to length i. The pattern is 2244 for all rows except the first one i=2 for which it's 0. This is achieved with the arithmetic expression 2%i*1122.