Recreate an xkcd graph procedurally with your favorite plotting tool Lately there have been quite a number of questions regarding the recreation of xkcd-style graphs like the following one (1064) in various languages.

Your goal is to recreate any existing xkcd comic as close to the original as possible. The comic has to have at least one simple graph or pie chart or similar element.

The highest voted answer wins, not sooner than 10 days after the first valid answer.

Your entry must contain code that displays an xkcd-comic as described above in a graphing language, making at least some use of its plotting tool (Mathematica, MatLab, etc.)

the comic must not be stored as an image, it has to be generated procedulally
there must not be any link whatsoever to the original website, or a mirror of it, or its contents on your hard drive, etc.

Votes should evaluate the similarity of the results to the original, and to a lesser extent, the beauty of the solution. No code golf here, but a solution as short and simple as possible is expected.

Here's a stab.

Postscript

[Count deleted because this isn't a golf question.]

Added a "style" section to make it look more hand-drawn.

Edit: Helvetica responds better than Courier. Tweaked and enhanced this "style" section. And added comments.

%!

%futz with a coordinate pair
/f { 2 { rand 100 mod 100 div 1.47 mul
        dup .4 mul sub add
        exch } repeat } def

/op 2 array def %original point
/cp 2 array def %current point
/setcp { 2 copy cp astore pop } def %set current point
/difcp { cp aload pop %x' y' x y   %diff between cp and point on stack
    3 2 roll exch sub %x' x y'-y
    3 1 roll sub %y'-y x'-x
    exch %dx dy
} def
/scale2 { /n exch def  %scale two values
    n mul exch n mul exch
} def
/add2 {
    3 2 roll add
    3 1 roll add exch
} def
%futz with a path
/fpath {
    2 {
    %flattenpath
    % replace lines with curves
    [ { setcp cp op copy pop /moveto cvx }
        {
            %cp aload pop 4 2 roll 2 copy
            2 copy difcp %x3 y3 x30 y30
            2 copy 1 4 div scale2 %x3 y3 x30 y30 (1/3)x30 (1/3)y30
            cp aload pop add2 %x3 y3 x30 y30 x1 y1
            4 2 roll 3 4 div scale2 %x3 y3 x1 y1 (2/3)x30 (2/3)y30
            cp aload pop add2 %x3 y3 x1 y1 x2 y3
            6 4 roll %x1 y1 x2 y2 x3 y3
            setcp
            /curveto cvx }
        { setcp /curveto cvx }
        { op cp copy pop /closepath cvx } pathforall ] cvx newpath exec
    % chop the curves
    flattenpath
    % futz all the points
    [ { f
        /moveto cvx }
        { f
            /lineto cvx }
        { %f
            f 6 2 roll
            f 6 2 roll
            f 6 2 roll
            2 copy
            /curveto cvx
            3 1 roll
            3{f}repeat /lineto cvx % extra triple-futz'd line after each curve
        }
        { /closepath cvx } pathforall ] cvx newpath exec
    } repeat
} def

%futz with strokes
/oldstroke /stroke load def
/stroke { fpath oldstroke } def

%futz with fills
/oldfill /fill load def
/fill { fpath oldfill } def

%make sure rectstroke doesn't bypass being futzed with
/rectstroke {
    4 2 roll moveto
    1 index 0 rlineto
    0 exch rlineto
    neg 0 rlineto
    closepath
    stroke
} def

%futz with strings
%by making sure show uses our futz'd fill
/show { gsave currentpoint newpath moveto dup
    false charpath 1{fpath}repeat fill grestore stringwidth rmoveto } def

%fatter lines
1 setlinejoin %round joins
currentlinewidth 1.9 mul setlinewidth
%chop curves very small so there's lots of points for futzing
currentflat 6 div setflat

/Helvetica 10 selectfont

<<
/in{72 mul}
>>begin
1 in 1 in translate

0 0 6 in 4 in rectstroke
1 in 3 in moveto (WALKING BACK TO MY) show
1 in 2.8 in moveto (FRONT DOOR AT NIGHT:) show

36 3.5 in moveto
0 -2.8 in rlineto
5 in 0 rlineto
3.45 in .55 in moveto
0 20 rlineto
4.05 in .55 in moveto
0 20 rlineto
2.7 in .40 in moveto
(YARD  STEPS DOOR  INSIDE ) show
0 .05 in rmoveto
.4 in 0 rlineto
currentpoint
stroke
moveto
-10 3 rlineto
0 -6 rlineto fill

2.6 in .45 in moveto
-2 in 0 rlineto
currentpoint
stroke
moveto
10 3 rlineto
0 -6 rlineto fill

(FEAR) .9 in 2.3 in moveto show
(THAT THERE'S) .9 in 2.1 in moveto show
(SOMETHING) .9 in 1.9 in moveto show
(BEHIND ME) .9 in 1.7 in moveto show
1.8 in 1.86 in moveto
2 -26 rlineto
stroke

(FORWARD) 2.2 in 2.1 in moveto show
(SPEED) 2.2 in 1.9 in moveto show
2.75 in 2 in moveto
3 -13 rlineto
stroke

(EMBARRASSMENT) 4.5 in 2.5 in moveto show
4.6 in 2.65 in moveto
-2 20
-5 22
-27 25 rcurveto
stroke

.6 setgray %gray
40 1.6 in moveto
2.7 in 0
2.9 in 20
3.2 in 1.5 in rcurveto
10 20
20 20
30 0 rcurveto
15 -1.7 in
30 -1.8 in
1.4 in -2 in rcurveto
stroke

0 0 1 setrgbcolor %blue
40 1.2 in moveto
.9 in 27
.8 in 20
1.4 in 21 rcurveto
1 in -20
1.2 in 6
1.3 in 1.6 in rcurveto
    10 20
    20 20
    30 0 rcurveto
15 -1.8 in
30 -1.9 in
1.8 in -2.1 in rcurveto
stroke

1 0 0 setrgbcolor %red
40 .9 in moveto
3.3 in 0
3.5 in 20
3.6 in 1.5 in rcurveto
10 72
20 80
30 80 rcurveto
.7 in -10
.3 in -35
1.1 in -40 rcurveto
stroke

%thank you for scrolling all the way down to here. :)


"i" have "i" chance of occuring Design a random number generator where the i th number has i% chance
  of occurring for all 0 < i < 14. 0 should have exactly 9% chance of
  occurring. The seed for the generator should be the system time.
  You cannot use a pre-defined function for random number generation.

Basically 1 has 1% chance of occurring, 2 has 2% chance and so on up to 13 having 13% chance of occurring. This is code-golf, so the shortest code wins.

CJam, 14 bytes

E,_T9t\]ze~es=

Test it here.

Explanation

E,   e# Push [0 1 2 ... 12 13].
_    e# Make a copy.
T9t\ e# Set the first element to 9. Swap with the original range.
]z   e# Wrap them in an array and transpose to get [[9 0] [1 1] [2 2] ... [13 13].
e~   e# Run-length decode to get `[0 0 0 0 0 0 0 0 0 1 2 2 3 3 3 ... 13 13 ... 13 13].
es=  e# Use the current timestamp as a cyclic index into this array.


Determine the busiest time This challenge was greatly inspired by this Stack Overflow post.

Challenge

Given a bunch of clients in terms of when they enter a room and when they exit it, determine the period(s) of time when the room has a maximum number of people. The time resolution should be to the minute.

For example, if there are three clients 8 - 10, 9 - 11, 10 - 12, then the correct answer would be 9 - 11; during this time period, there are two clients in the room, which is the largest possible.

Input

Input will be a list of pairs in some form. That can be either a list of 2-tuples, an even-length list with elements interleaved, etc, any reasonable input format. The times can be given in any reasonable format, in either 12- or 24- hour time. You may also input time as the number of minutes past midnight.

Output

Output should be a list of pairs in some form, but the output is stricter. The output cannot be a flat list, it must be a list of 2-tuples or a list of lists, etc. The times can be output in any reasonable format, in either 12- or 24- hour time. You may also output time as the number of minutes past midnight.

Examples

input
output

INPUT
08:00 - 10:00
09:00 - 11:00
10:00 - 12:00
OUTPUT
09:00 - 11:00

INPUT
08:20 - 09:20
09:00 - 09:10
08:00 - 09:30
08:50 - 10:40
OUTPUT
09:00 - 09:10

INPUT
08:00 - 10:00
09:00 - 10:00
09:30 - 11:00
OUTPUT
09:30 - 10:00 # The output is not always in the input list

INPUT
00:00 - 02:00
01:00 - 03:00
04:00 - 06:00
05:00 - 07:00
OUTPUT # This is the expected output for when there are multiple time ranges with the same "business".
01:00 - 02:00
05:00 - 06:00

You may assume that the second time in a pair will always be after the first time. Time ranges will not run over midnight.

Brachylog, 25 bytes

⟦₂ᵐkᵐcoḅlᵒlᵍthᵐ~c{~k~⟦₂}ᵐ

Try it online!

There's an obvious structure to this answer, which becomes even more obvious if you write it like this:

{⟦₂k}ᵐc oḅ lᵒlᵍ thᵐ ~c{~k~⟦₂}ᵐ

Unfortunately, Brachylog's evaluation order makes it so that the program goes into an infinite loop if you try to take advantage of the structure in question. Still, it's certainly possible to imagine a Brachylog-like language in which this is much shorter.


Build a Markdown bomb I'm sure most of us have heard of zip bombs and similar decompression bomb tricks, where a maliciously crafted input creates a massively disproportionate output.  We even had a question on here to do that to a compiler at one point.
Well, it occurs to me that Markdown is a compression format of sorts, replacing bulky HTML tags with "compressed" MD tokens.  Therefore, might it be possible to build a compression bomb in Markdown?
Challenge rules:

The submission should be a piece of markdown text, between 50 and 256 characters in length.  (Imposing a minimum to head off some smart-aleck posting a 3-character response or similar.)

The submission will be processed by StackExchange's Markdown processor as implemented in this site.

Your score will be the ratio of character count in the resulting HTML to the character count of your Markdown text.

Highest score wins.

Blockquotes, 137,469/256 = 536.99
6,908 characters, 511 new lines, 130,050 spaces
Markdown sure handles nested block-quotes oddly.  Each > character gets turned into

 so a solid 1 to 25 ratio. But wait! When rendering the HTML it also adds two spaces per nesting! Having this try to render causes my browser some grief, and I will keep it in the code-cage for now. Feel free to unlock it yourself!
The code input consists of 255 > followed by & as the last character doesn't transform, but it does get escaped. Thanks BWO ! as the last character which gives the last blockquote the spoiler class with an empty p tag inside. Thanks bta, 11 extra characters
Input:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>!
Output HTML:
...

...

Here is what it looks like in the editor view!

Plotting the results as the number of > increase as suggested by LambdaBeta:


Terrain Reachability Turn-based tactics games like Advance Wars, Wargroove, and Fire Emblem are made up of a square grid of varying terrain with units of differing movement classes requiring different costs for each terrain type. We'll be investigating a subset of that problem.

Challenge

Your task is to determine if one location is reachable from another given a grid of terrain costs and a movement speed.

Units can only move orthogonally where the cost of moving onto a square is the value of the corresponding cell on the grid (moving off is free). For instance, moving from a cell valued 3 onto a cell valued 1 costs 1 movement, but going the other way requires 3. Some squares may be inaccessible.

Example

1 [1] 1  1  1
1  2  2  3  1
2  3  3  3  4
1  3 <1> 3  4

Moving from [1] to <1> requires a minimum of 7 movement points by moving right one square and then down three. Thus, if given 6 or less as the movement speed, you should output a falsy answer.

Example Test Cases

These will use top-left-origin zero-indexed (row, column) coordinates rather than bracketed cells for start and end to make parsing easier. Unreachable cells will be represented with X

Case 1a

1 1 2 1 X
1 2 2 1 1
2 1 1 2 1
X X X 1 2
Speed: 5
From (2, 3) to (0, 1)

Output: True

Case 1b

1 1 2 1 X
1 2 2 1 1
2 1 1 2 1
X X X 1 2
Speed: 4
From (2, 3) to (0, 1)

Output: False

Case 1c

1 1 2 1 X
1 2 2 1 1
2 1 1 2 1
X X X 1 2
Speed: 5
From (0, 1) to (2, 3)

Output: False

Case 2a

3 6 1 1 X 4 1 2 1 X
5 1 2 2 1 1 1 X 1 5
2 1 1 1 2 1 1 1 X 1
2 1 1 3 1 2 3 4 1 2
1 1 2 1 1 4 1 1 1 2
3 2 3 5 6 1 1 X 1 4
Speed: 7
From (3, 4) to (2, 1)

Output: True

Case 2b

3 6 1 1 X 4 1 2 1 X
5 1 2 2 1 1 1 X 1 5
2 1 1 1 2 1 1 1 X 1
2 1 1 3 1 2 3 4 1 2
1 1 2 1 1 4 1 1 1 2
3 2 3 5 6 1 1 X 1 4
Speed: 4
From (3, 4) to (2, 1)

Output: False

Case 2c

3 6 1 1 X 4 1 2 1 X
5 1 2 2 1 1 1 X 1 5
2 1 1 1 2 1 1 1 X 1
2 1 1 3 1 2 3 4 1 2
1 1 2 1 1 4 1 1 1 2
3 2 3 5 6 1 1 X 1 4
Speed: 7
From (1, 8) to (2, 7)

Output: True

Case 3a

2 1 1 2
2 3 3 1
Speed: 3
From (0, 0) to (1, 1)

Output: False

Case 3b

2 1 1 2
2 3 3 1
Speed: 3
From (1, 1) to (0, 0)

Output: True

Rules, Assumptions, and Notes

Standard loopholes are banned, I/O can be in any convenient format
You may assume coordinates are all on the grid
Movement speed will never be over 100
Inaccessible cells may be represented with very large numbers (e.g. 420, 9001, 1 million) or with 0 or null, whichever is most convenient for you.
All inputs will consist of positive integers (unless using null or 0 to represent unreachable cells)

TSQL query, 205 191 bytes
Input is a table variable @t
@x=start xpos, @y=start ypos
@i=end xpos  , @j=end ypos
@ =speed
DECLARE @t table(x int,y int,v int)
INSERT @t
values
(0,0,1),(0,1,1),(0,2,2),(0,3,1),(0,4,null),
(1,0,1),(1,1,2),(1,2,2),(1,3,1),(1,4,1),
(2,0,2),(2,1,1),(2,2,1),(2,3,2),(2,4,1),
(3,0,null),(2,1,null),(2,2,null),(2,3,1),(2,4,2)

DECLARE @x INT=2,@y INT=3,@i INT=0,@j INT=1,@ INT=5;

WITH C as(SELECT @y f,@x r,@ s
UNION ALL
SELECT f+a,r+b,s-v FROM C
JOIN(values(1,0),(0,1),(-1,0),(0,-1))x(a,b)ON
s>0JOIN @t
ON f+a=x and r+b=y)SELECT
max(iif(S>=0and f=@j and r=@i,1,0))FROM c

Try it online ungolfed version


Check if rectangles fill a rectangular space without gaps or overlaps This challenge is based on another similar challenge. Because finding the most efficient packing of rectangles is NP-hard (that is, its solution is easy to check but hard to find), this challenge is a lot easier than this one here

This Challenge

Given a bunch of rectangles, figure out whether or not they fill a rectangular space with no gaps or overlaps.

Input

Input can be in two forms, one of which carries a scoring penalty.

The first: it contains a list of sublists, each with length 4. This list contains 4 integers which are the coordinates of opposite vertexes. Since all rectangles will be horizontal/vertical, there is no ambiguity as to where the rectangle is. Each sublist will contain four integers, which, in order, are the x-coordinate of the first vertex, the y-coordinate of the first vertex, the x-coordinate of the second vertex, and the y-coordinate of the second vertex.

The second: it contains four lists of integers with the same length. The four lists represent the different coordinates. If you imagine input option 1 as a matrix, the input here is just the transpose of the matrix. This input carries a +20% byte penalty.

Output

Simple truthy/falsy output.

Specifications

If there is a rectangle with area 0 (that is, x1 == x2 || y1 == y2), disregard this rectangle (so [0 0 1 1], [2 2 3 2] is valid). This specification is in place to make it harder for people to simply get the min/max x/y values.

x1 <= x2 and y1 <= y2 are not always true. If x1 > x2 || y1 > y2, the rectangle is not a zero-area rectangle; rather, it occupies the rectangular space between (x1, y1) and (x2, y2).
Coordinates can be negative, in which case they still occupy the space between the coordinates.
The top-left-most rectangle is not always at (0, 0); thus, the rectangular space that is filled doesn't necessarily have its top-left corner at (0, 0).
(Thanks to @xnor for pointing out these ambiguities)

Please specify how you want your input and how your output will be represented.

Scoring

Score is the size of the code in bytes, plus a byte penalty if applicable. Lowest score as of December 15th wins.

Test Cases

0 0 1 2
1 0 3 1 ==> true
1 1 3 2

0 0 2 2
0 0 1 1 ==> false
0 0 0 0

0 0 1 1
2 2 2 2 ==> true
0 1 2 1

Good luck, happy golfing!

JavaScript (ES6), 249 bytes

with(Math)a=>!(a=a.map(([l,t,r,b])=>[l<r?l:r,t<b?t:b,l>r?l:r,t>b?t:b]).filter(g=([l,t,r,b])=>(r-l)*(b-t))).reduce((s,b)=>s-g(b),g([min,min,max,max].map((f,i)=>f(...a.map(a=>a[i])))))>a.some(([l,t,r,b],i)=>a.some(([m,u,s,c],j)=>i!=j&l<s&m<r&t<c&u<b))

Note: To use this, either evaluate it as a string and assign the result to a variable, or insert the assignment after the with(Math). Explanation:

with(Math)a=>!( Bring min and max into scope.
a=a.map(([l,t,r,b])=>[l<r?l:r,t<b?t:b,l>r?l:r,t>b?t:b]) Normalise the coordinates
.filter(g=([l,t,r,b])=>(r-l)*(b-t))) Remove empty rectangles, also defining a function to calculate area
.reduce((s,b)=>s-g(b), Subtract the areas of all the rectangles
g([min,min,max,max].map((f,i)=>f(...a.map(a=>a[i]))))) from the area of the bounding box
>a.some(([l,t,r,b],i)=>a.some(([m,u,s,c],j)=>i!=j&l<s&m<r&t<c&u<b)) and check that no rectangles overlap.


Converging Sums of a Fractal Sequence Background

A fractal sequence is an integer sequences where you can remove the first occurrence of every integer and end up with the same sequence as before.

A very simple such sequence is called Kimberling's paraphrases. You start with the positive natural numbers:

1, 2, 3, 4, 5, 6, 7, 8, 9, ...

Then you riffle in some blanks:

1, _, 2, _, 3, _, 4, _, 5, _, 6, _, 7, _, 8, _, 9, ...

And then you repeatedly fill in the blanks with the sequence itself (including the blanks):

1, 1, 2, _, 3, 2, 4, _, 5, 3, 6, _, 7, 4, 8, _, 9, ...
1, 1, 2, 1, 3, 2, 4, _, 5, 3, 6, 2, 7, 4, 8, _, 9, ...
1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 6, 2, 7, 4, 8, _, 9, ...
1, 1, 2, 1, 3, 2, 4, 1, 5, 3, 6, 2, 7, 4, 8, 1, 9, ...

That's our fractal sequence! Now let's take the partial sums:

1, 2, 4, 5, 8, 10, 14, 15, 20, 23, 29, 31, 38, 42, 50, 51, 60, ...

But what if we iterate this process? "Fractalise" the new sequence (i.e. the partial sums obtained from the steps above):

1, _, 2, _, 4, _, 5, _, 8, _, 10, _, 14, _, 15, _, 20, _, 23, ...
1, 1, 2, _, 4, 2, 5, _, 8, 4, 10, _, 14, 5, 15, _, 20, 8, 23, ...
1, 1, 2, 1, 4, 2, 5, _, 8, 4, 10, 2, 14, 5, 15, _, 20, 8, 23, ...
1, 1, 2, 1, 4, 2, 5, 1, 8, 4, 10, 2, 14, 5, 15, _, 20, 8, 23, ...
1, 1, 2, 1, 4, 2, 5, 1, 8, 4, 10, 2, 14, 5, 15, 1, 20, 8, 23, ...

And take the partial sums again:

1, 2, 4, 5, 9, 11, 16, 17, 25, 29, 39, 41, 55, 60, 75, 76, 96, ...

Rinse, repeat. It turns out that this process converges. Every time you repeat this process, a larger prefix of the sequence will remain fixed. After an infinite amount of iterations, you would end up with OEIS A085765.

Fun fact: This process would converge to the same sequence even if we didn't start from the natural numbers as long as the original sequence starts with 1. If the original sequence starts with any other x, we'd obtain x*A085765 instead.

The Challenge

Given a positive integer N, output the Nth element of the converged sequence.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

You may choose whether the index N is 0- or 1-based.

Test Cases

The sequence starts with:

1, 2, 4, 5, 9, 11, 16, 17, 26, 30, 41, 43, 59, 64, 81, 82, 108, 117, 147, 151, 192, 203, 246, 248, 307, 323, 387, 392, 473, 490, 572, 573, 681, 707, 824, 833, 980, 1010, 1161, 1165, 1357, 1398, 1601, 1612, 1858, 1901, 2149, 2151, 2458, 2517

So input 5 should result in output 9.

Here is a naive CJam reference implementation which generates the first N numbers (given N on STDIN). Note that your code should only return the Nth element, not the entire prefix.

Python 2, 55 49 42
I have no idea what's going on, but it seems hard to beat the Maple formula from the OEIS page.
This uses 0-based indexing.
f=lambda n,t=0:n<1or f(n/2,n%2)-~-t*f(n-1)

Thanks to @PeterTaylor for -6 bytes.


Minimal Boggle-like Arrangements Consider how a word could be arranged on an arbitrarily large Boggle grid if the rule about not using the same letter cube more than once is ignored. Also assume that you have an unlimited number of letter cubes (with all letters present), and Qu is just Q.
The word MISSISSIPPI could be arranged using only 6 cubes. Here is one possible arrangement:
 S
MIS
 PP

Starting at the M we repeatedly take any step horizontally, vertically, or diagonally until the entire word is spelled out.
Surprisingly, a longer phrase like AMANAPLANACANALPANAMA also only needs 6 cubes:
MAN
PLC

However, the minimum number of cubes needed for longer, more complex strings is not always obvious.
Challenge
Write a program that takes in a string and arranges it in this Boggle-like fashion such that the minimum number of cubes are used. (The dimensions of the resulting grid and the number of empty cells are irrelevant.)
Assume you have have an unlimited number of cubes for each printable ASCII character except space (hex codes 21 to 7E), since it's used as an empty grid cell. Only printable ASCII strings (without spaces) will be input.
Input should be taken from stdin or the command line. Output should go to stdout (or
closest alternative).
Leading or trailing newlines and spaces in the output are fine (but hopefully there aren't an inordinate amount).
The search space blows up exponentially as the string gets longer, but you are not required to attempt to make your algorithm efficient (though that would be nice :) ). This is code-golf, so the shortest solution in bytes wins.
Example
If the input were Oklahoma! (8 character minimum), these would all be valid outputs because the all have exactly 8 filled grid cells and they follow the (revised) Boggle reading pattern:
Oklaho
   !m

or
  !
Oamo
klh

or
   lkO
  !amo
    h

etc.

Python 342 355 398

R=(-1,0,1)
A=[];b={}
def s(w,x,y):
 if w: # not at the end of the word yet?
  for I in R: # search adjacent squares
   for j in R:
    if I|j: # skip the square we are on
     i=I+x;j+=y;c=b.get((i,j)) # get square in board
     if c==w[0]:s(w[1:],i,j) # square is what we are looking for?
     elif not c:b[i,j]=w[0];s(w[1:],i,j);del b[i,j] # we can set square?
 else:A.append(dict(b)) # all solutions
s(raw_input(),9,9) # run the search
A=min(A,key=len) # A is now the shortest solution
C=sum(map(list,A),[]) # put all board coords together
C=range(min(C),max(C)+1) # find the board biggest square bound
for r in C:print"".join(A.get((c,r)," ") for c in C)

Indent at four spaces is actually a tab character.

AMANAPLANACANALPANAMA:

MC
NA
PL

MISSISSIPPI:

S
SI
PPM

Oklahoma!:

oh
 ma
 ! l
    k
     O

Llanfairpwllgwyngyll is lethal ;)


JavaScript (Node.js), 428 bytes
Uses 0 instead of #.

_=>Buffer('QaV6:)R/rEkQy|:|\\!8GG6Pzy}lO<:xv-q,GoKfhfkci;Br"? &]N9Xx[}~tvc1Z6;%Fq6>DO(9dGs&sG~n@z},=x7]+Qo4y}~8Tr~>45<y#J;_a-^"X=^:?`(8*QQh"GQ.V0>GBpa~ytaJYb^YJdo=/W&59kP#@pZ-pYt-uLLe-lDv/kV|}.ylnY<-$H@G&H{h4PPL%q&7t?1.?t}cI6Fcz-Nvo_wPUPP:Xh|tG0zp)lNIh`Ah-d"t.+0L8&}M6LK.Mr$4rH\'l(x4p4_v|[gdf-~9qo,c{U\\Vw(RCYJrd`^&G[{Tr$PGPkS\'$iaBKm{q').reduce((p,c)=>p*95n+BigInt(c-32),0n).toString(2).match(/.{62}/g).join`
`.split`1`.join` `

Try it online!
Not sure if it was intentional but, contrary to appearances, the tesseract is not symmetrical.
Storing only the upper part and encoding the differences for the lower part would most certainly be more efficient in some languages, but I didn't find a short enough way to do that in JS.
So this is just a binary to base-95 compression for now.
Note: With RegPack, we get 480 bytes. (Not a fully optimized version, but we could only shave a couple of bytes.)


Generate a mandelbrot fractal Your task is to draw the mandelbrot set in ascii. It should look something like

The complex number c lies in the mandelbrot set, when the sequence z(n+1) = z(n)^2 + c, z(0) = 0 remains bounded.
For the purpose of this challenge you can consider the sequence bounded for c if |z(32)| < 2.

Plot the mandelbrot set on the complex plane from (-2 - i) to (1 + i), and a minimum resolution of 40x30, using ascii characters in your favourite language, using as few characters as possible.


Write a function that takes (x, y) and return x to the power of y WITHOUT Loops This is a really neat short challenge.

Write a function or a procedure that takes two parameters, x and y and returns the result of xy WITHOUT using loops, or built in power functions.

The winner is the most creative solution, and will be chosen based on the highest number of votes after 3 days.

APL (7)

{×/⍵/⍺}

Left argument is base, right argument is exponent, e.g.:

     5 {×/⍵/⍺} 6
15625

Explanation:

⍵/⍺ replicates ⍺ ⍵ times, e.g. 5 {⍵/⍺} 6 -> 5 5 5 5 5 5
×/ takes the product, e.g. ×/5 5 5 5 5 5 -> 5×5×5×5×5×5 -> 15625


Create an n to the d tic tac toe win-checker Create the shortest program to check who has won in an nd tic tac toe game.

Your program should work when n (width) and d (dimension number) are in these ranges:

n∈[3,6]∩ℕ  ie a number from this list: 3,4,5,6
d∈[2,5]∩ℕ  ie a number from this list: 2,3,4,5

n = 3; d = 2 (32 ie 3 by 3):

[][][]
[][][]
[][][]

n = 3; d = 3 (33 ie 3 by 3 by 3):

[][][]
[][][]
[][][]

[][][]
[][][]
[][][]

[][][]
[][][]
[][][]

n = 6; d = 2 (62 ie 6 by 6):

[][][][][][]
[][][][][][]
[][][][][][]
[][][][][][]
[][][][][][]
[][][][][][]

And so on.

Winning (If you've played enough multi-dimensional tic tac toe, this is the same.)

In order for there to be a win, one player must have all the adjacent squares along a line. That is, that player must have n moves on a line to be a winner.

Adjacent:

each tile is a point; for example (0,0,0,0,0) is a point in d=5
adjacent tiles are tiles such they are both points on the same unit d-cube. In other words, the Chebyshev distance between the tiles is 1.
in other words, if a point p is adjacent to a point q, then every coordinate in ps corresponding coordinate in q differs from it by no more than one. Additionally, at least on coordinate pair differs by exactly one.

Lines:

Lines are defined by vectors and a tile. A line is each tile hit by the equation: p0 + t<some vector with the same number of coordinates as p0>

Input:

Input will be to STDIN. The first line of input will be two numbers, n and d in the form n,d.

After this will be a line consisting of coordinates specifying the moves that have been done. Coordinates will be listed in the form: 1,1;2,2;3,3. The upper left corner is the origin ( 0,0 for 2D). In the general case, this list will be like 1,2,...,1,4;4,0,...,6,0;... where the first number represents left-right-ness, the second up-down-ness, the third through the 3rd dimension, etc. Note that the first coordinate is Xs first turn, the second is Os first turn, ....

The input will be followed by a newline.

Output:

Output will be to STDOUT. Simply indicate who won if someone won, or if it is a tie. If it is neither a tie nor a win, don't output anything.

Additionally, indicate if there is a move clash, that is, if there are at least two moves in the same location.

If there was a win/draw before the input ended, your program can do whatever it wants.

Test cases (anyone want to suggest any more?):

Input:

4,3
0,0,0;1,1,1;1,0,1;2,0,2;0,0,1;2,0,0;2,0,1;3,0,2;3,0,1

Example Output:

X wins

Another possible output (requires explanation):

1

Not an answer - Java

I was curious to see how many different ways there were to win for a given n,d so I wrote this code to list them all.

import java.util.*;

public class MultiDTTT {
    static Set<Win> wins = new HashSet<Win>();
    static final int d = 3;
    static final int n = 3;
    static final char maxChar = (char)(n-1) + '0';

    public static void main(String[] args) throws Exception {
        String pad = "";
        for(int i=0; i<d; i++) pad = pad + "0";
        for(int i=0; i<Math.pow(n,d); i++) {
            String s = Integer.toString(i,n);
            s = pad.substring(s.length()) + s;
            buildWin(s,"",0);
        }
        System.out.println(wins.size());
        for(Win w : wins) System.out.println(w.toString());
    }

    static void buildWin(String s, String p,int i) {
        if(i<d) {
            if(s.charAt(i) == '0') {
                buildWin(s,p+"u",i+1);
                buildWin(s,p+"s",i+1);
            }
            else if(s.charAt(i) == maxChar) {
                buildWin(s,p+"d",i+1);
                buildWin(s,p+"s",i+1);
            }
            else {
                buildWin(s,p+"s",i+1);
            }
        }
        else {
            if(p.contains("u") || p.contains("d")) wins.add(new Win(s,p));
        }
    }

    static class Win {
        String start;
        String pattern;
        Set<String> list = new HashSet<String>();

        Win(String s, String p) {
            start = s;
            pattern = p;
            char[] sc = s.toCharArray();
            for(int i=0; i<n; i++) {
                list.add(new String(sc));
                for(int j=0; j<d; j++) {
                    switch (p.charAt(j)) {
                        case 'u':
                            sc[j]++;
                            break;
                        case 'd':
                            sc[j]--;
                            break;
                        case 's':
                            break;
                    }
                }
            }
        }

        public String toString() {
            String s = ""; //start + ", " + pattern + "\n    ";
            for(String ss : list) s = s + ss + " ";
            return s;
        }

        public boolean equals(Object x) {
            return (x instanceof Win) && this.list.equals(((Win)x).list);
        }
        public int hashCode(){
            return list.hashCode();
        }
    }
}

I hand-tested it on n,d = 2..3,2..3 and it appears to work… after that the number of possible ways to win grows quickly as shown below:

n       1       2       3       4       5       6
d
1       1       1       1       1       1       1
2       1       6       8       10      12      14
3       1       28      49      76      109     148
4       1       120     272     520     888     1400
5       1       496     1441    3376    6841    12496
6       1       2016    7448    21280   51012   107744

Having generated all wining sets, I could extend the program to check the given input against winning sets but, of course, that method would never win the golf.  So I was content to stop here - except it looked like I could find a closed-form solution for the number of ways to win as a function of n and d… It is Number of ways to win = 0.5( (n+2)^d - n^d).


For 2 arrays, subtract every element in one array from the position-matching element in the other For 2 arrays each with X elements, what is the SHORTEST code to subtract every element in the second from every element in the first, 1 to 1

so, for example:

A1 = [10,11,12]

A2 = [1,2,3]

A1 "-" A2 should == [9,9,9]

R, 3 chars
(following Chris' counting method that includes the variable names in the count)
a-b

a and b can be defined as follows:
a <- c(10,11,12)
b <- c(1,2,3)

(c is the array construction function in R)


Counting Gems on the Ground Counting Gems

Background

My jewel box just fell down! There're too many gems of different shape on the ground. And your task is to count number of a certain type of gem.

I/O

Your code should take two inputs S and G, which could be a string with newlines, an array of lines, a two-dimensional array of characters, a textfile or in any reasonable format (if so, please state it clearly).
These two strings will only contain !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (from 0x21 to 0x7E in ASCII table), space and newlines (binary form depending on your platform).
In each string, lines are in same length.
S is the gem we want to count. There're two circumstances.

Enclosed and doesn't contain any nested enclosed area. (in example 1/2)
Doesn't contain any enclosed area. (in example 3/4)

Surrounding spaces are not regarded as a part of the gem.
G is the shape of gems on the ground.
It is acceptable that your code requires extra input to specify the dimension(s) of S and G
It is acceptable that your code take ASCII values as inputs, instead of characters themselves. But you should not substitute characters with simpler integers (0,1,2,3). Your program should be able to process characters, or ASCII values.

Example 1 (Character as input)

Input S:

+-+
| +-+
| | |
| | |
| +-+
+-+

Input G:

    +-+       +-+
    | +-+   +-+ |
    | | |   | | |
    | | |   | | |
    | +-+   +-+ |
    +-+       +-+
         +-+
+---+    | +-+
|   |    | | |
|   |    | | |
|   |    | +-++
|   |    +-+| +-+
+---+       | | |
            | | |
  +-+       | +-+
  | +-+     +-+
  | |-|
  | |-|
  | +-+
  +-+

Ouptut:

2

Example 2 (ASCII value as input)

Input S:

32 32 32 32 32 32 32 32
32 32 32 32 99 32 99 32
32 32 32 99 32 99 32 99
32 32 32 99 32 32 32 99
32 32 32 99 32 32 32 99
32 32 32 99 32 32 32 99
32 32 32 32 99 32 99 32
32 32 32 32 32 99 32 32
32 32 32 32 32 32 32 32

Input G:

32 99 32 99 32 99 32 99 32 32 99 32
99 32 99 32 99 32 99 32 99 99 32 99
99 32 32 32 99 32 32 32 99 32 32 99
99 99 32 32 99 32 32 32 99 32 32 99
99 32 32 32 99 32 32 32 99 32 32 99
32 99 32 99 32 99 32 99 99 32 99 32
32 32 99 32 32 32 99 32 32 99 32 32

Output:

1

Visualized S (32 replaced with --):

-- -- -- -- -- -- -- --
-- -- -- -- 99 -- 99 --
-- -- -- 99 -- 99 -- 99
-- -- -- 99 -- -- -- 99
-- -- -- 99 -- -- -- 99
-- -- -- 99 -- -- -- 99
-- -- -- -- 99 -- 99 --
-- -- -- -- -- 99 -- --
-- -- -- -- -- -- -- --

Visualized G:

-- 99 -- 99 -- 99 -- 99 -- -- 99 --
99 -- 99 -- 99 -- 99 -- 99 99 -- 99
99 -- -- -- 99 -- -- -- 99 -- -- 99
99 99 -- -- 99 -- -- -- 99 -- -- 99
99 -- -- -- 99 -- -- -- 99 -- -- 99
-- 99 -- 99 -- 99 -- 99 99 -- 99 --
-- -- 99 -- -- -- 99 -- -- 99 -- --

Example 3 (Not enclosed)

Thanks to @Draco18s

Input S

AB

Input G

AAB BA CAB

Output

2

Example 4 (Not enclosed 2D)

Input S

ABCD
  GE
   F

Input G

ABCD
BGGED
CDEFE
    F

Output

1

Remarks

Only two gems of exact one shape are considered the same.
Same shape in different directions are not considered the same.
However, as is described in example I/O, overlapping is possible. Under such circumstances, only complete ones are counted.
+, - and | in the example have no special meanings. They do not indicate any corner or edge of the shape.
You may assume input is always valid.
You may assume two target gems never share an exactly same edge.
Standard loopholes are forbidden.
This is a code-golf, so shortest code wins!

C (gcc), 303 305 326 bytes

All optimizations need to be turned off and only work on 32-bit GCC.

#define r(z,k)for(z=0;z<k;z++)
#define c s[i][j]
x,y,o,p,t,i,j;char**s;h(i,j){!((i<0)+(j<0)+i/x+j/y+c-32)?h(i+1,j),h(i-1,j),h(i,j+1),h(i,j-1),c=0:0;}f(w,e,u,v,a,g)char**a,**g;x=w,y=e,s=a;r(o,x)h(o,0),h(o,y-1);r(p,y)h(0,p),h(x-1,p);w=0;r(o,u-x+1)r(p,v-y+1){t=1;r(i,x)r(j,y)t*=!(c*(c-g[i+o][j+p]));w+=t;}}

The code uses floodfill to replace surrounding spaces with \0 and looks for matches while ignoring \0.

ungolfed and macros calculated (some letters are different from the golfed version, but logic stays the same):

int x, y, o, p, c, d, t;
char **s, **g;
h(int i, int j) {                             // Floodfill function
    if(i<0 || j<0) return;                    // Boundary detection
    if(i>=x || j>=y) return;
    if(s[i][j] != ' ') return;                // Character detection

    s[i][j] = 0;                              // Replace it with \0
    h(i+1, j);
    h(i-1, j)
    h(i  , j+1);
    h(i  , j-1);
}
f(
    int w,    //1st dimension of S
    int e,    //2nd dimension of S
    int u,    //1st dimension of G
    int v     //2nd dimension of G
    char** i, //Input S
    char** j, //Input G
    );
{
    x=w,y=e,s=i,g=j;
    for(o=0; o<x; o++)                        // Replace all surrounding spaces using floodfill
    {
        h(o, 0);
        h(o, y-1);
    }
    for(p=0; p<y; p++)
    {
        h(0,   p);
        h(x-1, p);
    }
    w = 0;
    for(o=0; o<=u-x; o++)                     // Main O(w*e*u*v) matching process
        for(p=0; p<=v-y; p++) {
            t=1;
            for(c=0; c<x; c++)
                for(d=0; d<y; d++)
                if(s[c][d]*(s[c][d]-g[c+o][d+p]))
                    t=0;
            w+=t;
        }
}


Homework time! Find me the lowest even digit in a string Another brilliant question from Stack Overflow turned into a code-golf challenge!

Write a program that:

Accepts a string as user input (not piped in or a command line argument). The data type of the input must be a string, if the language does auto evals on input, it must be cast to a string.
Finds the index (0 or 1 based) of the first lowest even digit.
Prints 2 integers, the index and the lowest even digit.
If there is no even digit, return -1 as the index, the second number can be anything.
For the purposes of this zero is not even.

Test examples, given the string on the left output the values on the right:

25376  -->  0,2
523726 -->  1,2
583746 -->  4,4
53771  --> -1,0
_4___2 -->  5,2

The winner: is the program with the lowest character count. No bonuses, no penalties.

edit: (about stdin) I screwed up on the user input part, basically no piping data in, and no command line arguments. You must provide a user prompt of some kind within the program itself.

Golfscript, 26 (28) characters

'#{gets}'.'246'&8+$1<.@\?

Example:

;'583746'
.'246'&8+$1<.@\?
#44

;'53771'
.'246'&8+$1<.@\?
#8-1

live test: http://golfscript.apphb.com/?c=Oyc1Mzc3MScKLicyNDYnJjgrJDE8LjA9QD8%3D

Explanation:

'#{gets}' is an escape to ruby to satisfy the I/O requirements; STDIN is assumed to be empty
. clones the input
'246'&8+ finds which even digits are present in the input, except 8 is always retained
$1< sorts the list, then takes the first digit, but keeps it as a string
.@\? orders the stack {digit, input, digit}, then finds the digit in the input; thanks @peterTaylor for noticing me of the [array, array] signature of ?.

I've been very bold with the spec interpretation this time; namely:

The spec does not mandate in which order the integers are output; Use the other @peter's suggestion :x?x to fix (I don't like temporary variables.
The spec does not require any delimiter between the two integers; since the digit found is always a single digit, this does not matter much. If it does, append n@ (which also performs the swap), n\ (which doesn't), or ]` (which formats the output as ["8" -1]).


Surjective, Injective, Bijective, or Nothing? Given a mapping from the integers from 1 to N to the integers from 1 to N, determine if the mapping is surjective, injective, bijective, or nothing.
You may choose any character/digit for the four outputs.
Specs
Input format: n, arrays of pairs (n is the highest number in the domain and range)
For example, if the first number is 3, then both the domain and the co-domain are {1,2,3}.
For example, {i+1 | i from 1 to 9} (n=10) is represented by 10, [[1,2],[2,3],...,[9,10]].
The input may contain duplicate.
Testcases
2, [[1,2],[2,1]] => bijective
2, [[1,1],[1,2]] => surjective
3, [[1,1]] => injective
3, [[1,2],[2,3]] => injective
4, [[1,2],[2,2],[3,2],[4,2]] => nothing
2, [[1,2],[1,2]] => injective
3, [[1,1],[1,2],[1,3]] => surjective
2, [[1,1],[1,1],[2,2]] => bijective

Pyth - 10 9 13 bytes
im&{IdqSQSdE2

Takes domain and codomain separately as allowed by comments in OP.
Test Suite.


Take a byte out of it! Your task is to, given an unsigned integer n, find the largest number which can be created by removing a single byte (8 consecutive bits) of data.

Example

Given the number 7831, we first convert it to binary (removing any leading zeroes):

1111010010111

We then find the consecutive group of 8 bits which, when removed, will yield the largest new result. In this case, there are 3 solutions, shown below

1111010010111
  ^      ^
   ^      ^
    ^      ^

Removing this any of these yields 11111, which we then convert back to its decimal value 31 for the answer.

Test Cases

256        ->   1
999        ->   3
7831       ->   31
131585     ->   515
7854621    ->   31261
4294967295 ->   16777215 (if your language can handle 32 bit integers)

Rules

It is guaranteed that the bit length of n will be larger than 8.
Your solution should theoretically work for any bit length of n larger than 8, but in practice, needs only work for integers 255 < n < 216
Input/Output should be in decimal.
You may submit a full program or a function.
This is code-golf, so the shortest program (in bytes) wins!

Jelly, 6 bytes

BḄ-8ƤṀ

A monadic link taking a number and returning a number.

Try it online!

How?

Uses a nice quick, Ƥ, developed by miles...

BḄ-8ƤṀ - Link: number
B      - convert to a binary list
    Ƥ  - for loop over some slices to be determined...
  -8   - this is a negative nilad, therefore: use overlapping outfixes of length 8
       -   (exactly what the specification asks us to inspect)
 Ḅ     -   convert from a binary list to an integer (vectorises)
     Ṁ - maximum


Find the tangent of the sum of inverse tangents Background

It can be shown that for any integer k >= 0, f(k) = tan(atan(0) + atan(1) + atan(2) + ... + atan(k)) is a rational number.

Goal

Write a complete program or function which when given k >= 0, outputs f(k) as a single reduced fraction (the numerator and denominator are coprime).

Test cases

The first few values are

f(0) = (0,1)
f(1) = (1,1)
f(2) = (-3,1)
f(3) = (0,1)
f(4) = (4,1)
f(5) = (-9,19)
f(6) = (105,73)

Rules

Standard loopholes are forbidden.
Input and output may be in any
convenient format. You may output f(k) as a string numerator/denominator, as a tuple of two integers, a fraction or rational object, etc. If you output a string, give two integers only, that is, output 3/2 instead of 1 1/2.
This is code-golf, the shortest answer (in bytes)
wins.

Python 2, 76 72 bytes

from fractions import*
f=lambda k:Fraction(k and(k+f(k-1))/(1-k*f(k-1)))

Use the identity:

tan(A + B) = (tan(A) + tan(B)) / (1 - tan(A) * tan(B))

We have:

f(k) = 0                                    if k = 0
     = (k + f(k - 1)) / (1 - k * f(k - 1))  if k > 0

Try it online!

Thanks to Luis Mendo, save 4 bytes.


Write a program for splitting the string with alternative spaces Write a program in the minimum number of bytes that prints a string split into chunks of every length from 1 to the string's length (ascending and then descending), separated by spaces.

Example

Input : abcdef
Output: a b c d e f
        ab cd ef
        abc def
        abcd ef
        abcde f
        abcdef
        abcde f
        abcd ef
        abc def
        ab cd ef
        a b c d e f

Ruby, 84 81 characters

i=gets.chop
puts (a=(1..i.size).map{|n|i.scan(/.{0,#{n}}/)*' '})+a.reverse[1..-1]

The magic is in the regex: i.scan(/.{0,#{n}}/). Since Ruby does regex interpolation too, it will become

i.scan(/.{0,1}/)
i.scan(/.{0,2}/)
...

This means it will grab as many characters as it can, limited to n. n progressively gets bigger, and is used to generate the first half of the output.

Then I just call reverse to generate the second half. I had to use [1..-1] in order to avoid repeating the middle line (what that does is basically chop off the first element of the array).

Sample run:

c:\a\ruby>spacesplitgolf.rb
CodeGolfStackExchange         // (this is the input)
C o d e G o l f S t a c k E x c h a n g e
Co de Go lf St ac kE xc ha ng e
Cod eGo lfS tac kEx cha nge
Code Golf Stac kExc hang e
CodeG olfSt ackEx chang e
CodeGo lfStac kExcha nge
CodeGol fStackE xchange
CodeGolf StackExc hange
CodeGolfS tackExcha nge
CodeGolfSt ackExchang e
CodeGolfSta ckExchange
CodeGolfStac kExchange
CodeGolfStack Exchange
CodeGolfStackE xchange
CodeGolfStackEx change
CodeGolfStackExc hange
CodeGolfStackExch ange
CodeGolfStackExcha nge
CodeGolfStackExchan ge
CodeGolfStackExchang e
CodeGolfStackExchange
CodeGolfStackExchang e
CodeGolfStackExchan ge
CodeGolfStackExcha nge
CodeGolfStackExch ange
CodeGolfStackExc hange
CodeGolfStackEx change
CodeGolfStackE xchange
CodeGolfStack Exchange
CodeGolfStac kExchange
CodeGolfSta ckExchange
CodeGolfSt ackExchang e
CodeGolfS tackExcha nge
CodeGolf StackExc hange
CodeGol fStackE xchange
CodeGo lfStac kExcha nge
CodeG olfSt ackEx chang e
Code Golf Stac kExc hang e
Cod eGo lfS tac kEx cha nge
Co de Go lf St ac kE xc ha ng e
C o d e G o l f S t a c k E x c h a n g e


How even is a number? The ancient Greeks had these things called singly and doubly even numbers. An example of a singly even number is 14. It can be divided by 2 once, and has at that point become an odd number (7), after which it is not divisible by 2 anymore. A doubly even number is 20. It can be divided by 2 twice, and then becomes 5.

Your task is to write a function or program that takes an integer as input, and outputs the number of times it is divisible by 2 as an integer, in as few bytes as possible. The input will be a nonzero integer (any positive or negative value, within the limits of your language).

Test cases:

14 -> 1

20 -> 2

94208 -> 12

7 -> 0

-4 -> 2

The answer with the least bytes wins.

Tip: Try converting the number to base 2. See what that tells you.

x86_64 machine code, 4 bytes
The BSF (bit scan forward) instruction does exactly this!
0x0f    0xbc    0xc7    0xc3

In gcc-style assembly, this is:

    .globl  f
f:
    bsfl    %edi, %eax
    ret

The input is given in the EDI register and returned in the EAX register as per standard 64-bit c calling conventions.
Because of two's complement binary encoding, this works for -ve as well as +ve numbers.
Also, despite the documentation saying "If the content of the source operand is 0, the content of the destination operand is undefined.", I find on my Ubuntu VM that the output of f(0) is 0.
Instructions:

Save the above as evenness.s and assemble with gcc -c evenness.s -o evenness.o
Save the following test driver as evenness-main.c and compile with gcc -c evenness-main.c -o evenness-main.o:

#include <stdio.h>

extern int f(int n);

int main (int argc, char **argv) {
    int i;

    int testcases[] = { 14, 20, 94208, 7, 0, -4 };

    for (i = 0; i < sizeof(testcases) / sizeof(testcases[0]); i++) {
        printf("%d, %d\n", testcases[i], f(testcases[i]));
    }

    return 0;
}

Then:

Link: gcc evenness-main.o evenness.o -o evenness
Run: ./evenness

@FarazMasroor asked for more details on how this answer was derived.
I am more familiar with c than the intricacies of x86 assembly, so typically I use a compiler to generate assembly code for me.  I know from experience that gcc extensions such as __builtin_ffs(), __builtin_ctz() and __builtin_popcount() typically compile and assemble to 1 or 2 instructions on x86.  So I started out with a c function like:

int f(int n) {
    return __builtin_ctz(n);
}

Instead of using regular gcc compilation all the way to object code, you can use the -S option to compile just to assembly - gcc -S -c evenness.c.  This gives an assembly file evenness.s like this:

    .file   "evenness.c"
    .text
    .globl  f
    .type   f, @function
f:
.LFB0:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
    .cfi_def_cfa_register 6
    movl    %edi, -4(%rbp)
    movl    -4(%rbp), %eax
    rep bsfl    %eax, %eax
    popq    %rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   f, .-f
    .ident  "GCC: (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4"
    .section    .note.GNU-stack,"",@progbits

A lot of this can be golfed out.  In particular we know that the c calling convention for functions with int f(int n); signature is nice and simple - the input param is passed in the EDI register and the return value is returned in the EAX register.  So we can take most of instructions out - a lot of them are concerned with saving registers and setting up a new stack frame.  We don't use the stack here and only use the EAX register, so don't need to worry about other registers.  This leaves "golfed" assembly code:

    .globl  f
f:
    bsfl    %edi, %eax
    ret

Note as @zwol points out, you can also use optimized compilation to achieve a similar result.  In particular -Os produces exactly the above instructions (with a few additional assembler directives that don't produce any extra object code.)
This is now assembled with gcc -c evenness.s -o evenness.o, which can then be linked into a test driver program as described above.
There are several ways to determine the machine code corresponding to this assembly.  My favourite is to use the gdb disass disassembly command:
$ gdb ./evenness
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
...
Reading symbols from ./evenness...(no debugging symbols found)...done.
(gdb) disass /r f
Dump of assembler code for function f:
   0x00000000004005ae <+0>: 0f bc c7    bsf    %edi,%eax
   0x00000000004005b1 <+3>: c3  retq
   0x00000000004005b2 <+4>: 66 2e 0f 1f 84 00 00 00 00 00   nopw   %cs:0x0(%rax,%rax,1)
   0x00000000004005bc <+14>:    0f 1f 40 00 nopl   0x0(%rax)
End of assembler dump.
(gdb)

So we can see that the machine code for the bsf instruction is 0f bc c7 and for ret is c3.


Generate a right triangle In this challenge, you must take two numbers (separated by a space) as input and output an ASCII right triangle, made up of xs.

The first number will be the width and height of the triangle you should output. The second number will be which corner the right angle will be in. The corners are numbered 1 to 4, starting in the top left and going in English reading order:

1    2

3    4

For example (inputs and their respective triangle outputs):

INPUT | 3 1 | 3 2 | 3 3 | 3 4
------+-----+-----+-----+----
 OUT- | xxx | xxx | x   |   x
 PUT  | xx  |  xx | xx  |  xx
      | x   |   x | xxx | xxx

Your program's output must match these examples exactly for their respective inputs.

The input will always be valid: the first number will be an integer ≥1, and the second number will be 1, 2, 3, or 4.

This is code-golf; shortest code (in character count) wins.

APL (30)

{' x'[1+(⍎⍵⌷'⌽+⍉⊖')≤/¨⍳2⍴⍺]}/⎕

Explanation:

{...}/⎕: reduce given function over the input (so if the input has 2 numbers, just calls the function with those two numbers, ⍺ being the left number and ⍵ the right number)
≤/¨⍳2⍴⍺: Make an ⍺-by-⍺ coordinate matrix and set those positions where the X coordinate is not greater than the Y coordinate, giving a bitfield.
(⍎⍵⌷'⌽+⍉⊖'): select a transformation function given by ⍵ to put the triangle right-side-up.
' x'[1+...]: add one to the bitfield, and use the result as an index into the string ' x', so putting space for 0 and x for 1.


Acrostic polyglot programming The challenge is to write an acrostic piece of code.

When read normally (horizontally), the code should take an input string and remove all but the first character on each line. For example, the input:

float
or and
ord
 line
bool var
auto
real

Output:

foo bar

In addition to this, the code also must contain valid code when run vertically. Such that applying the horizontal code on itself yields a new piece of valid code in a different language.

Rules/Restrictions:

Each horizontal line must contain at least 2 non-whitespace characters
The vertical code cannot use newlines.
The vertical code must be in a different language from the horizontal language, preferably something entirely different
The code does not have to be a complete program (doesn't need main function, etc)

What the vertical code does is up to you, although the goal is to have it do something interesting. Having it do nothing is not interesting.

Easy Mode:

You may use the same language both horizontally and vertically
No restrictions on language choice

Hard mode:

No comments
Both codes should compile and run (main function, etc)
Horizontal code contains exactly 1 word per line

Brainfuck -> Ruby
e,
v[
a.
l>
"+
a[
=-<,----------
[>
i+
=<
0[-]
]>
*]
3,
e]
4[
;g
"4
+d
$)
<^
.%
b$
y@
ta
el
sD
.{
m[
a}
p]
{.
|d
bA
|:)
{y
?T
.K
,s
"+
pG
up
th
c}
 P
a$
[v
iF
]o
"d
,8
?t
,=
,h
"3
ay
[&
i*
]H
=s
gj
e9
t,
c<
"D
,d
?`
[q
,z
")
wT
hx
ie
lz
eW
 >
a$
[^
i!
];
>Y
0q
"#
,T
?X
]A
,b
"J
e$
n#
ds
"K
,$
?}
<?
,.
"e
iJ
-W
=k
1B
"&
,J
?g
>.
,>
"/
i@
+/
=s
1v
"E
,)
?.
+8
,v
"7
aS
[b
i$
]#
+5
=m
1w
"3
,*
?u
-f
,Z
"I
aW
[U
i%
]3
-v
=T
1E
":
}G
[;
b2
]@
};
*/
"+
;M
"B]

Horizontal is this little gem:
,[.>+[-<,----------[>+<[-]]>],]

And Vertical is this:
eval"a=[i=0]*3e4;"+$<.bytes.map{|b|{?.,"putc a[i]",?,,"a[i]=getc",?[,"while a[i]>0",?],"end",?<,"i-=1",?>,"i+=1",?+,"a[i]+=1",?-,"a[i]-=1"}[b]}*";"

Which is a brainfuck interpreter stolen from this question. It qualifies for all of the hard mode criteria except the no comments bit, which I don't think is really fair to apply to brainfuck, or pretty much nothing but BF->BF would be possible.
Horizontal program runs till EOF(0) is read. Assumes newline at end of file.


Ruby,87
->c,z{a=g=3-5**0.5
10.times{x=(c*="i".to_c**0.4).real
z=-z
a&&=z<1+x*g&&x*4>g-4+g*z}
a}

An anonymous function taking the x and y coordinates as a complex number and the z coordinate as a real. (The question says "any reasonable" format which is a bit vague. If the format is not acceptable I can change it.)
Explanation
Below you can see a view looking down the z axis at the icosahedron's vertices. (for simplicity I have just drawn 2 pentagons that are perpendicular to the z axis.)
I have labelled all the points with positive z with their approximate coordinates. I have given the exact coordinates sqrt 0.8, 0, sqrt 0.2 for the point with positive z that lies in the xz plane (y=0), and I have also labelled the opposing point.
It can be seen that there is an edge parallel to the y axis whose equation is approximately z=0.4472, x=-0.7236. This edge is common to two faces of the icosahedron. I will describe these as a polar face and an equatorial face.
The equation of the polar face is z=1+x*g where g=3-sqrt(5) (this value was arrived at by studying Wikipedia and Wolfram Alpha, plus a bit of my own maths.) So z must be less than 1+x*g if the point is inside the icosahedron.
The equation of the equatorial face is x*4=g-4+g*z so x*4 must be greater than
g-4+g*z if the point is inside the icosahedron.
We could rotate these faces through 72 degrees to test if the point is inside the icosahedron, but it is easier to rotate the point about the origin. In order to cover both the top and bottom of the icosahedron, the symmetry operation applied to the point is a rotation of 36 degrees combined with a reflection in the xy plane (flip the z axis.) This operation is applied 10 times to cover all possibilities.

Ungolfed in test program
f=->c,z{
  a=g=3-5**0.5                    #g is slope of polar face. It is truthy, so can also be used to initialize a
  10.times{                       #generate 10 images of the point
    x=(c*="i".to_c**0.4).real     #rotate the point 36 degrees, assign the real value to x
    z=-z                          #flip the z axis
    a &&= z<1+x*g && x*4>g-4+g*z  #check the point is inside the two test planes and update a if necessary
  }
a}                                #return a true or false

p f["0+0i".to_c,0]                     #true
p f["1+i".to_c,1]                      #false
p f["-0.152053-0.46797i".to_c,0.644105]#false
p f["-0.14609-0.449618i".to_c,0.618846]#true

p f["-0.8944+0i".to_c,-0.4472]         #true, just inside vertex
p f["-0.8944+0i".to_c,0.4472]          #false, outside midpoint of an edge
p f["-0.8945+0i".to_c,-0.4473]         #false, just outside vertex


Seventy Seven Sevens Given a number n and an upper limit l list the numbers that can be created by multiplying two or more numbers consisting of only sevens of length n or less that are less than l. A161145 is close to this challenge, however, you will NOT be including the 7, 77, 777, 7777, 77777, etc..
Examples
n=anything, l<49 would result in:
[]

n=1, l=49 would result in:
7*7=49

f(1,49)=[49]

n=1, l=343 would result in:
7*7   =49
7*7*7 =343

f(1,343)=[49,343]

n=2,l=6000 would result in:
7*7    =49
7*7*7  =343
7*7*7*7=2401
7*77   =539
7*7*77 =3773
77*77  =5929

f(2,6000)=[49,343,539,2401,3773,5929]

n=3, l=604000 would result in:
[49, 343, 539, 2401, 3773, 5439, 5929, 16807, 26411, 38073, 41503, 59829, 117649, 184877, 266511, 290521, 418803, 456533, 603729]

Etc...
Rules

You do not have to output intermediate steps, this was done for clarity.
Output can be as an array or separated by any character (even newlines).
Output must be in numerical order, lowest to highest.
To make the title relevant, highest n that must be handled is n=77 (if you can't handle that high, note why - language restrictions are acceptable, laziness is not). This limitation is to hinder those looking to build the entire superset in memory.
If TIO cannot run n=77 for your code, explain what specs were required to achieve n=77.
For a product to be valid it must consist of at least 2 numbers.
This is code-golf lowest byte-count will be deemed victorious.
You may choose the list to contain items less than l or less than/equal to l.
BONUS: If your code is exactly 77 bytes, kudos from me; worthless, I know.

Jelly, 21 20 19 18 bytes

R7ẋḌµ;ŒċP€⁹f€FµÐLḟ

Note that the output doesn't match the OP's. I've left a comment.

Try it online!

How it works

R7ẋḌµ;ŒċP€⁹f€FµÐLḟ  Main link. Left argument: n. Right argument: l

R                   Range; yield [1, ..., n].
 7ẋ                 Times; yield [[7], ..., [7] * n].
   Ḍ                Undecimal; yield s := [7, 77, ...].
    µ         µÐL   Begin a new chain with argument s and call the chain between
                    until the results no longer chain.
                    Return the last unique result.
      Œċ            Combinations; return all unordered pairs in integers in the
                    return value.
     ;              Concatenate the return value and its pairs.
        P€          Take the product of each individual integer and each pair in
                    the result.
          ⁹f€       Filter each; for each j in [1, ..., l], intersect [j] with the
                    array of products. The result is sorted and contains no
                    duplicates.
                 ḟ  Filterfalse; remove the elements of s from the result.


Maximise the squared difference Consider a permutation of the integer values from 1 to N. E.g. this example for N = 4:

[1, 3, 4, 2]

We'll consider this list to be cyclic, such that 1 and 2 are treated as adjacent. One quantity we can compute for such a list is the total squared difference of adjacent values:

(1-3)² + (3-4)² + (4-2)² + (2-1)² = 10

Your task is to find a permutation which maximises this quantity, given a positive integer N. In the case of N = 4 the above example is not optimal (in fact, it's minimal). We can achieve a total squared difference of 18 with the following permutation (as well as several others):

[1, 4, 2, 3]

Your algorithm must run in polynomial time (of N). In particular, you cannot simply compute the total squared difference of all permutations.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

Output may be in any convenient, unambiguous, flat list or string format. You may choose to return a list with values from 0 to N-1 instead of 1 to N.

Standard code-golf rules apply.

Test Data

There is a nice analytical solution for this problem. E.g. all valid solutions for N = 10 are equivalent to the following list (up to cyclic shifts and reversal):

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

I don't want to reveal too much beyond that (although it's probably enough to figure out the pattern), so instead of giving any more examples, you can check that your results have the following total squared differences for a given N:

N    Total squared difference

1                         0
2                         2
3                         6
4                        18
5                        36
6                        66
7                       106
8                       162
9                       232
10                      322
33                    11936
100                  333202
333                12308236
1000              333332002

This is OEIS entry A064842 (which also contains a reference to a paper with a solution to this challenge if you're stuck).

Jelly, 24 21 15 14 10 9 bytes

RUĖµ«/€ị"

To compute the total squared difference, append µ_ṙ1$²S to the code. Try it online!

Background

One way to generate a permutation with maximized squared difference is to take the integers 1 to n in ascending order, and swap the second from the left with the second from the right, the fourth from the left with the fourth from the right, and so forth until we meet in the middle.

For example, for n = 8, 9 we have

1 2 3 4 5 6 7 8        1 2 3 4 5 6 7 8 9
  ^   ^ ^   ^            ^   ^   ^   ^

(carets mark integers to be swapped), which results in

1 7 3 5 4 6 2 8        1 8 3 6 5 4 7 2 9

after swapping.

One way to achieve these swaps, independently of the parity of n, is as follows.

Start by writing the integers in ascending order and in descending order, one below the other.

1 2 3 4 5 6 7 8        1 2 3 4 5 6 7 8 9
8 7 6 5 4 3 2 1        9 8 7 6 5 4 3 2 1

For each pair of integers, compute the minimum of the pair. This gives the distance to the nearest edge, i.e., the index from the left or the right (whichever is lower).

1 2 3 4 5 6 7 8        1 2 3 4 5 6 7 8 9
8 7 6 5 4 3 2 1        9 8 7 6 5 4 3 2 1

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

If the minimum is odd, the integer should stay in its place, so we select the one from the first row; if it is even, the integers should be swapped, so we select the one from the second row.

1   3     6   8        1   3   5   7   9
  7   5 4   2            8   6   4   2

This is the desired output.

How it works

RUĖµ«/€ị"    Main link. Input: n

R            Range. Yields [1, ..., n].
 U           Upend. Yields [n, ..., 1].
  Ė          Enumerate. Yields p := [[1, n], [2, n-1], ... [n-1, 2], [n, 1]].

   µ         Begin a new, monadic chain. Argument: p
     /       Reduce...
      €        each pair of p...
    «          by minimum.
        "    For each minimum and the corresponding pair of p:
       ị       Select the element at that index.
            Indices are modular and 1-based in Jelly, so this selects the first
            element if the minimum is odd, and the second one if it is even.


Verify Brainfuck program Yet another Brainfuck parsing problem, but this time... different.

  You are working in the Infinite Monkeys Incorporated, the company making Brainfuck programs, to solve various interesting problems (by accident, no less - after all, the company makes random programs). However, it appears that your fast Turing machines that only execute Brainfuck have a small and expensive problem with syntax errors - make one, and the computer explodes. It's probably a design flaw, but nobody had bothered to find why it happens.

  As Turing machines (especially fast ones) are expensive (after all, they have infinity RAM which costs), it would be better to make sure that the program doesn't have any syntax errors before executing the code. Your company is going to run lots of code, so manual verification won't work. Write a program that reads the STDIN for Brainfuck code, and exits with exit status set to anything other than 0 (error) if program has any syntax error (for example, ] is a syntax error, because there is no matching [). Exit with exit status set to 0 if the program is completely fine.

  Make sure that your program correctly notices mistakes involving []. You wouldn't want another computer to explode, would you? Oh, and make sure it's as short as possible - your boss pays for short programs (because he thinks they are fast, or something). Oh, and you don't have to code in Brainfuck (in fact, you cannot, because Brainfuck doesn't support exit codes) - your code will be ran on normal computer.

So, as you can see, your job is to check if Brainfuck program is "valid" (has paired [] symbols). Please note that Brainfuck programs can have other characters than [], so don't refuse the program just because it has other commands. Smallest code wins, but probably you would care more about upvotes anyway.

Brainfuck 76 bytes
>>+[<+++++++++[->---------<]+>-[--[[-]<->]<[<[->-]>[<+]<]>]<[-<+>]+>,]<<[<+]

This goes out of it's bonds if square brackets are unbalanced turning the bf interpreter/compiler to fail runtime and some of them have exit codes to reflect that.
requires eof=0, wrapping values and finit number of cells
In Ubuntu you can use the interpreter bf (sudo apt-get install bf)
% echo '[[[]' | bf -n bf_matching.bf
Error: Out of range! Youwanted to '<' below the first cell.
To solve, add some '>'s at the beginning, for example.
an error occured
% echo $?
5
% bf -n bf_matching.bf < bf_matching.bf
% echo $?
0


How long is my number? Challenge
Given an integer \$Q\$ in the range \$-2^{100} ≤ Q ≤ 2^{100}\$, output the number of digits in that number (in base 10).
Rules
Yes, you may take the number as a string and find its length.
All mathematical functions are allowed.
You may take input in any base, but the output must be the length of the number in base 10.
Do not count the minus sign for negative numbers. The number will never have a decimal point.
Zero can either have one or zero digits.
Assume the input will always be a valid integer.
Examples
Input > Output

-45 > 2
12548026 > 8
33107638153846291829 > 20
-20000 > 5
0 > 1 or 0

Winning
Shortest code in bytes wins.

Taxi, 1118 bytes
1 is waiting at Starchild Numerology.Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Chop Suey.Go to Chop Suey:n 1 r 1 l 4 r 1 l.Pickup a passenger going to Crime Lab.'-' is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 3 l.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 1 r 2 r 2 l.Switch to plan "n" if no one is waiting.-1 is waiting at Starchild Numerology.[n]0 is waiting at Starchild Numerology.Go to Starchild Numerology:s 1 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Pickup a passenger going to Addition Alley.Go to Cyclone:e 1 l 2 r.[r]Pickup a passenger going to Cyclone.Pickup a passenger going to Addition Alley.Go to Zoom Zoom:n.Go to Addition Alley:w 1 l 1 r.Pickup a passenger going to Addition Alley.Go to Chop Suey:n 1 r 2 r.Switch to plan "f" if no one is waiting.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park:n 1 l 3 l 1 l.Go to Cyclone:n 1 l.Switch to plan "r".[f]Go to Addition Alley:n 1 l 2 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Try it online!
Ungolfed:
1 is waiting at Starchild Numerology.
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to Chop Suey.
Go to Chop Suey: north 1st right 1st left 4th right 1st left.
Pickup a passenger going to Crime Lab.
'-' is waiting at Writer's Depot.
Go to Writer's Depot: north 1st left 3rd left.
Pickup a passenger going to Crime Lab.
Go to Crime Lab: north 1st right 2nd right 2nd left.
Switch to plan "n" if no one is waiting.
-1 is waiting at Starchild Numerology.
[n]
0 is waiting at Starchild Numerology.
Go to Starchild Numerology: south 1st right 1st left 1st left 2nd left.
Pickup a passenger going to Cyclone.
Pickup a passenger going to Addition Alley.
Go to Cyclone: east 1st left 2nd right.
[r]
Pickup a passenger going to Cyclone.
Pickup a passenger going to Addition Alley.
Go to Zoom Zoom: north.
Go to Addition Alley: west 1st left 1st right.
Pickup a passenger going to Addition Alley.
Go to Chop Suey: north 1st right 2nd right.
Switch to plan "f" if no one is waiting.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: north 1st left 3rd left 1st left.
Go to Cyclone: north 1st left.
Switch to plan "r".
[f]
Go to Addition Alley: north 1st left 2nd left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: north 1st right 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.

Explanation:
Pickup the input and split it into individual characters
Pickup the value 1.
If the first character a hyphen, add -1. Otherwise, add 0.
Keep picking up characters and adding 1 until you're out.
Convert the running total to a string and print to stdout.


Magic mirror madness Introduction

I have a room full of magic mirrors.
They are mysterious artifacts that can duplicate any item, except another magic mirror.
More explicitly, a duplicate version of the item will appear on the other side of the mirror, at the same distance.
However, if there is another magic mirror in the way on either side, between the duplicating mirror and either item (original or duplicate), the duplicate is not formed.
The original item can be either left or right of the mirror, and the duplicate will appear on the other side.
Also, the duplicate item can itself be duplicated by another mirror.
Items never block the duplication of other items (except by being directly on the position of the would-be duplicate).

Input

Your input is a string consisting of the characters .#|, which represent empty space, items, and magic mirrors.
There will always be at least one magic mirror in the input.

Output

Your output shall be another string where each magic mirror has duplicated every item it can, according to the rules above.
You can assume that there will always be an empty space on the spot where a duplicate item appears (so they will no go out of bounds).

Examples

Consider the input string

.#.|.....|......#
 A B     C      D

where we have marked some positions for clarity.
The mirror B duplicates item A, which ends up to its right:

.#.|.#...|......#
 A B     C      D

Mirror C then duplicates the new item:

.#.|.#...|...#..#
 A B     C      D

Mirror C cannot duplicate item A, since mirror B is in the way.
It also cannot duplicate item D, since mirror B is in the way on the other side.
Likewise, mirror B cannot duplicate item D or the duplicate next to it, since mirror C is in the way, so this is the correct output.

For another example, consider the input

.##..#...|#..##...|..##....#.
 AB  C   DE  FG   H  IJ    K

Mirror D can duplicate A and B to the right, and E and G to the left.
C and F are already duplicates of each other.
The string becomes

.##.##..#|#..##.##|..##....#.
 AB  C   DE  FG   H  IJ    K

Mirror H can duplicate E, F, and the duplicates of A and B to the right, and I to the left.
G and J are already duplicates of each other, and mirror D is in the way of K.
Now we have

.##.##..#|#..#####|#####..##.
 AB  C   DE  FG   H  IJ    K

Finally, mirror D can duplicate the duplicate of I to the left.
We end up with

.#####..#|#..#####|#####..##.
 AB  C   DE  FG   H  IJ    K

Rules and scoring

You can write either a full program or a function.
The lowest byte count wins.
Submissions that don't use regex engines compete separately from those that do, and may be marked with (no regex).

Test cases

"|" -> "|"
"..|.." -> "..|.."
".#.|..." -> ".#.|.#."
"..#|.#." -> ".##|##."
".#..|....|.." -> ".#..|..#.|.#"
".|..|.#....." -> "#|#.|.#....."
"...|.#...|....#" -> ".##|##...|...##"
"......#|......." -> "......#|#......"
".#.|.....|......#" -> ".#.|.#...|...#..#"
".......|...#.##|...." -> "##.#...|...#.##|##.#"
"...#..||.......#..#...#" -> "...#..||.......#..#...#"
".##|.#....||#||......#|.#" -> ".##|##....||#||.....##|##"
".##..#...|#..##...|..##....#." -> ".#####..#|#..#####|#####..##."
".#|...||...|#...|..##...|#...." -> ".#|#..||.##|##..|..##..#|#..##"
"....#.|...#.|..|.|.....|..#......" -> "..#.#.|.#.#.|.#|#|#.#..|..#.#...."
"..|....|.....#.|.....|...|.#.|..|.|...#......" -> ".#|#...|...#.#.|.#.#.|.#.|.#.|.#|#|#..#......"

Retina, 50 bytes

+`([#.])(([#.])*\|(?>(?<-3>[#.])*))(?!\1)[#.]
#$2#

Try it online! (The first line enables a linefeed-separated test suite.)

I guess this is the opposite of a (no regex) submission.

Explanation

This is simply a regex substitution, which is applied repeatedly (+) until the string stops changing. I'm using balancing groups to make sure that the two mirrored positions are the same distance from the given mirror (backreferences won't do, since the exact string on both sides of the | may be different).

([#.])            # Match and capture a non-mirror cell.
(                 # This will match and capture everything up to its corresponding
                  # cell so that we can write it back in the substitution.
  ([#.])*         #   Match zero or more non-mirror cells and push each one onto
                  #   group 3. This counts the distance from our first match to
                  #   the mirror.
  \|              #   Match the mirror.
  (?>             #   Atomic group to prevent backtracking.
    (?<-3>[#.])*  #     Match non-mirror while popping from group 3.
  )               #   There are three reasons why the previous repetition
                  #   might stop:
                  #   - Group 3 was exhausted. That's good, the next position
                  #     corresponds to the first character we matched.
                  #   - We've reached the end of the string. That's fine,
                  #     the last part of the regex will cause the match to fail.
                  #   - We've hit another mirror. That's also fine, because
                  #     the last part of the regex will still fail.
)
(?!\1)            # Make sure that the next character isn't the same as the first
                  # one. We're looking for .|# or #|., not for #|# or .|.
[#.]              # Match the last non-mirror character.

This is replaced with #$2# which simply replaces both the first and last character of the match with a #.


Calculate Landau's function Landau's function \$g(n)\$ (OEIS A000793) gives the maximum order of an element of the symmetric group \$S_n\$.  Here, the order of a permutation \$\pi\$ is the smallest positive integer \$k\$ such that \$\pi^k\$ is the identity - which is equal to the least common multiple of the lengths of the cycles in the permutation's cycle decomposition.  For example, \$g(14) = 84\$ which is achieved for example by (1,2,3)(4,5,6,7)(8,9,10,11,12,13,14).

Therefore, \$g(n)\$ is also equal to the maximum value of \$\operatorname{lcm}(a_1, \ldots, a_k)\$ where \$a_1 + \cdots + a_k = n\$ with \$a_1, \ldots, a_k\$ positive integers.

Problem

Write a function or program that calculates Landau's function.

Input

A positive integer \$n\$.

Output

\$g(n)\$, the maximum order of an element of the symmetric group \$S_n\$.

Examples

n    g(n)
1    1
2    2
3    3
4    4
5    6
6    6
7    12
8    15
9    20
10   30
11   30
12   60
13   60
14   84
15   105
16   140
17   210
18   210
19   420
20   420

Score

This is code-golf: Shortest program in bytes wins.  (Nevertheless, shortest implementations in multiple languages are welcome.)

Note that there are no requirements imposed on run-time; therefore, your implementation does not necessarily need to be able to generate all the above example results in any reasonable time.

Standard loopholes are forbidden.

Wolfram Language (Mathematica), 44 bytes

Max[PermutationOrder/@Permutations@Range@#]&

Try it online!

Wolfram Language (Mathematica), 31 bytes

@DanielSchepler has a better solution:

Max[LCM@@@IntegerPartitions@#]&

Try it online!


Modular Fibonacci Cycles The Fibonacci sequence is a well known and famous sequence, where each successive element is the sum of the previous two. A modular Fibonacci sequence is the same, except that the addition is performed over a finite field, or to put it another way, a modulo operation is performed after each addition.

For instance, the modular Fibonacci sequence with starting values 1, 1 and modulus 5 is:

1, 1, 2, 3, 0, 3, 3, 1, 4, 0, 4, 4, 3, 2, 0, 2, 2, 4, 1, 0, 1, 1, ...

At this point, the sequence is once again 1, 1, and so the sequence will repeat, cyclically, with a cycle length of 20.

Your challenge is to find the (minimal) cycle length for a specific starting pair and modulus, in the fewest bytes.

Details: The initial values will both be in the range 0 <= i,j < m, where m is the modulus. The initial values will not both be zero, and the modulus will be at least 2. You may take the input in any standard means or format, in any order, function, program or similar, and output via return or print. Standard loopholes apply.

Examples:

First element, second element, modulus:

1, 1, 5 => 20
1, 1, 4 => 6
2, 4, 6 => 8
3, 3, 6 => 3

This is code golf - shortest code in bytes wins. Good luck!

Python, 56
g=lambda a,b,m,u=0:u!=(a,b)and-~g(b,(a+b)%m,m,u or(a,b))


Flappy Bird Clones :) Everyone's been freaking out about that stupid "Flappy Bird" game being removed. So, your task is to crate a Flappy Bird Clone game. Its really simple. Here are the guide lines:

It can use either ascii art or real images
You can make your "bird" flap with either a click or a key press
It should try to be as short as possible, hence the code-golf tag.

Here's an example: http://www.reddit.com/r/learnprogramming/comments/1xiimx/i_couldnt_sleep_so_i_cloned_your_flappy_bird/

In order to be a "Flappy Bird Clone," your game needs to have the following:

A bird, or other character
The "bird" should move slightly up when a key is pressed or you click/tap
If there is no clicking/tapping/etc, the "bird" should rapidly move downwards
Pipes or other obstacles should move leftwards on the screen, creating the illusion that the bird is moving
The pipes should have a small gap for the bird to fly through.
Every time you pass through a gap between pipes, your score increases by 1.
If you hit a pipe or the ground, the game ends and your score is displayed.

It doesn't really need to be a "bird" or a "pipe," it can all be ascii. Here's a very minimal example of a flappy bird screen:

/-----[4]-----\
| ||      ||  |
| ||      ¯¯  |
| ||  O>      |
| ¯¯      __  |
| __      ||  |
| ||      ||  |
\-------------/

Javascript + jQuery (997)

Tested on Chrome 32, Firefox 27, IE9

Open Console (F12) from this page and copy/paste the following code.

scroll(0,0);h=1/30;p=[];r=320;n=0;w=80;f=2.5;o=80;t=setInterval;$('#question').children().hide().end().append('

').append('

').click(function(){v=100});$('#s').css({position:'relative',margin:'auto',border:'2px solid',width:200,height:r}).append('');$('').appendTo('head');function u(){$('#m').text('score '+m+' (max '+n+')')}function i(){x=r/2;v=0;m=0;p.length=0;u()}i();t("v-=h*100;x+=h*v;if(x<0||x>r)i();$('.p').remove();for(j=0;j
200){p.shift();j--;m++;if(m>n)n=m;u();}else if((p[j].r>165&&p[j].r<185)&&(x
p[j].h+o))i();else{$('

').appendTo('#s').css({bottom:0,right:p[j].r,height:p[j].h});$('

').appendTo('#s').css({bottom:p[j].h+o,right:p[j].r,height:320-p[j].h-o})}}$('#b').css({position:'absolute',left:0,bottom:x-25})",h*1e3);t("p.push({h:Math.random()*(r-o),r:0})",f*1e3)

  The game replace the question block of this page.
  You have to click on the game frame to make the bird fly.

Ungolfed and commented version :

$('#question').children().hide();
$('#question').append('

');
$('#question').append('

');
$('#scene').css({position:'relative',margin:'auto',border:'2px solid black',width:'200',height:'320'});
$('#scene').append('');
$('#bird').css({display:'block',position:'absolute',left:0,'pointer-events':'none',margin:'0 auto'});
$(window).scrollTop(0);

//CONFIGURATION
var dt=1/30,      //delta timestep (typically 30Hz)
    pipevel=80,   //pipe velocity (in pixels per second)
    pipefreq=2.5, //pipe spawn frequency (in second)
    holesize=80,  //hole size (in pixels)
    gravity=-100, //gravity (in pixels per square second)
    punchvel=100; //velocity punch when clicked (in pixels per second)

var x, y, pipes=[], roof=$('#scene').height(), score, maxscore=0;

function updateScore() {
  $('#score').text('Score : '+score+' (max : '+maxscore+')');
}

function init() {
  x=roof/2; //position
  v=0; //velocity
  score=0;
  pipes.length=0;

  updateScore();
}

function step() {
  //euler integration
  v+=dt*gravity;
  x+=dt*v;

  if (x<0 || x>roof)  init();

  //pipes
  $('.pipe').remove();
  for (i=0; i<pipes.length; i++) {
    pipes[i].rightpos += dt*pipevel;
    if (pipes[i].rightpos > 200) {
      pipes.shift();
      i--;
      score++;
      if (score>maxscore) maxscore=score;
      updateScore();
    } else if ((pipes[i].rightpos > 165 && pipes[i].rightpos < 185) && (x < pipes[i].holepos || x > pipes[i].holepos+holesize)) {
      //collision
      init();
    } else {
      $('#scene').append('

');
      $('#scene').append('

');
    }
  }

  $('#bird').css({bottom:Math.floor(x)-25});

  setTimeout(step, dt*1000);
}

$('#question').click(function() {
  v=punchvel;
});

function addPipe() {
  pipes.push({holepos:Math.random()*(roof-holesize),rightpos:0});
  setTimeout(addPipe, pipefreq*1000);
}

init();
setTimeout(step, dt*1000);
setTimeout(addPipe, pipefreq*1000);

You can easily modify the configuration (gravity, pipe velocity...), have a look at commented version.


Cartesian LCM of two arrays Given two nonempty arrays of natural numbers \$a\$ and \$b\$, return the shortest nonempty array of pairs of natural numbers \$q\$ such that the sequence of first elements of \$q\$ consists of a whole number of repeated copies of \$a\$, and the sequence of second elements of \$q\$ consists of a whole number of repeated copies of \$b\$.

When \$a\$ and \$b\$ have the same length, this acts like a zip, but when the lengths of \$a\$ and \$b\$ are coprime, this acts like a Cartesian product.

You can use any reasonable input and output format for arrays (pointers, lists, space-separated strings, strings of char codes, etc.)

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

Test Cases

[1],          [2]       -> [(1, 2)]
[1, 2],       [3]       -> [(1, 3), (2, 3)]
[1, 2],       [3, 4]    -> [(1, 3), (2, 4)]
[1, 2, 3, 4], [5, 6]    -> [(1, 5), (2, 6), (3, 5), (4, 6)]
[5, 5, 5],    [5, 5, 5] -> [(5, 5), (5, 5), (5, 5)]
[5, 5],       [5, 5, 5] -> [(5, 5), (5, 5), (5, 5), (5, 5), (5, 5), (5, 5)]
[1, 2, 3, 4], [1, 2, 3, 4, 5, 6] ->
    [(1, 1), (2, 2), (3, 3), (4, 4),
     (1, 5), (2, 6), (3, 1), (4, 2),
     (1, 3), (2, 4), (3, 5), (4, 6)]

J, 14 13 bytes

,./@($&>~*./)

Try it online!

-1 byte thanks to Bubbler

This answer takes the two lists as its left arg, and the two list lengths as its right arg.

($&>~*./) is a dyadic hook which applies gcd between the two right arg lengths *./ and the reshapes the two left arg lists $ to that length after opening them &>.  At this point they'll be the same length so boxing is no longer needed.
[:,./ so now we can just zip them ,.

original answer taking the lists directly

J, 17 16 bytes

(*.&#$[),.*.&#$]

Try it online!

*.&# is the gcd *. after taking length # of both args

It turns out to be shorter to repeat this phrase than to remain DRY.

,. is zip and and $ is shape.  So we shape the left arg [ by the gcd of the list lengths, do the same to the right arg ], and zip them.


Riemann Series Theorem The Riemann series theorem states that the terms of a conditionally convergent series can be permutated such that the resulting series converges to an arbitrary value.

The Challenge

Write a program or function that takes in three parameters via stdin (or equivalent) or as parameters:

The expression for the sequence x_n (with variable n). The exact format (e.g., whether a power is represented as ^, pow() or **) is irrelevant and may be chosen to fit your language. Alternatively you may pass a function directly as an argument. The definition of the function does not count towards the byte count.
A value S that we want to approach. Numerical values only are fine, you don't need to support mathematical expressions.
A threshold t>0. Numerical values only are fine here as well.

Your program/function must output (to stdout or equivalent) resp. return a space- or newline-separated list p_1, ..., p_N of indices.

Your output must satisfy the condition that the sum from k = 1..N over x_(p_k) differs from S no more than t in terms of the absolute difference. In other words, it must satisfy

So far, since the output will be a finite number of indices, the order would not matter. Therefore, another restriction applies: with decreasing threshold t, you may only add indices to the output (assuming a fixed S).

In other words, for a fixed S, if t_1 < t_2 and [x_1, ..., x_N] is a solution for t_2, then a solution for t_1 must be of the form [x_1, ..., x_N, ..., x_M] with M >= N.

Details and Restrictions

The order of the arguments may be changed to suit your needs.
Provide an example call with the arguments from the example below. Ideally, post a link to an online interpreter/compiler.
eval and the like are explicitly allowed for the purpose of evaluating mathematical expressions.
Sequences are 1-based, so the first index is 1.
You don't need to take special care of big integers or floating point problems. There will be no extreme test cases such as using machine precision as the threshold.
Standard loopholes apply.
You may assume that the sequence passed to your program is conditionally convergent, i.e. that it is possible to solve the task with the given parameters.

Example

Say your program is in a file riemann.ext, then a call might be

./riemann.ext "(-1)^(n+1)/n" 0.3465 0.1

Scoring

This is code-golf. The shortest program in bytes (UTF-8 encoding) wins. In case of a tie, the earlier entry wins.


Find the longest run of consecutive digits Simple challenge: given a series of positive integer numbers, find the number that contains among its digits the longest run of consecutive digits. The trick? It's allowed for the digits in the runs to wrap around the possible values (0123456789) and to run backwards. So both 2345, 89012 and 5432109 are valid runs of consecutive digits (but not 3456765 nor 321090123 as the run must be always in the same direction, although 3456765 can be considered as two runs: 34567 and 765). In the case of ties, return the first one.

Test cases:

Input:  [3274569283, 387652323, 23987654323648, 2345687913624]
Output: 23987654323648
        (The run is 98765432; run length: 8)

Input:  [123012363672023, 098761766325432, 15890123456765]
Output: 15890123456765
        (The run is 8901234567; run length: 10)

Input:  [43, 19, 456]
Output: 456

Input:  [5, 9, 0]
Output: 5

Input:  [71232107, 7012347]
Output: 7012347

Input:  [1234, 32109876]
Output: 32109876

Input:  [9090, 123]
Output: 123

Notes:

There will be at least one number in the input.
Input numbers can contain leading zeroes.
Input and output can be in any reasonable format. So input numbers can be taken as strings, lists of digits/characters...
Output can contain trailing and/or leading whitespaces and newlines as long as the number is printed.
This is code-golf, so may the shortest program/function for each language win!

Jelly, 18 bytes

I9,-;N¤yŒgỊS€ṀµÐṀḢ

Try it online!

Takes and returns as list of digits so as to preserve leading zeroes.


P Pr Pre Pref Prefi Prefix Prefixe Prefixes Given some finite list, return a list of all its prefixes, including an empty list, in ascending order of their length.
(Basically implementing the Haskell function inits.)
Details

The input list contains numbers (or another type if more convenient).
The output must be a list of lists.
The submission can, but does not have to be a function, any default I/O can be used.
There is a CW answer for all trivial solutions.
This is code-golf, so the shortest code in bytes wins

Example
[] -> [[]]
[42] -> [[],[42]]
[1,2,3,4] -> [[], [1], [1,2], [1,2,3], [1,2,3,4]]
[4,3,2,1] -> [[], [4], [4,3], [4,3,2], [4,3,2,1]]

Haskell, 20 bytes

Edit: Yet a byte shorter with a completely different scan.

An anonymous function slightly beating the trivial import.

scanr(\_->init)=<<id

Try it online!

Uses =<< for the abbreviation (scanr(\_->init)=<<id) l = scanr(\_->init) l l.
Scans a list l from right to left, collecting intermediate results with the function \_->init.
That function ignores the elements scanned through (they're only used to get the right total length for the collected results), so really iterates applying init to the initial value of the scan, which is also l.


Polyglot the (non constant) OEIS! Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers.
Introduction
We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version of the interesting sequences? Well, that would be kinda too easy, wouldn't it and how would you select a sequence with our standard interface!? No. We need an easier solution to this. A polyglot!
Input
Your input will be a non-negative integer n.
Output
Your output will either be

The n-th entry of an OEIS sequence OR
The first n entries of an OEIS sequence.

You may take the index to be 1-based or 0-based as you prefer.
To not make this question a duplicate of The versatile integer printer constant sequences are banned. This should also increase the difficulty level of submissions and avoid "boring" solutions ;)
A sequence is non-constant if there exist two sequence members that are unequal.
Uhm, so where is the Challenge?
You have to polyglot the above functionality. That is if you support languages A, B and C all must implement different OEIS sequences. The choice of sequence is not limited except that you need different ones for all languages.
That is, if you run the provided program in language A, then sequence X shall be generated, if you run the provided program in language B, then sequence Y shall be generated (with X!=Y) and if you run the provided program in language C, then sequence Z shall be generated (with X!=Z && Y!=Z).
Who wins?
The answer with the most sequence/language pairs wins. First tie-breaker is code-size (in bytes) with lower being better. Second tie-breaker is submission time with earlier being better.
Any final Words / Rules?

You must declare which language will generate which sequence.
Standard I/O rules apply.
If different encodings are used between languages, both programs must use the same byte-sequence.
Language (Python 2/3) revisions do count as different languages. Different implementations of a language (such as Browser JS vs Node.js) also count as different languages.
Standard loopholes apply.

3 languages (1 byte) - Pyth (A001477), MATL (A000027), Braingolf (A000217)
Q

Try Pyth online!, 0-indexed (non-negative integers)
Try MATL online!, 0-indexes (positive integers)
Try Braingolf online!, 1-indexed (triangular numbers)

How?
Q does the following:

In MATL, it means + 1, so it basically evaluates to input + 1.

In Pyth, it means input, so it just outputs the input.

In Braingolf, it is the built-in for triangular numbers.

Mini-polyglot
Pyth can be replaced by any of the following languages: GolfScript, Pyke, Brachylog or Brain-Flak.


"Useful" self-modifying script for financial firm True Story:  Several years ago while interviewing at an investment advisory firm that managed over a billion dollars in client funds, I was asked a collection of reasonable and bizarre questions by a partner in the firm.  An example of a reasonable question would be "What can go wrong with a linear fit?".

But then, things devolved....

Interviewer: "Have you ever written code that modifies itself?"

Job Candidate:  "No, can't say that I have"

Interviewer: "We have one guy who writes programs that modify themselves, I think he uses awk"

Job Candidate: "Wow. That's pretty incredible. AWK? "

Now it is your turn to be that one guy that financial houses would kill to hire...

Challenge:  Write a self-modifying script of some kind that performs a "useful financial function".

Rules:

Use a scripting language, not a language requiring compilation such as C or Java.  Perl, Python and the like that will work from a #! are OK.  Of course, heroes use awk, but awk is not a requirement.
Self-modifying means that the script modifies its own source code. The script must be reusable after it has modified itself. The script might also generate useful user output to STDOUT or some other interface.
The definition of "useful financial function" is left to the voters and can be as intriguing or dysfunctional as you prefer. If you need examples for inspiration, here are a few ideas: stock picking, stock trading, prediction and/or fitting, future value of account, Ponzi scheme generator, risk analysis of Nigerian email deals, salary bonus calculator for partners vs employees, etc.
Most upvotes wins.

EDIT:  I agree with one participant who notes that it is not obvious how to read the current gawk script from within gawk. Here is a solution for Linux-based systems and other O/S that have a /proc filesystem.

#!/usr/bin/gawk -f
BEGIN {
pid = PROCINFO["pid"]
commfile = "/proc/"pid"/comm"
print "I will look here for the script file name: " commfile
print "Here is what is in that file:"
getline scriptfilename < commfile
print scriptfilename
print "Here is my script:"
while (getline line < scriptfilename){
      print line
      }
}

Pseudocode

// Set up a cron job to run this script (only) once a day

yesterdays_stock_price = '46.48'

todays_stock_price = curl_google_finance('VTSMX')

print "Difference between yesterday's stock price and today's: "

print todays_stock_price

self = open('self.file')

self.replace( /yesterdays_stock_price = '[0-9\.]+'/, todays_stock_price)

self.save()


Combinations of stepwise increasing integers Working on something in probability theory, I stumbled across another combinatorical exercise. These are always fun to solve, searching for intelligent approaches. Of course, one can use brute force for the following task, but this challenge is restricted complexity, so this is not allowed.

Task

Given an integer Input \$n > 1\$, print all integer vectors of length \$n\$, respecting following conditions:

\$v_1 = 1\$
\$v_{i+1} - v_i \in \{0,1\}\$
\$v_n \neq n\$

example:

Input:

n=4

Output:

[1 1 1 1]

[1 1 1 2]

[1 1 2 2]

[1 1 2 3]

[1 2 2 2]

[1 2 2 3]

[1 2 3 3]

Additionally, time complexity of your solution must be \$O(2^n)\$. Note that generating all vectors and then filtering would be \$O(n^n)\$, which is not acceptable. A direct construction, not generating any false vector or duplicate vector at all, seems to be a bit more of a challenge.

Having said that, shortest code in bytes, respecting the above condition, wins.

Ruby, 65 55 bytes

->n{(0..2**~-n-2).map{|x|w=1;(1..n).map{|d|w+=x[n-d]}}}

Try it online!
How:
Partial sum of bits (starting with 1) of all numbers up to 2n-1-2
For example: if the number is 111010011 it becomes:
  1 1 1 0 1 0 0 1 1
  | | |   |     | |
  v v v   v     v v
 +1+1+1  +1    +1+1
  -----------------
1 2 3 4 4 5 5 5 6 7
|
Initialized to 1


Celsius - Fahrenheit anagram Task

  Make a complete program or a function which calculates sum of all temperatures which, when written in Celsius and Fahrenheit scale, are anagram of each other.

Description

For example, 275 degree Celsius = 527 degree Fahrenheit, and 527 is anagram of 275. Non-integer temperatures (either in degree Celsius or degree Fahrenheit) and temperatures colder than 0 degree Celsius (like -40C = -40F) will not be considered.

Input

Input is a temperature in format ([1-9][0-9]*)(C|F) (example: 42F = 42 degree Fahrenheit, 125C = 125 degree Celsius, ...).

The program should be able to handle temperature less than 1000000C.

Output

Output is sum of all temperatures less than the temperature given by input, which, when written in Celsius and Fahrenheit scale, are anagram (without leading zeroes) of each other. Output will be two integers separated by a space. The first one will be the sum in degree Celsius, and the second one will be the sum in degree Fahrenheit.

If there's no such temperature, return or output 0 0.

Example

Input : 42C

There's no such temperature
Output : 0 0

Input : 300C

There's one temperature : 275C = 527F
Output : 275 527

Input : 10000F

There're three temperatures : 275C = 527F, 2345C = 4253F, and 4685C = 8465F
Output : 7305 13245

C# - 166

Due to the small number of matches, I thought it might be easier to hardcode the outputs:

void F(string i){int n=int.Parse(i.Substring(0,i.Length-1));
n=i.Last()=='C'?n:5*(n-32)/9;
Console.Write(n>4685?"7305 13245":n>2345?"2620 4780":n>275?"275 527":"0 0");}

Edit: 352

To do it right requires a bit more work. Here's a first attempt at using a whole pile of linq:

using System;
using System.Linq;
class P{static void Main(string[] i)
{
   int n=int.Parse(i[0].Substring(0,i[0].Length-1));
   n=i[0].Last()=='C'?n:5*(n-32)/9;
   var q=Enumerable.Range(1,n).Where(x=>new string(((decimal)x*9/5+32).ToString().OrderBy(y=>y).ToArray())==new string(x.ToString().OrderBy(y=>y).ToArray()));
   Console.Write(q.Sum()+" "+q.Sum(x=>x*9/5+32));
}}

Maybe the 'use a pile of linq instead of a loop' approach hurt me too much. I'll try and shorten it.

Edit 2: 356

Since I'm already way behind in raw count, here's a one-liner from hell:

Console.Write(Enumerable.Range(1,i.Last()=='C'?int.Parse(i.Substring(0,i.Length-1)):5*(int.Parse(i.Substring(0,i.Length-1))-32)/9).Where(x=>new string(((decimal)x*9/5+32).ToString().OrderBy(y=>y).ToArray())==new string(x.ToString().OrderBy(y=>y).ToArray())).Aggregate("0 0",(a,t)=>(int.Parse(a.Split(' ')[0])+t)+" "+(int.Parse(a.Split(' ')[1])+t*9/5+32)))