Bit-Reversal Permutations Your goal is to create a function or a program to reverse the bits in a range of integers given an integer \$n\$. In other words, you want to find the bit-reversal permutation of a range of \$2^n\$ items, zero-indexed. This is also the OEIS sequence A030109. This process is often used in computing Fast Fourier Transforms, such as the in-place Cooley-Tukey algorithm for FFT. There is also a challenge for computing the FFT for sequences where the length is a power of 2.
This process requires you to iterate over the range \$[0, 2^n-1]\$, convert each value to binary and reverse the bits in that value. You will be treating each value as a \$n\$-digit number in base 2 which means reversal will only occur among the last \$n\$ bits.
For example, if \$n = 3\$, the range of integers is [0, 1, 2, 3, 4, 5, 6, 7]. These are
i  Regular  Bit-Reversed  j
0    000        000       0
1    001        100       4
2    010        010       2
3    011        110       6
4    100        001       1
5    101        101       5
6    110        011       3
7    111        111       7

where each index \$i\$ is converted to an index \$j\$ using bit-reversal. This means that the output is [0, 4, 2, 6, 1, 5, 3, 7].
The output for \$n\$ from 0 thru 4 are
n    Bit-Reversed Permutation
0    [0]
1    [0, 1]
2    [0, 2, 1, 3]
3    [0, 4, 2, 6, 1, 5, 3, 7]

You may have noticed a pattern forming. Given \$n\$, you can take the previous sequence for \$n-1\$ and double it. Then concatenate that doubled list to the same double list but incremented by one. To show,
[0, 2, 1, 3] * 2 = [0, 4, 2, 6]
[0, 4, 2, 6] + 1 = [1, 5, 3, 7]
[0, 4, 2, 6] ⊕ [1, 5, 3, 7] = [0, 4, 2, 6, 1, 5, 3, 7]

where \$⊕\$ represents concatenation.
You can use either of the two methods above in order to form your solution. If you know a better way, you are free to use that too. Any method is fine as long as it outputs the correct results.
Rules

This is code-golf so the shortest solution wins.
Builtins that solve this challenge as a whole and builtins that compute the bit-reversal of a value are not allowed. This does not include builtins which perform binary conversion or other bitwise operations.
Your solution must be, at the least, valid for \$n\$ from 0 to 31.

Haskell, 40 37 bytes

f 0=[0]
f a=[(*2),(+1).(*2)]<*>f(a-1)

Try it online!

Thanks to @Laikoni for three bytes!


HangOver ACM problem! there is only one rule: get accept for this problem http://acm.ut.ac.ir/sc/problemset/view/1032!

to submit your code, you need to create an account(if you don't want to do so, just post your code here and I'll submit it). so far shortest code is written with C and has 85 character length.

winner will be the shortest C/C++ code submitted before 2012/02/01

note: to check shortest codes submitted you can click on "accepted runs" and then "code length"

as elssar suggested I've copied the question here :

How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendicular to the table.) With two cards you can make the top card overhang the bottom one by half a card length, and the bottom one overhang the table by a third of a card length, for a total maximum overhang of 1/2 + 1/3 = 5/6 card lengths. In general you can make n cards overhang by 1/2 + 1/3 + 1/4 + ... + 1/(n + 1) card lengths, where the top card overhangs the second by 1/2, the second overhangs tha third by 1/3, the third overhangs the fourth by 1/4, etc., and the bottom card overhangs the table by 1/(n + 1). This is illustrated in the figure below.

figure http://acm.ut.ac.ir/sc/assets/problem_images/1032_50ac13c53158fd843d1884e8afa962dd.jpg

Input

The input consists of one or more test cases, followed by a line containing the number 0.00 that signals the end of the input. Each test case is a single line containing a positive floating-point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three digits.

Output

For each test case, output the minimum number of cards necessary to achieve an overhang of at least c card lengths. Use the exact output format shown in the examples.

Sample Input

1.00
3.71
0.04
5.19
0.00

Sample Output

3 card(s)
61 card(s)
1 card(s)
273 card(s)

C, 149 89

Well, this was a noobish shot at it, but probably a decent starting point:

#include <cstdio>
float i;
int o(float a,int n=2){return a<0?n-2:o(a-1./n,n+1);}
main(){if (scanf("%f",&i),i==0) return 0;printf("%d card(s)\n",o(i));main();}

It reported as 145 characters.

With a push in the right direction, I got the solution down to 122 by changing the function to a for loop.

#include <cstdio>
float i;
main(){
if (scanf("%f",&i),i==0) return 0;
int n=2;for(;i>0;)i-=1./n++;
printf("%d card(s)\n",n-2);
main();}

On a roll!

#include <cstdio>
main()
{
    float i,n=2;
    for(scanf("%f",&i);i>0;i-=1/n++);
    if (n-=2) printf("%.0f card(s)\n",n), main();
}

Scooted scanf, for loop division doesn't need 1. any more, adjusting n now done in conditional.

Switched over to C, got some good savings.  Down to 89 characters.

main(n)
{
    float i;
    for(scanf("%f",&i);i>0;i-=1./++n);
    if (--n) printf("%d card(s)\n",n), main(1);
}


Prefixless Palindromes Write a program or function that takes N, and S and outputs the number of palindromes of length S you can build using an alphabet of size N such that any prefix of size between 2 and S-1 is not a palindrome.

For example if N were 2 and S were 5

The valid palindromes would be

01110
10001

And thus the answer would be 2

This is code-golf so answers will be scored in bytes based on their length with fewer bytes being better.

Jelly, 10 bytes

ṗŒḂƤ€Ḋ€Ḅċ1

This is a brute-force search over all ns possible strings.

My results differ from the other answers', but the solutions my answer counts seem to be valid.

Try it online!


Can this pattern be made with dominoes? Given a pattern of squares on a grid, determine if it is possible to create that pattern with non-overlapping dominoes. In case you are not familiar, a domino is a rectangular shape created by joining exactly two squares at their edges.
Examples
For the pattern on the left, O represents an occupied cell on the grid and . represents an empty cell. For the pattern to the right of the first |, numbers and letters will be used to mark individual dominoes in a possible solution
Possible
O  |  1  |  This is the trivial case:
O  |  1  |  a single domino laid vertically

. O . .  |  . 2 . .  |  This can be created with three
O O O O  |  1 2 3 3  |  dominoes in a simple pattern
O . . .  |  1 . . .  |

O O O O  |  1 1 2 2  |  A simple rectangular grid with
O O O O  |  3 3 4 4  |  even width is easily tiled with
O O O O  |  5 5 6 6  |  horizontally-laid dominoes

O O O  |  1 1 2  |  Four dominoes laid radially
O . O  |  3 . 2  |
O O O  |  3 4 4  |

. O O .  |  . 1 1 .  |  Dominoes do not need to touch
O . O .  |  2 . 3 .  |  and the grid may contain empty
O . O .  |  2 . 3 .  |  cells along an edge

. O . . O O O O O .  |  . K . . R R S S N .  |  A 10x10 test case and
O O O . . O . . O .  |  U K J . . 5 . . N .  |  one of its solutions
O . O . . O . O O O  |  U . J . . 5 . C C Q  |
O O O O O O . O . O  |  T B B 4 1 1 . 7 . Q  |
O . . O O O . O . .  |  T . . 4 6 6 . 7 . .  |
. . O O O . O O O .  |  . . 2 3 3 . 8 8 D .  |
O O O . . O . . O .  |  I I 2 . . 9 . . D .  |
. . O O O O . O O O  |  . . G O O 9 . E E L  |
. . O . . O O O . O  |  . . G . . A F F . L  |
O O . O O O . . O O  |  M M . H H A . . P P  |

Not Possible
O  |  You need at least two occupied cells to fit a domino

O .  |  Dominoes are squares joined by edges, not corners
. O  |

O  |  It is always impossible to create a pattern with an odd
O  |  number of squares with dominoes
O  |

O O . O  |  No matter how you lay the first few dominoes,
. O O O  |  at least two squares are always separated
. O . O  |

O O O .  |  This is a slightly more complicated version of the above
O . O O  |
O O O .  |
. O O O  |

. O . . . .  |  A small test case that cannot be decided with
O O O O O O  |  a chessboard painting algorithm
. . . . O .  |

. O O O O O . O O O  |  A 10x10 example test case
O O O . . O . . . O  |
. . O . O . O O O .  |  This pattern is almost possible
. O . . O . . . O O  |  except that the bottom-left corner
. O O O O O O O . O  |  contains an arrangement which is
. . . . O . . O O O  |  impossible to make with dominoes
O O O O O . O . . .  |
O . O . . . O . . O  |
. O O O . O O . O O  |
. . . O O . O O O .  |

. O O O O O O O O O  |  A pathological case for a chessboard
O O O O O O O O O .  |  painting algorithm.
O O O O O O O O O O  |
O O O O O O O O O O  |  This is also a pathological case for
O O O O O O O O O O  |  a backtracking algorithm.
O O O O O O O O O O  |
O O O O O O O O O O  |
O O O O O O O O O O  |
O O O O O O O O O O  |
O O O O O O O O O O  |

Rules and Scoring

This is Code Golf, so shortest code wins
Use any convenient I/O method.
Valid input formats for the grid include, but are not limited to:

Array of arrays
Height, width, array
Array of integers representing each row (or column) in binary
A string representation similar to the examples above
A PNG image

You may assume input grids are rectangular (not jagged)
Your solution should return answers within a reasonable amount of time (it should not time out on Try It Online, for example) for inputs up to 10x10 and be able to theoretically work for a grid of any size if given enough time and space.

JavaScript (V8), 129 bytes

f=(g,p=d=>(n=2,v=g.map((r,i)=>r.map((c,j)=>c*n&&(n>1?~(y=i+d,x=j+!d):i==y&j==x)?!n--:c)),n?n>1:f(v)))=>g in f?f[g]:f[g]=p(0)|p(1)

Try it online!
Receives the input as a 2-dimensional array of booleans and returns 0 for false or 1 for true.
Explanation
Solves the problem recursively calling itself with a single domino removed from the grid. If it is called with an empty grid (which will happen if the initial grid only contained valid domino positions) then it returns true. At each call it tries removing the top-left position containing a domino, calling itself with either the horizontal or vertical orientation removed.
f=(g,
// p = function to remove the top-left domino and recurse if the remove succeeded
p=d=>(
// n = squares remaining for removal
n=2,
// v = grid after removal
v=g.map((r,i)=>r.map((c,j)=>c*n&&(n>1?~(y=i+d,x=j+!d):i==y&j==x)?!n--:c)),
// if n=2 the grid was empty so we return true, if n=1 we could not remove the domino
// if n=0 the domino was successfully removed and we recurse
n?n>1:f(v))
// try removing the top-left square with a horizontal or vertical domino
// and cache results
)=>g in f?f[g]:f[g]=p(0)|p(1)


I'm a palindrome. Are you? There have been a couple of previous attempts to ask this question, but neither conforms to modern standards on this site. Per discussion on Meta, I'm reposting it in a way that allows for fair competition under our modern rulesets.

Background

A palindrome is a string that "reads the same forwards and backwards", i.e. the reverse of the string is the same as the string itself. We're not talking about "convenient palindromes" here, but a strict character-by-character reversal; for example, ()() is not a palindrome, but ())( is.

The task

Write a program or function that takes a string S (or the appropriate equivalent in your language) as input, and has one output Q (of a type of your choice). You can use any reasonable means to take the input and provide the output.

When the input S is a palindrome, the output Q should have a value A (that is the same for any palindromic S).
When the input S is not a palindrome, the output Q should have a value B (that is the same for any non-palindromic S).
A and B must be distinct from each other.

Or in other words: map all palindromes to one value, and all non-palindromes to another.

Additionally, the program or function you write must be a palindrome itself (i.e. its source code must be palindromic), making this a restricted-source challenge.

Clarifications

Although true and false are obvious choices for A and B, you can use any two distinct values for your "is a palindrome" and "isn't a palindrome" outputs, which need not be booleans.
We're defining string reversal at the character level here; éé is palindromic regardless of whether the program is encoded in UTF-8 or Latin-1, even though it's not a palindromic sequence of octets after UTF-8 encoding.
However, even if your program contains non-ASCII characters, it only needs to work for ASCII input. Specifically, the input S will only contain printable ASCII characters (including space, but not including newline). Among other things, this means that if you treat the input as a sequence of bytes rather than a sequence of characters, your program will still likely comply with the specification (unless your language's I/O encoding is very weird). As such, the definition of a palindrome in the previous bullet only really matters when checking that the program has a correct form.
Hiding half the program in a comment or string literal, while being uncreative, is legal; you're being scored on length, not creativity, so feel free to use "boring" methods to ensure your program is a palindrome. Of course, because you're being scored on length, parts of your program that don't do anything are going to worsen your score, so being able to use both halves of your program is likely going to be helpful if you can manage it.
Because the victory criterion is measured in bytes, you'll need to specify the encoding in which your program is written to be able to score it (although in many cases it will be obvious which encoding you're using).

Victory criterion

Even though the program needs to be a palindrome at the character level, we're using bytes to see who wins. Specifically, the shorter your program is, measured in bytes, the better; this is a code-golf challenge. In order to allow submissions (especially submissions in the same language) to be compared, place a byte count for your program in the header of your submission (plus a character count, if it differs from the number of bytes).

Brachylog (2), 3 bytes in Brachylog's codepage

I↔I

Try it online!

This is a full program that takes input via standard input (using Brachylog's syntax for constants, i.e. strings are enclosed in double quotes), and outputs via standard output. The outputs are true. for a palindromic input, and false. for a non-palindromic input.

Not only is this program palindromic, it also has left/right (and probably in some fonts up/down) mirror symmetry.

Explanation

In Brachylog, capital letters mark points in the program which have identical values; this is used almost like an electrical circuit to carry information from one part of the program to another. One consequence of this is that if you enclose a command between an identical pair of capital letters, you're effectively asserting that the command's input and output are the same. Brachylog implicitly takes input, so in this case we're also asserting that the input to the command is the same as the input to the program. In this program, we're using the command ↔, which reverses things (in this case, strings); so the program effectively asserts that the input is the same forwards and backwards.

A full program (as opposed to a function) in Brachylog returns a boolean, false. if there's no way to make all the assertions in the program correct at once, or true. if the assertions in the program are all compatible with each other. We only have one assertion here – that reversing the input does not change it – so the program acts as a palindrome checker.


Python 3, 29 bytes

lambda s,p,a:(a-2*s)**2<8*a*p

Try it online!

Explanation

The cop's position at time t is st.

The robber's position at time t is a(t)(t+1)/2 + p.

The signed distance from the cop to the robber is (a/2)t^2 + (a/2-s)t + p.

It never reaches zero if the discriminant is negative, the discriminant being (a/2 - s)^2 - 4(a/2)(p) = [(a-2s)^2-8ap]/4, which has the same sign as (a-2s)^2-8ap.


Recognise a Digit from a Positional Encoding Starting an the origin on an infinite grid, you follow a predetermined path going up (U), down (D), left (L), or right (R). You paint every square you visit, including the square you started at and the square you finish at. Using this method, we can paint the number six using the instructions RRDDLLUUUURR:

The origin is shown as a green star. We call this a positional encoding of the number six. Note that a positional encoding is not unique; the encoding LLUURRDDUULLUURR also encodes the number six with some redundancy:

Note that if you visit a square you've already painted in your path, you leave it as is.
Challenge
Given a positional encoding of one of the digits zero through nine taken as a string, output which digit it encodes.
All digits will be encoded in a \$3\times5\$ format as follows:
#     ###   ###   # #   ###
#       #     #   # #   #
#     ###   ###   ###   ###
#     #       #     #     #
#     ###   ###     #   ###

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

Note that:

The positional encoding given will always map to one of the ten digits given above exactly; the input string is guaranteed to be valid.
The digit will never be mirrored or rotated.
There may be redundancy in the encoding (eg LR).
The square you start at is always painted.

Test Cases
Input                -> Output
DDDD                 -> 1
UUUU                 -> 1
DDUDDUDD             -> 1
DDUUUUDDUUDD         -> 1
LRRDDLLDDRLRR        -> 2
LDDRRLLUURRUULL      -> 2
RRDDLLRRDDLL         -> 3
LLRRUULLRLRRUUDULL   -> 3
LUUDDRRUUDDDD        -> 4
DDLLUUDDRRDD         -> 4
LLDDRRDDLL           -> 5
DLLRRUULLUURRLLRR    -> 5
RRDDLLUUUURR         -> 6
LLUURRDDUULLUURR     -> 6
RRDDLLUURRDDLLUUUURR -> 6
RRDDDD               -> 7
LLRRDDDD             -> 7
LUURRDDDDLLU         -> 8
RUULLUURRDDLLDD      -> 8
RRDDLLUURRDDDDLL     -> 9
DUDLRLLRRUULLRRUULLD -> 9
RRUUUULLDDD          -> 0
UUUUDDDDRRUUUULRDDDD -> 0

Also in list form:
[['DDDD', 1], ['UUUU', 1], ['DDUDDUDD', 1], ['DDUUUUDDUUDD', 1], ['LRRDDLLDDRLRR', 2], ['LDDRRLLUURRUULL', 2], ['RRDDLLRRDDLL', 3], ['LLRRUULLRLRRUUDULL', 3], ['LUUDDRRUUDDDD', 4], ['DDLLUUDDRRDD', 4], ['LLDDRRDDLL', 5], ['DLLRRUULLUURRLLRR', 5], ['RRDDLLUUUURR', 6], ['LLUURRDDUULLUURR', 6], ['RRDDLLUURRDDLLUUUURR', 6], ['RRDDDD', 7], ['LLRRDDDD', 7], ['LUURRDDDDLLU', 8], ['RUULLUURRDDLLDD', 8], ['RRDDLLUURRDDDDLL', 9], ['DUDLRLLRRUULLRRUULLD', 9], ['RRUUUULLDDD', 0], ['UUUUDDDDRRUUUULRDDDD', 0]]

Scoring
Shortest code in bytes wins.

JavaScript (Node.js),  89 ... 77  71 bytes
Saved 6 bytes by using the modulo chain provided by @KjetilS.
s=>Buffer(s).map(c=>o|=p*=4**(c%5)/8,o=p=4**8)|(o/=o&-o)*321%3081%53%11

Try it online!
How?
We take the ASCII code \$c\$ of the direction character modulo \$5\$ to map it to an index in \$\{0,1,2,3\}\$.
For each direction, we update a bit mask \$p\$ by shifting it by a specific amount and mark the bits that are visited in another bit mask \$o\$.
 char. | ASCII | mod 5 | shift
-------+-------+-------+-------
  'U'  |   85  |   0   | >> 3
  'L'  |   76  |   1   | >> 1
  'R'  |   82  |   2   | << 1
  'D'  |   68  |   3   | << 3

Conveniently, the shift is equivalent to multiply \$p\$ by:
$$\frac{4^{(c\bmod 5)}}{8}$$
We start with both \$p\$ and \$o\$ set to \$4^8=2^{16}\$. This value is safe because we will never right-shift by more than \$4\times 3 + 2\times 1=14\$ (e.g. with "UUUULL", which draws a \$7\$, or any other path going from the bottom-right to the top-left corner). Likewise, we will never left-shift by more than \$14\$ and never exceed \$2^{30}\$. So, both \$p\$ and \$o\$ remain 32-bit values.
Because we don't know which cell in the digit was our starting point, we normalize the final value of \$o\$ by removing all trailing zeros:
o /= o & -o

We end up with a unique 15-bit key identifying the digit.
 digit |   binary mask   | decimal
-------+-----------------+---------
   0   | 111101101101111 |  31599
   1   | 001001001001001 |   4681
   2   | 111001111100111 |  29671
   3   | 111100111100111 |  31207
   4   | 100100111101101 |  18925
   5   | 111100111001111 |  31183
   6   | 111101111001111 |  31695
   7   | 100100100100111 |  18727
   8   | 111101111101111 |  31727
   9   | 111100111101111 |  31215

It can be seen as a binary representation of the digit shape rotated by 180°. For instance:
                       100    111
                       100    001
100 100 100 100 111 -> 100 -> 001 -> "7"
                       100    001
                       111    001

We apply the following function to turn it into the expected digit:
$$f(n)=\big(((n\times 321)\bmod 3081)\bmod 53\big)\bmod 11$$


Turn an integer n into a list containing it n times Given an integer n as input, return a list containing n, repeated n times. For example, the program would take 5 and turn it into [5,5,5,5,5]. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed.

This is code-golf, so standard rules apply.

Jelly, 1 byte

x

Try it online!

Note that this is not the “repeat n n times” built-in — its function is more general than that. For example 4,5,6x1,2,3 equals [4, 5, 5, 6, 6, 6]. Given only one argument, Jelly just happens to use it as both the left and right argument for the supplied link, but this functionality is not inherent to x.

If this doesn’t count, there are various fun 2-byte alternatives:

x` ṁ` Ra Rị R» a€ oR oḶ oṬ oẊ Ḷị Ḷ» Ṭị Ṭ» Ẋị Ẋ» ị€ ṛ€ ȧ€ »€

etc.


Make it look like I'm working Often, I find myself running a script or query that will take a significant amount of time to run.  I can leave that script open and enjoy some guilt-free procrastination.
Now, what if I could write a script that seems to be one of the above scripts to any onlookers, but in looks only?  I could put it up on a screen and enjoy days of kitten livestreams before anyone realised that all the complicated rigmarole on the screen didn't have anything to do with my actual job.
Your challenge is to write this script for me (yes, I'm that lazy).
A good answer will:

Make something appear on the screen that looks like a script is doing work.  "Screen" can be terminal, browser, etc.
Be fairly original (yes, we've all seen the neverending progress bar programs)
Survive cursory examination by a technical person

A bad answer will:

Get me fired
Rehash something we all were forwarded in the 90's

A stellar answer might:

Transcend one of the bad bullet points above (for instance)
Survive critical examination
*gasp* actually do something that's useful or aids in my work shirking

Acceptance will be based on votes, with bonus from real-life results.  I will actually run these scripts (Linux Mint 16) at work when my screen is visible (meetings and the like) to determine detection.  If anyone notices that it's faking, you're out of the running.  If someone comments on how hard I'm working, +5 bonus upvotes for you.
"Useful" in this case can apply to any coder, but if you're looking for that extra shine on your teacher-bound apple, I'm a full-stack webdev who works in code roughly according to my tags.
Question partially inspired by this.
Results
Disappointingly, I didn't get any comments either way on these entries.  They're all awesome, so you're all winners in my heart.  However, Loktar has the most votes by a long shot, so he gets the +15 from the accept.  Congrats!

JavaScript

So I went a little crazy with this. I did it between breaks from working on my GUI to track IP's using Visual Basic.

You can access it by going to the super serious domain I made for it tonight as well so you can look busy anywhere Gui Hacker and fork and create your own from the following sources

Fiddle
CodePen
github

Basically, if you have this running no one will bother you because they know you are doing some serious stuff.

var canvas = document.querySelector(".hacker-3d-shiz"),
  ctx = canvas.getContext("2d"),
  canvasBars = document.querySelector(".bars-and-stuff"),
  ctxBars = canvasBars.getContext("2d"),
  outputConsole = document.querySelector(".output-console");

canvas.width = (window.innerWidth / 3) * 2;
canvas.height = window.innerHeight / 3;

canvasBars.width = window.innerWidth / 3;
canvasBars.height = canvas.height;

outputConsole.style.height = (window.innerHeight / 3) * 2 + 'px';
outputConsole.style.top = window.innerHeight / 3 + 'px'

/* Graphics stuff */
function Square(z) {
  this.width = canvas.width / 2;
  this.height = canvas.height;
  z = z || 0;

  this.points = [
    new Point({
      x: (canvas.width / 2) - this.width,
      y: (canvas.height / 2) - this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) + this.width,
      y: (canvas.height / 2) - this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) + this.width,
      y: (canvas.height / 2) + this.height,
      z: z
    }),
    new Point({
      x: (canvas.width / 2) - this.width,
      y: (canvas.height / 2) + this.height,
      z: z
    })
  ];
  this.dist = 0;
}

Square.prototype.update = function() {
  for (var p = 0; p < this.points.length; p++) {
    this.points[p].rotateZ(0.001);
    this.points[p].z -= 3;
    if (this.points[p].z < -300) {
      this.points[p].z = 2700;
    }
    this.points[p].map2D();
  }
}

Square.prototype.render = function() {
  ctx.beginPath();
  ctx.moveTo(this.points[0].xPos, this.points[0].yPos);
  for (var p = 1; p < this.points.length; p++) {
    if (this.points[p].z > -(focal - 50)) {
      ctx.lineTo(this.points[p].xPos, this.points[p].yPos);
    }
  }

  ctx.closePath();
  ctx.stroke();

  this.dist = this.points[this.points.length - 1].z;

};

function Point(pos) {
  this.x = pos.x - canvas.width / 2 || 0;
  this.y = pos.y - canvas.height / 2 || 0;
  this.z = pos.z || 0;

  this.cX = 0;
  this.cY = 0;
  this.cZ = 0;

  this.xPos = 0;
  this.yPos = 0;
  this.map2D();
}

Point.prototype.rotateZ = function(angleZ) {
  var cosZ = Math.cos(angleZ),
    sinZ = Math.sin(angleZ),
    x1 = this.x * cosZ - this.y * sinZ,
    y1 = this.y * cosZ + this.x * sinZ;

  this.x = x1;
  this.y = y1;
}

Point.prototype.map2D = function() {
  var scaleX = focal / (focal + this.z + this.cZ),
    scaleY = focal / (focal + this.z + this.cZ);

  this.xPos = vpx + (this.cX + this.x) * scaleX;
  this.yPos = vpy + (this.cY + this.y) * scaleY;
};

// Init graphics stuff
var squares = [],
  focal = canvas.width / 2,
  vpx = canvas.width / 2,
  vpy = canvas.height / 2,
  barVals = [],
  sineVal = 0;

for (var i = 0; i < 15; i++) {
  squares.push(new Square(-300 + (i * 200)));
}

//ctx.lineWidth = 2;
ctx.strokeStyle = ctxBars.strokeStyle = ctxBars.fillStyle = '#00FF00';

/* fake console stuff */
var commandStart = ['Performing DNS Lookups for',
    'Searching ',
    'Analyzing ',
    'Estimating Approximate Location of ',
    'Compressing ',
    'Requesting Authorization From : ',
    'wget -a -t ',
    'tar -xzf ',
    'Entering Location ',
    'Compilation Started of ',
    'Downloading '
  ],
  commandParts = ['Data Structure',
    'http://wwjd.com?au&2',
    'Texture',
    'TPS Reports',
    ' .... Searching ... ',
    'http://zanb.se/?23&88&far=2',
    'http://ab.ret45-33/?timing=1ww'
  ],
  commandResponses = ['Authorizing ',
    'Authorized...',
    'Access Granted..',
    'Going Deeper....',
    'Compression Complete.',
    'Compilation of Data Structures Complete..',
    'Entering Security Console...',
    'Encryption Unsuccesful Attempting Retry...',
    'Waiting for response...',
    '....Searching...',
    'Calculating Space Requirements '
  ],
  isProcessing = false,
  processTime = 0,
  lastProcess = 0;

function render() {
  ctx.clearRect(0, 0, canvas.width, canvas.height);

  squares.sort(function(a, b) {
    return b.dist - a.dist;
  });
  for (var i = 0, len = squares.length; i < len; i++) {
    squares[i].update();
    squares[i].render();
  }

  ctxBars.clearRect(0, 0, canvasBars.width, canvasBars.height);

  ctxBars.beginPath();
  var y = canvasBars.height / 6;
  ctxBars.moveTo(0, y);

  for (i = 0; i < canvasBars.width; i++) {
    var ran = (Math.random() * 20) - 10;
    if (Math.random() > 0.98) {
      ran = (Math.random() * 50) - 25
    }
    ctxBars.lineTo(i, y + ran);
  }

  ctxBars.stroke();

  for (i = 0; i < canvasBars.width; i += 20) {
    if (!barVals[i]) {
      barVals[i] = {
        val: Math.random() * (canvasBars.height / 2),
        freq: 0.1,
        sineVal: Math.random() * 100
      };
    }

    barVals[i].sineVal += barVals[i].freq;
    barVals[i].val += Math.sin(barVals[i].sineVal * Math.PI / 2) * 5;
    ctxBars.fillRect(i + 5, canvasBars.height, 15, -barVals[i].val);
  }

  requestAnimationFrame(render);
}

function consoleOutput() {
  var textEl = document.createElement('p');

  if (isProcessing) {
    textEl = document.createElement('span');
    textEl.textContent += Math.random() + " ";
    if (Date.now() > lastProcess + processTime) {
      isProcessing = false;
    }
  } else {
    var commandType = ~~(Math.random() * 4);
    switch (commandType) {
      case 0:
        textEl.textContent = commandStart[~~(Math.random() * commandStart.length)] + commandParts[~~(Math.random() * commandParts.length)];
        break;
      case 3:
        isProcessing = true;
        processTime = ~~(Math.random() * 5000);
        lastProcess = Date.now();
      default:
        textEl.textContent = commandResponses[~~(Math.random() * commandResponses.length)];
        break;
    }
  }

  outputConsole.scrollTop = outputConsole.scrollHeight;
  outputConsole.appendChild(textEl);

  if (outputConsole.scrollHeight > window.innerHeight) {
    var removeNodes = outputConsole.querySelectorAll('*');
    for (var n = 0; n < ~~(removeNodes.length / 3); n++) {
      outputConsole.removeChild(removeNodes[n]);
    }
  }

  setTimeout(consoleOutput, ~~(Math.random() * 200));
}

render();
consoleOutput();

window.addEventListener('resize', function() {
  canvas.width = (window.innerWidth / 3) * 2;
  canvas.height = window.innerHeight / 3;

  canvasBars.width = window.innerWidth / 3;
  canvasBars.height = canvas.height;

  outputConsole.style.height = (window.innerHeight / 3) * 2 + 'px';
  outputConsole.style.top = window.innerHeight / 3 + 'px';

  focal = canvas.width / 2;
  vpx = canvas.width / 2;
  vpy = canvas.height / 2;
  ctx.strokeStyle = ctxBars.strokeStyle = ctxBars.fillStyle = '#00FF00';
});
@font-face {
  font-family: 'Source Code Pro';
  font-style: normal;
  font-weight: 400;
  src: local('Source Code Pro'), local('SourceCodePro-Regular'), url(http://themes.googleusercontent.com/static/fonts/sourcecodepro/v4/mrl8jkM18OlOQN8JLgasDxM0YzuT7MdOe03otPbuUS0.woff) format('woff');
}
body {
  font-family: 'Source Code Pro';
  background: #000;
  color: #00FF00;
  margin: 0;
  font-size: 13px;
}
canvas {
  position: absolute;
  top: 0;
  left: 0;
}
.bars-and-stuff {
  left: 66.6%;
}
.output-console {
  position: fixed;
  overflow: hidden;
}
p {
  margin: 0
}
<canvas class='hacker-3d-shiz'></canvas>
<canvas class='bars-and-stuff'></canvas>


Find the 10-adic cube root of 3 I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10.

Things carry infinitely to the left and vanish. To see what I mean, note that ...6667 * 3 = 1 in the 10-adic land, since the "2" that carries to the left goes to infinity.

Addition and multiplication make sense for 10-adic numbers, since the last n digits of the sum/product only depend on the last n digits of the summands/multiplicands.

Given n, you need to print the last n digits of the 10-adic cube root of 3, i.e. x satisfiying x*x*x = 3.

It ends:

...878683312291648481630318492665160423850087895134587

Your code must terminate for n=1000 before submission.

Let's say that if the number you need to print begins with zero, then you don't need to print the leading zeroes, since it isn't actually the point to print extra zeroes.

This is code-golf. Shortest answer in bytes wins.

Python 2, 33 bytes

lambda k:pow(3,10**k*2/3+1,10**k)

Try it online!

The pow function efficiently computes the modular exponent 3**(10**k*2/3+1)%10**k.

We're asked to find a solution to r**3 = 3 (mod 10**k). We want to find an exponent e for which the map x -> x**e is inverse to cubing x -> x**3 working mod 10**k, just as the decryption and encryption exponents in RSA cancel to produce the original value. This means that (x**3)**e = x (mod 10**k) for all x. (We'll assume throughout that gcd(x,10) = 1.)  Then, we can recover r by inverting the cubing to get r = 3**e (mod 10**k).

Expanding out (r**3)**e = r (mod 10**k), we get

r**(3*e-1) = 1 (mod 10**k)

We're looking for an exponent 3*e-1 that guarantees that multiplying that many copies gives us 1.

Multiplication modulo 10**k forms a group for invertible numbers, that is those with gcd(x,10) = 1. By Lagrange's Theorem, x**c = 1 where c is the count of elements in the group. For the group modulo N, that count is the Euler totient value φ(N), the number of values from 1 to N that are relatively prime to N. So, we have  r**φ(10**k) = 1 (mod 10**k). Therefore, its suffices for 3*e-1 to be a multiple of φ(10**k).

We compute

φ(10**k) = φ(5**k) φ(2**k)= 4 * 5**(k-1) * 2**(k-1) = 4 * 10**(k-1)`

So, we want 3*e-1 to be a multiple of 4 * 10**(k-1)

3*e - 1 = r * 4 * 10**(k-1)
e = (4r * 10**(k-1) + 1)/3

Many choices are possible for r, but r=5 gives the short expression

e = (2 * 10**k + 1)/3

with e a whole number. A little golfing using floor-division shortens e to 10**k*2/3+1, and expressing r = 3**e (mod 10**k) gives the desired result r.


Find Patterns in Strings In this challence, your task is to locate substrings with a given structure.

Input

Your input shall be two non-empty alphanumeric strings, a pattern p and a text t.
The idea is that each character of p represents a contiguous non-empty substring of t which occur next to each other, and p represents their concatenation.
Identical characters correspond to identical substrings; for example, the pattern aa represents any non-empty square (a string obtained by concatenating a shorter string to itself).
Thus the pattern aa can match the substring byebye, with each a matching bye.

Output

If the text t contains a substring that p matches, then your output shall be that substring, with colons : inserted between the strings that correspond to characters of p.
For example, if we have t = byebyenow and p = aa, then bye:bye is an acceptable output.
There may be several choices for the matching substring, but you shall only output one of them.

If t does not contain a matching substring, your output shall be a sad face :(.

Rules and Clarifications

Different characters of p can correspond to identical substrings, so p = aba can match the string AAA.
Note that the characters must correspond to non-empty strings; in particular, if p is longer than t, the output must be :(.

You can write a full program or a function, and you can also change the order of the two inputs.
The lowest byte count wins, and standard loopholes are disallowed.

Test Cases

Given in the format pattern text -> output.
Note that other acceptable outputs may exist.

a Not -> N
aa Not -> :(
abcd Not -> :(
aaa rerere -> re:re:re
xx ABAAAB -> A:A
MMM ABABBAABBAABBA -> ABBA:ABBA:ABBA
x33x 10100110011001 -> 10:1001:1001:10
abcacb 0a00cca0aa0cc0ca0aa0c00c0aaa0c -> c:a0aa:0c:c:0c:a0aa
abccab 0a00cca0aa0cc0ca0aa0c00c0aaa0c -> a:a:0c0:0c0:a:a
abcbcab 0a00cca0aa0cc0ca0aa0c00c0aaa0c -> :(
abcbdcab 0a00cca0aa0cc0ca0aa0c00c0aaa0c -> 00:c:ca0aa0c:c:0:ca0aa0c:00:c

Python, 207 bytes

import re
h=lambda x:"a"+str(ord(x))
def g(a,b):
 c,d="",set()
 for e in a:
  c+=["(?P<"+h(e)+">.+)","(?P="+h(e)+")"][e in d]
  d.add(e)
 f=re.search(c,b)
 return f and":".join(f.group(h(e))for e in a)or":("

Call with g(pattern, string)

Uses the re module to do most of the work.


Complete the Magic Square Background
A magic square is an n×n matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows:
4 9 2
3 5 7
8 1 6

Here, each row, column, and diagonal sum to the magic sum of 15, which can be calculated with the following formula:
$$
n × \frac{n^2 + 1}{2}
$$
Even if you didn't have the full n×n magic square, you could reproduce it without guessing. For example, given just the 4, 9, 2, and 3 of the prior magic square, you could fill
4 9 2    4 9 2    4 9 2    4 9 2    4 9 2    4 9 2
3 _ _ => 3 _ _ => 3 5 _ => 3 5 7 => 3 5 7 => 3 5 7
_ _ _    8 _ _    8 _ _    8 _ _    8 1 _    8 1 6

Task
Given a partially-filled magic square, your program or function should output the full magic square.
The input is guaranteed to be part of of a magic square, such that the only deduction necessary to solve it is taking a row, column, or diagonal in which n-1 values are determined and filling in the final entry (without this rule, 4 9 _ / _ _ _ / _ _ _ would be a valid input since only one magic square starts 4 9, but that would require a more complicated approach or a brute-force of all possibilities).
Input and output may be any reasonable format for a square matrix (n×n matrix datatype; string representations; length-n×n flat array; etc.). In all formats, you may optionally take n as another input.
You may use any character or value other than _ in the input to represent blanks as long as that value is unmistakable for a possible entry.
Related decision-problem variant: Is Magic Possible?
Sample Testcases
(one newline between input and output; three between cases)
4 9 2
3 5 7
8 1 6

4 9 2
3 5 7
8 1 6

4 9 2
3 _ _
_ _ _

4 9 2
3 5 7
8 1 6

4 9 _
_ 5 _
_ _ _

4 9 2
3 5 7
8 1 6

_ _ _
_ 5 7
_ 1 6

4 9 2
3 5 7
8 1 6

_   16  13  _
11  5   _   _
7   9   12  6
_   _   _   15

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

1   23  _   4   21
15  14  _   18  11
_   _   _   _   _
20  8   _   12  6
5   3   _   22  25

1   23  16  4   21
15  14  7   18  11
24  17  13  9   2
20  8   19  12  6
5   3   10  22  25

MATL, 36 bytes
`nZ@[]etGg)GXz-yt!hs&ytXdwPXdhsh&-ha

The input is an \$ n \times n\$ matrix, with \$0\$ for the unknown numbers.
The code keeps generating random \$ n \times n\$ matrices formed by the numbers \$1, \dots, n^2\$ until one such matrix meets the required conditions. This procedure is guaranteed to finish with probability one.
This is a terrible approach, in that:

running time is random, and unbounded;
average running time increases as \$(n^2)!\$ (that's more than exponentially);
and so it very likely times out in the online interpreter.

... but hey, it's the shortest answer so far!
(Don't) try it online.
See below a sped-up animated GIF of an example run which happened to take about 2 minutes, here compressed to a few seconds.

Explanation
`         % Do...while
  n       %   Number of elements. This implictly takes the input in the first
          %   iteration, or uses the candidate solution from the previous iteration.
          %   Let this number be denoted as N
  Z@      %   Random permutation of integers 1, 2, ..., N
  []e     %   Reshape as a square matrix. This yields a candidate solution
  t       %   Duplicate
  Gg)     %   Push input, convert to logical, index: this produces a column vector
          %   of the entries of the candidate solution that correspond to nonzero
          %   entries in the input matrix
  GXz     %   Push input, take its nonzero elements. Gives a column vector
  -       %   Element-wise difference (*). This will be all zeros for a valid
          %   solution
  y       %   Duplicate second-top object from the stack, that is, the candidate
          %   solution
  t!      %   Duplicate, transpose
  h       %   Concatenate horizontally
  s       %   Sum of columns. This also gives the sum of rows, thanks to the
          %   concatenated, transposed copy. The result is a two-element row
          %   vector (**)
  &y      %   Duplicate third-top object from the stack: the candidate solution
  tXd     %   Duplicate, extract diagonal as a column vector
  wPXd    %   Swap, flip vertically, extract diagonal. This gives the anti-diagonal
          %   as a column vector
  h       %   Concatenate horizontally
  s       %   Sum of each column. This gives the sum of the diagonal and that
          %   of the anti-diagonal
  h       %   Concatenate horizontally with (**)
  &-      %   Matrix of all element-wise differences. This will be a matrix of
          %   zeros for a valid solution (***)
  h       %   Concatenate (*) and (***) horizontally. Since sizes do not match,
          %   both (*) and (***) are first linearized to row vectors, and the
          %   result is a row vector
  a       %   Any. This gives true if any element is non-zero
          % End (implicit). A new iteration is run if the top of the stack is true
          % Display (implicit). The candidate solution from the last iteration is
          % the valid solution


The vanilla factorial challenge Task
Given a non-negative integer \$n\$, evaluate the factorial \$n!\$.
The factorial is defined as follows:
$$
n!=\begin{cases}1 & n=0\\n\times(n-1)!&n>0\end{cases}
$$
Rules

All default I/O methods are allowed.
Standard loopholes are forbidden.
Built-ins are allowed.
There is no time or memory limit.
Giving imprecise or incorrect results for large inputs due to the limit of the native number format is fine, as long as the underlying algorithm is correct. Specifically, it is not allowed to abuse the native number type to trivialize the challenge, which is one of the standard loopholes.
This is code-golf. Shortest code in bytes wins, but feel free to participate in various esolangs (especially the ones hindered by the restrictions of the former challenge).

Test cases
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600

Note: We already have the old factorial challenge, but it has some restrictions on the domain, performance, and banning built-ins. As the consensus here was to create a separate challenge without those restrictions so that more esolangs can participate, here it goes.
Also, we discussed whether we should close the old one as a duplicate of this, and we decided to leave it open.

Shakespeare Programming Language, 106 bytes
,!Ajax,!Puck,!Act I:!Scene I:![Enter Ajax and Puck]Ajax:Listen tothy!You is the factorial ofyou!Open heart

Try it online!
Uses the built-in the factorial of, which isn't described at all in the official docs.
Commented
,!Ajax,!Puck,!Act I:!Scene I:![Enter Ajax and Puck] # header
Ajax:Listen tothy!                                  # read (numeric) input
You is the factorial ofyou!                         # take factorial
Open heart                                          # numeric output


Print E=mc² or E=mc^2, by using the right side of this equation Your task – if you choose to accept it – is to have your program print, literally, either one of the following:

E=mc² (if your language supports Unicode (so no HTML trickery, for instance))
E=mc^2 (if your language doesn't support Unicode)

Here are the conditions:

Your program must consist of exactly two expressions (one representing the m, the other the c, in mc²), which, when fed into your language's representation of the formula mc², and whose result is then printed, will show one of the above results.
Both expression may be assigned to variables before feeding them into mc², but the expressions themselves are not allowed to use intermediate variables.
Both expressions must evaluate to an absolute value larger than 1 (e.g abs(expression) > 1).
You may assign the result of mc² to an intermediate variable, representing the E, before printing this E, but that is not necessary – you may print the result of mc² directly as well.
When printing the final result, you are allowed to use your language's libraries to convert the possibly numeric or binary result to it's string representation.
Added condition: no operator overloading in the final expression that represents mc². The result must be the algebraic result of expression m times expression c squared.

Here's an example template, of what I'm looking for, expressed in PHP:

$m = /* some expression */;
$c = /* some expression */;
$E = $m * pow( $c, 2 );
print $E; // should print on of the results mentioned at the beginning of this challenge

To be honest, I'm not even sure this challenge is doable, but my gut says it must be possible in at least one, or even a few, languages.

Winning solution is the one with the shortest code, in characters, in a week from now.

For clarification, it's perfectly fine to merely do something like this as well — if your language allows for it:

print( someExpression * someOtherExpression ** 2 ); // or something to that effect

... in other words: without assigning anything to any intermediate variables. Just as long as the algebraic calculation remains intact.

C, 66 59 57 bytes
Ignore the compiler warnings. It should work OK as long as you compile it on a big little-endian machine. This code could probably be made a lot shorter on a 64-bit machine, but I'm unable to test:
main(){long long m=1130224008533LL,c=7,E=m*c*c;puts(&E);}

9 fewer characters thanks to @Adam Davis and @Michael :-)


Arithmetic Progressions Your task is to analyse the input and output the formula for the n-th term if it is an arithmetic sequence, otherwise it should print "NAAP".

Input

Input (from STDIN) will consist of few numbers, between 4 to 10 numbers where each number will be in the range between -1000 and 1000 inclusive, separated by a delimiter (a space or a comma or a semi-colon [whichever is to your preference]). Here are some example inputs.

12,14,16,18       //valid
-3 4 5 1 -2 -4    //valid
45;35;-35         //invalid (only three numbers are present instead of the minimum of 4 numbers)
2,32;21,321       //invalid (it uses two different delimiters: `,` and `;`)

Output

The program should first check whether the input is an arithmetic progression or not.

Arithmetic Progressions (AP) in a nutshell: Every AP will have a common difference. This is the difference between the $n$ and ${n-1}$ th terms (basically $a(n+1) - a(n)$ where a is the function for the sequnce). This difference stays the same for any value of $n$ in an AP. If there is no common difference, then it is not an arithmetic sequence. To calculate the value of the n-th term, use this formula $a(n) = a(1) + (n-1)d$ where $a(1)$ is the first term and $d$ is the common difference.

If it is not an arithmetic progression, then the program should print the error message "NAAP" (short for "Not An Arithmetic Progression").

If it is an arithmetic progression, then the program should print the simplified n-th term of the sequence to STDOUT.

Example:

> 1,3,5,7,9
2n-1

Explanation: This is an AP because there is a common difference ($3 - 1 = 2$). Then you use the formula $a(n) = a(1) + (n-1)d$

$$a_n = a_1 + (n-1)d$$

$$a_n = 1 + (n-1)2$$

$$a_n = 1 + 2n - 2$$

$$a_n = 2n - 1$$

Therefore output is 2n-1 (notice the absence of spaces)

Standard loopholes are disallowed by default.

You are allowed to create a function if you want (with the array of numbers as your parameter). If not, then you must create a full program that takes input as a string or an array and outputs accordingly.

Test cases:

1.

1,3,5,7,9
2n-1

2.

1 3 12312 7 9
NAAP

3.

-6;8;22;36;50
14n-20

4.

5,1,-3,-7,-11,-15
-4n+9

5.

-5,-7,-9,-11,-13,-15
-2n-3

6.

3,3,3,3,3,3,3,3,3
0n+3

7.

-4,-5,-6,-7
-1n-3

This is code-golf so the shortest code in bytes wins!
(sorry for bad math-jax)

Any suggestions are welcome!

Pyth, 30 bytes

?tJ{-VtQQ"NAAP"+hJ%"n%+d"-hQhJ

Test suite

To check whether it's a arithmetic procession, this uses a vectorized subtraction between each element and the previous, -VtQQ. A ternary checks if there are multiple values in the result (?tJ{) and prints NAAP if so. Then, to get the + or - right, the mod-formating %+d is used.


Double-duty quine: quine!dlroW ,olleH Write a program that will output its own source code when run, and nothing else. Seems easy, right?

The catch is that when the source code is reversed, your program must output "Hello, World!" exactly, without the quotes.

This is code-golf, so lowest byte count wins.

Edit: Your quine must be a proper quine.

JavaScript (ES6), 42 38 bytes

f=_=>/\//g&&"f="+f||"!dlroW ,olleH">=_

Reversed

_=>"Hello, World!"||f+"=f"&&g//\/>=_=f

Explanation

When reversed, it becomes an anonymous function that returns the string Hello, World!.

The regex /\//g becomes a comment when it is reversed, which allows the syntactically invalid >=_=f to be commented out in the reversed code.


Nobody knows GAU Numbers Let me introduce you to GAU numbers
GAU(1) = 1
GAU(2) = 1122
GAU(3) = 1122122333
GAU(4) = 11221223331223334444
GAU(6) = 11221223331223334444122333444455555122333444455555666666
...
GAU(10) = 11221223331223334444122333444455555122333444455555666666122333444455555666666777777712233344445555566666677777778888888812233344445555566666677777778888888899999999912233344445555566666677777778888888899999999910101010101010101010

This challenge is pretty simple!
Given an integer n>0, find the number of digits of GAU(n)
Example
Let's make GAU(4)
we take the following steps (until we get to 4) and concatenate them
[1][122][122333][1223334444]

you must write every number as many times as its value, but you have to count every time from 1
Let's try to make GAU(5)
we will have to count from 1 to 1
[1]

then from 1 to 2 (but repeating every number as many times as its value)
[122]

then from 1 to 3
[122333]

then from 1 to 4
[1223334444]

and finally from 1 to 5 (this is the last step because we want to find GAU(5))
[122333444455555]

Now we take all these steps and concatenate them
the result is GAU(5)
11221223331223334444122333444455555

We are interested in the number of digits of these GAU numbers.
Test cases
Input⟼Output
n   ⟼ Length(GAU(n))

1   ⟼ 1
2   ⟼ 4
3   ⟼ 10
10  ⟼ 230
50  ⟼ 42190
100 ⟼ 339240
150 ⟼ 1295790

This is a code-golf challenge.
Shortest code in bytes will win.
If you still have any questions please let me know.
I really want everyone here to understand this magic-hidden-complex pattern

SOGL V0.12, 11 10 8 7 5 bytes
∫∫l*+

Try it Here! - this expects to be called as a function with the input on the stack and the input box empty.
7 byte alternative taking the input from the input box:
0.∫∫l*+

Try it Here!
0      push 0
 .     push the input
  ∫    iterate over a range 1..POP (input) inclusive, pusing the current number
   ∫    iterate over 1..POP (above loops number) inclusive, pusing the current number
    l    push that numbers length without popping the number
     *   multiply the length by the number
      +  add to the zero, or whatever it is now


2D partitioned cumulative sum Challenge

Given a matrix M with r rows and c columns, and two Boolean lists V of length r and H of length c, calculate the partitioned cumulative vertical and horizontal sums.

Rules

r and c are greater than or equal to one
H and V begin with a true value
The values in M are within your language's reasonable numeric domain.
Partitioning and summing begins in the top left corner.

Walk through

Given M:

┌──────────────┐
│ 1  2  3  4  5│
│ 6  7  8  9 10│
│11 12 13 14 15│
│16 17 18 19 20│
└──────────────┘

H: 1 0 1 0 0

V: 1 1 0 1

Split M into groups of columns, beginning a new group at every true value of H

┌─────┬────────┐
│ 1  2│ 3  4  5│
│ 6  7│ 8  9 10│
│11 12│13 14 15│
│16 17│18 19 20│
└─────┴────────┘

Split each group of columns into groups of rows, beginning a new group at every true value of V:

┌─────┬────────┐
│ 1  2│ 3  4  5│
├─────┼────────┤
│ 6  7│ 8  9 10│
│11 12│13 14 15│
├─────┼────────┤
│16 17│18 19 20│
└─────┴────────┘

Cumulatively sum each cell horizontally:

┌─────┬────────┐
│ 1  3│ 3  7 12│
├─────┼────────┤
│ 6 13│ 8 17 27│
│11 23│13 27 42│
├─────┼────────┤
│16 33│18 37 57│
└─────┴────────┘

Cumulatively sum each cell vertically:

┌─────┬────────┐
│ 1  3│ 3  7 12│
├─────┼────────┤
│ 6 13│ 8 17 27│
│17 36│21 44 69│
├─────┼────────┤
│16 33│18 37 57│
└─────┴────────┘

Result:

┌──────────────┐
│ 1  3  3  7 12│
│ 6 13  8 17 27│
│17 36 21 44 69│
│16 33 18 37 57│
└──────────────┘

Additional test cases

M:

┌───────────┐
│15 11 11 17│
│13 20 18  8│
└───────────┘

H: 1 0 0 1 V: 1 0

Result:

┌───────────┐
│15 26 37 17│
│28 59 88 25│
└───────────┘

M:

┌─┐
│7│
└─┘

Result (H and V must be 1):

┌─┐
│7│
└─┘

M:

┌──┐
│ 3│
│-1│
│ 4│
└──┘

V: 1 1 0 (H must be 1)

Result:

┌──┐
│ 3│
│-1│
│ 3│
└──┘

M:

┌───────────────────────────────────────────────────────┐
│10    7.7 1.9 1.5 5.4  1.2 7.8 0.6 4.3 1.2  4.5 5.4 0.3│
│ 2.3  3.8 4.1 4.5 1    7.7 3   3.4 6.9 5.8  9.5 1.3 7.5│
│ 9.1  3.7 7.2 9.8 3.9 10   7.6 9.6 7.3 6.2  3.3 9.2 9.4│
│ 4.3  4.9 7.6 2   1.4  5.8 8.1 2.4 1.1 2.3  7.3 3.6 6  │
│ 9.3 10   5.8 9.6 5.7  8.1 2.1 3.9 4   1.3  6.3 3.1 9  │
│ 6.6  1.4 0.5 6.5 4.6  2.1 7.5 4.3 9   7.2  2.8 3.6 4.6│
│ 1.7  9.9 2.4 4.5 1.3  2.6 6.4 7.8 6.2 3.2 10   5.2 8.9│
│ 9.9  5.3 4.5 6.3 1.4  3.1 2.3 7.9 7.8 7.9  9.6 4   5.8│
└───────────────────────────────────────────────────────┘

H: 1 0 0 1 0 1 1 1 0 1 1 1 0

V: 1 0 0 0 0 1 0 0

Result:

┌────────────────────────────────────────────────────────────────┐
│10   17.7 19.6  1.5  6.9  1.2  7.8  0.6  4.9  1.2  4.5  5.4  5.7│
│12.3 23.8 29.8  6   12.4  8.9 10.8  4   15.2  7   14    6.7 14.5│
│21.4 36.6 49.8 15.8 26.1 18.9 18.4 13.6 32.1 13.2 17.3 15.9 33.1│
│25.7 45.8 66.6 17.8 29.5 24.7 26.5 16   35.6 15.5 24.6 19.5 42.7│
│35   65.1 91.7 27.4 44.8 32.8 28.6 19.9 43.5 16.8 30.9 22.6 54.8│
│ 6.6  8    8.5  6.5 11.1  2.1  7.5  4.3 13.3  7.2  2.8  3.6  8.2│
│ 8.3 19.6 22.5 11   16.9  4.7 13.9 12.1 27.3 10.4 12.8  8.8 22.3│
│18.2 34.8 42.2 17.3 24.6  7.8 16.2 20   43   18.3 22.4 12.8 32.1│
└────────────────────────────────────────────────────────────────┘

Jelly, 10 bytes

Zœṗ@+\€Ẏð/

Try it online! and The Last Test Case
 (With a G at the end for readability).

Input is taken as a list [M, H, V].

Explanation

Zœṗ@+\€Ẏð/  Input: [M, H, V]
        ð/  Insert the previous (f) as a dyadic link
            Forms f( f(M, H) , V)
            For f(x, y):
Z             Transpose x
 œṗ@          Partition the rows of x^T at each true in y
    +\€       Compute the cumulative sums in each partition
       Ẏ      Tighten (Joins all the lists at the next depth)


Draw an ASCII Rectangle Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height.

Or, if your language supports it, the two integers can be given as separate inputs.

Assume the width and height will never be less than 3, and they will always be given.

Example Outputs:

[3, 3]

|-|
| |
|-|

[5, 8]

|---|
|   |
|   |
|   |
|   |
|   |
|   |
|---|

[10, 3]

|--------|
|        |
|--------|

This is code-golf, so the answer with the lowest amount of bytes wins.

Jelly, 14 bytes

,þ%,ỊḄị“-|| ”Y

Try it online! or verify all test cases.

How it works

,þ%,ỊḄị“-|| ”Y  Main link. Left argument: w. Right argument: h

,þ              Pair table; yield a 2D array of all pairs [i, j] such that
                1 ≤ i ≤ w and 1 ≤ j ≤ h.
   ,            Pair; yield [w, h].
  %             Take the remainder of the element-wise division of each [i, j]
                by [w, h]. This replaces the highest coordinates with zeroes.
    Ị           Insignificant; map 0 and 1 to 1, all other coordinates to 0.
     Ḅ          Unbinary; convert each pair from base 2 to integer.
                  [0, 0] -> 0 (area)
                  [0, 1] -> 1 (top or bottom edge)
                  [1, 0] -> 2 (left or right edge)
                  [1, 1] -> 3 (vertex)
       “-|| ”   Yield that string. Indices are 1-based and modular in Jelly, so the
                indices of the characters in this string are 1, 2, 3, and 0.
      ị         At-index; replace the integers by the correspoding characters.
             Y  Join, separating by linefeeds.


Print 123454321 without if statements and using only 2 variables The challenge: Write a function, that delivers following output: "1 2 3 4 5 4 3 2 1".

Kids stuff? Of course. But here's the point:

You only can use: 1 for loop, 2 int variables.
You must not use: IF terms, another function, ...
Do not hardcode the output

There are also some more restrictions to make this harder:

No functions like abs or sth. else are allowed! (Yep, it's possible)
No static output like echo "1 2 3 4 5 4 3 2 1"

This is a popularity-contest, so the answer with the most votes wins!

Python

One for loop, one int variable (i), no if, no other functions (unless you consider print or +-*/ as functions, haha):

for i in range(9):
    print i+1 - 2*(i//5)*(i-4),


What are my dimensions? Task: Given the area of a triangle, find a Heronian triangle with that area. Any Heronian triangle with the specified area is allowed.

A Heronian triangle is a triangle with integer sides and integer area. By Heron's formula, a triangle with sides lengths a,b,c has area

sqrt(s*(s-a)*(s-b)*(s-c))

where s=(a+b+c)/2 is half the perimeter of the triangle. This can also be written as

sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c)) / 4

If no such triangle exists, output with a consistent falsey value.

Input: A single, positive integer representing the area of the triangle.

Output: Any three side lengths for such a triangle OR a falsely value.

Examples:

Input -> Output
6 -> 3 4 5
24 -> 4 15 13
114 -> 37 20 19
7 -> error

Standard loopholes apply

This is code golf, shortest answer in bytes wins.

Jelly, 17 16 bytes

-1 byte thanks to Erik the outgolfer (make use of the quick, ¥)

SHð;_P
ṗ3Ç⁼¥Ðf²Ḣ

Brute force application of Heron's formula.

Try it online! (reaches the 60s time out for the 114 tests case. Takes 3m 30s locally - it does check 1143 = 1,481,544 triples)

How?

A true golf solution - given an area a it finds all tuples of three integers between 1 and a (even with repeated triangles and ones of no area), gets their area and filters for those with the desired area (it doesn't even stop as soon as one is found, it ploughs through them all and pops the first result afterwards). Yields 0 if none exists.

SHð;_P - Link 1, get the square of the area of a triangle: list of sides
S      - sum the sides (get the perimeter)
 H     - halve
  ð    - dyadic chain separation (call that p)
    _  - subtraction (vectorises) =    [p-side1,  p-side2,  p-side3]
   ;   - concatenate              = [p, p-side1,  p-side2,  p-side3]
     P - product                  =  p*(p-side1)*(p-side2)*(p-side3)
                                  = the square of Heron's formula = area squared

ṗ3Ç⁼¥Ðf²Ḣ - Main link: number a (area)
ṗ3        - third Cartesian power (all triples of [1,area] : [[1,1,1],[1,1,2],[1,2,1],[1,2,2],[2,1,1],[2,1,2],[2,2,1],[2,2,2], ... ,[a,a,a]]
       ²  - square a
     Ðf   - filter keep if:
    ¥     -   last two links as a dyad:
  Ç       -     call last link (1) as a monad f(list of sides)
   ⁼      -     left (that result) equals right (square of a)?
        Ḣ - head - get the first one (an empty list yields 0, perfect for the falsey case)


Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted The formula

Take for instance the number 300

The prime factors of 300 are [2, 3, 5] (unique numbers that are
factors of 300 and prime)
Squaring each of those numbers will give
you [4, 9, 25]
Summing that list will give you 4 + 9 + 25 = 38
Finally subtract that sum (38) from your original number 300-38 = 262 (this is the result)

Input

Your input will be a positive integer greater than 2. You must check all numbers from 2 to the input value (inclusive) and find the number that produces the greatest result with the formula above.

Output

Your output will be two numbers separated by a space, comma, newline or whatever you language allows (the separation is necessary to distinguish the two numbers). These can be output to a file, stdout, or whatever your language uses. Your goal is to find the number in the range that produces the maximum output when run through the formula above. The first number displayed should be the starting number (like 300) and the second number should be the output that the formula produced (like 262)

Test Cases

Input: 3       Output: 2, -2
Input: 10      Output: 8, 4
Input: 50      Output: 48, 35
Input: 1000    Output: 1000, 971
Input: 9999    Output: 9984, 9802

Worked Through Example

Consider the input of 10, we must run the formula for all numbers from 2-10 (inclusive)

Num PrimeFacs PrimeFacs^2 SumPrimeFacs^2 Result
2   [2]       [4]         4              -2
3   [3]       [9]         9              -6
4   [2]       [4]         4               0
5   [5]       [25]        25             -20
6   [2, 3]    [4, 9]      13             -7
7   [7]       [49]        49             -42
8   [2]       [4]         4               4
9   [3]       [9]         9               0
10  [2, 5]    [4, 25]     29             -19

As you can see the greatest result is 4, which was a result of inputting the value 8 into the formula. That means the output for an input of 10 should be 8, 4

Scoring & Rules

The default rules for inputs and outputs apply: Default for Code Golf: Input/Output methods

The standard loopholes are forbidden: Loopholes that are forbidden by default

Submissions can be functions or full programs

Shortest code in bytes wins

Pyth, 17 15 bytes
_eSttm,-ds^R2{P

Test suite.


Reverse an xxd hexdump Given an xxd hexdump such as this one:
00000000: 1f8b 0808 4920 2258 0003 7069 6c6c 6f77  ....I "X..pillow
00000010: 2e74 7874 00d3 d707 8218 10d0 2799 c545  .txt........'..E
00000020: ba96 41a1 994c 7d60 d650 d53c 44a3 8a22  ..A..L}`.P.<D.."
00000030: cd43 34aa 28d2 3c44 a38a 22cd 4334 aa28  .C4.(.<D..".C4.(
00000040: d20c 00fd 512d 46b8 0500 00              ....Q-F....

Reverse it to produce the original input:
I "Xpillow.txt����'��E��A��L}`�P�<D��"�C4�(�<D��"�C4�(�
                                                      �Q-F�

(This is only an approximation of the original input)
You do not need to expand to shellcodes.
Dupe alert
This is not a duplicate of the other xxd hexdump challenge because this one does not to be expanded to shellcodes.
Rules

You may not use external programs that parse hexdumps (such as xxd).
Standard loopholes apply
This is code-golf, smallest code wins.

V, 27 bytes
ÎdW40|D
Í üî
Ó../<C-v><C-v>x&
éiD@"

Try it online!
Note that <C-v> represents the unprintable character 0x16.
Explanation
This answer is pretty fun because it's about modifying the input into V code and then executing that code. I'll explain each command one at a time
Î                " On every line:
 dW              "   Delete a word
   40|           "   Move to the 40th column
      D          "   Delete everything after this

Í                " Remove all occurrences of
                 " A space
  üî             " or a newline

Now the buffer looks like this:
1f8b080849202258000370696c6c6f772e74787400d3d707821810d02799c545ba9641a1994c7d60d650d53c44a38a22cd4334aa28d23c44a38a22cd4334aa28d20c00fd512d46b8050000

The command to insert a character by its hex value is
<C-v>x<hex-value>

Here is where we start transforming it into actual V code.
Ó                " Replace
 ..              "   Two characters
   /             "   with
    <C-v><C-v>x  "   the text "<C-v>x"
               & "   And the two characters we just matched

<C-v>x1fi<C-v>x8bi<C-v>x08i<C-v>x08i<C-v>x49...

But the command has to be in insert mode. So we insert an 'i' at the beginning.
éi               " Insert an 'i'
  D              " Delete this line
   @"            " And evaluate it as V code


Construct the Identity Matrix The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has 1s spanning from the top left down to the bottom right. You will write a program or a function that will return or output the identity matrix you constructed. Your output may be a 2D array, or numbers separated by spaces/tabs and newlines.

Example input and output

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

1
===
1

2
===
1 0
0 1

3
===
1 0 0
0 1 0
0 0 1

etc.

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

MATL, 2 bytes
Xy

A translation of my Octave answer.
Try it online.
A 4 byte version with no built-ins (thanks to Luis Mendo):
:t!=
:     take input n and a generate row array [1,2,...n]
 t    duplicate
  !   zip
   =  thread compare over the result


Longest mathematical expression in a grid Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a mathematically valid expression formed on this grammar:

E := T '=' T
T := F 'x' T | F
F -> {0..9}+

More formally, a solution will have this form: an equality between a product of terms:

S = F0 x .. x Fp = Fp+1 x .. x Fn

I define N(S) = Max_i(F_i)

If two strings of the same length need to be compared, then I will compare their largest multiplicand. i.e.  30x3=90 < 33x3=99 because  90 < 99

 The grids

Grid 0: 3 x 3

13x
=73
481

which contains: 13x37=481

Grid 1: 7 x 9

6996640
1127=39
186=940
8329706
3683980
6349307
75x19x0
5065350
0051900

which contains:

a=611333
b=599999
c=494687
d=531337
and a*b=366799188667
and c*d=262845506519

Grid 2: 8 x 8

1851x412
40081737
72330964
14461858
17604=67
89653745
13612200
14433193

Grid 3:  16 x 16

0951x71=7=41659x
958525855332=25x
8462=1x119191x76
993928209055089x
1523060251420490
=883152021094970
0146645532106152
87x96=294=x80675
7960948222x0440x
x577x987x0993241
29564563x=x5=800
03508x17050=6565

OK so after a short discussion in the comment sections, I am adding a few restrictions to allow me to do a fair comparison of solutions:

I will run the solution on my Macbook Pro which is 2,4 GHz Core 2 Duo running Mavericks. The language you are going to propose needs to be running natively on my computer, but fortunately, a lot of languages are available on OS X.

I will measure the quality of a program by comparing the time taken to find my hidden solution. Your program will probably find strings that are even longer that the one I hid in the first place, but this can not be avoided as I would need a program that enumerates all the solution of the grids I'm going to submit.. and this is the reason of this code golf..

C, checks about 7,500,000 paths per second

So here is my first pass over this. It's quite horrible code because it's all in one huge main and the two (nested) loops over the left-hand side and right-hand-side of the equation are pretty much exactly the same, but well, it works.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#define MAX_SIZE 32

typedef struct {
    char symbol;
    int visited;
} cell;

typedef struct {
    int x;
    int y;
} coord;

static cell grid[MAX_SIZE][MAX_SIZE];
static int nEquals = 0;
static coord equals[MAX_SIZE*MAX_SIZE];

static coord dirs[8] = {
    { .x = -1, .y = -1 },
    { .x =  0, .y = -1 },
    { .x =  1, .y = -1 },
    { .x =  1, .y =  0 },
    { .x =  1, .y =  1 },
    { .x =  0, .y =  1 },
    { .x = -1, .y =  1 },
    { .x = -1, .y =  0 },
};

static char best_string[2*MAX_SIZE*MAX_SIZE+1];
static int best_length = 0;
static unsigned long long best_factor;

int main(int argc, char *argv[])
{
    FILE *fp = fopen("grid.txt", "r");
    if (!fp) perror("Memory allocation failed"), exit(1);

    fseek(fp, 0L, SEEK_END);
    long lSize = ftell(fp);
    rewind(fp);

    char *buffer = calloc(1, lSize+1);
    if (!buffer)
    {
        fclose(fp);
        perror("Memory allocation failed");
        exit(1);
    }

    if (1 != fread(buffer, lSize, 1, fp))
    {
        fclose(fp);
        free(buffer);
        perror("Reading file failed");
        exit(1);
    }

    fclose(fp);

    char *cp;
    cp = buffer;
    int width = (int)strtol(cp, &cp, 10);
    int height = (int)strtol(cp, &cp, 10);

    ++cp;
    int i, j;
    for (j = 0; j < height; ++j)
    {
        for (i = 0; i < width; ++i)
        {
            grid[j][i].symbol = *cp;
            grid[j][i].visited = 0;

            if (*cp == '=')
            {
                equals[nEquals].x = i;
                equals[nEquals].y = j;
                ++nEquals;
            }
            ++cp;
        }
        ++cp;
    }

    printf("Analysing %d x %d grid...\n", width, height);

    unsigned long long strings_checked = 0;

    clock_t start = clock();

    for (j = 0; j < nEquals; ++j)
    {
        char expression[2*MAX_SIZE*MAX_SIZE+1];
        coord lpos = equals[j];
        coord rpos = equals[j];

        // Set to spaces to ease parsing
        for (i = 0; i < 2*MAX_SIZE*MAX_SIZE+1; ++i)
            expression[i] = ' ';

        int center = MAX_SIZE*MAX_SIZE;
        expression[center] = '=';

        int lhs_size = 0;
        int lhs_n_factors = 0;

        int lhs_dirs[MAX_SIZE*MAX_SIZE];
        for (i = 0; i < MAX_SIZE*MAX_SIZE; ++i)
            lhs_dirs[i] = -2;
        int rhs_dirs[MAX_SIZE*MAX_SIZE];
        for (i = 0; i < MAX_SIZE*MAX_SIZE; ++i)
            rhs_dirs[i] = -2;

        unsigned long long lhs_factors[MAX_SIZE*MAX_SIZE];
        unsigned long long lhs_max_factors[MAX_SIZE*MAX_SIZE];
        unsigned long long lhs_products[MAX_SIZE*MAX_SIZE];
        lhs_max_factors[0] = 0;
        lhs_products[0] = 1;

        while (lhs_size >= 0)
        {
            int dir = ++lhs_dirs[lhs_size];
            char lmost_char = expression[center-lhs_size];

            if (dir == -1)
            {
                grid[lpos.y][lpos.x].visited = 1;

                if (lmost_char == 'x')
                {
                    unsigned long long factor = strtoll(expression+center-lhs_size + 1, NULL, 10);
                    lhs_factors[lhs_n_factors] = factor;
                    ++lhs_n_factors;
                    if (factor > lhs_max_factors[lhs_n_factors-1])
                        lhs_max_factors[lhs_n_factors] = factor;
                    else
                        lhs_max_factors[lhs_n_factors] = lhs_max_factors[lhs_n_factors-1];
                    lhs_products[lhs_n_factors] = lhs_products[lhs_n_factors-1] * factor;
                    continue;
                }
                else if (lmost_char == '=')
                    continue;
                else
                {
                    unsigned long long factor = strtoll(expression+center-lhs_size, NULL, 10);
                    unsigned long long max_lhs_factor;
                    if (factor > lhs_max_factors[lhs_n_factors])
                        max_lhs_factor = factor;
                    else
                        max_lhs_factor = lhs_max_factors[lhs_n_factors];

                    unsigned long long lhs_product = lhs_products[lhs_n_factors] * factor;

                    int rhs_size = 0;

                    int rhs_n_factors = 0;
                    unsigned long long max_rhs_factor = 0;

                    unsigned long long rhs_factors[MAX_SIZE*MAX_SIZE];
                    unsigned long long max_factors[MAX_SIZE*MAX_SIZE];
                    unsigned long long rhs_products[MAX_SIZE*MAX_SIZE];
                    max_factors[0] = max_lhs_factor;
                    rhs_products[0] = 1;

                    char *rhs_factor_pointers[MAX_SIZE*MAX_SIZE];
                    rhs_factor_pointers[0] = expression+center+1;

                    while (rhs_size >= 0)
                    {
                        int dir = ++rhs_dirs[rhs_size];
                        char rmost_char = expression[center+rhs_size];

                        if (dir == -1)
                        {
                            grid[rpos.y][rpos.x].visited = 1;

                            if (rmost_char == 'x')
                            {
                                factor = strtoll(rhs_factor_pointers[rhs_n_factors], NULL, 10);
                                rhs_factors[rhs_n_factors] = factor;
                                ++rhs_n_factors;
                                rhs_factor_pointers[rhs_n_factors] = expression + center + rhs_size + 1;
                                if (factor > max_factors[rhs_n_factors-1])
                                    max_factors[rhs_n_factors] = factor;
                                else
                                    max_factors[rhs_n_factors] = max_factors[rhs_n_factors-1];
                                rhs_products[rhs_n_factors] = rhs_products[rhs_n_factors-1] * factor;
                                continue;
                            }
                            else if (rmost_char == '=')
                                continue;
                            else
                            {
                                // check for solution
                                ++strings_checked;

                                factor = strtoll(rhs_factor_pointers[rhs_n_factors], NULL, 10);
                                unsigned long long max_factor;
                                if (factor > max_factors[rhs_n_factors])
                                    max_factor = factor;
                                else
                                    max_factor = max_factors[rhs_n_factors];

                                unsigned long long rhs_product = rhs_products[rhs_n_factors] * factor;

                                //printf("%.19s = %d\n", expression + center - 9, rhs_product);
                                //  printf("%.51s\n", expression + center - 25);
                                int length = rhs_size + lhs_size + 1;

                                if (lhs_product == rhs_product &&
                                    (length > best_length ||
                                     length == best_length && max_factor > best_factor))
                                {
                                    best_length = length;
                                    best_factor = max_factor;
                                    memcpy(best_string, expression + center - lhs_size, length);
                                    best_string[length] = 0;
                                }

                            }
                        }
                        else if (dir < 8)
                        {
                            coord step = dirs[dir];
                            int new_x = rpos.x + step.x;
                            int new_y = rpos.y + step.y;
                            char new_char;

                            if (new_x < 0 || new_x >= width ||
                                new_y < 0 || new_y >= height ||
                                grid[new_y][new_x].visited ||
                                (new_char = grid[new_y][new_x].symbol) == '=' ||
                                new_char == 'x' && (rmost_char == 'x' || rmost_char == '=')) continue;

                            // TODO: Should diagonally crossing paths be disallowed, too?

                            ++rhs_size;

                            rpos.x = new_x;
                            rpos.y = new_y;
                            expression[center+rhs_size] = new_char;
                        }
                        else
                        {
                            if (rmost_char == 'x')
                                --rhs_n_factors;

                            rhs_dirs[rhs_size] = -2;
                            if (rmost_char != '=') expression[center+rhs_size] = ' ';
                            grid[rpos.y][rpos.x].visited = 0;

                            --rhs_size;
                            coord step = dirs[rhs_dirs[rhs_size]];
                            rpos.x -= step.x;
                            rpos.y -= step.y;
                        }
                    }
                }
            }
            else if (dir < 8)
            {
                coord step = dirs[dir];
                int new_x = lpos.x + step.x;
                int new_y = lpos.y + step.y;
                char new_char;

                if (new_x < 0 || new_x >= width ||
                    new_y < 0 || new_y >= height ||
                    grid[new_y][new_x].visited ||
                    (new_char = grid[new_y][new_x].symbol) == '=' ||
                    new_char == 'x' && (lmost_char == 'x' || lmost_char == '=')) continue;

                // TODO: Should diagonally crossing paths be disallowed, too?

                ++lhs_size;

                lpos.x = new_x;
                lpos.y = new_y;
                expression[center-lhs_size] = new_char;
            }
            else
            {
                if (lmost_char == 'x')
                    --lhs_n_factors;

                lhs_dirs[lhs_size] = -2;
                expression[center-lhs_size] = ' ';
                grid[lpos.y][lpos.x].visited = 0;

                --lhs_size;
                coord step = dirs[lhs_dirs[lhs_size]];
                lpos.x -= step.x;
                lpos.y -= step.y;
            }
        }
    }

    clock_t end = clock();
    float seconds = (float)(end - start) / CLOCKS_PER_SEC;

    printf("Checked %llu paths.\n", strings_checked);

    printf("Took %f seconds.\n", seconds);

    printf("Result: %s\n", best_string);
}

This expects the input stored in a file grid.txt. The first line is the space-separated size of the grid, which is followed by the grid itself. Like:

3 3
13x
=73
481

The algorithm is currently checking all possible well-formed paths (brute force). By well-formed, I mean that paths containing xx or two = are skipped, and I only start looking for paths starting from a = in both directions. Basically, I check all possible LHSs and for each such path, I check all possible RHSs. Over the next few days, I plan to add several optimisations to skip more paths, since the runtime per path will only go up and not down from here.

This will run into some problems with grid sizes of more than some 20 cells, due to integer overflow. I'll have to use some bigint-library when I get to solving those in a reasonable amount of time (which, I'm afraid, will reduce the paths/second a bit).

Currently, the largest sizes that can be solved in a reasonable amount of time at the moment are 7x3 or 5x4 (both taking under two minutes). 8x3 would take about half an hour, and 9x3 or 6x4 or 5x5 would take a few hours (between 1 and 7 I think).

EDIT: Managed to speed it up by close to 20 percent, because now I'm parsing each multiplicand when it's "locked" (i.e. when an x next to it has been parsed) instead of parsing the entire right-hand side for each possible path. And I should add that I observed those 20% for a grid where there's only a single x to be found, so I expect the performance gain for grids with many x to actually be quite substantial. Next stop: bigints.


Plant a binary forest! Inspired by A014486.

Challenge

Given an integer input in base 10, construct a representation for the binary forest corresponding to the input. Representations include, but are not limited to, nested arrays and strings.

How?

Convert the input to binary. 1s represent branches, and 0s represent leaves.

To make this easier to understand, let's use 834 (1101000010 in binary) as an example.

We start with the first digit. The first digit is a 1, so we draw branches:

\ /
 1

or as an array, {{1}}

The next digit is 1, so we draw more branches (we go from left to right):

\ /
 1
  \   /
    1

or as an array, {{1, {1}}}

The next digit is 0, so we place a leaf:

0
 \ /
  1
   \   /
     1

or as an array, {{1, {1, 0}}}

The next digit is a 1, so we place a branch:

     \ /
0     1
 \   /
   1
      \     /
         1

or as an array, {{1, {1, 0, {1}}}}

Repeating the process, we obtain the following tree after the 8th digit:

    0   0
     \ /
0     1
 \   /
   1           0
      \     /
         1

or as an array, {{1, {1, 0, {1, 0, 0}}, 0}}

For the remaining digits, we draw more trees:

The 9th digit is a 0, so we place a leaf (aww, it's a young shoot!)

    0   0
     \ /
0     1
 \   /
   1           0
      \     /
         1         0

or as an array, {{1, {1, 0, {1, 0, 0}}, 0}, 0}

When we use all the digits, we end up with this:

    0   0
     \ /
0     1
 \   /
   1           0       0
      \     /           \ /
         1         0     1

or as an array, {{1, {1, 0, {1, 0, 0}}, 0}, 0, {1, 0}}

That looks weird, so we pad a zero to complete the tree:

    0   0
     \ /
0     1
 \   /
   1           0       0   0
      \     /           \ /
         1         0     1

or as an array, {{1, {1, 0, {1, 0, 0}}, 0}, 0, {1, 0, 0}}

Note that the flattening the array yields the original number in binary, but with a padded zero.

Criteria

The output must clearly show the separation of the trees and branches (if it is not a nested array, please explain your output format).
Extracting all digits from the output must be identical to the binary representation of the input (with the padded zero(s) from the above process).

Test cases

The output may differ as long as it meets the criteria.

0    -> {0}
1    -> {{1, 0, 0}}
44   -> {{1, 0, {1, {1, 0, 0}, 0}}}
63   -> {{1, {1, {1, {1, {1, {1, 0, 0}, 0}, 0}, 0}, 0}, 0}}
404  -> {{1, {1, 0, 0}, {1, 0, {1, 0, 0}}}}
1337 -> {{1, 0, {1, 0, 0}}, {1, {1, {1, 0, 0}, {1, 0, 0}}, 0}}

Scoring

This is code-golf, so lowest bytes wins!

Befunge, 138 117 104 bytes

p&1v
%2:_v#:/2p9p00+1:g00
3\9g<>$\:!v!:<
9g!v ^,"}"_1-\1-:
"0"_2\"1{",,:|:,
`#@_\:#v_"}",>$\:8
,"0":-1<^

Try it online!

Explanation

Line 1 reads a number from stdin, and line 2 converts that number to a binary sequence which it stores in the playfield on line 10. Lines 3 to 5 then iterate over those binary digits, outputting the appropriate tree representation as each digit is processed. The Befunge stack is used to keep track of the depth into the tree and how much leaf space is left at each level so we know when to create a new branch. Lines 6 and 7 handle the final 0 padding to fill up any empty leaves.

In order to golf this as much as possible, I removed the commas from the output as well as the extraneous outer braces. This still hasn't beat the Mathematica solution, but it's been fun trying.

If you want to see what it looked like with the original verbose output format, I saved an earlier version of the code here (131 bytes).


Match the permutations! Your challenge is to create a regex that matches every string permutation of itself, and nothing else. The match must also be case-sensitive.

So, for example, if your regex is:

ABC

It should match (and only match) these strings:

ABC
ACB
BAC
BCA
CAB
CBA

It shouldn't match things like:

AABC (contains an extra A)
ABCD (contains an extra D)
AC   (no B)
AAA  (no B and C, extra 2 A's)
abc  (case-sensitive)

Rules:

You are allowed to use any flavour of regex you like.
Standard loopholes apply.
You must have at least two different characters in your code. That means solutions like 1 are invalid.
The regex should contain only printable ASCII, and nothing else.

JavaScript, 64 57 bytes
4 bytes removed thanks to Martin Ender.
^(?!.*([^])(.*\1){3}]?)[$$[-^?!!.'''-*11{33}5577\\-]{57}$

Try it here.
Explanations (outdated)
^                                  # Beginning of the string.
(?!.*                              # Match only the strings that don't contain...
  (.)(.*\1){4}                     #     5 occurrences of the same character.
  [^1]?[^1]?                       #     Something that doesn't matter.
)
[]zzz^(?!!!.**[)\\1{{44}}666]{64}  # 64 occurrences of these 16 characters.
                                   # Some are duplicated to make sure the regex
                                   # contains 4 occurrences of each character.
\z                                 # End of the string.


Armistice Day Challenge Today, November 11th, is known as Remembrance Day, Armistice Day, or Veterans Day (depending upon the country), and is a day of reflection and gratitude for members of the military and their service, specifically started to reflect the end of European hostilities in the first World War. Let us reflect on that with a simple ASCII-art output of 11/11.

Given an input n, output an ASCII-art rendition of 11/11 that is n units tall. Specifically, each 1 is composed of vertical pipes ||, the slash is composed of slashes //, and each character is two spaces apart. Note that this means varying output widths -- for example, for n=3 below, see how the "bottom" of the slash is two spaces from the 1 to its left, but is four spaces from the 1 on its right, so that the top of the slash lines up appropriately and is two spaces from the 1 on its right.

n = 1
||  ||  //  ||  ||

n = 2
||  ||   //  ||  ||
||  ||  //   ||  ||

n = 3
||  ||    //  ||  ||
||  ||   //   ||  ||
||  ||  //    ||  ||

n = 4
||  ||     //  ||  ||
||  ||    //   ||  ||
||  ||   //    ||  ||
||  ||  //     ||  ||

n = 5
||  ||      //  ||  ||
||  ||     //   ||  ||
||  ||    //    ||  ||
||  ||   //     ||  ||
||  ||  //      ||  ||

and so on.

Input

A single positive integer in any convenient format, n > 0.

Output

An ASCII-art representation of 11/11, following the above rules and examples. Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.


So obviously, P = NP SAT is the problem of determining whether a boolean expression can be made true. For example, (A) can be made true by setting A=TRUE, but (A && !A) can never be true. This problem is known to be NP-complete. See Boolean Satisfiability.

Your task is to write a program for SAT that executes in polynomial time, but may not solve all cases.

For some examples, the reason it is not really polynomial could be because:

There is an edge case that is not obvious but has a poor runtime
The algorithm actually fails to solve the problem in some unexpected case
Some feature of the programming language you are using actually has a longer runtime than you would reasonably expect it to have
Your code actually does something totally different from what it looks like it's doing

You may use any programming language (or combination of languages) you wish. You do not need to provide a formal proof of your algorithm's complexity, but you should at least provide an explanation.

The primary criteria for judging should be how convincing the code is.

This is a popularity contest, so the highest rated answer in a week wins.

C#

  Your task is to write a program for SAT that appears to execute in polynomial time.

"Appears" is unnecessary. I can write a program that really does execute in polynomial time to solve SAT problems. This is quite straightforward in fact.

  MEGA BONUS: If you write a SAT-solver that actually executes in polynomial time, you get a million dollars! But please use a spoiler tag anyway, so others can wonder about it.

Awesome. Please send me the million bucks. Seriously, I have a program right here that will solve SAT with polynomial runtime.

Let me start by stating that I'm going to solve a variation on the SAT problem. I'm going to demonstrate how to write a program that exhibits the unique solution of any 3-SAT problem.  The valuation of each Boolean variable has to be unique for my solver to work.

We begin by declaring a few simple helper methods and types:

class MainClass
{
    class T { }
    class F { }
    delegate void DT(T t);
    delegate void DF(F f);
    static void M(string name, DT dt)
    {
        System.Console.WriteLine(name + ": true");
        dt(new T());
    }
    static void M(string name, DF df)
    {
        System.Console.WriteLine(name + ": false");
        df(new F());
    }
    static T Or(T a1, T a2, T a3) { return new T(); }
    static T Or(T a1, T a2, F a3) { return new T(); }
    static T Or(T a1, F a2, T a3) { return new T(); }
    static T Or(T a1, F a2, F a3) { return new T(); }
    static T Or(F a1, T a2, T a3) { return new T(); }
    static T Or(F a1, T a2, F a3) { return new T(); }
    static T Or(F a1, F a2, T a3) { return new T(); }
    static F Or(F a1, F a2, F a3) { return new F(); }
    static T And(T a1, T a2) { return new T(); }
    static F And(T a1, F a2) { return new F(); }
    static F And(F a1, T a2) { return new F(); }
    static F And(F a1, F a2) { return new F(); }
    static F Not(T a) { return new F(); }
    static T Not(F a) { return new T(); }
    static void MustBeT(T t) { }

Now let's pick a 3-SAT problem to solve. Let's say

(!x3) &
(!x1) &
(x1 | x2 | x1) &
(x2 | x3 | x2)

Let's parenthesize that a bit more.

(!x3) & (
    (!x1) & (
        (x1 | x2 | x1) &
        (x2 | x3 | x2)))

We encode that like this:

static void Main()
{
    M("x1", x1 => M("x2", x2 => M("x3", x3 => MustBeT(
      And(
        Not(x3),
        And(
          Not(x1),
          And(
            Or(x1, x2, x1),
            Or(x2, x3, x2))))))));
}

And sure enough when we run the program, we get a solution to 3-SAT in polynomial time. In fact the runtime is linear in the size of the problem!

x1: false
x2: true
x3: false

   You said polynomial runtime. You said nothing about polynomial compile time. This program forces the C# compiler to try all possible type combinations for x1, x2 and x3, and choose the unique one that exhibits no type errors. The compiler does all the work, so the runtime doesn't have to.  I first exhibited this interesting techinque on my blog in 2007: http://blogs.msdn.com/b/ericlippert/archive/2007/03/28/lambda-expressions-vs-anonymous-methods-part-five.aspx Note that of course this example shows that overload resolution in C# is at least NP-HARD. Whether it is NP-HARD or actually undecidable depends on certain subtle details in how type convertibility works in the presence of generic contravariance, but that's a subject for another day.


Parse RNA into codons Introduction

RNA is the less famous cousin of DNA.
Its main purpose is to control the production of proteins in cells through a process called translation.
In this challenge, your task is to implement a part of this process where the RNA is split into codons.

This challenge is thematically related, but concentrates on another part of the translation process.

Codons

We will think of RNA as a long string over the alphabet of base pairs, AUCG.
In translation, RNA is split into non-overlapping chunks of three base pairs, called codons.
The process begins at a start codon, AUG, and ends at a stop codon, one of UAA, UAG or UGA.
Each codon (except the stop codons) corresponds to an amino acid, and the resulting string of amino acids forms the protein.

Input

Your input is a non-empty string of RNA.

Output

Your output is the list of codons in which the RNA is split, in any reasonable format.
In this simplified model, the process begins at the leftmost start codon AUG, which is included in the output.
It ends when a stop codon is encountered, or when we run out of RNA.
If the input contains no start codon, the output shall be an empty list.

Examples

Consider the input sequence

ACAUGGAUGGACUGUAACCCCAUGC

The parsing begins at the leftmost occurrence of AUG, at index 2.
It continues as follows:

AC AUG GAU GGA CUG UAA CCCCAUGC
   *   ^   ^   ^   +

The codon marked with * is the start codon, and those marked with ^ are also part of the output.
The stop codon is marked with +.
The correct output is

AUG,GAU,GGA,CUG

For the shorter input

ACAUGGAUGGACUGU

the process goes

AC AUG GAU GGA CUG U
   *   ^   ^   ^

This time, a stop codon is not encountered, so the process stops when we run out of base pairs.
The output is the same as above.

Rules and scoring

You can write a full program of a function.
The lowest byte count wins, and standard loopholes are disallowed.

Test cases

GGUACGGAUU ->
GGCGAAAUCGAUGCC -> AUG
ACAUGGAUGGACUGU -> AUG,GAU,GGA,CUG
AUGACGUGAUGCUUGA -> AUG,ACG
UGGUUAGAAUAAUGAGCUAG -> AUG,AGC
ACAUGGAUGGACUGUAACCCCAUGC -> AUG,GAU,GGA,CUG
CUAAGAUGGCAUGAGUAAUGAAUGGAG -> AUG,GCA
AAUGGUUUAAUAAAUGUGAUAUGAUGAUA -> AUG,GUU
UGUCACCAUGUAAGGCAUGCCCAAAAUCAG -> AUG
UAUAGAUGGUGAUGAUGCCAUGAGAUGCAUGUUAAU -> AUG,GUG,AUG,AUG,CCA
AUGCUUAUGAAUGGCAUGUACUAAUAGACUCACUUAAGCGGUGAUGAA -> AUG,CUU,AUG,AAU,GGC,AUG,UAC
UGAUAGAUGUAUGGAUGGGAUGCUCAUAGCUAUAAAUGUUAAAGUUAGUCUAAUGAUGAGUAGCCGAUGGCCUAUGAUGCUGAC -> AUG,UAU,GGA,UGG,GAU,GCU,CAU,AGC,UAU,AAA,UGU

Retina, 39 38 32 30 bytes

M!`AUG|\B\G...
U(AA|AG|GA)\D*

The trailing linefeed is significant.

Output as a linefeed-separated list.

Try it online.

Explanation

M!`AUG|\B\G...

This is match stage which turns the input into a linefeed-separated list of all matches (due to the !). The regex itself matches every codon starting from the first AUG. We achieve this with two separate options. AUG matches unconditionally, so that it can start the list of matches. The second match can be any codon (... matches any three characters), but the \G is a special anchor which ensures that this can only match right after another match. The only problem is that \G also matches at the beginning of the string, which we don't want. Since the input consists only of word characters, we use \B (any position that is not a word boundary) to ensure that this match is not used at the beginning of the input.

U(AA|AG|GA)\D*

This finds the first stop codon, matched as U(AA|AG|GA) as well as everything after it and removes it from the string. Since the first stage split the codons into separate lines, we know that this match is properly aligned with the start codon. We use \D (non-digits) to match any character, since . wouldn't go past the linefeeds, and the input won't contain digits.


Squares in the Squares Given input of a positive integer n, write a program that completes the following process.

Find the smallest positive integer greater than n that is a perfect square and is the concatenation of n and some other number. The order of the digits of n may not be changed. The number concatenated onto n to produce a perfect square may be called r_1.
If r_1 is not a perfect square, repeat the above process with r_1 as the new input to the process. Repeat until r_k is a perfect square, denoted s.
Print the value of sqrt(s).

Input can be taken in any format. You can assume that n is a positive integer. If any r_k has a leading zero (and r_k≠0), the zero can be ignored.

Test cases

Here are some test cases. The process demonstrates the above steps.

Input:   23
Process: 23, 2304, 4
Output:  2

Input:   10
Process: 10, 100, 0
Output:  0

Input:   1
Process: 1, 16, 6, 64, 4
Output:  2

Input:   5
Process: 5, 529, 29, 2916, 16
Output:  4

Input:   145
Process: 145, 145161, 161, 16129, 29, 2916, 16
Output:  4

Input:   1337
Process: 1337, 13373649, 3649, 36493681, 3681, 368102596, 2596, 25969216, 9216
Output:  96

This is code golf. Standard rules apply. The shortest answer (in bytes) wins.

MATL, 35 44.0 bytes
XK``x@2^tVKVXf1=a~]VKVnQ0h)UXKX^t1\

Try it online!
XK        % implicit input: n. Copy to clipboard K
`         % do...while. Each iteration applies the algorithm
  `       %   do...while. Each iteration tests a candidate number
    x     %     delete top of stack
    @2^   %     iteration index squared
    t     %     duplicate
    V     %     convert to string
    K     %     paste from clipboard K: n or r_k
    V     %     convert to string
    Xf    %     find one string within another. Gives indices of starting matches, if any
    1=a~  %     test if some of those indices is 1. If not: next iteration
  ]       %   end. We finish with a perfect square that begins with digits of n or r_k
  V       %   convert to string
  K       %   paste from clipboard K: n or r_k
  VnQ0h   %   index of rightmost characters, as determined by r_k
  )       %   keep those figures only
  U       %   convert to number. This is the new r_k
  XK      %   copy to clipboard K, to be used as input to algorithm again, if needed
  X^      %   square root
  1\      %   fractional part. If not zero: apply algorithm again
          % implitic do...while loop end
          % implicit display


Count Consecutive Characters Given a string containing only letters, output the length of the longest run of consecutive alphabetical letters the word contains, where order does not matter. An example algorithm may sort the word, remove duplicates, and then output the length of the longest run.

Test Cases

watch -> 1
stars -> 3
antidisestablishmentarianism -> 3
backdoor -> 4
a -> 1
tutorials -> 4

For example, antidisestablishmentarianism contains the letters abdehilmnstr. The longest runs are lmn and rst, both of length 3.

Notes

You may take all lowercase, all uppercase, or mixed-case letters as input, but the case cannot encode information about the word (i.e. you cannot make the first n characters capitalized where n is the length of the longest run).

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


How many arguments were passed? Using your language of choice, write a function that takes a variable number of arguments and returns the number of arguments it was called with.

Specifics:

Your language needs to support variadic argument functions: something callable that takes an arbitrary number of arguments and returns a value.
Parameters must be able to be passed individually. This means that passing an array would only count for one parameter. You can use an "all passed arguments" array if your language supports it; the restriction is on how the function is called.
Code that calls this function must not be required to pass the number of arguments in its source. If a compiler inserts the number of arguments as part of a calling convention, that is allowed.
The arguments can be of any type you want. You can support only a single type (e.g. only supporting int is still valid), arbitrary types (any type of argument is allowed), or any combination of argument types (e.g. first arg is int, rest are strings).
Your function may have a maximum number of arguments (especially since resources are finite), but must support at least 2 arguments.

Samples:

f() returns 0
f(1) or f("a") returns 1
f([1, 2, 3]) returns 1 as it is passed an array, not 3 arguments
f(1, 10) or f(1, "a") returns 2

As this is code-golf, the winning solution is the one that uses the fewest number of bytes.

Java (JDK 10), 11 bytes

a->a.length

Try it online!