Perfect scores in Martian rules football Story

Martians have been observing Aussie rules football matches from space with great curiosity. Having totally fallen in love with the game, they have been inspired to start their very own football league. However, being dim-witted creatures, they are unable to comprehend the scoring system.*

We know that in Aussie rules, a goal is worth 6 points (\$G=6\$) and a behind is worth 1 point (\$B=1\$). The Martians are cluey enough to work out that there are two types of scores, but not smart enough to realise that they can deduce the point values of these scores by analysing match outcomes. Undeterred, the International Olympus Mons Committee decrees that in all Martian rules football matches, the point values for goals and behinds (i.e. \$G\$ and \$B\$) will be chosen at random.

'Perfect' scores

When \$G = 6\$ and \$B = 1\$ (as in Aussie rules), there are exactly four integer pairs \$[g,b]\$ such that a team with \$g\$ goals and \$b\$ behinds has a score of \$gb\$ points. We will refer to \$[g,b]\$ pairs that satisfy $$gG+bB=gb$$ as perfect scores. The four perfect scores in Aussie rules are
\$[g,b]=[2,12]\$, \$[3,9]\$, \$[4,8]\$, and \$[7,7]\$.

Challenge

Given two strictly positive integers \$G\$ and \$B\$ representing the point values of goals and behinds in a Martian rules football match, write a program or function that determines all possible perfect scores for that match. Rules:

Input may be taken in any convenient format (pair of integers, list, string, etc.). You may not assume that \$G>B\$.
Output may also be in any format, provided that the \$[g,b]\$ pairs are unambiguously identifiable (e.g. successive elements in a list or string). The order of pairs does not matter. You may output pairs in \$[b,g]\$ order instead provided that you state this in your answer. You may not output the total scores (the products \$gb\$) instead, because in general there are multiple non-perfect ways to achieve the same total score.
Your program/function must terminate/return in finite time.

This is code-golf: the shortest submission (in bytes) in each language wins.

Test cases

Input -> Output

[6, 1] -> [[2, 12], [3, 9], [4, 8], [7, 7]]
[6, 2] -> [[3, 18], [4, 12], [5, 10], [6, 9], [8, 8], [14, 7]]
[1, 1] -> [[2, 2]]
[1, 6] -> [[7, 7], [8, 4], [9, 3], [12, 2]]
[7, 1] -> [[2, 14], [8, 8]]
[7, 5]  -> [[6, 42], [10, 14], [12, 12], [40, 8]]
[13, 8] -> [[9, 117], [10, 65], [12, 39], [16, 26], [21, 21], [34, 17], [60, 15], [112, 14]]

* This problem never, ever, occurs on Earth.

05AB1E, 10 bytes
>PLãʒ*OyPQ

Try it online or verify all test cases.
Explanation:

>           # Increase both values in the (implicit) input-pair by 1
 P          # And take the product of those
  L         # Pop and push a list in the range [1, (G+1)*(B+1)]
   ã        # Create all possible pairs by taking the cartesian product with itself
    ʒ       # Filter those pairs [g,b] by:
     *      #  Multiply it with the (implicit) input-pair at the same positions:
            #   [G,B] * [g,b] will result in [Gg,Bb]
      O     #  Sum those: Gg+Bb
       yP   #  Take the product of the current pair: gb
         Q  #  And check that both values are the same: Gg+Bb == gb
            # (after which the result is output implicitly)

The last test case no longer times out by using an upper bound of \$(G+1)\times(B+1)\$ instead of my initial \$(2^G+2^B)\$ (byte count remains the same). Make sure to upvote @SurculoseSputum's Python answer for providing this mathematical upper bound.


What is the shortest infinite loop statement in Java? I'm working on a golf for Java and I need an infinite loop. Obviously, I don't want to spend any more bytes than I have to, especially in such an expressive language.

Assuming I have some code I want to run, obviously the baseline is set at while(1>0)/*stmt*/ or 10 additional characters for a single line and while(1>0){/*stmt1*//*stmt2*/} or 12 additional characters for multiple lines. I say additional because the code I want to loop forever (well, forever-ish... I may or may not want to break out of or return from the loop) will have a certain length, and then I must tack on additional characters to make it actually loop.

At first I thought this was the best I'd get, but I figured I'd throw it out to the experts to see if they can find a better one.

for(;;){}

It works cause no condition evaluates to always true.
Insert the code between the braces.

If you only got a few statements you can place them inside the head (the (;;) part. That the loop still runs is caused by when the condition statement is not a boolean it counts as always true.
Thanx to @Ypnypn for the reminder


Proportion of self-avoiding walks on a square lattice The challenge

Given a positive integer N, compute the proportion of N-step walks on a plane that don't intersect themselves.

Each step can have any of the 4 possible directions North, East, South, West.

A walk intersects itself if it visits a previously visited point.

Examples

N=1: a single-step walk obviously doesn't intersect itself. So the result is 1.
N=2: given the first step in any direction, there are 3 possible directions that avoid intersection, and one that goes back to the origin, causing intersection. So the result is 3/4 = 0.75.
N=3: if the second step doesn't cause intersection, which happens 3/4 of the times, the third step will not cause intersection with probability again 3/4. So the result is (3/4)^2 = 0.5625.
N=4: things become more interesting because proper loops can be formed. A similar computation as above gives (3/4)^3 - 8/4^4 = 0.390625, where the second term accounts for the 8 proper loops out of the 4^4 possible paths (these are not excluded by the first term).

Additional rules

Output can be floating-point, fraction, or numerator and denominator.
If floating point, the result should be accurate up to at least the fourth decimal.
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

1  -> 1
2  -> 0.75
3  -> 0.5625
4  -> 0.390625
5  -> 0.27734375
6  -> 0.1904296875
7  -> 0.132568359375
8  -> 0.09027099609375
9  -> 0.0620574951171875
10 -> 0.042057037353515625
11 -> 0.02867984771728515625
12 -> 0.0193674564361572265625

Haskell, 153 149 144 140 126 118 92 bytes
Here we represent the 2d coordinates as a single integer: We start at 0, and the directions N,E,S,W correspond to adding +n,+1,-n,-1 where n is the input (we could also use any larger number). Using this we generate all possible paths, and then just check for duplicate numbers in those paths.
Thanks @H.PWiz for -26 bytes!

g n|a<-scanl(+)0<$>mapM(\_->[1,-1,n,-n])[1..n]=sum[1|x<-a,[b|b<-x,c<-x,b==c]==x]/sum[1|x<-a]

Try it online!
Explanation
--generate all possible paths
    a<-scanl(+)0<$>mapM(\_->[1,-1,n,-n])[1..n]
--count the non-self intersecting paths, compute the ratio to the total
g n|a<- ... =sum[1|x<-a,[b|b<-x,c<-x,b==c]==x]/sum[1|x<-a]


Is this quadrilateral cyclic? In mathematics, a cyclic quadrilateral is one whose vertices all lie on the same circle. In other words, every vertex is on the circumcircle of the other three. For more information, see the MathWorld article.
Examples
These quadrilaterals are cyclic:

This trapezoid is not cyclic.

(Images from Wikipedia)
Objective
Given the coordinates of four vertices in counterclockwise order which form a convex quadrilateral, determine if the quadrilateral is cyclic.
Coordinates will be integers (note, however, that the circumcenter coordinates and circumradius are not necessarily integers.) As implied by the previous paragraph, no three points will be co-linear and no two coincident.
I/O
You may take input using any reasonable format. In particular, [[x1,x2,x3,x4],[y1,y2,y3,y4]], [[x1,y1],[x2,y2],[x3,y3],[x4,y4]] and complex numbers are all fine.
Output using any different consistent values for true and false.
Test cases
True:
[0,0], [314,0], [314,1], [0,1]
[-5,5], [5,-5], [1337,42], [42,1337]
[104, -233], [109, -232], [112, -231], [123, -224]

False:
[0,0], [314,0], [314,100], [0,99]
[31,41],[59,26],[53,58],[0,314]

Wolfram Language (Mathematica), 23 bytes

#∈Circumsphere@{##2}&

Try it online!

Takes four inputs: the lists {x1,y1}, {x2,y2}, {x3,y3}, and {x4,y4}. Checks if the first point lies on the circumcircle of the other three. Also works for checking if \$n+1\$ points in \$\mathbb R^n\$ are concyclic, provided the last \$n\$ of them are affinely independent (because Circumsphere is sad if you give it a degenerate input).

Alternatively, here is a mathematical approach:

Wolfram Language (Mathematica), 29 28 25 24 bytes

Det@{#^2+#2^2,##,1^#}^0&

Try it online!

Takes two lists as input: {x1,x2,x3,x4} and {y1,y2,y3,y4}. Returns Indeterminate when the four points are on a common circle, and 1 otherwise.

From the four points \$(x_1, y_1), (x_2,y_2), (x_3, y_3), (x_4, y_4)\$, this solution constructs the matrix below:

\$\begin{bmatrix}x_1^2 + y_1^2 & x_2^2 + y_2^2 & x_3^2 + y_3^2 & x_4^2 + y_4^2 \\ x_1 & x_2 & x_3 & x_4 \\ y_1 & y_2 & y_3 & y_4 \\ 1 & 1 & 1 & 1 \end{bmatrix}\$

The determinant of this matrix is 0 if and only if the four rows are linearly dependent, and a linear dependency between the rows is the same thing as the equation of a circle that's satisfied at all four points.

The shortest way I could think of to check if the determinant is 0 is to raise it to the 0-th power: 0^0 is Indeterminate while anything else gives 1.


Manhattan Directions Code Golf This code golf challenge is to show directions through numbers.

When the user enters a number, then that means a direction change as follows:

0 means stay still
1 means forward (initially from left to right and initially start with `:`)
2 means turn right
3 means turn left
4 means go backward

I will show you an example: 122123333114

1 means 1 step forward

:═>

2 means 1 step to the right

   :═╗
     ‖
     V

2 means 1 step to the right

    :═╗
      ‖
    <═╝

1 means 1 step forward

    :═╗
      ‖
   <══╝

2 means 1 step to the right

   ^:═╗
   ‖  ‖
   ╚══╝

3 means 1 step to the left

 <═╗:═╗
   ‖  ‖
   ╚══╝

3 means 1 step to the left

 ╔═╗:═╗
 ‖ ‖  ‖
 V ╚══╝

3 means 1 step to the left

 ╔═╗:═╗
 ‖ ‖  ‖
 ╚═>══╝

3 means 1 step to the left

 ╔═^:═╗
 ‖ ‖  ‖
 ╚═╝══╝

1 means 1 step forward

   ^
 ╔═‖:═╗
 ‖ ‖  ‖
 ╚═╝══╝

1 means 1 step forward

   ^
   ‖
 ╔═‖:═╗
 ‖ ‖  ‖
 ╚═╝══╝

4 means 1 step backward

   ‖
 ╔═V:═╗
 ‖ ‖  ‖
 ╚═╝══╝

These are the rules:

Start with : and the initial direction will be from left to right

If starting with 0, then start with:

:

If starting with 1, then start with:

:=>

If starting with 2 then start with:

:╗
 ‖
 V

If starting with 3, then start with:

 ^
 ‖
:╝

If starting with 4, then start with:

<=:

Any other numbers or letters in the input will be ignored

T6@1 92J;{4 will mean 124

If two arrows came on top of each other, the new arrow should overwrite the old one

An example of this:

 ╔═╗:═╗
 ‖ ‖  ‖
 V ╚══╝

3 means 1 step to the left

 ╔═╗:═╗
 ‖ ‖  ‖
 ╚═>══╝

Arrow head should be > for left to right direction
Arrow head should be < for right to left direction
Arrow head should be V for top to bottom direction
Arrow head should be ^ for bottom to top direction

Do not forget the joint if you turn.

:╗
 ‖
 V

  :
<═╝

^
‖
╚:

╔═>
:

I hope I did not miss anything.
If you have any questions or if I missed anything, I will be editing this post.

Ruby, 302 306 322 327 bytes

+4 bytes to fix the edge case with the \$-i\$ direction (its angle is negative so we need to mod 4)
+16 bytes for even more edge case fixes in the stepping algorithm...
+5 bytes to fix the edge case where no inputs from 1-4 are present.

P=Math::PI/2
b=0i;f=d=p
c={b=>?:}
gsub(/[1-4]/){x=$&.to_i;d||=1
c[b+=d]="╗╝╚╔╗"[d.arg/P%4+x%2]if x[1]>0
d*=[0,1,1i,-1i,-1][x]
c[b+=d]="═║"[d.imag.abs]if x<4||!f
f=1}
c[b+=d]=">V<^"[d.arg/P]if d
q=c.keys.map &:rect
q=q.pop.zip *q
i,j=q[0].minmax
k,l=q[1].minmax
puts (k..l).map{|y|(i..j).map{|x|c[x+y*1i]||' '}*''}

Try it online!
Explanation
We initiate the grid as a hash table where the keys are complex numbers (real is the X-axis, imaginary is the Y-axis, lower numbers are closer to the top-left corner). This is convenient because we can initialize the direction variable as \$1\$, multiply by \$i\$ to turn right, and multiply by \$-i\$ to turn left. Also, we can quickly determine which way we're facing by dividing the direction's angle by \$\pi/2\$ and use that in our lookup tables.
Our algorithm, then, is roughly as follows:

Get the next number from the input in the range 1-4.
If the number is 2-3, step once and add the correct corner piece.
Look up the corresponding direction change and multiply.
Step once and add the correct straight piece. (Don't need to step if we turn around.)
Repeat until done.
Step and add the arrow piece.
Print the grid.

Code explanation (out of date, will fix later)
P=Math::PI/2                            # Save PI/2
b=0i;d=1                                # Set initial coordinates and direction
c={b=>?:}                               # Create grid with starting `:`
gsub(/[1-4]/){x=$&.to_i                 # For each number 1-4
c[b+=d]="╗╝╚╔╗"[d.arg/P+x%2]if x[1]>0   # If 2-3 (second bit is a 1), step and write the corner piece
                                        # If turning left (3), +1 to the index
d*=[0,1,1i,-1i,-1][x]                   # Multiply direction to turn accordingly
c[b+=d]="═‖"[d.imag.abs]                # Step and write the straight piece
}                                       # (end the loop)
c[b]=">V<^"[d.arg/P]                    # Write the corresponding arrow piece
q=c.keys.map &:rect                     # Get the filled-in grid spaces as X,Y coordinates
i,*_,j=q.map(&:first).sort              # Find the min and max X coordinate
k,*_,l=q.map(&:last).sort               # Find the min and max Y coordinate
puts (k..l).map{|y|                     # For each Y coordinate in range
      (i..j).map{|x|                    # For each X coordinate in range
                    c[x+y*1i]||' '      # Get the character, or space if not present
                }*''                    # Join characters on that Y coordinate and print
        }


How long is your (language) snake? Following on from the third order quine challenge, your task is to write an Ouroboros program that uses as many languages as possible.

That is, in language A, write a program pA which outputs program pB in language B. Program pB should output program pC in language C, and so on until eventually a program outputs the original program pA in language A.

No two languages in your loop can be the same or subsets or supersets of each other. None of the programs in the loop may be identical.

The longest chain of languages win. The length of the source code will be the tie-breaker.

Here is an example solution of length 3 given by Ventero.

s='print q<puts %%q{s=%r;print s%%s}>';print s%s

with Python generates this Perl snippet

print q<puts %q{s='print q<puts %%q{s=%r;print s%%s}>';print s%s}>

which generates the following Ruby code

puts %q{s='print q<puts %%q{s=%r;print s%%s}>';print s%s}

which then prints the original Python snippet:

s='print q<puts %%q{s=%r;print s%%s}>';print s%s


Tips for golfing in Factor What general tips do you have for golfing in Factor? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Factor (e.g. "remove comments" is not an answer).

math.unicode
this thing is a golfing jewel. http://docs.factorcode.org/content/vocab-math.unicode.html
Here, I should let it speak for itself.
Word    Stack effect    Equivalent   (Byte  Char) Savings (best case)
¬       ( obj -- ? )    not           1     2
²       ( m -- n )      2 ^ , 2^      1     2
³       ( m -- n )      3 ^           1     2
¹       ( m -- n )      1 ^           1     2
¼       ( -- value )    1/4 , 1 4 /   1     2
½       ( -- value )    1/2           1     2
¾       ( -- value )    3/4           1     2
×       ( x y -- z )    *             -1    0
÷       ( x y -- z )    /             -1    0
Π       ( seq -- n )    product       5     6
Σ       ( seq -- n )    sum           1     2
π       ( -- pi )       pi            0     0
φ       ( -- n )        phi           1     2
‰       ( m -- n )      1000 /        4     5
‱       ( m -- n )      10000 /       5     6
ⁿ       ( x y -- z )    ^             -1    0
⅓       ( -- value )    1/3           1     2
⅔       ( -- value )    2/3           1     2
⅕       ( -- value )    1/5           1     2
⅖       ( -- value )    2/5           1     2
⅗       ( -- value )    3/5           1     2
⅘       ( -- value )    4/5           1     2
⅙       ( -- value )    1/6           1     2
⅚       ( -- value )    5/6           1     2
⅛       ( -- value )    1/8           1     2
⅜       ( -- value )    3/8           1     2
⅝       ( -- value )    5/8           1     2
⅞       ( -- value )    7/8           1     2

Those are the simple constants. Now for the functions:
Word    Stack effect        Equivalent  (Byte  Char) Savings (best case)
∀       ( seq quot -- ? )   all?         1    3
∃       ( seq quot -- ? )   any?         1    3
∄       ( seq quot -- ? )   none?        2    4
∈       ( elt seq -- ? )    member?      4    6
∉       ( elt seq -- y )    ∈ ¬          3    2
∋       ( seq elt -- ? )    swap member? 9    11
∌       ( seq elt -- y )    ∋ ¬          3    2
−       ( x y -- z )        -            -1   0
∕       ( x y -- z )        /            -1   0
∖       ( s1 s2 -- set )    diff         1    3
√       ( x -- y )          sqrt         1    3
∛       ( x -- y )          ⅓ ^          2    2
∜       ( x -- y )          ¼ ^          2    2
∞       ( -- value )        1/0.         1    3
∧       ( o1 o2 -- ? )      and          0    2
∨       ( o1 o2 -- ? )      or           -1   1
∩       ( s1 s2 -- set )    intersect    6    8
∪       ( s1 s2 -- set )    union        2    4
≠       ( o1 o2 -- ? )      = ¬          1    2
≤       ( x y -- ? )        <=           -1   1
≥       ( x y -- ? )        >=           -1   1
⊂       ( s1 s2 -- ? )      subset?      4    6
⊃       ( s1 s2 -- ? )      superset?    6    8
⊄       ( s1 s2 -- ? )      ⊂ ¬          3    2
⊅       ( s1 s2 -- ? )      ⊃ ¬          3    2
⊼       ( o1 o2 -- ? )      ∧ ¬          3    2
⊽       ( o1 o2 -- ? )      or ¬         2    3
⌈       ( x -- y )          floor        2    4
⌊       ( x -- y )          ceiling      4    6

Yes, I did make that table by hand, and yes, I did the math in my head, so there might be some, er, wrong numbers. I'll go write a program to do it for me, now :P


Implement multiplication by a constant with addition and bit shifts While looking at the ARM instruction set, you notice that the ADD instruction has the so-called "Flexible second operand", which can be abused for quick multiplication. For example, the following instruction multiplies register r1 by 17 (shifting it left by 4 bits and adding to itself):

ADD r1, r1, r1, LSL #4
; LSL means "logical shift left"

The subtraction instruction has that feature too. So multiplication by 15 is also easy to implement:

RSB r1, r1, r1, LSL #4
; RSB means "reverse subtract", i.e. subtract r1 from (r1 << 4)

So this is an excellent optimization opportunity! Certainly, when you write in a C program x *= 15, the compiler will translate that to some inefficient code, while you could replace it by x = (x << 4) - x, and then the compiler will generate better code!

Quickly, you come up with the following cunning plan:

Write a program or a subroutine, in any language, that receives one parameter m, and outputs a C optimizing macro, like the following (for m = 15):

#define XYZZY15(x) (((x) << 4) - (x))

or (which is the same)

#define XYZZY15(x) (-(x) + ((x) << 4))

???
Profit!

Notes:

The macro's name is essential: magic requires it.
Parentheses around x and the whole expression are required: ancient C arcana cannot be taken lightly.
You can assume m is between 2 and 65535.
The input and output can be passed through function parameters, stdin/stdout or in any other customary way.
In C, addition and subtraction have tighter precedence than bit shift <<; use parentheses to clarify order of calculations. More parentheses than necessary is OK.
It is absolutely vital that the C expression be optimal, so e.g. x+x+x is not acceptable, because (x<<1)+x is better.
Expressions x + x and x << 1 are equivalent, because both require one ARM instruction to calculate. Also, (x << 1) + (x << 2) (multiplication by 6) requires two instructions, and cannot be improved.
You are amazed to discover that the compiler detects that (x << 0) is the same as x, so x + (x << 0) is an acceptable expression. However, there is no chance the compiler does any other optimizations on your expression.
Even though multiplication by 17 can be implemented in one instruction, multiplication by 17*17 cannot be implemented in two instructions, because there is no C expression to reflect that:

#define XYZZY289(x) x + (x << 4) + (x + (x << 4) << 4) // 3 operations; optimal

In other words, the compiler doesn't do common sub-expression elimination. Maybe you will fix that bug in version 2...

This is code-golf: the shortest code wins (but it must be correct, i.e. produce correct and optimal expressions for all m)

Please also give example outputs for m = 2, 10, 100, 14043 and 65535 (there is no requirement on the length of the expression - it can contain extra parentheses, whitespace and shift left by 0 bits, if that makes your code simpler).

Python - 414 393 331

This is my entry, which finds the least possible addition/subtraction operations, and subsequently evaluates to a C expression. Not sure it is optimal as multiplication of subexpressions may offer less operations.

import itertools as l
def w(N,s=''):
 for k,v in enumerate(min([t for t in l.product((1,0,-1),repeat=len(bin(N))-1)if sum([v*2**k for k,v in enumerate(t)])==N],key=lambda t:sum(abs(k)for k in t))):
  if v!=0:s+='{:+d}'.format(v)[0];s+='((x)<<{})'.format(k)if k>0 else'(x)'
 return '#define XYZZY{}(x) ({})'.format(N,s.lstrip('+'))

For the cases 2, 10, 100, 14043, 65535:

#define XYZZY2 (((x)<<1))
#define XYZZY10 (((x)<<1)+((x)<<3))
#define XYZZY100 (((x)<<2)+((x)<<5)+((x)<<6))
#define XYZZY14043 (-(x)-((x)<<2)-((x)<<5)-((x)<<8)-((x)<<11)+((x)<<14))
#define XYZZY65535(x) (-(x)+((x)<<16))

The final 65535 took around 11 minutes to compute. Suggestions for improvement (also speedwise) are welcome :-). Thanks to mbomb007 and plg for golfing improvements.


Find all times that follow a pattern Your job is write a program that prints all times (in the format HH:MM, 24 hours) that follow any of the following patterns:

Hours equal to minutes, e.g. 22:22,01:01
Hours equal to reverse minutes, e.g. 10:01, 01:10, 22:22
Sequences, that match H:MM, or HH:MM, always printed with HH:MM. E.g. 00:12, 01:23, 23:45, 03:45, etc (always a single step between digits)

Rules:

You may choose any language you like
You cannot print repeated times
One time per line, following the order of the day
The winner will be chosen in February 5.

PS: this is my first question, it might have some inconsistencies. Feel free to edit.

PS2: Here is the expected 44 solutions (already presented by Josh and primo, Thanks!)

00:00
00:12
01:01
01:10
01:23
02:02
02:20
02:34
03:03
03:30
03:45
04:04
04:40
04:56
05:05
05:50
06:06
07:07
08:08
09:09
10:01
10:10
11:11
12:12
12:21
12:34
13:13
13:31
14:14
14:41
15:15
15:51
16:16
17:17
18:18
19:19
20:02
20:20
21:12
21:21
22:22
23:23
23:32
23:45


Count the number of times a function runs This is a teaser a friend of mine sent. It seems straightforward, but I can't seem to get my head around it, probably due to my lack of sleep.

You have 16 bits available.
Compose a function, and find a way to know when the function has run approximately one million times.
You MAY NOT use any additional memory space other than the 16 bits given.
Recursion may be used for efficiency, but, again, you MAY NOT use
memory definition inside the recursion frames: only the 16 bits.

One-million in binary is equal to 11110100001001000000 (20 bits).  Thus, we cannot implement a simple counter for this.

Instead, the max number we can represent with 16 bits is 1111111111111111 = 65,535.  Since the answer requires that we only need to approximate 1 million function runs, we could add one to the counter approximately once every 16 function runs, and know that the function has run about 1 million times when the counter reaches 1000000/16 = 62500.

Below is the pseudocode of a potential solution, assuming that counter is a positive integer stored in 16 bits.  Also, this assumes that calls such as random(1,16) do not count towards memory as long as they are not stored in a variable.  Last, the random(x,y) function should give a random integer between x and y inclusive.

counter = 0;

function amIAttaBoutaMillionYet(){
    if(random(1,16)==16 && counter<62501){
        counter++;
    }
    if(counter==62500){
        return true;
    }
    return false;
}

UPDATE

Fixed function so that it won't show true after about 2 million+, 3 million+, etc.   function runs.  (thanks trinithis!)


Seamless conversion from square to hexagon For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons.
However, I've gotten lazy in my old age. It should be easy to automate the process with a small script.
However, I've gotten lazy in my old age. So I'm outsourcing it to you, and disguising it as a code golf challenge1.

Input
Input is a square image in any common image format capable of 24-bit RGB color. You may also take a filename as input instead of the image data itself.
You may assume the image is square, and that the side length is a multiple of four.
Output
Output is the input tile, but converted to a hexagon (the image itself will be square, with transparent areas). You may save it to a file or display to the screen.
Again, any common image format will do. If the format you're using supports transparency, background areas must be transparent. If it doesn't, you may use color #FF00FF (that horrible fuchsia one) as a stand-in.
Method
So how do we do it? The method I use2 squashes the image a bit vertically, but overall it looks pretty good for most things. We'll do an example with this input image:

Scale: Scale the image to a 3:2 ratio. Since our images will be squares, this means you simply scale them to 75% width and 50% height. Our example input is 200x200, so we end up with this 150x100 image:

Tile: Place down copies of your scaled image in a 2x2 grid:

Crop: Grab an appropriately sized hexagon from anywhere in this 2x2 grid. Now, for ease of tiling, this hexagon isn't exactly regular. After cropping a square of the original size (here 200x200), you then crop out the corners. The crop lines should run from (roughly) the center of each left/right side to one quarter from the edge on the top/bottom:

And that's your output!
Here's an example of what it might look like when tiled (zoomed out here):

This is code golf, so shortest code in bytes wins. Standard loopholes apply, etc and so on.

1 Feel free to believe this or not.
2 Method one from this helpful site.

Mathematica, 231 211 209 208 201 188 173 bytes

ImageCrop[ImageCollage@{#,#,#,#},e,Left]~SetAlphaChannel~ColorNegate@Graphics[RegularPolygon@6,ImageSize->1.05e,AspectRatio->1]&@ImageResize[#,{3,2}(e=ImageDimensions@#)/4]&

This is an unnamed function which takes an image object and returns an image object:

I don't think there's a lot to explain here, but some details which are of note:

Normally, to tile an image 2x2, you'd use ImageAssemble[{{#,#},{#,#}}], i.e. you hand ImageAssemble a 2x2 matrix with copies of the image. However, there's ImageCollage which is some sort of magic function which tries to arrange a bunch of pictures as "well" as possible (whatever that means... you can even give the individual images weights and stuff). Anyway, it you give it four images of equal size and with equal (or no) weights, it will also arrange them in a 2x2 grid. That allows me to save some bytes for the nesting of the matrix, as well as the function name.
The hexagon is rendered as a single polygon via Graphics. I'm using the built-in RegularPolygon@6, but enforce an aspect ratio of 1 to stretch it as necessary. Unfortunately, Graphics needs a couple of expensive options to avoid padding and such, and it also renders black on white instead of the opposite. The result is fixed with ColorNegate and then attached to the image's original channels with SetAlphaChannel.
Graphics puts a small amount of padding around the hexagon, but we want the alpha hexagon to cover the full size of the cutout. However, SetAlphaChannel can combine images of different sizes, by centring them on top of each other and cropping to the smallest size. That means, instead of manually setting PlotRangePadding->0, we can simply scale up the hexagon image a bit with ImageSize->1.05e (and we need the `ImageSize option anyway).


Reduced Factorization Leader Changes tl;dr: Output the values where the reduced prime factorization leader changes.

Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of multiplicity of the prime factors, ordered by the size of the factors. For instance, the reduced prime factorization of 1980 is [2, 2, 1, 1], because 1980 = 2 * 2 * 3 * 3 * 5 * 11.

Next, let's record how often each reduced prime factorization happens, over integers in [1, 2, ..., n]. For instance, in [1, 2, ..., 10], the following reduced prime factorizations occur:

[1]: 4 (2, 3, 5, 7)
[2]: 2 (4, 9)
[1, 1]: 2 (6, 10)
[]: 1 (1)
[3]: 1 (8)

We'll call the leader up to n the reduced prime factorization that occurs the most often over [1, 2, ..., n]. Therefore, the reduced prime factorization leader for n = 10 is [1]. Ties will be broken by the size of the largest integer less than or equal to n with that reduced prime factorization, with smaller largest integer being better. For instance, up to n = 60, the reduced prime factorizations [1] and [1, 1] occur 17 times each. The maximum integer in that range giving [1, 1] is 58, while the maximum integer giving [1] is 59. Therefore, with n = 60, the reduced prime factorization leader is [1, 1].

I'm interested in the values of n where the reduced prime factorization leader changes. Those are the values of n where the reduced prime factorization leader is different from the reduced prime factorization leader up to n-1. As an edge case, we will say that the leadership changes at n = 1, because a leader does not exist for n = 0.

Your challenge is to output.

An initial sequence of the desired output is:

1, 3, 58, 61, 65, 73, 77, 1279789, 1280057, 1280066, 1280073, 1280437, 1280441, 1281155, 1281161, 1281165, 1281179, 1281190, 1281243, 1281247, 1281262, 1281271, 1281313, 1281365

Allowed output styles are:

Infinite output.
The first k leader changes, where k is the input.
The kth leader change, where k is the input.

k may be zero or one indexed.

This is code-golf. If you're not sure about anything, ask in the comments. Good luck!

Husk, 18 bytes

m←ġ(←►Lk=mȯmLgpṫ)N

Try it online!
This prints the infinite list.
The link truncates the result to the first 7 values, since the program is quite inefficient and times out after that on TIO.

The parentheses are ugly, but I don't know how to get rid of them.

Explanation

m←ġ(←►Lk=mȯmLgpṫ)N  No input.
                 N  The list of natural numbers [1,2,3,4,..
  ġ(            )   Group into slices according to this function.
                    Each slice corresponds to a run of numbers with equal return values.
    ←►Lk=mȯmLgpṫ    Function: from n, compute the reduced factorization leader in [1..n].
                     As an example, take n = 12.
               ṫ     Reversed range: [12,11,10,9,8,7,6,5,4,3,2,1]
         m           Map over this range:
              p       Prime factorization: [[2,2,3],[11],[2,5],[3,3],[2,2,2],[7],[2,3],[5],[2,2],[3],[2],[]]
             g        Group equal elements: [[[2,2],[3]],[[11]],[[2],[5]],[[3,3]],[[2,2,2]],[[7]],[[2],[3]],[[5]],[[2,2]],[[3]],[[2]],[]]
          ȯmL         Take length of each run: [[2,1],[1],[1,1],[2],[3],[1],[1,1],[1],[2],[1],[1],[]]
       k=            Classify by equality: [[[2,1]],[[1],[1],[1],[1],[1]],[[1,1],[1,1]],[[2],[2]],[[3]],[[]]]
                     The classes are ordered by first occurrence.
     ►L              Take the class of maximal length: [[1],[1],[1],[1],[1]]
                     In case of a tie, ► prefers elements that occur later.
    ←                Take first element, which is the reduced factorization leader: [1]
                    The result of this grouping is [[1,2],[3,4,..,57],[58,59,60],[61,62,63,64],..
m←                  Get the first element of each group: [1,3,58,61,65,73,77,..


Seconds to human readable format Given a positive integer input n seconds, output the time in human readable format.
The time will be considered from 00:00:00, 1st January, 1 A.D.
Leap years must be taken into account.
Assume that the gregorian calendar was followed since the beginning.
(Gregorian Calendar: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 were not leap years, but the years 1600 and 2000 were)
Output must be a string of the format:
x Millennia/Millennium, x Centuries/Century, x Decades/Decade, x Years/Year, x Months/Month, x Days/Day, x Hours/Hour, x Minutes/Minute and x Seconds/Second

The 0 values must not be shown.
Program must handle at least up to 999 Millennia(inclusive).
Plural/Singular must be kept in mind.
(For millennium, both millennia and millenniums are valid)
,,and and spaces must also be kept in mind.
Case may be anything.
Examples:
1:1 second
2:2 seconds
60:1 minute
62:1 minute and 2 seconds
3600:1 hour
3661:1 hour, 1 minute and 1 second
31536001:1 year and 1 second
317310301:1 decade, 20 days, 13 hours, 45 minutes and 1 second
3499454714:1 century, 1 decade, 10 months, 22 days, 22 hours, 45 minutes and 14 seconds
73019321114:2 millennia, 3 centuries, 1 decade, 3 years, 10 months, 22 days, 45 minutes and 14 seconds

Reference: date-difference to duration converter
This is code-golf so shortest code wins

Perl 6, 273 245 233 230 bytes

-28 bytes thanks to nwellnhof!

{S/rys/ries/}o{S:th(*)/\,/ and/}o{join ', ',map {$_~'s'x(.[0]>1)},grep *[0],(|[R,](.[0].polymod(10 xx 3)),|.skip Z <millennium century decade year month day hour minute second>)}o{~DateTime.new($_-62135596800)~~m:g/\d+/Z-(^6 X<3)}

Try it online!

I think there might be a trick or two I can use with EVAL to make this shorter. This solution takes into account leap seconds, so the last test case is a bit off. Both no longer applicable.

(Old) Explanation:

{                                      } # First code block
 DateTime.new($_-62135596800)  # Initialise a date time object with input amount of seconds
{  ...  }o    # Pass value to the next code block
 fmt(.year-1: "%04d").comb Z   # Zip each digit of the year with
                             <millennium century decade year>  # The appropriate word
 <month day hour minute second>.map:{  ...  }   # For each of these words
                                ".$^a".EVAL     # EVAL the method on the DateTime
                                           -(2>$++)     # -1 if month or day
                                                   ,$a  # Followed by the word itself
  grep +*[0],  # From these, filter out the ones with value 0
  map {$_~'s'x(.[0]>1)},    # Add plurals if greater than 1
  join ', ',                # Join with commas
 {  ...  }o         # Pass string to next code block
  S:th(*)           # Substitute the last instance of
         /\,/       # A comma
            / and/  # With ' and'
 {  ...  }o         # Pass to next code block
  S/rys/ries/       # Fix plural of century


Gif - Jif, Jif - Gif Stolen from @Downgoat with permission

The point of this challenge is to (not) settle the  debate on the pronunciation of "gif".

"

The pronunciation of gif is debated and while it's supposed to be (and should be) pronounced jif, it's still commonly disputed.

In this challenge you will be given a set of words that have a g or j, representing the sound that the word is pronounced with. You'll also get some text in which you have to fix the incorrect spellings of gif.

Because this is the internet and everyone always wrong. It's (not) common courtesy to correct them.

An example of a wrong pronunciation would be:

There was a gif of a mouse eating a burrito

The wrong spelling of gif? Unacceptable! This must be corrected immediately:

There was a jif (as in jar) of a mouse eating a burrito

Are we done? Nope, you're still wrong.

You're always wrong

This must work the other way:

In the jif the cat wore a hat of a cat

This obvious misspelling must be fixed, we shall correct this to:

In the gif (as in graphic) the cat wore a hat of a cat

Rules

Input is a string (the sentence) and an array of strings (or any reasonable alternative, such as a comma separated string) in any order
You may take the g and j words in any order. They may be taken separately.
Every instance of gif (any case) in the sentence must be replaced with jif (as in ___) where ___ is a uniformly random selected word beginning with j  from the array of strings, and vice versa for jif with words beginning with g.
ONLY the words gif and jif should be replaced (i.e "jiffy" should not be changed). Those words have done no wrong.
You are guaranteed that at least one word in the array begins with g and at least one begins with j.
Case must be preserved (e.g. GiF -> JiF).
You may write a program or a function
Standard loopholes apply
We need to (not) settle the debate quickly; shortest code in bytes wins

Examples

Input and output separated by a single line:

graphic, jar, jam, gram
I saw a jif of how to pronounce gif that showed gif is pronounced jif

I saw a gif (as in graphic) of how to pronounce jif (as in jar) that showed jif (as in jam) is pronounced gif (as in gram)

gravy, jeff
G is for gIf, h is for JiF, i is for gIF, j is for JIf

G is for jIf (as in jeff), h is for GiF (as in gravy), i is for jIF (as in jeff), j is for JIf (as in gravy)

joke, june, gorilla, great
Jiffy should not be treated as a GIF or JIF, like gifted.

Jiffy should not be treated as a JIF (as in june) or GIF (as in great), like gifted.

Mathematica, 164 165 bytes

This is an abomination, but I want someone to share my pain.

StringReplace[f[f@"g"="j"]="g";f[f@"G"="J"]="G";z=IgnoreCase->1>0;#,x:"g"|"j"~~y:"if ":>{f@x,y,"(as in ",RandomChoice@StringCases[#2,f@x~~Except[","]..,z]}<>") ",z]&

Function which expects the first argument # to be the sentence to be (in)corrected and the second argument #2 to a be comma separated string of words.

f[f@"g"="j"]="g";f[f@"G"="J"]="G" defines a function f which takes the letters g, G, j, and J to their appropriate replacements. This is ever so slightly shorter than f@"g"="j";f@"j"="g";f@"G"="J";f@"J"="G".

I also set z equal to IgnoreCase->True since I'll be using it twice.

x:"g"|"j"~~y:"if " is a StringExpression which matches "gif " or "jif ", naming the first letter x and the last three characters y. Since the option z (also known as IgnoreCase->True) is passed to StringReplace, these letters can be in any combination of upper and lower case.

I then replace every such match with

{f@x,y,"(as in ",RandomChoice@StringCases[#2,f@x~~Except[","]..,z]}<>") "

RandomChoice@StringCases[#2,f@x~~Except[","]..,z] randomly selects a word out of the second argument #2 which begins with f[x], again ignoring case because the option z is given.


Abbreviate list of names until they fit Given a list (array) of names, your challenge is to join the items using some glue and abbreviate the longest items first until the joined string fits a maximum length. And output that string. Since the glue is part of the final string, the length of the glue is included too

Abbreviation is done using the … character

Examples

For example when | is the glue and 20 is the maximum length

giraffe would become giraffe (length = 7)
giraffe, Spiny lumpsucker would become giraffe|Spiny lumps… (length = 20)
giraffe, Spiny lumpsucker, rhinoceros would become giraf…|Spiny…|rhino… (length = 20)
giraffe, Spiny lumpsucker, rhinoceros, Hellbender would become any of these:

gira…|Spi…|rhi…|Hel…
gir…|Spin…|rhi…|Hel…
gir…|Spi…|rhin…|Hel…
gir…|Spi…|rhi…|Hell… (all length = 20)

Rules

The list, glue and maximum length are input parameters of the program.

When abbreviation is needed, abbreviation must be done on any of the longest items first. When the longest items are equally long, it doesn't matter which you abbreviate.

The output length is smaller than the maximum length when no abbreviation was necessary. When abbreviation needs to occur, the length of the output is exactly equal to the maximum length.

The order of the (abbreviated) items must match the order of the items in the input

You can't assume that the abbreviation character … and the glue won't occur as characters in the items in the list.

Update

I'm afraid that I overlooked the fact that the length of the glue concatenated with many items by itself may result into a string that is longer than the allowed maximum length. Without considering this, your program may run into an infinite loop. I prefer your program to throw an error in this case. I hope that's not too much of an inconvenience for the ones who already wrote an answer or that are busy writing one. To throw an error is NOT a requirement to win, but I would appreciate if you add a variant that does.

The winner

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

Jelly, 25 bytes

ṖṖ;⁽÷ẓỌµ€µL€MḢµ¦µj⁴L>⁵ð¿j

Try it online!

This unfortunately does not contain the error-if-invalid feature.

Explanation

This is what I call the Jelly syndrome: the easy part is explaining the algorithm, the hard part is explaining how you found the exact order to put the code in to make it execute correctly.

ṖṖ;⁽÷ẓỌµ€µL€MḢµ¦µj⁴L>⁵ð¿j
                       ¿     While
                 j           joining the input list
                  ⁴          with the glue produces a string
                   L         whose length
                    >        is larger than
                     ⁵       the maximum,
               ¦             in the input array at the
             Ḣ               first of the positions that
            M                have maximal
          L€                 length,
ṖṖ                           remove the last two characters,
  ;                          append
   ⁽÷ẓ                       the number 8230
      Ọ                      and cast it to a character.
                        j    Finally, join again with the glue.


Make a (software) modem! Objective

Design a modulator/demodulator pair to accurately transmit data as quickly as possible over simulated plain old telephone service (POTS).

Steps

Generate some random (/dev/random or the like) data that will take 3-4 seconds to transmit
Modulate the data with your modulator to produce an audio file
Pass the audio file through the POTS simulator. If you don't have Python/Scipy you can upload a file with the form, or do a JSON API request.
Demodulate the audio file back to binary data
Validate that the input and output are equal-ish* (limit 1 out of every 1000 bits can be corrupted)
Score is number of bits transmitted divided by the length of the audio file (bits/second)

Rules

Input file must be 3-4 seconds, 44.1 kHz, mono.
Run the simulator with an SNR of 30 dB (it's default)
The demodulator must reconstruct the transmitted data with a bit error rate of no more than 10-3 (1 per thousand bits).
No digital compression is allowed (i.e. zipping the data. It's outside the scope of the challenge.)
No attempting to shove data into frequencies above 4 kHz. (My filters aren't perfect, but they're reasonably POTS-like with a relatively small number of taps.)
If your modem protocol requires a short preamble (no more than 1 second) to synchronize/calibrate the receiver, it isn't penalized.
If possible, please host the audio file somewhere accessible so we can listen to a cacophony of beeps and boops.

Example

Here's an example notebook that demonstrates the modulation/demodulation with simple "on-off keying" (audio samples included!).

It would score 100 (bits/second). Note that it's transmitting with a much worse 5 dB SNR.

MATLAB, 1960 bps

Here is my updated attempt:

fs = 44100; %44.1kHz audio rate
fc = 2450;  %2.45kHz carrier - nice fraction of fs!
fsym = fc/5; %symbol rate

tmax = 4; %about 4 seconds worth

preamblesyms = 6;

t = 1/fs:1/fs:(tmax+preamblesyms/fsym);

symbols = preamblesyms+fsym*tmax;
symbollength = length(t)/symbols;
bits = symbols*3;
bitstream = [zeros(1,preamblesyms*3),rand(1,bits-preamblesyms*3)>0.5]; %Add a little preamble of 18 bits
data = bin2dec(char(reshape(bitstream,3,symbols)'+'0'))';

greycode = [0 1 3 2 6 7 5 4];

%Encode the symbols using QAM8 - we use effectively grey code so that
%adjacent symbols in the constellation have only one bit difference
%(minimises error rate)
encoded = zeros(2,symbols);
encoded(1,data==1) = 1/sqrt(2);
encoded(1,data==3) = 1;
encoded(1,data==2) = 1/sqrt(2);
encoded(1,data==7) = -1/sqrt(2);
encoded(1,data==5) = -1;
encoded(1,data==4) = -1/sqrt(2);
encoded(2,data==0) = 1;
encoded(2,data==1) = 1/sqrt(2);
encoded(2,data==2) = -1/sqrt(2);
encoded(2,data==6) = -1;
encoded(2,data==7) = -1/sqrt(2);
encoded(2,data==4) = 1/sqrt(2);

%Modulate onto carrier
carrier = [sin(2*pi*fc*t);cos(2*pi*fc*t)];
signal = reshape(repmat(encoded(1,:)',1,symbollength)',1,[]);
signal(2,:) = reshape(repmat(encoded(2,:)',1,symbollength)',1,[]);
modulated = sum(signal.*carrier)';

%Write out an audio file
audiowrite('audio.wav',modulated,fs);

%Wait for the user to run through the POTS simulator
input('');

%Read in the filtered data
filtered=audioread('audio.pots-filtered.wav')';

%Recover the two carrier signals
preamblecos = filtered(symbollength+1:symbollength*2);
preamblesin = filtered(symbollength+1+round(symbollength*3/4):symbollength*2+round(symbollength*3/4));

%Replicated the recovered carriers for all symbols
carrierfiltered = [repmat(preamblesin,1,symbols);repmat(preamblecos,1,symbols)];

%Generate a demodulation filter (pass up to 0.66*fc, stop at 1.33*fc
%(really we just need to kill everything around 2*fc where the alias ends up)
d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.05,0.1,0.5,60);
Hd = design(d,'equiripple');

%Demodulate the incoming stream
demodulated = carrierfiltered .* [filtered;filtered];
demodulated(1,:)=filtfilt(Hd.Numerator,1,demodulated(1,:));
demodulated(2,:)=filtfilt(Hd.Numerator,1,demodulated(2,:));

%Split signal up into bit periods
recovereddemodulated=[];
recovereddemodulated(1,:,:) = reshape(demodulated(1,:),symbollength,symbols);
recovereddemodulated(2,:,:) = reshape(demodulated(2,:),symbollength,symbols);

%Extract the average level for each bit period. Only look at the second
%half to account for slow rise times in the signal due to filtering
recoveredsignal=mean(recovereddemodulated(1,round(symbollength/2):symbollength,:));
recoveredsignal(2,:)=mean(recovereddemodulated(2,round(symbollength/2):symbollength,:));

%Convert the recovered signal into a complex number.
recoveredsignal=recoveredsignal(2,:) + 1j*recoveredsignal(1,:);

%Determine the magnitude and angle of the symbol. The phase is normalised
%to pi/4 as that is the angle between the symbols. Rounding this to the
%nearest integer will tell us which of the 8 phases it is closest to
recoveredphase = round(angle(recoveredsignal)/(pi/4));
recoveredphase = mod(recoveredphase+8,8)+1; %Remap to an index in the grey code vector.

%Determine the symbol in the QAM8 constellation
recoveredencoded=greycode(recoveredphase);
recoveredencoded(1:preamblesyms)=0; %Assume the preamble is correct for comparison

%Turn it back in to a bit stream
bitstreamRecovered = reshape(dec2bin(recoveredencoded)'-'0',1,[]);

%And check if they are all correct...
if(all(bitstream==bitstreamRecovered))
    disp(['Woop, ' num2str(fsym*4) 'bps']);
else
    error('Its corrupt Jim.');
end

Since my first attempt, I have played around a bit. There is now a small preamble at the beginning (18 bit periods, but could be shorter) which contains just a cosine wave. I extract this and replicated it to create correctly phased sine and cosine carriers for demodulation - as it is a very short preamble, I haven't counted it in the bit rate as per your instructions.

Also since the first attempt I am now using a QAM8 constellation to achieve 3 bits per symbol instead of 2. This effectively doubles the transfer rate. So with a ~2.4kHz carrier I am now achieving 1960bps.

I've also improved the symbol detection so that the averaging doesn't get affected by slow rise times caused by the filtering - basically only the second half of each bit period is averaged to remove the impact of rise times.

Still nowhere near the 40kbps theoretical channel bandwidth from the Shannon-Hartley theory (assuming the 30dB SNR)

Just for those that like horrible sounds, this is the new entry:

And in case anyone is interested, this is the previous 960bps entry


Build a script to generate the Deep Note The THX deep note is one of the most recognizable sounds in audio/video production technology. According to its creator, it took about 20,000 lines of C code to generate the final result. We can do better than that.

Your task is to write a script in any language that will generate a sound (to a file or directly to hardware) that fits the trademark description of the THX sound, as provided by the US Patent and Trademark office:

  The THX logo theme consists of 30 voices over seven measures, starting in a narrow range, 200 to 400 Hz, and slowly diverting to preselected pitches encompassing three octaves. The 30 voices begin at pitches between 200 Hz and 400 Hz and arrive at pre-selected pitches spanning three octaves by the fourth measure. The highest pitch is slightly detuned while there are double the number of voices of the lowest two pitches.

Note that the "preselected pitches" must be roughly the same as the pitches in the actual THX deep note, which are in the key of E flat.

The shortest code to do so in any language wins.

C, 323 bytes

#include<math.h>
#define A y=-2*y*y*y+3*y*y
main(i,j,o,e){e=44100;write(1,"RIFF´9WAVEfmt      D¬  ±    data9",44);float r[30],x,y,k,v;for(i=0;i++<30;r[i]=.5-(9*i%7)/7.);for(i=0;i++<9*e;){x=2.*M_PI*i/(0.+e),k=y=1-i/(8.*e),v=0,A,A,A,y=y>1?1:y;for(j=0;j++<30;o=j%6,v+=(7-o)*.1*sin(x*(20<<o)*(1+y*r[j])));write(1,&v,4);}}

(among others, NUL characters could't be pasted in the textbox; you can view or download the original file here)

Usage:

gcc deep-note.c -o deep-note
./deep-note > deep-note.wav

Click here to listen to a preview of the generated sound!


What's my name? Produce the name of the language indirectly Produce only the name of a programming language using only the facilities of the language itself. The name of the language can only be invoked indirectly, i.e., from non custom environment variables, built-in functions or methods or the interpreter/compiler of the language. Output should be the name of the language only.

One example would be:

$ awk --v | awk 'NR<2 { print $2}'  # GNU Awk 3.1.8
Awk

The answer I select will be the one with the most up votes. In case of a tie, the shortest golfed version (separate or the only given answer), will be the tie breaker.


Tetris! Final heights (Day 3) Challenge Taken from my university code challenge contest

This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here.

Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a board, so that they fit in the most compact way possible.

In this problem we will assume a sequence of pieces that fall, each in a certain position and with a certain orientation that can not be changed. The pieces are piled up as they fall and the complete rows are not eliminated (as in the original game). The objective is to determine the final height of each column of the board after all the pieces fall.

There are a total of 7 different pieces, shown in the figure:

Challenge

Given a list of pieces, output the height of all the columns from the board after all pieces falls

A piece consists of three numbers: I, R and P. The first number, I, is the identifier of the piece (a number between 1 and 7, in the same order as in the figure). The second number, R, is the rotation of the piece. It can take the values 0, 90, 180 or 270 and represents the angle of rotation of the piece in the anti-clockwise direction. The third number, P, indicates the position of the piece. Represents the column on the left occupied by the piece (this can be 1 or 0 Index. Please specify).

Example and Test case (1 Index)

Given [[1, 0, 1], [4, 0, 1], [5, 90, 4]]

Output [3, 3, 1, 3, 2]

Given [[6, 270, 4], [1, 180, 5], [1, 90, 6], [7, 0, 4]]

Output [0, 0, 0, 9, 9, 8, 3, 3]

Given [[3,0,1],[3,180,3]] Output [1,1,4,4,4]
Given [[2,180,1],[2,0,3]] Output [2,2,4,3,3]

Notes

This is code-golf
Row/Column can be 1 or 0 Index. Please specify.
You can redefine input values (maybe you want to call piece 1 as A, etc..). In that case please specify

Questions

Can we use any 4 distinct values instead of an angle in degrees?: Yes
Are we supposed to handle "holes" if a piece doesn't exactly fit over the previous ones?: Yes
Is the height or the width of the board bounded? No. Neither the width nor the height are bounded

Thanks @Arnauld for the images and the test cases *.*

JavaScript (Node.js),  286 284 270  266 bytes
Pieces and positions are 0-indexed. Angles are in \$[0..3]\$.

a=>a.map(([p,r,x])=>(g=y=>y>3?g(+!Y--):b[Y+y]&(m[y]=('0x'+`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`[(p*2+r*56+y*99+13)%113])<<x)?m.map(v=>(g=x=>v&&g(x+1,H[x]=v&1?Y:~~H[x],v>>=1))(0,b[++Y]|=v)):g(y+1))(Y=a.length*4),m=[b=[-1]],H=[])&&H

Try it online!
or try an enhanced version that also displays the final board.
Shape encoding
All pieces are stored as exactly 4 nibbles (4x4 bits) with the rows sorted in reverse order and the leftmost pixel mapped to the least significant bit. In other words, the binary representation of the shape is mirrored both vertically and horizontally.
Example:

Hash function and lookup table
Given a piece \$p \in [0..6]\$, a rotation \$r \in [0..3]\$ and a row \$y \in [0..3]\$, we use the following hash function to get the index \$n\$ of the corresponding bitmask from a lookup table:
$$n=(2p+56r+99y+13)\bmod 113$$
Only the first \$82\$ entries are explicitly stored. Everything else is set to \$0\$.
These entries are packed as:
`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`

which expands to the following 82 nibbles:
"717433667233ff47173333276611000000000000113213001112221112123333333311133233221211"

Using hexadecimal in the final format is only required for the two horizontal representations of the \$I\$ piece, hence the "ff" in the above string.
The parameters of the hash function were brute-forced in a way that optimizes leading and trailing zeros. The fact that the string can be compressed some more by using 1e12 for the zeros in the middle and a conversion from base-16 to base-4 for the right part is just a welcome but unexpected side effect. :-)
Here is a demonstration of the unpacking process for all pieces and all rotations.
Commented
a => a.map(([p, r, x]) => (     // for each piece p with rotation r and position x:
  g = y =>                      //   g = recursive function taking y
    y > 3 ?                     //   if y is greater than 3:
      g(+!Y--)                  //     reset y to 0, decrement Y and try again
    :                           //   else:
      b[Y + y] & (              //     test if we have a collision of the board with
        m[y] =                  //     the y-th row m[y] of the current piece
          ('0x' + `717...`[     //     which is extracted from a lookup table
            (p * 2 + r * 56 +   //     using the hash function described in the
             y * 99 + 13) % 113 //     previous paragraph
          ]) << x               //     and shifted to the left according to x
      ) ?                       //     if we have a collision:
        m.map(v => (            //       we iterate again on the piece rows stored in m[]
          g = x =>              //         g = recursive function taking x
            v &&                //         if v is not equal to 0:
            g(                  //           do a recursive call:
              x + 1,            //             increment x
              H[x] =            //             update the height at x:
                v & 1 ?         //               if this bit is set:
                  Y             //                 set it to Y
                :               //               else:
                  ~~H[x],       //                 leave it unchanged or force it to 0
                                //                 if it was still undefined
              v >>= 1           //             shift v to the right
            )                   //           end of recursive call
          )(0,                  //         initial call to g with x = 0
               b[++Y] |= v)     //         increment Y and copy the piece row to the board
        )                       //     end of map()
      :                         //   else (no collision):
        g(y + 1)                //     do a recursive call to test the next row
  )(Y = a.length * 4),          //   initial call to g with y = Y = 4 * the number of pieces
                                //   (assuming the worst case: piled vertical I pieces)
  m = [b = [-1]], H = []        //   initialize m[], b[] and H[]
                                //   we set a full line at the bottom of b[]
) && H                          // end of map(); return H[]


Recreate the Stack Overflow logo In response to here.
Unlike the previous one, this focuses on code-golf and a new logo, no longer consisting of 6 sticks and the graying-effect as the position of the sticks go deeper.

Make the Stack Overflow logo using the following criteria:

The tray:

Make a gray tray shaped like a bracket facing upwards using the following RGB values: 188, 187, 187 (#bcbbbb)
The dimensions of the tray by pixels:

The sticks:

Make 5 orange sticks using the following RGB values: 244, 128, 36 (#f48024)
Each stick has a dimension of 44 by 9 pixels.
The gap between the tray and the bottom stick is 8 pixels:

The sticks' angles:
These angles are relative to the horizontal position which is zero degrees.

1st stick (bottom): 0°
2nd stick (second-to-bottom): 10°
3rd stick (middle): 25°
4th stick (second-to-top): 40°
5th stick (top): 50°

The entire image:

The image should look like the image given.
The entire dimensions of the whole image is 82 by 97 pixels.

Stick positions (x, y):
These coordinates refer to the top-left points of each stick. The system used is the top-left point of the entire surface being (0, 0), and the numbers increasing as we go down and to the right. We also assume that the left part of the tray is at the leftmost possible point, i.e. at the far bottom left. Feel free to transcribe this into your system.

1st stick: 17, 71
2nd stick: 19, 51
3rd stick: 27, 31
4th stick: 40, 13
5th stick: 55, 0

Rules:

The image should apply all descriptions from above.
Standard loopholes are forbidden.
Shortest code in bytes wins.

HTML+CSS, 550 bytes

div {position: absolute;}
.z1 {background:#bcbbbb;top:80px;width:78px;height:34px;}
.z2 {background:#ffffff;left:9px;width:60px;height:25px;}
.s {background: #f48024;top:-15px;width:44px;height:9px;}
.a {top:8px;left:8px;}
.b {transform:rotate(10deg) translate(1px,1px);}
.c {transform:rotate(15deg) translate(2px,-1px);}
.d {transform:rotate(15deg) translate(2px,-1px);}
.e {transform:rotate(10deg) translate(1px,1px);}


Number that can eat itself Given a positive integer, output a truthy/falsy value as to whether the number can eat itself.

Rules

Leftmost is the head, rightmost is the tail

If the head is greater than or equal to the tail, the head eats the tail and the new head becomes their sum.

If \$sum \ge 10 \$ then the head is replaced by \$sum \mod 10\$.

\$sum=0\$ cannot be ignored, however the input number will never have any leading zeroes.

Example:

number=2632
head-2, tail-2

2632 -> 463
head-4, tail-3

463 -> 76
head-7, tail-6

76 -> 3
If only one digit remains in the end, the number can eat itself.

If at any point the head cannot eat the tail, the answer will be False.

number=6724
072
False (0<2)

Test Cases:

True:
[2632, 92258, 60282, 38410,3210, 2302, 2742, 8628, 6793, 1, 2, 10, 100, 55, 121]

False:
[6724, 47, 472, 60247, 33265, 79350, 83147, 93101, 57088, 69513, 62738, 54754, 23931, 7164, 5289, 3435, 3949, 8630, 5018, 6715, 340, 2194]

This is code-golf so shortest code wins.

JavaScript (ES6),  52 51  50 bytes
Saved 1 byte thanks to @tsh
Takes input as a string. Returns a Boolean value.

f=n=>n>[n%10]?f(-(-n[0]-n)%10+n.slice(1,-1)):!n[1]

Try it online!
Commented
f = n =>                 // f = recursive function taking n (a string)
  n > [n % 10]           // The last digit is isolated with n % 10 and turned into a
                         // singleton array, which is eventually coerced to a string
                         // when the comparison occurs.
                         // So we do a lexicographical comparison between n and its
                         // last digit (e.g. '231'>'1' and '202'>'2', but '213'<'3').
  ?                      // If the above result is true:
    f(                   //   do a recursive call:
      -(-n[0] - n) % 10  //     We compute (int(first_digit) + int(n)) mod 10. There's no
                         //     need to isolate the last digit since we do a mod 10 anyway.
      + n.slice(1, -1)   //     We add the middle part, as a string. It may be empty.
    )                    //   end of recursive call
  :                      // else:
    !n[1]                //   return true if n has only 1 digit, or false otherwise


Find the occurrences of a character in an input string Challenge

Write a program that, given a string x which is 10 characters long and a character y, outputs the number of times character y occurs in string x.

The shortest program in bytes to do so wins.

Example

Input: tttggloyoi, t
Output: 3

Input: onomatopoe, o
Output: 4

Pyth, 3 bytes

/ww

Example run:

$ pyth -c '/ww'
sdhkfhjkkj
k
3

Of course, the user could input more or less than 10 letters on the first input, but we don't need to worry about what happens when the user violates the spec.


Python 2, 34 bytes

lambda l:map(sum,zip(l+[0],[0]+l))

Try it online!
37 bytes

lambda l:map(int.__add__,l+[0],[0]+l)

Try it online!
Python 2, 38 bytes

p=0
for x in input()+[0]:print x+p;p=x

Try it online!
Python 3.8 (pre-release), 37 bytes

lambda l,p=0:[p+(p:=x)for x in l]+[1]

Try it online!


String of alphanumeric characters to a sorted list of comma-separated ranges Given a string of unsorted alphanumeric characters, e.g.

ABC321STPpJqZZr0

output a ", "-separated list of character ranges, sorted by ASCII value, ignoring case and removing duplicates (i.e. outputting only uppercase and numeric characters), e.g.

0-3, A-C, J, P-T, Z

Rules

The length of your program is your base score, as usual.
You must initialize (hardcode) the above example within your program, but you may discount the length of that example from your program length, e.g. for char* s="ABC321STPpJqZZr0"; you may discount 16 chars, the other 11 chars counting toward your program length.

Bonus (+50 bounty)

As this was a real problem encountered by my coworker today, needing to be written in Tcl 8.0.5 (an ancient version, lacking many of the latest Tcl built-ins), I'll award 50 points to whomever writes the shortest Tcl 8.0.5 solution, if there are at least 2 valid submissions in Tcl 8.0.5.

Ruby, 87-16=71

EDIT:  Had to add some characters so that two-character ranges are displayed correctly.  Also using ?[ instead of ?Z to fix a bug with ranges ending in Z.

$><<[*?0..?[].join.gsub(/[^ABC321STPpJqZZr0]/i,$/).gsub(/\B.+\B/,?-).scan(/.-.|./)*', '

You can see the Ideone run here.


Line up the Diagonals of a Grid of Text Given a rectangular grid of text, line up the diagonals that go from the upper-left to the bottom-right into columns such that the lowest-rightmost characters of all diagonals are on a level. Use spaces for indentation.

For example, if the input grid of text is

abcd
1234
WXYZ

then you'd line up the diagonals W, 1X, a2Y, b3z, c4, and d in columns giving this output:

  ab
 123c
WXYZ4d

Note that the lowest-rightmost characters of all diagonals, WXYZ4d, are at the same level.

Details

The input grid of text will be at minimum 1×1 in size and all lines will be the same length.
You may take the input grid as a multiline string or as a list of single line strings.
The input grid will only contains printable ASCII characters (includes space).
The output may optionally have one trailing newline but there should be no other empty lines.
The lines of the output may optionally have trailing spaces but should not have unnecessary leading spaces.

Other Examples

Empty lines separate examples. Each input is directly followed by its output.

123
456
789

  1
 452
78963

123.?!
456??!
789!!!

  123.
 456???
789!!!!!

**@
@

 **
@  @

/\/\
\/ /
/ /\
\/\/

   /
  \/\
 / / /
\/\/\/\

12
34
56
78
90

 7531
908642

Code

Code

G
O
L
F

FLOG

~

~

Scoring

The shortest code in bytes wins.

J, 12 bytes

|./.&.|:&.|.

Defines an anonymous verb.
Try it online!

Explanation

|./.&.|:&.|.
|.            Reversed
  /.          anti-diagonals
    &.        under
      |:      transpose
        &.    under
          |.  reversal

In J, u &. v (read: u under v) means "v, then u, then inverse of v".
Reversal and transpose are self-inverses, so the program really means "reverse, transpose, extract reversed anti-diagonals, transpose, reverse".

With example input:

abcd
1234
WXYZ

Reverse:

WXYZ
1234
abcd

Transpose:

W1a
X2b
Y3c
Z4d

Extract reversed anti-diagonals (and pad with spaces):

W
X1
Y2a
Z3b
4c
d

Transpose:

WXYZ4d
 123c
  ab

Reverse:

  ab
 123c
WXYZ4d


The first n numbers without consecutive equal binary digits The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits.

The sequence is probably easiest to explain by just showing the relationships between the binary and decimal representations of the numbers:

0       ->  0
1       ->  1
10      ->  2
101     ->  5
1010    ->  10
10101   ->  21
101010  ->  42

Challenge:

Take an input integer n, and return the first n numbers in the sequence. You may choose to have the sequence 0-indexed or 1-indexed.

Test cases:

n = 1   <- 1-indexed
0

n = 18
0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682, 1365, 2730, 5461, 10922, 21845, 43690, 87381

Explanations are encouraged, as always.

This is OEIS A000975.

Python 2, 36 bytes

lambda n:[2**i*2/3for i in range(n)]

Try it online! Explanation: The binary representation of \$\frac{2}3\$ is 0.101010101... so it simply remains to multiply it by an appropriate power of 2 and take the integer portion.


2 factors factorization Given a natural number n write a program or function to get a list of all the possible two factors multiplications that can be used to achieve n. To understand better what is pretended you can go to http://factornumber.com/?page=16777216 to see when n is 16777216 we get the following list:

   2 × 8388608
   4 × 4194304
   8 × 2097152
  16 × 1048576
  32 ×  524288
  64 ×  262144
 128 ×  131072
 256 ×   65536
 512 ×   32768
1024 ×   16384
2048 ×    8192
4096 ×    4096

No need to pretty print things like here. The requirement is that each entry (pair of factors) is well distinguished from each other and inside each pair, the first factor is also well distinguished from the other. If you choose to return a list/array, the inside element can be a list/array with two elements, or some structure of your language that supports a pair of things like C++ std::pair.

Do not print the multiplication by 1 entry, nor repeat entries with the first factor commuted by the second, as they are pretty useless.

No winner; it will be a per language basis code golf.

Java (OpenJDK 8), 81 66 65 bytes

-15 Bytes thanks to Olivier Grégoire.
-1 Byte: ++j<=i/j -> j++<i/j.

i->{for(int j=1;j++<i/j;)if(i%j<1)System.out.println(j+" "+i/j);}

Try it online!

Old one (for reference)

Java (OpenJDK 8), 126 bytes

i->{java.util.stream.IntStream.range(2,i).filter(d->d<=i/d&&i%d==0).forEach(e->System.out.println(""+e+"x"+i/e));return null;}

Try it online!

First codegolf submit and first lambda usage. Future self, please forgive me for the code.


Draw the Utah Teapot The Utah teapot, originally created by Martin Newell, is a convenient object for testing 3D graphics programs.

The task is to create a wireframe image of the teapot in perspective projection. To encourage the idea of a source-code application, the viewing and camera control may be isolated and excluded from the count. This is so the parameters and input file may be modified and the code re-used to generate diverse images, but it is not necessary to create a full-fledged utility that accepts complicated command-line arguments or such. A "hackerly" balance is sought.

ref. StackOverflow: How do Bezier Patches work in the Utah Teapot?

So there are three subtasks here:

read-in the teapot data in its original format.
subdivide the patch data using deCasteljau splitting or other method. Other methods are using Bezier basis matrices and evaluating the polynomials (standard refs, like Foley and van Dam, Newmann and Sproull), or Bernstein basis methods (which are still beyond me).
project the points to 2D (if the language does not support 3D natively) and draw the outline of each small patch as seen from an Eye point whose view is centered on a LookAt point and whose vertical axis is aligned with the vertical axis of the teapot (ie. draw it "upright" from a nice vantagepoint).

Assuming that reading line-oriented text data from a file is little trouble, this challenge is really about getting hands-on with Bi-Cubic Bezier patch data.

Since the simple normal test for backface culling is not sufficient (the patches are not all oriented outward), no hidden-line or -surface removal is necessary. As a wireframe, it should look just fine with the back visible. The appearance may be improved by adjusting the line-width depending upon the distance from the eye, but this is not strictly necessary (my own programs do not do this).

This is both code-golf and rosetta-stone. Answers competing in the golf should include a count as normal. But submissions in unusual languages are very much encouraged, even if they're not particularly short.

For Kolmogorov-complexity enthusiasts, there is a more concise dataset where the full set may be reconstructed by adding rotations and mirroring of patches. And in Jim Blinn's A Trip Down the Graphics Pipeline, there is an even more concise method of generation by using the fact that the individual patches have rotational or other symmetries. The entire body (or lid) can be described by a single Bezier curve which is rotated around the y-axis. The spout and handles can be described by the two curves of their profile, and then selecting the intermediate control points to approximate a circular extrusion.

Postscript

Not fully golfed, but this illustrates a different approach than deCasteljau subdivision: evaluating the basis polynomial. Uses mat.ps.

(mat.ps)run[    % load matrix library, begin dictionary construction

/N 17
/C [ 0 7 4 ]   % Cam
/E [ 0 0 40 ] % Eye
/R 0 roty 120 rotx 90 rotz   % Rot: pan tilt twist
          matmul   matmul

/f(teapot)(r)file
/t{token pop exch pop}      % parse a number or other ps token
/s{(,){search not{t exit}if t 3 1 roll}loop}  % parse a comma-separated list
/r{token pop{[f 99 string readline pop s]}repeat}>>begin   % parse a count-prefixed paragraph of csv numbers
[/P[f r]/V[f r]/v{1 sub V exch get}        % Patches and Vertices and vert lookup shortcut
/B[[-1 3 -3 1][3 -6 3 0][-3 3 0 0][1 0 0 0]]              % Bezier basis matrix
/A{dup dup mul exch 2 copy mul 3 1 roll 1 4 array astore} % x->[x^3 x^2 x 1]
/M{[1 index 0 4 getinterval 2 index 4 4 getinterval       % flattened matrix->rowXcolumn matrix
3 index 8 4 getinterval 4 index 12 4 getinterval]exch pop}
/J{ C{sub}vop R matmul 0 get                              % perspective proJection  [x y z]->[X Y]
    aload pop E aload pop
    4 3 roll div exch neg
    4 3 roll add 1 index mul 4 1 roll
    3 1 roll sub mul}
>>begin

300 400 translate
1 14 dup dup scale div currentlinewidth mul setlinewidth  % global scale
/newline { /line {moveto /line {lineto} store} store } def
newline
P{
    8 dict begin
        [exch{v J 2 array astore}forall]/p exch def   % load patch vertices and project to 2D
        /X[p{0 get}forall] M B exch matmul B matmul def  % multiply control points by Bezier basis
        /Y[p{1 get}forall] M B exch matmul B matmul def

        0 1 N div 1 1 index .2 mul add{A/U exch def   % interpolate the polynomial over (u,v)/(N)
            /UX U X matmul def
            /UY U Y matmul def
            0 1 N div 1 1 index .2 mul add{A/V exch 1 array astore transpose def
                /UXV UX V matmul def
                /UYV UY V matmul def
                UXV 0 get 0 get
                UYV 0 get 0 get line
            }for
            newline
        }for

        0 1 N div 1 1 index .2 mul add{A/V exch def   % interpolate the polynomial over (u,v)/(N)
            /V [V] transpose def
            /XV X V matmul def
            /YV Y V matmul def
            0 1 N div 1 1 index .2 mul add{A/U exch 1 array astore transpose def
                /UXV U XV matmul def
                /UYV U YV matmul def
                UXV 0 get 0 get
                UYV 0 get 0 get line
            }for
            newline
        }for

    end

    %exit
}forall
stroke

1112

Stripping out the vertical lines, and discounting the parameters, yields
this 1112 char version. Uses mat.ps.

(mat.ps)run[    % 12

/N 17
/C [ 0 7 4 ]   % Cam
/E [ 0 0 40 ] % Eye
/R 0 roty 120 rotx 90 rotz   % Rot: pan tilt twist
          matmul   matmul

/f(teapot)(r)file/t{token pop exch pop}/s{(,){search not{t exit}if t   % 1100
3 1 roll}loop}/r{token pop{[f 99 string readline pop
s]}repeat}>>begin[/P[f r]/V[f r]/v{1 sub
V exch get}/B[[-1 3 -3 1][3 -6 3 0][-3 3 0 0][1 0 0 0]]/A{dup dup mul exch
2 copy mul 3 1 roll 1 4 array astore}/M{[1 index 0 4 getinterval 2 index 4 4 getinterval
3 index 8 4 getinterval 4 index 12 4 getinterval]exch pop}/J{C{sub}vop R matmul 0 get
aload pop E aload pop 4 3 roll div exch neg 4 3 roll add 1 index mul 4 1 roll
3 1 roll sub mul}>>begin 300 400 translate
1 14 dup dup scale div currentlinewidth mul setlinewidth
/newline{/line{moveto/line{lineto}store}store}def newline
P{8 dict begin[exch{v J 2 array astore}forall]/p
exch def/X[p{0 get}forall] M B exch matmul B matmul
def/Y[p{1 get}forall] M B exch matmul B matmul def
0 1 N div 1 1 index .2 mul add{A/U exch def/UX U X matmul def/UY U Y matmul def
0 1 N div 1 1 index .2 mul add{A/V exch 1 array astore transpose
def/UXV UX V matmul def/UYV UY V matmul def UXV 0 get 0 get UYV 0 get 0 get line}for
newline}for end}forall stroke


ROT13 one ASCII character This kind of question has been asked before, but I wanted to make it more specific. The linked question asks to read from stdin and rot13 the input. I don't want the disadvantage of I/O code that differs a lot for each language in length.

The challenge:

  Write a function that will ROT13 (wiki link) one char (as defined by the ASCII table).
  No built-in ROT13 functionality allowed.

Shortest code wins.

You can use this kind of C-family loop to test your function:

for (int i = '!'; i <= '~'; ++i)
{
    char c = (char) i;
    System.out.println(c + "   ->   " + f(c));
}


Looking for shorter alternatives to `range(...)` The best solution I've found so far for a golf code puzzle I'm working on includes two rather fat-looking invocations of range.  I'm very new at code golf, especially in Python, so I could use a few tips.

The relevant fragment is this

[x for x in range(n+1,7**6)if`x`==`x`[::-1]*all(x%i for i in range(2,x))]

The upper limit of the first range is not a sharp one.  It should be at least 98690, and all else being equal (golf-wise, that is), the smaller the difference between this upper limit and 98690 the better, performance-wise1.  I'm using 76 (=117649) because 7**6 is the shortest Python expression I can come up with that fits the bill.

In contrast, the lower limit in the first range, as well as both limits in the second one, are firm.  IOW, the program (in its current form) will produce incorrect results if those limits are changed.

Is there a way to shorten one or both of the expressions

range(n+1,7**6)
range(2,x)

?

BTW, in this case, aliasing range to, say, r gains nothing:

r=range;rr
rangerange

EDIT: FWIW, the full program is this:

p=lambda n:[x for x in range(n+1,7**6)if`x`==`x`[::-1]*all(x%i for i in range(2,x))][0]

p(n) should be the smallest palindromic prime greater than n.  Also, p should not be recursive.  Warning: It is already obscenely slow!

1Yes, I know: performance is irrelevant in code golf, but that's why I wrote "all else being equal (golf-wise, that is)".  For example, my choice of 7**6, and not the more immediately obvious, but poorer-performing, "golf-equivalent" alternative 9**9.  I like to actually run my code golf attempts, which means not letting the performance degrade to the point that it would take years to run the code.  If I can help it, of course.

Make it a single loop

As is, you have two loops: one iterating over x that might be palindromic primes, another iterating over i to check if x is prime by trial division. As you noticed, loops is Python take many characters, often to write range, but also to write while _: or for x in _. So, a golfed Python solution should take pains to use as few loops as possible.

feersum's comment "The best-golfed programs often make surprising connections between different part of the programs" is very applicable here. The prime-checking might seem like a separate subroutine for which all(x%i for i in range(2,x)) is the classic expression. But we'll do it another way.

The idea is to use Wilson's Theorem. For each potential prime k, we keep a running product of (k-1)!, and check is it's a multiple of k. We can keep track of (k-1)! while we test potential k to be prime palindromes by keeping a running product P.

Actually, we'll use the stronger version of Wilson's Theorem that (k-1)! % k equals 0 for composite k and only for composite numbers, except k=4 gives 2, and so (k-1)!**2 % k equals 0 exactly for composite numbers. We'll update P to equal k!**2 via the update P*=k*k.

(See this answer for this method used to find primes in Python.)

Putting it all together:

def p(n):
 k=P=1
 while(`k`!=`k`[::-1])+(k<=n)+(P%k==0):P*=k*k;k+=1
 return k

This isn't yet fully golfed -- the condition in particular is written inefficiently.
We can compress the condition to check that k is a palindrome while at the time enforcing the other conditions via a chained inequality.

def p(n):
 k=P=1
 while`k`*(P%k>0>n-k)!=`k`[::-1]:P*=k*k;k+=1
 return k


Rotate simple ASCII art This is similar to a previous question on this site, but with much simpler rules, so we should get much shorter results (in bytes):

Input:  ASCII art with only two possible characters: space and '#'.
Output: Input sequence rotated 90 degrees counter-clockwise.

Winner is answer with least number of bytes including length of language name.


I'm too cold, turn up the temperature This is my first golf contest.

What you need to do

Build me, in the shortest amount of bytes possible, my AC remote control system. My room is too cold right now, and I'm missing my remote.

Now, I don't want you literally building it or anything, just golf this:

A slow increment of temperature, starting at 40 degrees, and ending at exactly 72. The increment time must always be 500 millis per increment. It can wait another 500ms at the end. I would prefer it to stop however. The increment itself must go up by two each time, like my remote.

You should not clear the screen. You should have newlines.

What should happen

Example output (everything in parentheses shouldn't be outputted).

40
(wait 500 millis)
42
(wait 500 millis)
44
(..repeat until 72..)
72
(stop or wait 500ms)

Keep in mind
This is my first golf, so I apologize if this is too hard to golf. :(

Best of luck, golfers!

Minecraft 1.9.0+, 204 162 bytes +  58 36 28 24 20  blocks = 262 240 232 186 182 blytes
This solution is golfed down, and it can't be seen whole in one, or even two screenshots. Uses two glitches and abuses another two features of the game

This solution uses the same principles as the one below, just a 4 blocks more compact design.

Abuses the fact that Chain command blocks (green blocks) can't be powered by redstone, only by a singal from a impulse command block (orange).

Abuses the fact pistons take 0.30 seconds to extend completely, and redstone needs only 0.10s to register a signal.

Also abuses a twofold glitch to set the timer (TNT) off: the redstone next to the timer (TNT) gets not only powered, but also thinks the TNT is another redstone and powers it.

On top of all these abuses, the signal shortener (thing under the TNT) is one-use, after it gets powered it changes shape, allowing to pass signal through it to the "incrementer" (topmost orange block)

A bit of explanation on the functionality of it's different parts can be seen in older solutions (but best in the one just below). You can also Try it Offline! (simplified solution incrementing by 4, works only in 1.11+) by running this command in a command block.

Old solution, Minecraft 1.9.0+, 186 blytes:

Since TNT normally explode after 3.0s in Minecraft, this one has to be placed by a command (/setblock) with a specified fuse. Also uses a more compact design to remove redundant command block (containing 42 bytes) and redstone against the older versions. I'm sure this can't get any lower...
Older solution, Minecraft 1.9.0+, 232 blytes:
Oops, I found out these older solutions increment by 4...

Uses the 1.9 command block chain feature (green block thing) to save blocks. Also uses a more compact signal shortener then in the older solutions
Even older solution, Minecraft 1.7.0+, 240 blytes:

Uses a more compact timer (TNT) then the first solution (below).
Oldest solution, Minecraft 1.7.0+, 262 blytes:

This is so long because of the way Minecraft handles variables:

To define a variable (int): scoreboard objectives add <variable> dummy

To set a value to a variable (each entity including players has it's own variable value): scoreboard players set <entity> <variable> <value>

* can be used as <entity> to select all entities and save bytes.

only defined variables may be used

the value of the variable must be set to a number, not a variable

To increment var1 by var2: scoreboard players operation <entity> var1 += <entity> var2

<entity> must be a single entity, eg. @p, not *

Screenshots are of my own, dual licenced under WTFPL and what licence SE decides to use today (currently  cc by-sa 3.0 with attribution required) :-)


Separate a list into even-indexed and odd-indexed parts Inspired by this question:

Make a function (or a full program) that receives a list of numbers and outputs the list rearranged, so that even-indexed numbers appear first, and odd-indexed numbers follow. The values of the numbers themselves don't affect ordering - only their indices do. All indices are zero-based.

For example:

Input: [0, 1, 2, 3, 4]

Output: [0, 2, 4, 1, 3]

Another example:

Input: [110, 22, 3330, 4444, 55555, 6]

Output: [110, 3330, 55555, 22, 4444, 6]

Use most natural representation for lists that your language has. There are no limitations on complexity (e.g. allocating a temporary list is OK - no need to do it in-place).

P.S. It should work for the empty list (empty input => empty output).

Python, 23 bytes
lambda x:x[::2]+x[1::2]

Try it online


Exchange capitalization Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins.

Input:   CodeGolf xxPPCGxx
Output:  coDEGOlf XxppCgxx

Both strings will be equal-length and nonempty, with only letters a..z and A..Z.
You may output the two resulting strings in either order relative to the inputs.
You may represent a pair of strings as one string with a non-letter single-character separator for input and/or output.
You may represent a string as a list of characters or one-character strings, but not as a sequence of code point values unless these are simply strings in your language.
Your input and output may represent strings differently.

Test cases:

CodeGolf xxPPCGxx -> coDEGOlf XxppCgxx
lower UPPER -> LOWER upper
MiXeD lower -> mixed LoWeR
A A -> A A
ABcd EfGh -> AbCd EFgh

Java (JDK 10), 66 bytes

a->b->{for(int i=a.length,t;i-->0;b[i]^=t)a[i]^=t=(a[i]^b[i])&32;}

Try it online!

Explanations

a->b->{                           // Curried lambda
 for(int i=a.length,t;i-->0;      //  Descending loop on i,
                                  //  Declare t
     b[i]^=t                      //   Apply the case difference to b[i]
   )
  a[i]^=t=(a[i]^b[i])&32;         //   Assign the case difference of the two letters to t, and apply it to a[i].
}


Make a rectangle from a collection of (sliced) squares Inspired by Make a Rectangle from a Triangle.

Task

There is a famous formula on the sum of first \$n\$ squares:

$$
1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}
$$

It is known that this number is composite for any \$n \ge 3\$.

Now, imagine a collection of row tiles (a tile of shape \$1 \times k\$ with the number \$k\$ written on each cell), and you have 1 copy of size-1 tile, 2 copies of size-2 tiles, ... and \$n\$ copies of size-\$n\$ tiles.

[1]  [2 2]  [2 2]  [3 3 3]  [3 3 3]  [3 3 3] ...

Then arrange them into a rectangle whose width and height are both \$ \ge 2\$. You can place each tile horizontally or vertically.

+-----+---+-+-+
|3 3 3|2 2|1|2|
+-----+---+-+ |
|3 3 3|3 3 3|2|
+-----+-----+-+

Output such a matrix if it exists. You don't need to indicate the boundaries; just output the resulting matrix of integers. Your program may do whatever you want if the solution doesn't exist.

I believe there exists a solution for any \$n \ge 3\$. Please let me know if you find a proof or counterexample!

Standard code-golf rules apply. The shortest code in bytes wins.

Examples

n = 3: (2x7 example)
3 3 3 3 3 3 1
3 3 3 2 2 2 2

n = 4: (3x10 example)
4 4 4 4 4 4 4 4 2 2
4 4 4 4 3 3 3 2 2 1
4 4 4 4 3 3 3 3 3 3

n = 5: (5x11 example)
5 5 5 5 5 4 4 4 3 3 3
5 5 5 5 5 4 4 4 3 3 1
5 5 5 5 5 4 4 4 3 3 2
5 5 5 5 5 4 4 4 3 3 2
5 5 5 5 5 4 4 4 4 2 2

n = 6: (7x13 example)
6 6 6 6 6 5 5 5 5 5 3 3 3
6 6 6 6 6 5 5 5 5 3 3 3 1
6 6 6 6 6 5 5 5 5 4 3 3 3
6 6 6 6 6 5 5 5 5 4 4 4 2
6 6 6 6 6 5 5 5 5 4 4 4 2
6 6 6 6 6 5 5 5 5 4 4 4 2
6 6 6 6 6 6 4 4 4 4 4 4 2

Python 2, 238 ... 186 bytes

-2 bytes thanks to @Arnauld!

-5 bytes thanks to @ovs!!

-6 bytes thanks to @Jonathan Allan!!

n=input()
p=w=~n*n*(~n-n)/6
e=range(n+1)
def f(a,b,c,d=[]):1>a>exit(c);1>b>f(a-1,w,c+[d]);g=n;exec"e[g]-=1;g<=b>-1<e[g]>f(a,b-g,c,d+[g]*g);e[g]+=1;g-=1;"*n
while 1:1>p%w>f(p/w,w,[]);w-=1

Try it online!

Notice that the above code only used horizontal tiles. To prove it's correct...

C++ (gcc), 4355 bytes

This code is an explicit construction using only horizontal tiles for \$n>6\$. It can produce correct solutions (at least) up to \$n=99\$.

#include <bits/stdc++.h>
using namespace std;
void dim(int x,int&p,int&q)
{
	int u[]={x,x+1,x+x+1},o=0;
	while(u[o]%2) ++o; u[o]/=2;
	o=0; while(u[o]%3) ++o; u[o]/=3;
	sort(u,u+3);if(x%3==1)swap(u[0],u[1]);
	p=u[0];q=u[1]*u[2];
}
int o[100][99999],c[99999],g[99999];
void brute(int n,int& v,int& u,bool t)
{
	for(int i=1;i<=n;++i) c[i]=i;
	if(t)
	{
		u=n*(n+1)*(2*n+1)/6,v=2;
		while(u%v) ++v;
		if(n>=5) v=u/v;
		u/=v; c[2]-=n==6;
	}
	for(int i=1;i<=v;++i)
	{
		int s=u,cnt=0;
		for(int j=n;j>=1;--j) while(s>=j&&c[j])
		{
			s-=j, --c[j]; for(int k=j;k--;) o[i][++cnt]=j;
		}
	}
	c[2]+=t&&n==6;
	for(int i=u;i>=u-1&&i;--i)
		for(int j=1;j<=v;++j) if(!o[j][i])
		{
			int x=0; while(!c[x]) ++x;
			--c[x]; int l=x; --j;
			while(l--) o[++j][i]=x;
		}
}
int s0[99999],s1[99999];
//find a subset of a with sum b
//guaranteed b is half of a's sum
//guaranteed a is consecutive
pair<vector<int>,vector<int>> solve2(vector<int> a,int b)
{
	if(!a.size()) return make_pair(a,a);
	int w=0,s=0,as=a.size();
	for(int i=0;i<as;++i)
		s0[i+1]=s0[i]+a[i],
		s1[i+1]=s1[i]+a[as-1-i];
	while(w<a.size()&&s+a[w]<=b)
		s+=a[w++];
	assert(w!=a.size()&&w>0);
	for(int l=0;l<w;++l)
	{
		int r=w-1-l;
		int p=s0[l]+s1[r];
		if(p>b) continue;
		int q=b-p;
		if(!(a[l]<=q&&q<=a[as-r-1]))
			continue;
		//first l, last r, q.
		vector<int> A,B;
		for(int j=0;j<l;++j) A.push_back(a[j]);
		A.push_back(q);
		for(int j=as-r;j<as;++j) A.push_back(a[j]);
		for(int j=l;j<as-r;++j)
		{
			if(a[j]==q) q=-1;
			else B.push_back(a[j]);
		}
		return make_pair(A,B);
	}
	assert(0);
}
int main()
{
	int n,p,q;
	cin>>n;
	assert(n>=3);
	if(n<=6) brute(n,p,q,1);
	else
	{
		if(n%3==1)
		{
			int x=n%3,pp,qq;
			dim(x,p,q);
			brute(x,p,q,0);
			while(n!=x)
			{
				//x+1...x+3
				int xx=x+3; dim(xx,pp,qq);
				assert(pp-p==2&&qq-q==x*3+6);
				for(int i=x+1;i<=x+3;++i) c[i]=i;
				int mr=x/6;
				for(int i=1;i<=p;++i)
				{
					int cnt=q;
					vector<int> rv;
					if(i<=mr) rv=vector<int>{x+2,x+2,x+2};
					else rv=vector<int>{x+1,x+2,x+3};
					for(int j:rv)
					{
						assert(c[j]); --c[j];
						for(int k=j;k--;) o[i][++cnt]=j;
					}
				}
				vector<int> rv;
				for(int i=x+1;i<=x+3;++i)
					for(int j=c[i];j;--j) rv.push_back(i);
				pair<vector<int>,vector<int>> s=solve2(rv,qq);
				for(int i=p+1;i<=pp;++i)
				{
					int cnt=0;
					for(auto j:(i==pp)?s.first:s.second)
					{
						assert(c[j]); --c[j];
						for(int k=j;k--;) o[i][++cnt]=j;
					}
				}
				p=pp; q=qq; x=xx;
			}
		}
		else
		{
			int x=n%6,pp,qq;
			dim(x,p,q);
			brute(x,p,q,0);
			while(n!=x)
			{
				int xx=x+6; dim(xx,pp,qq);
				if(n%6==0)
					assert(pp-p==1&&qq-q==24*x+90); //[1 2 3 4 5 6]*3+[2 3 5 5 6 6]
				else if(n%6==2)
					assert(pp-p==2&&qq-q==12*x+39); //[1 2 3 4 5 6]+[1 1 2 3 5 6]
				else if(n%6==3)
					assert(pp-p==2&&qq-q==12*x+45); //[1 2 3 4 5 6]+[1 2 4 5 6 6]
				else if(n%6==5)
					assert(pp-p==1&&qq-q==24*x+78); //[1 2 3 4 5 6]*3+[1 1 2 2 4 5]
				else assert(0);
				vector<int> uv;
				if(n%6==0) uv=vector<int>{2,3,5,5,6,6};
				else if(n%6==2) uv=vector<int>{1,1,2,3,5,6};
				else if(n%6==3) uv=vector<int>{1,2,4,5,6,6};
				else uv=vector<int>{1,1,2,2,4,5};
				for(int j=1;j<4/(pp-p);++j)
					for(int k=1;k<=6;++k) uv.push_back(k);
				for(int i=x+1;i<=x+6;++i) c[i]=i;
				for(int i=1;i<=p;++i)
				{
					int cnt=q;
					for(auto j_:uv)
					{
						int j=j_+x;
						assert(c[j]); --c[j];
						for(int k=j;k--;) o[i][++cnt]=j;
					}
				}
				vector<int> rv;
				for(int i=x+1;i<=x+6;++i)
					for(int j=c[i];j;--j) rv.push_back(i);
				if(pp-p==2)
				{
					pair<vector<int>,vector<int>> s=solve2(rv,qq);
					for(int i=p+1;i<=pp;++i)
					{
						int cnt=0;
						for(auto j:(i==pp)?s.first:s.second)
						{
							assert(c[j]); --c[j];
							for(int k=j;k--;) o[i][++cnt]=j;
						}
					}
				}
				else
				{
					int i=pp,cnt=0;
					for(auto j:rv)
					{
						assert(c[j]); --c[j];
						for(int k=j;k--;) o[i][++cnt]=j;
					}
				}
				p=pp; q=qq; x=xx;
			}
		}
	}
	cerr<<p<<","<<q<<"\n";
	for(int i=1;i<=p;++i,cout<<"\n")
		for(int j=1;j<=q;++j)
			cout<<setw(2)<<o[i][j]<<" ";
	if(n>6)
	{
		for(int i=1;i<=n;++i) c[i]=i;
		for(int i=1;i<=p;++i)
			for(int j=1;j<=q;++j)
			{
				int u=o[i][j];
				assert(u>=1&&u<=n);
				for(int k=2;k<=u;++k)
					assert(o[i][++j]==u);
				--c[u];
			}
		for(int i=1;i<=n;++i) assert(!c[i]);
	}
}

Try it online!

How does the construction work?

It's an incremental construction. Consider \$n \bmod 6\$, we can have these values for height and width of rectangles:

\$n/6\times (n+1)(2n+1)~(n\bmod 6=0)\$
\$(2n+1)/3\times n(n+1)/2~(n\bmod 6=1)\$
\$(n+1)/3\times n(2n+1)/2~(n\bmod 6=2)\$
\$n/3\times (n+1)(2n+1)/2~(n\bmod 6=3)\$
\$(2n+1)/3\times (n+1)n/2~(n\bmod 6=4)\$
\$(n+1)/6\times n(2n+1)~(n\bmod 6=5)\$

(dimensions might be \$1\$ for \$n\leq 6\$ so these small cases are handled manually)

So the main idea of my construction is:

We construct rectangles with the heights and widths as in above list.
If \$n\bmod 3 \neq 1\$, construct the solution for \$n-6\$ recursively, add in \$n-5,n-4\cdots n\$. The height of the rectangle will only increase 1 or 2.
If \$n\bmod 3=1\$, construct the solution for \$n-3\$ recursively and add in \$n-2,n-1,n\$. The height of the rectangle will only increase 2.
We first carefully assign the new numbers to the added columns, and then put rest of the numbers into one or two added rows.

The rest of the job is some careful casework to pick the numbers. These details are left as an exercise to the readers (Be ready for some long and tedious casework!). If you complete all the details, this should become a formal proof for the existence of the solutions (and using only horizontal tiles!).


Balanced ternary logic Balanced ternary logic

Ternary is normally another name for base 3, that is to say, each digit is 0, 1, or 2, and each place is worth 3 times as much as the next place.

Balanced ternary is a modification of ternary which uses digits of -1, 0 and 1. This has the advantage of not needing a sign. Each place is still worth 3 times as much as the next place. The first few positive integers are therefore [1], [1, -1], [1, 0], [1, 1], [1, -1, -1] while the first few negative integers are [-1], [-1, 1], [-1, 0], [-1, -1], [-1, 1, 1].

You have three inputs x, y, z. z is either -1, 0, or 1, while x and y can be from -3812798742493 to 3812798742493 inclusive.

The first step is to convert x and y from decimal to balanced ternary. This should give you 27 trits (TeRnary digITS). You then have to combine the trits from x and y in pairs using a ternary operation and then convert the result back to decimal.

You can choose which values of z map to one of these three ternary operations each:

A: Given two trits, if either is zero, then the result is zero, otherwise the result is -1 if they are different or 1 if they are the same.
B: Given two trits, if either is zero, then the result is the other trit, otherwise the result is zero if they are different or the negation if they are the same.
C: Given two trits, the result is zero if they are different or their value if they are the same.

Example. Suppose x is 29 and y is 15. In balanced ternary, these become [1, 0, 1, -1] and [1, -1, -1, 0]. (The remaining 23 zero trits have been omitted for brevity.) After each of the respective operations they become A: [1, 0, -1, 0], B: [-1, -1, 0, -1], C: [1, 0, 0, 0]. Converted back to decimal the results are 24, -37 and 27 respectively. Try the following reference implementation for more examples:

function reference(xd, yd, zd) {
    var rd = 0;
    var p3 = 1;
    for (var i = 0; i < 27; i++) {
        var x3 = 0;
        if (xd % 3 == 1) {
            x3 = 1;
            xd--;
        } else if (xd % 3) {
            x3 = -1;
            xd++;
        }
        var y3 = 0;
        if (yd % 3 == 1) {
            y3 = 1;
            yd--;
        } else if (yd % 3) {
            y3 = -1;
            yd++;
        }
        var r3 = 0;
        if (zd < 0) { // option A
            if (x3 && y3) r3 = x3 == y3 ? 1 : -1;
        } else if (zd > 0) { // option B
            if (!x3) r3 = y3;
            else if (!y3) r3 = x3;
            else r3 = x3 == y3 ? -x3 : 0;
        } else { // option C
            r3 = x3 == y3 ? x3 : 0;
        }
        rd += r3 * p3;
        p3 *= 3;
        xd /= 3;
        yd /= 3;
    }
    return rd;
}

<input type=number id=x><input type=number id=y><select id=z><option value=-1>A</option><option value=1>B</option><option value=0>C</option><select>

The reference implementation follows the steps given above but you are of course free to use any algorithm that produces the same results.

This is code-golf, so the shortest program or function that violates no standard loopholes wins!

Clean, 231 ... 162 bytes

import StdEnv
$n=tl(foldr(\p[t:s]#d=sign(2*t/3^p)
=[t-d*3^p,d:s])[n][0..26])
@x y z=sum[3^p*[(a+b)/2,[1,-1,0,1,-1]!!(a+b+2),a*b]!!(z+1)\\a<- $x&b<- $y&p<-[0..26]]

Defines the function @, taking three Ints and giving an Int.
Operators map as 1 -> A, 0 -> B, -1 -> C.

Try it online!

The function $ folds a lambda over the digit places [0..26], into a list of ternary digits. It uses the head of the list it yields to keep a current total difference from the requisite number (which is why it is tailed prior to returning), and sign(2*t/3^p) to determine the current digit to yield. The sign trick is equivalent to if(abs(2*t)<3^p)0(sign t).


The Pyramid of Languages Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages.

Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python...
Each language must output a list of language names separated with a newline, sorted by length.

Output must be a pyramid: The list can only contain used language names, that are shorter than the running script language name + the running script language's name.

Leading and trailing newlines are allowed.
Standard loopholes are forbidden.
It's not allowed to create custom programming languages just to increase the score.
Version numbers don't count in language name, but you can specify it in your post if there are any incompatible changes in new versions of the language.
You can decide if you want to use the shortcut for the language name or it's full name, but you can't submit both forms in one answer. You can use ex. either SPL or Shakespeare Programming Language.

Only letters, numbers, ASCII symbols and single spaces (not leading nor trailing) count in language name length.

Examples

Example outputs for C, C# and C++:

C

C

C#

C
C#

C++

C
C#
C++