text:
Knight on the Rim is Grim
Introduction
Aron Nimzowitsch was a leading chess master and a influential chess writer.
In his book 'My System', the first chapter deals about the importance of the center and why you should dominate it. The simple reason is that your pieces have more possible direct next moves when being in the center which again gives the player more power.
This gets very clear when looking at different positions of a knight and its potential next moves (shown in pink) on an empty board:

Objective
Evaluate the number of potential direct next moves of a knight on an empty board based on its position.
Input Specs
The position of the knight.
First the x (column) and then the y (row). 0 0 is the left bottom corner.
For simplicity, I changed the labels of a chess board to numbers only. For our examples and test cases we use a 0-based index, you are free to use a 1-based index though.
You can use any type of possible input formats, an array, function arguments, etc.
Output Specs
The number of potential direct next moves for a knight on an empty board.
Test Cases
3 4 => 8
4 6 => 6
7 7 => 2
1 0 => 3

Test cases are employing a 0-based index. The full grid of values is:
2 3 4 4 4 4 3 2
3 4 6 6 6 6 4 3
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
3 4 6 6 6 6 4 3
2 3 4 4 4 4 3 2

Nice first challenge! :-)

"Knight on the rim is grim"

@stacey Your comment would have been a great title for this puzzle :)

Now for the really hard question: Are the red knights in the above images all the same color?

Python 2, 35 bytes
lambda x,y:50/(8+x*x/7-x+y*y/7-y)-4

Try it online!

Python 2, 39 bytes
lambda x,y:50/(8-x*(7-x)/5-y*(7-y)/5)-4

Try it online!
Takes inputs 0-indexed.
The expression x*(7-x)/5 takes the coordinate values 0..7 to
[0, 1, 2, 2, 2, 2, 1, 0]

(min(x,7-x,2) does the same, but is longer.) Summing this for x and y gives the right pattern but with the wrong numbers
0 1 2 2 2 2 1 0
1 2 3 3 3 3 2 1
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
1 2 3 3 3 3 2 1
0 1 2 2 2 2 1 0

(See Neil's solution for better reasoning as to why this gives about the right pattern.)
Finally, the mapping a -> 50/(8-a)-4 with floor-division gives the right values
2 3 4 4 4 4 3 2
3 4 6 6 6 6 4 3
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
3 4 6 6 6 6 4 3
2 3 4 4 4 4 3 2

An alternative equally-long solution with 1-indexed inputs:
lambda x,y:(x*(9-x)/6+y*(9-y)/6)**2/6+2

(7-a)*a/5 is 3 bytes shorter than min(a,7-a,2).

*l actually costs you a byte overall, lambda a,b:"23468"[(7-a)*a/5+(7-b)*b/5] is only 41 bytes.

@Neil I had just found the same thing with x*(9-x)/6, one-indexed.

Why don't you use <strike> like everyone else to show golfing progress?

@Insane I think it looks ugly and doesn't actually help. The code is the important thing, and anyone who wants to see its evolution still need to look in the edit history. When my old code is different enough to be worth showing, I show the versions like here. But on this question, it's all minor improvements to the same strategy, so I found it cleaner just to mention the different possibilities.

MATL, 17 14 13 12 bytes
Thanks to @Neil for 1 byte off!
8:HZ^ZP5X^=s

Input is 1-based.
Try it online!
Explanation
This computes the Euclidean distance from the input to each of the 64 positions in the chessboard, and finds how many of those values equal the square root of 5.
Since the coordinates are integer values, we can be sure that the two floating-point values representing the square root of 5 (that computed from the coordinates and that computed directly) are indeed the same.
8:      % Push array [1 2 ... 8]
H       % Push 2
Z^      % Cartesian power. Gives 2D array [1 1; 1 2; ... 1 8; 2 1; ... 8 8]
ZP      % Implicit input. Compute Euclidean distances, considering each row as a point
5X^     % Square root of 5
=s      % Compute how many squared distances equal sqrt(5). Implicit display

Impressive and thanks for the explanation

If comparing the square of the square root of 5 to 5 fails due to rounding errors, can you not at least compare the square root of 5 to the square root of 5?

@Neil Thanks for the idea! Yes, since computations are with integers, I can be sure that the two "roots of 5" are the same double number. Ant it saves a byte

Mathematica 63 43 bytes
With 20 bytes saved thanks to suggestions by Martin Ender!
EdgeCount[8~KnightTourGraph~8,#+1+8#2/<->_]&

The above finds the number of squares that are 1 hop away from the given cell on the  complete knights tour graph.

g=KnightTourGraph[8,8,VertexLabels->"Name",Axes->True]
displays the complete knight's tour graph, with vertex names and coordinates.  Note that Mathematica defaults to one-based indexing for the coordinates.

#+1+8#2&[r,f] converts returns the vertex corresponding to square at rank (row), r, and file (column), f, using zero-based values as input.
For example #+1+8#2&[2,1] returns 11.

EdgeCount gives the number of edges in the neighborhood graph.

The edges for rank 2, file 1 (square 11):
IncidenceList[8~KnightTourGraph~8, 8 #2 + # + 1] &[2, 1]

(*{1 <-> 11, 5 <-> 11, 11 <-> 17, 11 <-> 21, 11 <-> 26, 11 <-> 28}*)

The highlighted edges:
HighlightGraph[g, {1, 5, 11, 17, 21, 26, 28, Style[1 <-> 11, Thick, Blue], Style[5 <-> 11, Thick, Blue], Style[11 <-> 17, Thick, Blue], Style[11 <-> 21, Thick, Blue], Style[11 <-> 26, Thick, Blue], Style[11 <-> 28, Thick, Blue]},GraphHighlightStyle -> "DehighlightFade", PlotRangePadding -> .5]

Method 2: Euclidean distance
70 bytes
This method is longer, but possibly of some interest.  The approach is to check the Euclidean distance between the center of the chessboard and the cell of interest.
Which[(x=Sqrt@Tr[({3.5, 3.5}-#)^2])<2.2,8,x<3,6,x<4,4,x<4.6,3,x>4.6,2]&

Exemplifying
Which[(x=Sqrt@Tr[({3.5, 3.5}-#)^2])<2.2,8,x<3,6,x<4,4,x<4.6,3,x>4.6,2]&@{0, 0}
Which[(x=Sqrt@Tr[({3.5, 3.5}-#)^2])<2.2,8,x<3,6,x<4,4,x<4.6,3,x>4.6,2]&@{3, 3}

2
8

To help visualize how the distance from the center of the chessboard is sufficient for assigning a value.
values={{2,3,4,4,4,4,3,2},{3,4,6,6,6,6,4,3},{4,6,8,8,8,8,6,4},{4,6,8,8,8,8,6,4},{4,6,8,8,8,8,6,4},{4,6,8,8,8,8,6,4},{3,4,6,6,6,6,4,3},{2,3,4,4,4,4,3,2}};
f[x_]:=Text[x,#]&/@Position[values,x]r_~w~p_:=RegionMember[{3.5`,3.5`}~Disk~r,p]
h@y_:=Which[2.2~w~y,8,3~w~y,6,4~w~y,4,4.6~w~y,3,2<3,2]

Graphics[{Circle[{4.5, 4.5}, 2.3], Circle[{4.5, 4.5}, 3],

Circle[{4.5, 4.5}, 4],
Circle[{4.5, 4.5}, 4.6], Flatten[f /@ {2, 3, 4, 6, 8}, 1]}, Axes -> True, AxesOrigin -> {-1, -1}]

The numbers 2.2, 3, 4, and 4.6 are the radii of the circles.

Great tour graph

KnightTourGraph Mathematica and its builtins... :-)

I think there's a stray # at the end of your source code (just before the ]). You should be able to use IncidenceList instead of EdgeList@NeighborhoodGraph though. (Alternatively, there's also EdgeCount, but I think that ends up being longer.)

Oh wait, it's actually shorter: EdgeCount[8~KnightTourGraph~8,#+1+8#2<->_]&

EdgeCount is very cool!

@LuisMendo [tag:builtin-request] Goat-tour graph?

@EᴀsᴛᴇʀʟʏIʀᴋ :-)

JavaScript (ES6), 38 bytes
(x,y)=>+"23468"[((7-x)*x+(7-y)*y)/5|0]

Takes 0-indexed inputs. Explanation: Look at the squares of the distances to the centre:
24.5 18.5 14.5 12.5 12.5 14.5 18.5 24.5
18.5 12.5  8.5  6.5  6.5  8.5 12.5 18.5
14.5  8.5  4.5  2.5  2.5  4.5  8.5 14.5
12.5  6.5  2.5  0.5  0.5  2.5  6.5 12.5
12.5  6.5  2.5  0.5  0.5  2.5  6.5 12.5
14.5  8.5  4.5  2.5  2.5  4.5  8.5 14.5
18.5 12.5  8.5  6.5  6.5  8.5 12.5 18.5
24.5 18.5 14.5 12.5 12.5 14.5 18.5 24.5

The number of reachable squares falls into five bands:
8    0-5
6    5-10
4   10-15
3   15-20
2   20-25

I actually calculate 24.5 - (3.5 - x) ** 2 - (3.5 - y) ** 2 = (7 - x) * x + (7 - y) * y as it's a shorter calculation, but all it does is reverse the order of the bands.

Super concise and very nice approach, so I don't have to start my own JS solution anymore :)

Good point about the formula being equivalent about radius squared. I had thought of x*(7-x) as just an operation that looks like a downward arc on 0..7 and happens to curve fit, but this explains why it produces such a nice pattern when summed for x and y.

Jelly, 10 bytes
8ṗ2_³²S€ċ5

1-indexed. Takes a single argument of the form [x,y]. Try it here.
8ṗ2          Cartesian square [[1,1],[1,2]…[8,8]]
   _³        Subtract the input
     ²S€     Compute the norm of each vector
        ċ5   Count fives

Dennis saved a byte!

Just eleven bytes, wow!

I saw this question in the morning and this is the exact algorithm I thought I'd implement in Jelly when I had time. :P

Mathematica, 44 40 bytes
I've currently got three solutions at the same byte count:
2[3,4,6,8][[Tr@⌊3.2-.8Abs[#-4.5]⌋]]&
Tr@⌈.85(4-Abs[#-4.5])⌉/.{5->6,6->8}&
⌊Tr@⌈.85(4-Abs[#-4.5])⌉^1.1608⌋&

All of those are unnamed functions that take pair of coordinates like {3, 4}, which are 1-based.
I tried coming up with a somewhat explicit formula. The general pattern on the entire board looks like this:

The actual values of those colours (from lightest to darkest) are 2, 3, 4, 6, 8. That is:
2 3 4 4 4 4 3 2
3 4 6 6 6 6 4 3
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
4 6 8 8 8 8 6 4
3 4 6 6 6 6 4 3
2 3 4 4 4 4 3 2

We first exploit the symmetry by shifting the origin to the centre, taking the absolute value and subtracting the result from 4. This gives us coordinates 0.5 to 3.5 increasing from each corner. In order to make the centre coordinates the same we need to map 0.5 and 1.5 to different values and 2.5 and 3.5 to the same value. This is easily done by multiplying by 0.8 (gives{0.4, 1.2, 2., 2.8}) and flooring the result. So now we've got {0, 1, 2, 2} as distances from the centre. If we add up the coordinates in each cell, we get this table:
0 1 2 2 2 2 1 0
1 2 3 3 3 3 2 1
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
2 3 4 4 4 4 3 2
1 2 3 3 3 3 2 1
0 1 2 2 2 2 1 0

This has unique values for all the different possible results, so we simply use it as an index into 2[3,4,6,8].
In the second version we use ceiling instead floor. This way, 2, 3 and 4 are already correct, but we get 5 and 6 instead of 6 and 8, so we correct those manually with a substitution rule.
Finally, in the third version, we extend 5 and 6 upwards to 6 and 8 by means of exponentiation, followed by another floor operation.

I like very much the approach using the board's general pattern, great!

Java - 160 150 bytes
int m(int r,int c){int m=0,i,j;for(i=0;i<3;i+=2)for(j=0;j<3;j+=2){m+=r+i>0&r+i<9&c+2*j>1&c+2*j<11?1:0;m+=r+2*i>1&r+2*i<11&c+j>0&c+j<9?1:0;}return m;}

Ungolfed:
public static int m(int r, int c) {
    int m=0;
    for(int i=-1;i<2;i+=2)
        for(int j=-1;j<2;j+=2){
            m += r+i>-1 && r+i<8 && c+2*j>0 && c+2*j<8 ? 1:0;
            m += r+2*i>0 && r+2*i<8 && c+j>1 && c+j<8 ? 1:0;
        }
    return m;
}

The ungolfed code is identical except for changing the bounds of the for loop to save 4 bytes. Works by iterating through each possible move and performing a bounds check (>0 and <8). Uses the fact that the offsets are (1, 2), (2, 1), (-1, 2), (-2, 1), etc. and is able to check 2 moves for each value of i and j.
Edit: 10 bytes saved thanks to suggestions by Leaky Nun and u902383.

This was also fast, nice!

Had an error in there, it has been fixed.

int m=0,i=-1,j; to save some bytes

change logical AND to bitwise AND and that will allow you to remove additional 6 characters

APL, 21 chars
{+/,5=+/¨×⍨(⍳8 8)-⊂⍵}

In English:

(⍳8 8): 8x8 rank-2 array containing the coordinates of all the cells;
+/¨×⍨(⍳8 8)-⊂⍵: square of the euclidean distances of the given cell with respect to every cell on the board;
5=: matrix of 0/1, where the 1s appear at squared distances equal 5;
+/,: sum the flattened matrix

Test (in origin 1):
    f←{+/,5=+/¨×⍨(⍳8 8)-⊂⍵}
    f¨1+(3 4)(4 6)(7 7)(1 0)
8 6 2 3

In this form:
f←{+/,5=+/¨×⍨(⍳⍺)-⊂⍵}

the left argument can specify the dimensions of the board. Hence 8 8 f will work for the standard square chessboard. But on a larger and rectangular board, the test cases would give different results. For instance, on a 12x10 board:
    g←(10 12)∘f
    g¨1+(3 4)(4 6)(7 7)(1 0)
8 8 8 3

In APL jargon, a matrix is an array of rank 2, nothing said about the content of the cells. Years of (ab)use of the terms made me insensitive to it. I'll update the description for the more traditionally inclined readers. Thank you.

@Istefano That use of "rank" as "number of dimensions" seems to suffer from the same affliction :-P

I'll be... You are right! You can see that it's been a while since I took Linear Algebra. I give up :-)

Full program, 27: ≢⍸5=+/¨×⍨-∘⎕¨⍳8 8 Try it online!

@Adám you mean 17

@ngn Yes, typo.

C, 44 Bytes
f(x,y){return "23468"[((7-x)*x+(7-y)*y)/5];}

But this is better:
f(x,y){return "2344443234666643468888644688886446888864468888643466664323444432"[x*8+y];}

Missing ;. Won't compile.

@GiacomoGarabello See: http://meta.codegolf.stackexchange.com/a/1146/55729

It's not a snippet, it's a function and it's not forbidden post functions. Sorry for the missing semicolon. Fixed.

Java, 81 characters (113 bytes)
int r(int a,int b){return "⍄䐲㑦晃䚈衤䚈衤䚈衤䚈衤㑦晃⍄䐲".codePointAt(a*2+b/4)>>(3-b%4)*4&15;}

Encode the whole result table as unicode table and then get appropriate bytes doing bitwise operations.
You can see it online here: https://ideone.com/K9BojC

Haskell, 49 48 bytes
w=[0..7]
x%y=sum[1|a<-w,b<-w,(a-x)^2+(b-y)^2==5]

You can save [0..7] to a variable for 1 byte.

Python, 94 bytes
lambda x,y,a=[2,1,-1,-2,-2,-1,1,2]:list((9>x+a[i]>0)&(9>y+a[5-i]>0)for i in range(8)).count(1)

Uses 1 based indexing.
Demo at https://repl.it/C6gV.

Pyth - 33 15 bytes
Thanks to @LeakyNun for reducing my size by half.
Rearranging the maps and V's will probably lemme golf a little off.
/sM*Fm^R2-Rd8Q5

Test Suite.

This was fast, nice!

15 bytes

APL (Dyalog Unicode), 15 bytesSBCS
≢⍸2=|×.-∘⎕¨⍳8 8

Try it online!

J, 23 bytes
1#.1#.5=[:+&*://]-/i.@8

Try it online!
Homage to Lynn's method, converted to J

Actually, 18 bytes
`;7-2km`MΣ8-:50\¬¬

Try it online!
This implements the same formula that many other answers have been using: 50/(8-x*(7-x)//5+y*(7-y))//5)-4. Input is taken as a list: [x,y] (or any iterable literal in Python, like (x,y) or x,y).
Explanation:
`;7-2km`MΣ8-:50\¬¬
`;7-2km`M           for each value in input:
 ;7-                  make a copy, subtract from 7
    2                 push 2
     km               minimum of the three values (x, 7-x, 2)
         Σ          sum
          8-        subtract from 8
            :50\    integer divide 50 by the value
                ¬¬  subtract 2 twice

Perl 6, 44 bytes
{+grep {5==[+] $_>>²},((^8 X, ^8)XZ-(@_,))}

Try it online!

Forth (gforth), 49 bytes
: g 9 over - 6 */ ;
: f g swap g + dup 6 */ 2 + ;

Try it online!
Port of xnor's 1-based solution. f takes x y (1-based) on the stack and computes (x(9-x)/6 + y(9-y)/6)**2/6+2. Uses the built-in */ to do a multiplication followed by division at once and save a space.
: g ( x -- x(9-x)/6 )
  9 over -  \ ( x 9-x )
  6 */      \ x*(9-x)/6
;

: f ( x y -- ans )
  g swap g    \ apply g to y, then to x
  + dup 6 */  \ (gx+gy)*(gx+gy)/6
  2 +
;


text:
I only pay with dollars
As the title -- although discretely -- hints, I only pay with dollars.
The challenge
Write a function/program that takes a string as input, which is a monetary value preceded by a symbol. ex) £4.99. Then, return that same amount converted to USD.
Input
You will get a string as input. It will have the currency symbol followed by a number with two decimal places (which could be .00). There will either be decimal points . and/or commas , separating the number. The following currency symbols will come in the inputs:

Euro: €Pound Sterling: £Yuan Renminbi: ¥

Also, there will be a comma or decimal point depending on the currency to separate the 'dollars' from the 'cents':

Euro: #.###,##Pound Sterling: #,###.##Yuan Renminbi: #,###.##

Output
You will convert the input from the currency determined by the symbol to USD, rounding to two decimal places. The output will be in the format $#,###.##, and there will of course be more numbers on the left of the output if need be (EDIT: this means that there is an arbitrary number of commas in the output, just like in the input). The currency exchange rate we will be using are below.
You can assume that the input contains a symbol that is only one of the above (€ £ ¥ . ,)--that it is always valid.
Exchange rates
€1 : $1.10
£1 : $1.37
¥1 : $0.15

Examples
Input:
€1,37
£4.00
¥2,782,122.78

Respective output:
$1.51
$5.48
$417,318.42

Final words

If you use one of the above symbols (€, £, ¥), you may count them as 1 byte
This is code golf, so shortest code in bytes wins!

If you want to use true l10n, renminbi should have a comma delimiter at the 10k mark, not at the 1k mark. (e.g., 10,0000.15)

It's funny that if you've posted this question yesterday, the English Pound's exchange rate would have been £1 : $1.51 xD

Ok @Adnan, I'll do that. Done.

Hmm, is that output correct? 1.37 * 1.10 = 1,507 = 1,51 (so not 1.52) and 4.00 * 1.37 = 5.48 (not 5.50) and 2782122.78 * 0.15 = 417318.417 = 417318.42 (not 420165.06)... :S

@KevinCruijssen, I just realized that, when using Google to convert, the exchange rate had already changed. Fixed it.

What's the maximum input? (Basically, I tested some answers with a huge input (e.g. ¥892,213,489,287,893,323,479,987.67) and all of them gave a rounding/overflow error (e.g. I got $1,222,332,480,324,410,000,000,000.00)

@ev3commander, I'd say that the max input is just about the max-int for each respective language. I don't want to say something too specific now because I don't want to invalidate Abu answers.

Pyth - 54 53 48 47 bytes
Forgot about conditional application W.
.F"${:,.2f}"*v-tXWqhQ\€Q",.")\,@[1.1.15d1.37)Ch

Test Suite.

Hmm.. is it me or is this a pretty big answer for Pyth in terms of bytes? o.Ô It's almost 1/4th of my Java answer! (Usually it's 1/50th or so.. xD)

@KevinCruijssen yeah, the string formatting and the raw currency data make up almost half the size.

Python 3.6 (pre-release), 87
lambda s:f"${int(s.translate({46:'',44:''})[1:])*[110,15,0,137][ord(s[0])%4]/1e4:,.2f}"

Uses f-strings to evaluate the result and format it.
s.translate({46:'',44:''}) removes dots and commas from s, thus making it a valid int literal, then int(...) converts it into the actual int object.

Convex, 56 55 54 bytes
(\®\.|,"ö)\e_\'.\++~\"€£¥"#[1.1_.27+.15]=*"%,.2f"\Ø'$\

Well, this can definitely be shortened. Try it online!
Saved a byte thanks to Lynn!
Explanation to come when I can get access to a computer.

How about [1.1_.27+.15]?

@Lynn thats genius! Thanks!

"Explanation to come when I can get access to a computer," implying that that little nugget of awesome unreadability was written on a mobile device. well done, learned scholar. well done.

@strugee Yeah, Ive been out all day but I have made a CP-1252 keyboard for my iPhone for this purpose.

Why the last 55 bytes mark is struck out? Also, typo in definetely - definitely.

@zyabin101 oops, good catch!

Java 7, 240 227 215 211 207 202 199 196 bytes
(201 - 2 bytes because of the rule "If you use one of the above symbols (€, £, ¥), you may count them as 1 byte")
Thanks to @Frozn for saving a lot of bytes.
String c(String a){int c=a.charAt(0);return java.text.NumberFormat.getCurrencyInstance(java.util.Locale.US).format(new Long(a.substring(1).replaceAll(",|\\.",""))*(c<'¥'?1.37:c>'¥'?1.1:.15)/100);}

Ungolfed & test code:
Try it here.
class Main{
  static String c(String a){
    int c = a.charAt(0);
    return java.text.NumberFormat.getCurrencyInstance(java.util.Locale.US)
        .format(new Long(a.substring(1).replaceAll(",|\\.","")) *
                 (c < '¥'
                   ? 1.37
                   : c > '¥'
                     ? 1.1
                     : .15
                  ) / 100);
  }

  public static void main(String[] a){
    System.out.println(c("€1,37"));
    System.out.println(c("£4.00"));
    System.out.println(c("¥2,782,122.78"));
  }
}

Output:
$1.51
$5.48
$417,318.42

char c=a.charAt(0) (all in all you don't need c at all, see my answer)

By pulling the d * out of the ternary you save some duplication. Looks like this: d*(c=='€'?1.1:c=='£'?1.37:.15)/100.

@Frozn Thanks. Also, unfortunately /100 and *.01 is the same amount of bytes, and c=='€'?.011:c=='£'?.0137:.0015 is also the exact same as with the /100.

Yeah that's bad. But here is the good news: Thanks to the unique unicode values of the currency signs you can shorten it because '£' < '¥' < '€'. Thus you can write c<'¥'?1.37:c>'¥'?1.1:.15 which is 2 characters shorter.

Just saw we don't need d anymore as it is only used once.

JavaScript (ES6), 107
Simple and straightforward, probably more golfable
Note: tested in FireFox. Many browsers (especially mobile) have buggy support of toLocaleString
a=>(a.replace(/\D/g,'')/1e4*(a<'¥'?137:a>'€'?110:15)).toLocaleString('en',{style:'currency',currency:'USD'})

TEST

function test()
{
  var i=I.value
  var F=a=>(a.replace(/\D/g,'')/1e4*(a<'¥'?137:a>'€'?110:15)).toLocaleString('en',{style:'currency',currency:'USD'})
  O.textContent=F(i)
}

test()
<input id=I value='¥2,782,122.78' oninput='test()'>

I could only test this on Firefox. Can you give me a link to Firefoex?

@NoOneIsHere Google "Firefoex", it will give you the correct link even if it's misspelled

Python 3.5, 137 131 121 120 117 bytes:
(Thanks to Maltysen for a hint on saving 6 bytes (137 -> 131)!)
lambda u:'${:,.2f}'.format(float(u[1:].translate([{44:''},{44:46,46:''}]['€'in u]))*{'€':1.1,'£':1.37,'¥':.15}[u[0]])

Try It Online! (Ideone)

you don't need to do your own rounding, .format() does it for  you if you do ${:,.2f}

@Maltysen Thanks! I did not know I could do that! :)

46:0 replaces dots with NUL characters.

@vaultah So what? It works for Euro inputs.

@vaultah Well, it works perfectly fine on Ideone and my computer.

Your code passes all the tests from the OP but it doesn't work properly for €2.121,37.

@vaultah Oh, all right. It's fixed now.

Python 3.5, 101 98
lambda x:'${:,.2f}'.format(int(x[1:].translate({44:'',46:''}))*{'€':110,'£':137,'¥':15}[x[0]]/1e4)

The Euro, Pound, and Yen symbols are counted as 1 byte/character each, per the challenge rules.
Instead of translating among or interpreting thousands and decimal separators, these are just stripped out to give a plain digit string.
The digit string (after the currency symbol) is converted to an integer.
The currency symbol is used as an index into a dictionary of conversion rates; the conversion is performed by multiplying by the conversion rate and dividing by 10000.
The result is formatted with a leading dollar sign, two decimal places of precision, and commas for grouping.

Why don't you delete the 0 from 1.10 to save 1 byte?

Maybe you can skip the . in the ratios and divide by 1e4

F#, 198 bytes
(s:string)="$"+(System.Double.Parse(if s.[0]='€'then s.[1..].Replace(".","").Replace(',','.')else s.[1..].Replace(",",""))*(if s.[0]='€'then 1.1 else if s.[0]='£'then 1.37 else 0.15)).ToString("N2")

Un-Golfed:
let IOnlyUseDollars(s : string) =
    let cur = s.[0]
    let str = if cur = '€' then s.[1..].Replace(".","").Replace(',', '.') else s.[1..].Replace(",","")
    let amt = System.Double.Parse(str)
    let dol = amt * (if cur = '€' then 1.1 else if cur = '£' then 1.37 else 0.15)
    "$" + dol.ToString("N2")

I'm still trying to figure out F#, so dealing with the thousands separators is taking up a lot of bytes.
According to the challenge rules, the Euro, Yen, and Pound symbols count as one byte each, despite how Unicode stores them internally.

Python 3, 112 bytes NOT COMPETING
def c(x):x=x.translate(None,",.");print“$”+‘{:,.2f}’.format([1.1,1.37,0.15][“€£¥”.index(x[0])]*int(x[1:])/100,2)

This is not competing because I do not think that I am allowed to answer my own question.
Also, I have not yet had a chance to run this on a computer, but it seems to me like it should work. I will run it on a computer as soon as I have a chance.

You are completely fine to answer your own question. Some people even come up with an answer before making the question itself. Usually they still get beaten by golfing languages like Jelly, Pyth, Pyke and alike, though. ;)

PHP, 117 bytes
function f($s){return'$'.number_format(ereg_replace('[^0-9]','',substr($s,1))*[E=>.011,P=>.0137,Y=>.0015][$s[0]],2);}

This makes use of a deprecated function; replace ereg_replace('[^0-9]' with preg_replace('%[^\d]%' to make the code fully modern; adds 1 byte.

CJam, 54 bytes
'$q(\",."-de-2\"€£¥"#[1.1 1.37 .15]=*2mOs'./~\3/',*'.@

Try it here!

Nice answer, and welcome to the site! Just so you know, there is an online CJam interpreter here You could link to that in your post to make it easier for reader to run/test your answer.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Time for some TEA!
Introduction
A while back I stumbled across the tiny encryption algorithm (TEA) and since then I have recommended it whenever special cryptographic security properties were un-needed and a self-implementation was a requirement.
Now today, we want to take the name *tiny* encryption algorithm literally and your task will be to implement the tiniest encryption algorithm!
Specification
Input
The input is a list of 8 bytes (or your language equivalent), this is the plaintext, and another list of 16 bytes (or your language equivalent), this is the key.
Input conversion from decimal, hexadecimal, octal or binary is allowed. Reading 1 64-bit, 2 32-bit or 4 16-bit integers as output (optionally as a list) is allowed (for the plaintext, double the numbers for the key)
Output
The output is a list of 8 bytes (or your language equivalent), this is the ciphertext.
Output conversion to decimal, hexadecimal, octal or binary is allowed, but not mandatory.
Writing 1 64-bit, 2 32-bit or 4 16-bit integers as output (optionally as a list) is allowed.
What to do?
Your task is to implement the encryption direction of the tiny encryption algorithm (TEA), note XTEA and XXTEA are other algorithms.
Wikipedia has a C-code example and a list of references to some implementations in other languages, this is the original description (PDF).
More Formally:
Let k1, k2, k3, k4, v1, v2, sum be unsigned 32-bit integers.
(k1,k2,k3,k4) <- key input
(v1,v2) <- plaintext input
sum <- 0
repeat 32 times:
    sum <- ( sum + 0x9e3779b9 ) mod 2^32
    v0  <- ( v0 + ( ((v1 << 4) + k0) XOR (v1 + sum) XOR ((v1 >> 5) + k1) ) ) mod 2^32
    v1  <- ( v1 + ( ((v0 << 4) + k2) XOR (v0 + sum) XOR ((v0 >> 5) + k3) ) ) mod 2^32
output <- (v0,v1)

where 0x9e3779b9 is a hexadecimal constant and
"<<" denotes logical left shift and ">>" denotes logical right shift.

Potential corner cases
\0 is a valid character and you may not shorten your input nor output.
Integer encoding is assumed to be little-endian (e.g. what you probably already have).
Who wins?
This is code-golf so the shortest answer in bytes wins!
Standard rules apply of course.
Test-cases
Test vectors were generated using the Wikipedia C code example.
Key: all zero (16x \0)
Plaintext -> Ciphertext (all values as two 32-bit hexadecimal words)
00000000 00000000 -> 41ea3a0a 94baa940
3778001e 2bf2226f -> 96269d3e 82680480
48da9c6a fbcbe120 -> 2cc31f2e 228ad143
9bf3ceb8 1e076ffd -> 4931fc15 22550a01
ac6dd615 9c593455 -> 392eabb4 505e0755
ebad4b59 7b962f3c -> b0dbe165 cfdba177
ca2d9099 a18d3188 -> d4641d84 a4bccce6
b495318a 23a1d131 -> 39f73ca0 bda2d96c
bd7ce8da b69267bf -> e80efb71 84336af3
235eaa32 c670cdcf -> 80e59ecd 6944f065
762f9c23 f767ea2c -> 3f370ca2 23def34c

Here are some self-generated test vectors with non-zero keys:
format: ( 4x 32-bit word key , 2x 32-bit word plaintext ) -> ( 2x 32-bit word ciphertext )
(all in hexadecimal)

( 4300e123 e39877ae 7c4d7a3c 98335923 , a9afc671 79dcdb73 ) -> ( 5d357799 2ac30c80 )
( 4332fe8f 3a127ee4 a9ca9de9 dad404ad , d1fe145a c84694ee ) -> ( a70b1d53 e7a9c00e )
( 7f62ac9b 2a0771f4 647db7f8 62619859 , 618f1ac2 67c3e795 ) -> ( 0780b34d 2ca7d378 )
( 0462183a ce7edfc6 27abbd9a a634d96e , 887a585d a3f83ef2 ) -> ( d246366c 81b87462 )
( 34c7b65d 78aa9068 599d1582 c42b7e33 , 4e81fa1b 3d22ecd8 ) -> ( 9d5ecc3b 947fa620 )
( f36c977a 0606b8a0 9e3fe947 6e46237b , 5d8e0fbe 2d3b259a ) -> ( f974c6b3 67e2decf )
( cd4b3820 b2f1e5a2 485dc7b3 843690d0 , 48db41bb 5ad77d7a ) -> ( b4add44a 0c401e70 )
( ee2744ac ef5f53ec 7dab871d d58b3f70 , 70c94e92 802f6c66 ) -> ( 61e14e3f 89408981 )
( 58fda015 c4ce0afb 49c71f9c 7e0a16f0 , 6ecdfbfa a705a912 ) -> ( 8c2a9f0c 2f56c18e )
( 87132255 41623986 bcc3fb61 7e6142ce , 9d0eff09 55ac6631 ) -> ( 8919ea55 c7d430c6 )

When I tried the Wikipedia C code, using a zero key and plaintext I got the second row of your plaintext as my ciphertext...

Well, the first two do now; I'm too lazy to try the rest though.

@Neil, that's the nice thing about crypto: Chances are high, that if a trivial (0-based) and a nontrivial testvector pass, all test vectors will pass :)

I suggest you add some test cases with a non-zero key.

@Dennis those can now be found at the bottom of the question :)

JavaScript (ES6), 122 118 114 113 bytes

f=
(v,w,k,l,m,n)=>{for(s=0;s<84e9;v+=w*16+k^w+s^(w>>>5)+l,w+=v*16+m^v+s^(v>>>5)+n)s+=0x9e3779b9;return[v>>>0,w>>>0]}
;

parseInt(i.value,16))).map(i=>(i+(1<<30)*4).toString(16).slice(1))">
Plain 0: <input id=v0>

Plain 1: <input id=v1>

Key 0: <input id=k0>

Key 1: <input id=k1>

Key 2: <input id=k2>

Key 3: <input id=k3>

Cipher 0: <input id=r0 readonly>

Cipher 1: <input id=r1 readonly>

Note: Uses little-endian arithmetic. Accepts and returns unsigned 32-bit integer values. Edit: Saved 4 bytes by using multiplication instead of left shift. Saved 4 bytes by testing on s thus avoiding a separate loop variable. Saved 1 byte by moving the +=s inside the for.

Why not use eval with its implicit return instead of return?

Replacing {return} with eval('') doesn't save me any bytes

Oh okay. Thought it save a couple of bytes :(

Ruby, 114 113 106 bytes
Because Ruby doesn't have 32-bit arithmetic, the extra mod operations caused it to almost tie with Javascript anyways despite the other byte-saving operations Ruby has...

(-1 byte from extra semicolon)
(-7 bytes from trimming out unnecessary mod operations and shifting stuff around)

Try it online!
->v,w,a,b,c,d{s=0
32.times{s+=0x9e3779b9;v+=w*16+a^w+s^w/32+b;v%=m=2**32;w+=v*16+c^v+s^v/32+d;w%=m}
[v,w]}

C, 116 bytes
T(v,w,k,l,m,n,s)unsigned*v,*w;{for(s=0;s+957401312;*v+=*w*16+k^*w+s^*w/32+l,*w+=*v*16+m^*v+s^*v/32+n)s+=2654435769;}

Takes plaintext as v and w; key as k, l, m, and n; and stores the ciphertext in v and w.
Test it on Ideone.

J, 149 bytes
4 :0
'u v'=.y
s=.0
m=.2x^32
for.i.32
do.s=.m|s+2654435769
u=.m|u+(22 b.)/(s+v),(2{.x)+4 _5(33 b.)v
v=.m|v+(22 b.)/(s+u),(2}.x)+4 _5(33 b.)u
end.u,v
)

Yay! explicit (Boo!) J! I think there's a way to do this tacitly, but it'd probably become unreadable.
Usage
Takes the keys as four 32-bit integers on the LHS and the plaintext as two 32-bit integers on the RHS. The prefix 16b is equivalent to 0x in other languages and represents a hex value. The builtin hfd formats the output into a hex string for ease in testing.
    f =: 4 :0
'u v'=.y
s=.0
m=.2x^32
for.i.32
do.s=.m|s+2654435769
u=.m|u+(22 b.)/(s+v),(2{.x)+4 _5(33 b.)v
v=.m|v+(22 b.)/(s+u),(2}.x)+4 _5(33 b.)u
end.u,v
)
   hfd 0 0 0 0 f 0 0
41ea3a0a
94baa940
   hfd 0 0 0 0 f 16b3778001e 16b2bf2226f
96269d3e
82680480
   hfd 16b4300e123 16be39877ae 16b7c4d7a3c 16b98335923 f 16ba9afc671 16b79dcdb73
5d357799
2ac30c80

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Solve the chromatic puzzle
Over at our friends at Puzzling.SE, the following puzzle was posted: Is this chromatic puzzle always solvable? by Edgar G. You can play it here.
Puzzle explanation
Given a m x n grid with tiles of three different colours, you may select any two adjacent tiles, if their colours are different. These two tiles are then converted to the third colour, i.e., the one colour not represented by these two tiles. The puzzle is solved if all tiles have the same colour. Apparently, one can prove that this puzzle is always solvable, if  neither m nor n are divisible by 3.

Of course, this begs for a solving algorithm. You will write a function or program that solves this puzzle. Note that functions with 'side effects' (i.e., the output is on stdout rather than in some awkward data type return value) are explicitly allowed.
Input & Output
The input will be an m x n matrix consisting of the integers 1, 2 and 3 (or 0, 1, 2 if convenient). You may take this input in any sane format. Both m and n are >1 and not divisible by 3. You may assume the puzzle is not solved
You will then solve the puzzle. This will involve a repeated selection of two adjacent tiles to be 'converted' (see above). You will output the two coordinates of these tiles for each step your solving algorithm took. This may also be in any sane output format. You are free to choose between 0-based and 1-based indexing of your coordinates, and whether rows or columns are indexed first. Please mention this in your answer, however.
Your algorithm should run within reasonable time on the original 8x8 case. Brute-forcing it completely is explicitly disallowed, i.e. your algorithm should run under O(k^[m*(n-1)+(m-1)*n]) with k the number of steps needed for the solution. The solution however is not required to be optimal. The proof given in the linked question may give you an idea as to how to do this (e.g., first do all columns using only vertically adjacent tiles, and then do all rows)
Test cases
In these test cases, the coordinates are 1-based and rows are indexed first (like MATLAB/Octave and probably many others).
Input:
[1 2]
Output: (result: all 3's)
[1 1],[1,2]

Input:
[ 1 2
  3 1 ]
Output: (result: all 1's)
[1 1],[2 1]        (turn left column into 2's)
[2 1],[2 2]        (turn right column into 3's)
[1 1],[1 2]        (turn top row into 1's)
[2 1],[2 2]        (turn bottom row into 1's)

Input:
[1 2 3 2
 3 2 1 1]

Output: (result: all 3's)
[1 1],[1 2]
[1 3],[1 4]
[1 2],[1 3]
[1 1],[1 2]
[1 2],[1 3]
[1 1],[1 2]
[1 3],[1 4]
[2 1],[2 2]
[1 1],[2 1]
[1 2],[2 2]
[1 3],[2 3]
[1 4],[2 4]

If desired, I may post a pastebin of larger test cases, but I think this should be sufficient.

I'd love to see a code challenge version of this, where the goal is to solve a set of puzzles with the least total moves.

@Mego I definitely considered this. However, I'm afraid that this will turn into a DFS or BFS which will take forever to run; or, to prevent this, a set of vague restrictions (like 'must run within an hour' which favors people with a massive computer, or which will require me to test all solutions). And furthermore, the current challenge has zero answers spare mine, so I doubt that an even more difficult version requiring heuristics etc. will prove to be more popular... But perhaps if this challenge picks up momentum I may post a sibling challenge like you describe.

I think I'll try to do that in Lua, but it may be longer than your 324 Bytes solution ^^

@Katenkyo Only one way to find out! I'm looking forward to seeing your solution.

You'll have to wait a little bit sadly, you prevented brute-force solution so I have to find a solution that's short in lua :p

Is the output sane if it is as in the op to solve all rows, then an extra new line, and then a set of moves that you'll have to repeat for each column ? something like [x 1],[x 2]

@Maliafo No, every step needs to be printed.

Ruby, 266 bytes
More-or-less just a port of the Octave solution, except it solves rows first instead of columns. Input is an array of arrays, with the inner arrays being the rows. Output moves are [row, column, row, column]. Test suite
->m{t=->v{v.size*v.inject(:+)%3}
s=->a,x,r{g=t[a]
(q=(r=0..a.size-2).find{|i|a[i]!=a[i+1]&&g!=a[i]}||r.find{|i|a[i]!=a[i+1]}
a[q,2]=[t[a[q,2]]]*2
p r ?[x,q,x,q+1]:[q,x,q+1,x])while[]!=a-[g]}
m.size.times{|i|s[m[i],i,1]}
m=m.shift.zip *m
m.size.times{|i|s[m[i],i,p]}}

Ungolfed with explanation
->m{                                  # Start lambda function, argument `m`
  t=->v{v.size*v.inject(:+)%3}        # Target color function
  s=->a,x,r{                          # Function to determine proper moves
                                      #   a = row array, x = row index, r = horizontal
    g=t[a]                            # Obtain target color
    (
      q=(r=0..a.size-2).find{|i|      # Find the first index `i` from 0 to a.size-2 where...
        a[i]!=a[i+1]                  # ...that element at `i` is different from the next...
        &&g!=a[i]                     # ...and it is not the same as the target color
      } || r.find{|i|a[i]!=a[i+1]}    # If none found just find for different colors
      a[q,2]=[t[a[q,2]]]*2            # Do the color flipping operation
      p r ?[x,q,x,q+1]:[q,x,q+1,x]    # Print the next move based on if `r` is truthy
    ) while[]!=a-[g]}                 # While row is not all the same target color, repeat
m.size.times{|i|                      # For each index `i` within the matrix's rows...
  s[m[i],i,1]                         # ...run the solving function on that row
                                      #   (`r` is truthy so the moves printed are for rows)
}
m=m.shift.zip *m                      # Dark magic to transpose the matrix
m.size.times{|i|s[m[i],i,p]}}         # Run the solving function on all the columns now
                                      #   (`r` is falsy so the moves printed are for columns)

Interesting to see that a port between two non-golfing languages can still make a ~20% difference. Could you maybe add a short explanation?(especially line 3 - I'm secretly hoping I can use that in my answer since intersect is such a bulky keyword)

@sanchises an explanation was added. Regarding intersect, I don't know if you can fix that the way mine works because Ruby find basically operates on functions, and your function keyword is just as bulky.

I could actually still use your method for find - thanks! Still, nowhere close to beating you...

Octave, 334 313 bytes
Since the challenge may seem a bit daunting, I present my own solution. I did not formally prove that this method works (I guess that will come down to proving that the algorithm will never get stuck in a loop), but so far it works perfectly, doing 100x100 testcases within 15 seconds. Note that I chose to use a function with side effects rather than one that returns all the coordinates since that saved me a few bytes. Coordinates are row-major, 1-based, and formatted as row1 col1 row2 col2. Input colours are 0,1,2 since this works better with mod, at the cost of having to use numel rather than nnz. Golfed version: Edit: saved another few bytes by using a technique from Kevin Lau's answer.
function P(p)
k=0;[m,n]=size(p);t=@(v)mod(sum(v)*numel(v),3);for c=1:n
p(:,c)=V(p(:,c));end
k=1;for r=1:m
p(r,:)=V(p(r,:));end
function a=V(a)
while any(a-(g=t(a)))
isempty(q=find(diff(a)&a(1:end-1)-g,1))&&(q=find(diff(a),1));
a([q q+1])=t(a([q q+1]));if k
disp([r q r q+1])
else
disp([q c q+1 c])
end;end;end;end

Example GIF of the solving algorithm:

Ungolfed version:
function solveChromaticPuzzle(p)
[m,n]=size(p);                           % Get size
t=@(v)mod(sum(v)*numel(v),3);            % Target colour function
for c=1:n                                % Loop over columns
    p(:,c)=solveVec(p(:,c));             % Solve vector
end
for r=1:m                                % Loop over rows
    p(r,:)=solveVec(p(r,:));
end
    function a=solveVec(a)               % Nested function to get globals
        g=t(a);                          % Determine target colour
        while(any(a~=g))                 % While any is diff from target...
            % Do the finding magic. Working left-to-right, we find the
            % first pair that can be flipped (nonzero diff) that does not
            % have the left colour different from our goal colour
            q=min(intersect(find(diff(a)),find(a~=g)));
            if(isempty(q))               % In case we get stuck...
                q=find(diff(a),1);       % ... just flip the first possible
            end;
            a([q q+1])=t(a([q q+1]));    % Do the actual flipping.
            if(exist('r'))               % If we're working per row
                disp([r q r q+1])        % Print the pair, using global row
            else
                disp([q c q+1 c])        % Print the pari, using global col
            end
        end
    end
end

Just noticed, but my name isn't Kenny Lau... that's another user and my username specifically states that I'm not Kenny

Lua, 594 575 559 Bytes
Warning There's still lots of work before I'm done with this golfing! I should be able to take that under 500 Bytes, at the very least. For the moment, it's the first solution that worked, and I'm still working on it.
I will provide a full explanation once I'm done.
function f(t)s=#t a=","for i=1,s do p=t[i]for i=1,s
do p.Q=p.Q and p.Q+p[i]or p[i]end p.Q=(p.Q*#p)%3 for i=1,s do for j=1,#p-1 do
x=p[j]y=p[j+1]u=x~=y and(p.S and p.R==p.S or x~=p.Q)v=(x+y)*2p[j]=u and v%3or x
p[j+1]=u and v%3or y print(i..a..j,i..a..j+1)end
p.R=p.S p.S=table.concat(p)end end
for i=1,s do Q=Q and Q+t[i][1]or t[i][1]end Q=(Q*s)%3 for i=1,s
do for j=1,s-1 do p=t[j]q=t[j+1]x=p[1]y=q[1]u=x~=y and(S and R==S or x~=Q)v=(x+y)*2
for k=1,#p do p[k]=u and v%3or x q[k]=u and v%3or y
print(j..a..k,j+1..a..k)end Y=Y and Y..x or x end
R=S S=Y end end

Rust, 496 495 bytes
Sadly I can't beat OP, but for a Rust answer I am quite satisfied with the bytecount.
let s=|mut v:Vec<_>,c|{
let p=|v:&mut[_],f,t|{
let x=|v:&mut[_],i|{
let n=v[i]^v[i+1];v[i]=n;v[i+1]=n;
for k in f..t+1{print!("{:?}",if f==t{(k,i,k,i+1)}else{(i,k,i+1,k)});}};
let l=v.len();let t=(1..4).find(|x|l*x)%3==v.iter().fold(0,|a,b|a+b)%3).unwrap();
let mut i=0;while i<l{let c=v[i];if c==t{i+=1;}else if c==v[i+1]{
let j=if let Some(x)=(i+1..l).find(|j|v[j+1]!=c){x}else{i-=1;i};x(v,j);}else{x(v,i);}}t};
p(&mut (0..).zip(v.chunks_mut(c)).map(|(i,x)|{p(x,i,i)}).collect::<Vec<_>>(),0,c-1usize)};

Input: a vector of numbers as well as the number of columns. E.g.
s(vec!{1,2,1,3},2);

outputs
 (row1,col1,row2,col2)

to the command line.
I first solve every row and then solve the resulting column only once ,but print the steps for all columns. So it is actually quite efficient :-P.
With formating:
let s=|mut v:Vec<_>,c|{
    let p=|v:&mut[_],f,t|{     // solves a single row/column
        let x=|v:&mut[_],i|{   // makes a move and prints it
            let n=v[i]^v[i+1]; // use xor to calculate the new color
            v[i]=n;
            v[i+1]=n;
            for k in f..t{
                print!("{:?}",if f==t{(k,i,k,i+1)}else{(i,k,i+1,k)});
            }
        };
        let l=v.len();
        // find target color
        // oh man i am so looking forward to sum() being stabilized
        let t=(1..4).find(|x|(l*x)%3==v.iter().fold(0,|a,b|a+b)%3).unwrap();
        let mut i=0;
        while i<l{
            let c=v[i];
            if c==t{             // if the color is target color move on
                i+=1;
            }else if c==v[i+1]{ // if the next color is the same
                                // find the next possible move
                let j=if let Some(x)=(i+1..l).find(|j|v[j+1]!=c){x}else{i-=1;i};
                x(v,j);
            }else{              // colors are different so we can make a move
                x(v,i);
            }
        }
        t
    };
    // first solve all rows and than sovle the resulting column c times
    p(&mut (0..).zip(v.chunks_mut(c)).map(|(i,x)|p(x,i,i)).collect::<Vec<_>>(),0,c-1usize)
};

Edit:
now returns the color of the solution which saves me a semicolon^^

Befunge, 197 368 696 754 Bytes

(yes, I'm doing some reverse code golf, the more bytes the better)

I was thinking it could be a challenge to write this algorithm in Befunge and that it could be fun
I would like it to be a community program, so if anyone wants to work on it, please, do so.
In the end, I made everything alone so far, so I'll finish on my own (it's almost done)

What's done yet: a troll-shaped code
&:19p&:09p:v:p94g92g90  <
 v94+1:g94&_$59g1+59p1-:|
 >p59gp1-: ^    vp95g93$<
v94\-1<v:g<     >  v
>g:1+v^_$v^90p94g92<
v5p94<   3>1+59p   ^
>9gg+\:^ %g   v93:g95<           v3_2         v
v1pg95g94<^95<>g-v>$v^           v ^-%3*2\gg9<
>9g39g+59g-1-|v-1_^ #^pg95+g92g90<1_09g:29g+5^
       ;  >  >  09g:29g+59gg\3%-# !^v         <
          ^p95<                  ^  <
     v  p96-1+g90g92<
     v                  p95_@
            >59g1+:39g-19g-^
     v    >p 79g:59gg\1+59gp$$$$$29g49pv
    > p59g^ |<<<<<<<<<<<<<<<<<<!-g96g94<
>:79^>29g49p>69g1+59gg49g:59gg\1+49p- v
^\-\6+gg95+1\g< v         !-g96:<-1g94_^
>"]",52*,::59g^v_::1+59gg\59gg-v^ <
^ .-g93g95,.-g<>:69g- v  v-g96:_1+^
>+" [,]",,,\29^       >#v_$:49g2-v
^1:.-g93g95,.-g92\,"[ ":<        <

(yes, it's a troll, believe me)

Basically, it reads an array and computes the move to do to solve the rows, given an input as
(number of rows) (number of columns) 1 2 3 1 1 3 2 1 2 ....

(the whole array is passed as a list [row1, row2, row3,…])
output is
[col row],[col',row']
[col2 row2],[col2',row2']
...

rows and cols both start at 0.

Now that rows are solved, it's almost done ! Hooray !

Explanation: (will be updated later on)

So there are 5 main parts :

The first one, in green, reads the input line and writes one row of the array
The second one, in orange, passes to the next row of the array
The third, in the blue, sums a row
The fourth one, in hot pink, takes the modulus 3 of the sum, saves it at the right of the concerned row, and go to the next row
Finally, in the red, the part that computes the target color from the previously computed number. This part is really dumb and should probably be rewritten, but I didn't figure out how I could do that in a nice way (passed from 197 bytes to 368 with just that part)

Grey parts are initialisations

Here is a a deeper explanation of the module that finds the to boxes to combine (which is coded here, by the way)
                                       B
            @                          v
            |                  !-g96g94<
ENTRY>29g49p>69g1+59gg49g:59gg\1+49p- v
                v         !-g96:<-1g94_^
               v_::1+59gg\59gg-v^ <
               >:69g- v  v-g96:_1+^
                      >#v_$:49g2-v
                    CALL<        <

The CALL part is when the instruction pointer is going to another module, to combine to boxes. It comes back to this module through the 'B' entry
Here is some pseudo code:
(currentx is related to the array reading)
    For:
    69g1+59gg  // read target color
    49g:59gg\1+49p // read current color and THEN shift the currentx to the next box
    if ( top != top ){  // if the current color is bad
        49g1-          //  put the current place  (or currentx - 1) in the stack
        While:
            if ( :top != 69g ){   // if you didn't reach the end of the list
                ::1+              // copy twice, add 1
                if ( 59gg == \59gg ){ // if the next color is the same than current
                   1+                // iterate
                   break While;
                }
            }

        : // copies j (the previous raw iterator)
        if ( top == 69g ){  // if you reached the end of the row (which mean you can't swap with the color after that point)
            $:              // discard j's copy and copy target
            49g2-           // put the place just before the color change on the stack
            combine_with_next;
        } else {
            combine_with_next;
        }
        29g49p   // back to the beginning of the row (there was some changes int the row)
    }

    if ( 49g != 69g ) // if you didn't reach the end of the list
        break For:

Note that if you want to test it, you will have to put some trailing space and trailing new lines so that there is enough space to store the array, if you wish to use the interpret I linked.
22 + the number of rows in input as trailing lines, and 34 + the number of columns as trailing spaces on one line should be ok.

Just curious, why is this non-competing?

Because of this part : 'I would like it to be a community program'. I thought I would be a bit of cheating otherwise

I have a result of 197 Bytes, do you work under windows? (and counted \r\n instead of \n only?)

Hm, I guess I copy pasted some trailing when counting the bytes, thank you

If at the end I'm the only one who made it, I'll erase the mention, but I hope I won't

Well, I'll try to, but I don't think I'll have time ; I moved house yesterday, so, ... :/

C, 404 bytes
My first code golf, I'm pretty happy with how it turned out. Took way too long, though. It's not fully standard C, just whatever will compile under gcc with no special flags (and ignoring warnings). So there's a nested function in there. The function f takes the dimensions m and n as its first arguments, and as it's third argument takes takes an (int pointer) to an array of size m×n (indexed by rows first). The other arguments are dummy arguments, you don't need to pass them in, they're just there to save bytes on declaring variables.  It writes each changed pair to STDOUT in the format row1,col1:row1,col1;, with the semicolon separating the pairs. Uses 0-based indexing.
#define A a[i*o+p
#define B A*c
f(m,n,a,i,j,o,p,b,c,d)int*a;{
int t(x){printf("%d,%d:%d,%d;",b?i:c+x,b?c+x:i,b?i:c+1+x,b?c+1+x:i);}
o=n;p=b=1;for(;~b;b--){
for(i=0;i<m;i++){c=j=0;
for(;j<n;)c+=A*j++];d=c*n%3;
for(j=0;j<n-1;j++)
while(A*j]^d|A*j+p]^d){
for(c=j;B]==B+p];c++);
if(c<n-2&B]==d&2*(B+p]+A*(c+2)])%3==d)
B+p]=A*(c+2)]=d,t(1);else
B]=B+p]=2*(B]+B+p])%3,
t(0);}}o=m;p=m=n;n=o;o=1;}}

I used a slightly different algorithm than OP for solving individual rows/columns. It goes something like this(pseudocode):
for j in range [0, rowlength):
    while row[j] != targetCol or row[j+1] != targetCol:
        e=j
        while row[e] == row[e+1]:
            e++             //e will never go out of bounds
        if e<=rowLength-3 and row[e] == targetCol
                and (row[e+1] != row[e+2] != targetCol):
            row.changeColor(e+1, e+2)
        else:
            row.changeColor(e, e+1)

The for(;~b;b--) loop executes exactly twice, on the second pass it solves columns instead of rows. This is done by swapping n and m, and changing the values of o and p which are used in pointer arithmetic to address the array.
Here's a version that's ungolfed, with a test main, and prints the whole array after every move (press enter to step 1 turn):
#define s(x,y)b?x:y,b?y:x
#define A a[i*o+p
#define B A*e
f(m,n,a,i,j,o,p,b,c,d,e)int*a;{

    int t(x){
        printf("%d,%d:%d,%d;\n",s(i,e+x),s(i,e+1+x));
        getchar();
        printf("\n");
        for(int i2=0;i2<(b?m:n);i2++){
            for(int j2=0;j2<(b?n:m);j2++){
                printf("%d ",a[i2*(b?n:m)+j2]);
            }
            printf("\n");
        }
        printf("\n");
    }

    printf("\n");
    b=1;
    for(int i2=0;i2<(b?m:n);i2++){
        for(int j2=0;j2<(b?n:m);j2++){
            printf("%d ",a[i2*(b?n:m)+j2]);
        }
        printf("\n");
    }
    printf("\n");

    o=n;p=1;
    for(b=1;~b;b--){
        for(i=0;i<m;i++){
            c=0;
            for(j=0;j<n;j++) c+= a[i*o+p*j];
            d=0;
            d = (c*n)%3;
            for(j=0;j<n-1;j++) {
                while(a[i*o+p*j]!=d||a[i*o+p*j+p]!=d){
                    for(e=j;a[i*o+p*e]==a[i*o+p*e+p];e++);
                    if(e<=n-3 && a[i*o+p*e]==d
                            && 2*(a[i*o+p*e+p]+a[i*o+p*(e+2)])%3==d){
                        a[i*o+p*e+p]=a[i*o+p*(e+2)]=d;
                        t(1);
                    }else{
                        a[i*o+p*e]=a[i*o+p*e+p] = 2*(a[i*o+p*e]+a[i*o+p*e+p])%3;
                        t(0);
                    }
                }
            }
        }
        o=m;p=m=n;n=o;o=1;
    }
}

main(){
    int g[11][11] =
    {
        {0,2,1,2,2,1,0,1,1,0,2},
        {2,1,1,0,1,1,2,0,2,1,0},
        {1,0,2,1,0,1,0,2,1,2,0},
        {0,0,2,1,2,0,1,2,0,0,1},
        {0,2,1,2,2,1,0,0,0,2,1},
        {2,1,1,0,1,1,2,1,0,0,2},
        {1,0,2,1,0,1,0,2,2,1,2},
        {0,0,2,1,2,0,1,0,1,2,0},
        {1,2,0,1,2,0,0,2,1,2,0},
        {2,1,1,0,1,1,2,1,0,0,2},
        {0,2,1,0,1,0,2,1,0,0,2},
    };
    #define M 4
    #define N 7
    int grid[M][N];
    for(int i=0;i<M;i++) {
        for(int j=0;j<N;j++) {
            grid[i][j] = g[i][j];
        }
    }
    f(M,N,grid[0],0,0,0,0,0,0,0,0);
};

Just out of curiousity: why did you choose a different algorithm (in terms of byte savings)?

I think it's more interesting when people come up with different solutions, and from some quick tests I guesstimated the two methods would be about the same in byte count. I'll probably try your algorithm too and see if I can get lower.

Posting this here because I don't have enough rep to comment on the question. Would it be valid to brute force each row, then each column individually? That's technically not "brute-forcing it completely" and should be lower than the specified time complexity bound. I actually considered doing that.

The brute-forcing mention was meant to intensify the 'reasonable time' remark, so see it as t«O(...). I know there's a gray area between brute force and a reasonable algorithm, so use your own judgement on whether you feel it's working towards solving the puzzle or if it's just a slight modification on DFS or BFS which are agnostic of 'progress' so to say.


text:
Falling ASCII balls
Input
You are given a 2D map with balls and ground in it.
It looks like this:
  1         5          2
                 3
     4

__________________________

Each number is a ball, and the _ is ground level. The underscore _ character is not allowed in any other line than ground level line. There are only spaces, newlines and digits 0-9 allowed above ground level. You cannot assume that last line is the ground level - empty lines below ground level are allowed. You can also add spaces, to fill empty lines, if that does help you.
Balls can have numbers from 0 to 9, can be placed above each other, but not under ground. The ball's numbers will be unique.
Assume that each character is one meter.
Get map from pastebin!
Test case 1 - should output something like this
Test case 2 - should produce same results as first map
Challenge
Your challenge is to read a map like that from a file or from stdin — you are allowed to use cat balls.txt | ./yourexecutable — and output velocity of each ball when it hits the ground.
Here's the formula for velocity:

Assume that h is the line number difference between the ground's line number, and the ball's line number, and that g equals 10m/s^2.
Output
You should output each balls number and velocity in m/s at ground level.
For example N - Vm/s, where N is ball number and V is its velocity.
You can also output an array if you want.
Happy coding! :)

Test cases with no expected result are not test cases

@edc65 I added expected results to the question

Is it okay if I take the directory as input from the user as part of the program?

@Dopapp What do you mean exactly?

See my answer.

MATL, 31 30 27 25 bytes
95\16\5B#fG&X>1)b- 20*X^h

Input is a 2D char array with ; as row separator:
['  1         5          2  ';'                 3        ';'     4                    ';'                          ';'                          ';'__________________________']

Try it online! Or include an initial t in the code to display the map for greater clarity.
Here are the other test cases: first, second.
Explanation
95\      % Take input implicitly. Modulo 95: convert to numbers and map '_' into 0
16\      % Modulo 16: map space into 0 and digit chars into corresponding numbers
5B#f     % Find row indices and values of nonzero entries
G        % Push input again
&X>      % Index of maximum of each column. This finds character '_'
1)       % Get first value (they are all equal)
b        % Bubble row indices of numbers up in the stack
-        % Subtract to get distance from each number to the ground
20*X^    % Multiply by 20, take sqrt. This gives the velocity values
h        % Horizontally concat numbers and velocities. Display implicitly

C, 125 122 121 bytes
b[99]={};main(l,c){for(;(c=getchar())<95u;)b[c]=(l+=c==10);for(c=47;++c<58;)b[c]&&printf("%c,%f\n",c,sqrt((l-b[c])*20));}

Compile & run with gcc -w golf.c -lm && cat balls.txt | ./a.out.

That's really great, sir! I didn't say that in my question, but I'd like you to know, that your example does not output anything, when character other than 0 ... 9 occurs in text file. Anyway, +1, because not pointing this out is my fault

@Jacajack No, any character is fine as long as it does not contain a character with ASCII code bigger than _. However, this could be fixed with one extra byte (!= instead of <).

Well, I used 'x' for testing. Nevermind. Your code's great :)

@Jacajack In the new version it's not a one character fix anymore, but I saved 3 more bytes :)

Nice! :) I'll take a look at what I can do with my code, when I come back home. I know it can be shortened a lot, but I don't want it to be a copy of yours :p

C -194(-5) 150 137 bytes
With a little bit more time and thinking, I golfed off 44 bytes
 Thanks to orlp for helping me to save 13 bytes
I'll start with my C code:
b[256]={},n,i=47;main(l,c){for(;~(c=getchar());n=c==95?l:n)b[c]=(l+=c==10);for(;++i<58;)b[i]&&printf("%d %f\n",i-48,sqrt((n-b[i])*20));}

And human readable version:
//Throws many warnings, but lack of libraries is tolerated

/*
    c - current character
    l - line number (starts at 1)
    n - ground level
    i - iterator
    b - balls array
*/

b[256] = {}, n, i = 47; //That actually works, as long as you are using ASCII

main( l, c )
{
    for ( ;~( c = getchar( ) ); n = c == 95 ? l : n ) //Read stdin and search for ground
        b[c] = ( l += c == 10 ); //Increment lines counter on newlines, and save line numbers

    for ( ; ++i < 58; ) //Iterate through balls
        b[i] && printf( "%d %f\n", i - 48, sqrt( ( n - b[i] ) * 20 ) ); //Print out data
}

Compile and run like that:
gcc -o balls ballsgolf.c -lm && cat 1.txt | ./balls
Output
1 10.000000
2 10.000000
3 8.944272
4 7.745967
5 10.000000

Save 4 bytes: ~(c=getchar()) instead of (c=getchar())!=EOF.

@marinus That's what I had.

if (x != -1) is the same as if (~x) (on two's complement machines) because ~-1 is (uniquely) 0. In C golf never use while(cond), as for(;cond;) is just as long and provides more opportunities for golfing. In your example this can become for(;~(c=getchar());n=c==95?l:n)b[c]=(l+=c==10);.

@orlp I understand, thanks for advice :)

l=1 can be circumvented by making l the first argument for main, as the C runtime passes the number of arguments to main as its first argument (argc), and when you call a program without any command line arguments (./a.out), then argc = l = 1. n=0; is unnecessary, as global integers are automatically initialized to 0. So just n; will suffice.

The c=n; is unnecessary if you rename the loop variable n in the second loop to i.

@orlp That's right. I don't know why, I was little bit afraid of not initializing variables with 0. Also, I thought that declaring variable like this in for loop would be invalid. argc stuff is whlole new level of trickiness, though. It's good to know things like these, thanks a lot! :)

Pyth, 27 26 25 24 bytes

smf-hT" _".e,b@*20-xd\_k2dC
smf@hT`M;.e,b@*20-xd\_k2dC
smf@T`M;.e,b@*20-xd\_k2dC
sm@#`M;.e,b@*20-xd\_k2dC

Try it online!

Fails if the last line is not the ground.

@orlp Oh, I thought the ground level can only be in the last line.

It still fails after your edit.

@orlp No, it doesn't

Yes it does. I gave an input on which it fails, which is exactly one empty line after the underscores.

@orlp It was in the rules that "You can add spaces, to fill empty lines, if that does help you."

Matlab, 100 96 89 90  bytes
s=input('');X=find(s==95);for i=0:9
[x y]=find(s==48+i);if(x)[i sqrt(20*(X(1)-x))]
end
end

Many bytes saved thanks to Luis Mendo
Input format:
['  1         9          2  ';'                 3        ';'     4                    ';'                          ';'                          ';'__________________________']

Explanation:
X=find(s==95)         -- finds '_', we'll need X(1) to determine max height
for i=0:9             -- loops through balls' numbers
[x y]=find(s==48+i)   -- finds the ball
if(x)                 -- if it is present
[i sqrt(20*(X(1)-x))] -- output its number and velocity

Python 3, 84 bytes
Version 6, 84 bytes: (Thanks to Leaky Nun!)
lambda a:[(c,(~-(len(a)-i)*20)**.5)for i,s in enumerate(a)for c in s if c.isdigit()]

Version 5, 91 bytes:
lambda a:[c+":"+str((~-(len(a)-i)*20)**.5)for i,s in enumerate(a)for c in s if c.isdigit()]

Version 4, 92 bytes:
lambda i:[c+":"+str((~-(len(i)-n)*20)**.5)for n in range(len(i))for c in i[n]if c.isdigit()]

Version 3, 99 bytes:
def r(i):x=len(i);print([c+":"+str((~-(x-n)*20)**.5)for n in range(x)for c in i[n] if c.isdigit()])

Version 2, 102 bytes:
def r(i):
 n=len(i)
 for l in i:
  for c in l:
   if c.isdigit():print(c+":"+str((~-n*20)**.5))
  n-=1

The above versions take an array of strings as input.
Version 1, 140 bytes:
with open(input(),"r")as i:
 n=sum(1for l in i);i.seek(0)
 for l in i:
  for c in l:
   if c.isdigit():print(c+":"+str((~-n*20)**.5))
  n-=1

This takes the directory of the file as input from the user.

1 for l in i -> 1for l in i

@LeakyNun, does that trick work with all keywords and numbers?

I believe so. Also, (n-1)*20 -> ~-n*20

I'm not sure, but I guess you could probably save a lot of byte by taking an array of strings as input instead, or just define a function taking an array of strings.

Hold on. Doesn't Python3 require parentheses with the print call?

I'm not sure, but I think you could make this into one line: for c in l:if c.isdigit():print c+":"+str((~-n*20)**.5)

@TuukkaX, yeah you're right. Thanks for catching that!

@LeakyNun, do you know if I am allowed to take an array as input?

@Dopapp I think so. The MATL answer does it as well.

@LeakyNun No it doesn't work for all keywords and numbers in Python 2. It specifically does not work for keywords starting with an e, because then the Python tokenizer will attempt to parse it as floating point scientific notation (e.g. 1e5). Example that fails: f = lambda n:-1if n<0else 1. An example that fails in both Python version is 0or 1, because the tokenizer thinks 0o starts an octal number.

Try enumerate.

@LeakyNun, do you have an idea of how to improve my last answer which uses enumerate?

lambda a:[(c,(~-(len(a)-i)*20)**.5)for i,s in enumerate(a)for c in s if c.isdigit()] Oh, also it doesn't work if the ground level is not the last line.

@LeakyNun, why would that not work if the ground level is not the last line? Doesn't if c.isdigit() take care of that?

Python 3, 84 bytes
lambda x:[[i,(20*x[x.find(i):x.find('_')].count('\n'))**.5]for i in x if i.isdigit()]

An anonymous function that accepts input by argument as a multi-line string with all empty lines filled with spaces, and returns an array where each element is of the form [ball number, speed].
How it works
lambda x                      Function with input x
...for i in x if i.isdigit()  Loop through all characters i in x for which i is a digit,
                              and hence one of the balls
x[x.find(i):x.find('_')]      Slice x to give the substring between the ball and the ground
....count('\n')               Count the number of newlines in the substring to give the
                              height of the ball
(20*...)**.5                  Calculate the speed of the ball as it hits the ground
[i,...]                       Package the ball number and speed into a list
:[...]                        Return all ball-speed pairs as a list with elements [ball
                              number, speed]

Try it on Ideone

In this case, I think, it's code snippet rather than full standalone Python script, isn't it?

@Jacajack This is in fact a function, not a snippet, which is allowed by default. In Python, lambda functions are functions without a name which can assigned to a variable and then called when needed; you could write f = MyAnswer, and then call using f(x). There is a consensus that there is no need to name lambdas. Nice challenge, by the way!

Sure, I just thought lambdas were assumed to be code snippets here (http://meta.codegolf.stackexchange.com/a/1146/55729). I guess everything is fine, then. Thank you for your opinion :)

JavaScript (ES6) 93
Edit 2 bytes saved thx @Jacajack
A function with a multiline string as input parameter. Output is not sorted (as this in not requested)

a=>[...a].reverse().map(c=>c>'Z'?b=i:c<' '?++i:c>' '&&console.log(c,Math.sqrt((i-b)*20)),i=0)

Test

F=
a=>[...a].reverse().map(c=>c>'Z'?b=i:c<' '?++i:c>' '&&console.log(c,Math.sqrt((i-b)*20)),i=0)

function test()
{
  F(I.value);
}

test()
#I { height: 12em; width: 30em}
<textarea id=I>

  1         5          2
                 3
     4

__________________________

</textarea>
<button onclick="test()"></button>

Wouldn't sqrt(x) be shorter than pow(x,.5)?

@Jacajack yes thanks I don't know how that slipped off my mind


text:
Flood-fill a 2D grid
Challenge description
Let's call a two-dimentional, rectangular array (meaning its every subarray has the same length), a grid. Every unit of a grid is either an empty space or a border. In a grid of characters, empty space is represented by a single whitespace; any other character is treated as a border. Sample grids (+'s, |'s and -'s added for readability - they are not part of the grid):
+----+
|    |
|    |
|    |
|    |
|    |
+----+  an empty 4x5 grid

+------+
|      |
|  #   |
|  #   |
+------+  a 6x3 grid with 2 borders

+----------+
|          |
|          |
|  #####   |
|  #   #   |
| ##   # <------ enclosed area
| #    #   |
| ######   |
|          |
+----------+  a 10x8 grid with an enclosed area

Given a 2D grid and a pair of coordinates, fill the enclosed area surrounding the point represented by the coordinates.
Sample inputs / outputs
1)
0 0
+----------+      +----------+
|          |      |XXXXXXXXXX|
|          |  ->  |XXXXXXXXXX|
|          |      |XXXXXXXXXX|
+----------+      +----------+

2)
6 5
+-----------------+      +-----------------+
|                 |      |                 |
|                 |      |                 |
|    ########     |      |    ########     |
|    #       #    |      |    #XXXXXXX#    |
|    #    ####    |      |    #XXXX####    |
|    #    #       |      |    #XXXX#       |
|    #    #       |  ->  |    #XXXX#       |
|    #    #       |      |    #XXXX#       |
|     ####        |      |     ####        |
|                 |      |                 |
|                 |      |                 |
+-----------------+      +-----------------+

3)
4 6
+-----------------+      +-----------------+
|                 |      |XXXXXXXXXXXXXXXXX|
|    ####         |      |XXXX####XXXXXXXXX|
|   #    #        |  ->  |XXX#    #XXXXXXXX|
|    ####         |      |XXXX####XXXXXXXXX|
|                 |      |XXXXXXXXXXXXXXXXX|
+-----------------+      +-----------------+

4)
4 5
+-----------------+      +-----------------+      +-----------------+
|                 |      |                 |      |                 |
|                 |      |                 |      |                 |
|    ####         |      |    ####         |      |     XXXX        |
|    ####         |  ->  |    ####         |  or  |     XXXX        |
|    ####         |      |    ####         |      |     XXXX        |
|                 |      |                 |      |                 |
+-----------------+      +-----------------+      +-----------------+

5)
2 6
+----------------+      +----------------+
|                |      |XXXXXXXXXXXXXXXX|
|                |      |XXXXXXXXXXXXXXXX|
|                |      |XXXXXXXXXXXXXXXX|
|                |  ->  |XXXXXXXXXXXXXXXX|
|                |      |XXXXXXXXXXXXXXXX|
|BBBBBBBBBBBBBBBB|      |BBBBBBBBBBBBBBBB|
|                |      |                |
|                |      |                |
+----------------+      +----------------+

Notes

An empty grid is considered enclosed, i.e. borders are implicitly situated along the edges of the grid as well (see examples 1. and 5.),
A corner of an enclosed area doesn't need to be L-shaped. The following two areas are therefore equivalent:

####         ##
#  #        #  #
#  #   ==   #  #
#  #        #  #
####         ##

If a unit under the coordinates happens to be a border you can either leave the grid unchanged (as in example 4.) or treat it as an empty space,
You can choose any character for filler / empty space as long as you include this information in the submission,
If using a type other than char suits your purposes better, you can use ints (0 for empty space, 1 for border) or booleans (true and false respectively) or any other type - just make sure to include this information in your submission,
Coordinates used in the examples above are 0-indexed (row, column) coordinates, as it's more convenient for two-dimensional array. If you want to use (column, row) (cartesian) system and/or non-0-indexed coordinates, specify it in your submission.
If you don't know where to start, check out Wikipedia article on flood fill
Remember that this is a code-golf challenge, so make your code as short as possible!

Related: 1, 2, 3, 4, possibly more.

Might be worth having a test case with a single border unit at the position of the coordinates, to show that there are two valid outputs: Either the grid is all filled or the grid is unchanged. (If I have understood your 3rd note correctly.)

See ex. 4) update

I don't get how you get your alternative example 4. That appears to be destroying border cells other than the specified input square.

MATLAB, 30 7 bytes
As we can use logical inputs instead of strings, we can use the bare function, as it is:
@imfill

This is an anonymous function. For the usage, we have to assume a name, e.g. f=@imfill. Then we can just evaluate it as f(input,point), where input is a logical matrix, e.g. [0,0;0,1], and point is a 2d-vector with 1-based coordinates, e.g. [1,2].
Old version working on strings:
@(a,p)[imfill(a>32,p)*3+32,'']

This anonymous function accepts the input as well as a vector with the coordinates (1-based index). The function imfill does exactly what we need, but operates only on binary images. That is why we convert the input matrix to a logical array (where # are the boundaries, and   (spaces) are the void), performs the filling and is then converted back. (again # is filled, space is not filled).
Thanks @LuisMendo for -1 byte.

For the string version, you can replace ~=32 by >32

C, 162 bytes
w,l;char*d;f(z){z<0||z>l||d[z]^32||++d[z]&&f(z+1)+f(z-1)+f(z+w)+f(z-w);}main(c,v)char**v;{l=strlen(d=v[3]),w=strchr(d,10)-d+1,f(atoi(v[2])*w+atoi(v[1]));puts(d);}

Takes input from arguments (./floodfill X Y grid). Grid must contain \n or \r\n between each line, final newline is optional. Simplest way I've found to invoke from shell:
./floodfill 1 0 "$(printf "   \n###\n   \n")"
# or
./floodfill 1 0 "$(cat gridfile)"

Outputs to stdout, using ! for the fill character. If the start position coincides with a #, makes no change.
Breakdown:
                                    // GCC is happy enough without any imports
w,l;                                // Globals (line width, total length)
char*d;                             // Global grid pointer
f(z){                               // "Fill" function - z=current cell
    z<0||z>l||                      // Check if out-of-bounds...
    d[z]^32||                       // ...or not empty
        ++d[z]&&                    // Fill cell...
        f(z+1)+f(z-1)+f(z+w)+f(z-w);// ...and continue in "+" pattern
}
main(c,v)char**v;{                  // K&R style function to save 2 bytes
    l=strlen(d=v[3]),               // Store grid & length
    w=strchr(d,10)-d+1,             // Store width of grid (including newlines)
    f(atoi(v[2])*w+atoi(v[1]));     // Parse X & Y arguments and invoke fill

    puts(d);}                       // Print the result

Note that this relies on modifying the input argument string, which is forbidden, so this may not work on all platforms (implicit declarations also make this non-standard).

You can save 4 bytes by changing int w, l; to simply w, l; - gcc defaults it to int type

@Jacajack good point! Thanks

C - 263 247 240 238 bytes
This is first second third version, I believe code can be shrinked too.
m[99][99],x,y,a,b,c,n;f(v,w){if(m[v][w]==32){m[v][w]=88;f(v,w+1);f(v+1,w);f(v,w-1);f(v-1,w);}}main(){scanf("%d %d\n",&a,&b);for(;~(c=getchar());m[x++][y]=c,n=x>n?x:n)c==10&&++y&&(x=0);f(b+2,a+1);for(a=-1;++a<y*n+n;)putchar(m[a%n][a/n]);}

And readable version:
m[99][99], x, y, a, b, c, n;

/*
    a, b - flood fill start coordinates
    v, w - recursive function start coordinates
    x, y - iterators
    c - character read
    m - map
    n - maximum map width found

*/

//Recursive flood function
f( v, w )
{
    if ( m[v][w] == 32 ) //If field is empty (is ' '?)
    {
        m[v][w] = 88; //Put 'X' there
        f(v,w+1);f(v+1,w); //Call itself on neighbour fields
        f(v,w-1);f(v-1,w);
    }
}

main( )
{
    //Read coordinates
    scanf( "%d %d\n", &a, &b );

    //Read map (put character in map, track maximum width)
    for ( ; ~( c = getchar( ) ); m[x++][y] = c, n = x > n ? x : n )
        c == 10 && ++y && ( x = 0 );

    //Flood map
    f( b + 2, a + 1 );

    //Draw
    for ( a = -1; ++a < y * n + n; )
            putchar( m[a % n][a / n] );

}

Compile and run:
gcc -o flood floodgolf.c && cat 1.txt | ./flood
Resources:

Input format
Results

Note: I'm working on int values. Every   (32) is treated as empty space. Any other value is treated as border. Coordinates are in format (row, column)

Don't forget you can save semicolons by putting statements inside the for (scanf here), and using the first parameter of main as a cheap int declaration will work in most compilers. Also you might be able to save a bit by flattening your array (should certainly help the print loop)

@Dave That's right. I've learned a bit since I wrote this code. I think storing data in 1D array would help me to save a lot too, but obviously I don't want to copy your idea. I'll see what I can do later. Thanks!

Python 2, 158 bytes
Try it online. Simple recursive solution
a,X,Y=input()
M=len(a)
N=len(a[0])
def R(x,y):
 if~0<x<M and~0<y<N and a[x][y]:a[x][y]=0;R(x-1,y);R(x+1,y);R(x,y-1);R(x,y+1)
R(X,Y)
print'\n'.join(map(str,a))

0-indexed in row-column order
1 - empty space, 0 - filled space
Takes input as array of arrays of 1 and 0, and two numbers

Perl 5, 129 + 1 (-a) = 130 bytes
sub f{my($r,$c)=@_;$a[$r][$c]eq$"&&($a[$r][$c]=X)&&map{f($r+$_,$c);f($r,$c+$_)}-1,1}@a=map[/./g],<>;f$F[0]+1,$F[1]+1;say@$_ for@a

Try it online!
How?
sub f{   # recursive subroutine
  my($r,$c)=@_; # taking row and column as inputs
  $a[$r][$c]eq$"&&  # using Boolean short circuit as an 'if' statement to
                    # check if the current position in the global array is blank
  ($a[$r][$c]=X)&&  # then setting it to 'X'
  map{f($r+$_,$c);f($r,$c+$_)}-1,1 # and checking the four surrounding spaces
}
# -a command line option implicitly splits the first line into the @F array
@a=map[/./g],<>;    # put the input in a 2-D array
f$F[0]+1,$F[1]+1;   # start the fill at the given position, correcting for
                    # Perl's 0 based arrays
say@$_ for@a        # output the resulting pattern

05AB1E, 53 bytes
[©g_#®ć©d®IgIнg‚‹«PisD®нèD®θèi2®θǝ®нǝs1ÝÂ‚D(«ε®+}ìë\s

Input-coordinate as a wrapped pair of integers \$[[x,y]]\$, and input-grid as a matrix of 1s and 0s for empty spaces and borders respectively. Flood-fills with 2s.
Try it online or verify all test cases. (The ]J» in the footer of the single TIO is used to pretty-print the output-matrix. Feel free to remove it to see the actual output.)
Explanation:
Despite being a codegolf language, 05AB1E's matrix builtins aren't too useful here. And 05AB1E's modular indexing is only a disadvantage for a challenge like this, where you want to stay within the dimension of the grid.
[                  # Start an infinite loop:
 ©                 #  Store the list of coordinates in variable `®` (without
                   #  popping)
                   #  (which is the first implicit input in the first iteration)
  g_               #  If it's empty:
    #              #   Stop the infinite loop
  ©ć               #  Extract head of `®`; pop and remainder-list and first
                   #  coordinate separated to the stack
    ©              #  Store this coordinate as new variable `®` (without popping)
     d             #  Check [x>=0,y>=0]
       Ig          #  Push the amount of rows of the input-matrix
         Iнg       #  Push the amount of columns of the input-matrix
            ‚      #  Pair them together
      ®      ‹     #  Check [x<rowCount,y<columnCount]
              «    #  Merge the two lists together
               Pi  #  Pop, and if all were truthy (so [x,y] is within bounds):
 s                 #   Swap so the matrix is at the top
  D                #   Duplicate this matrix
   ®нè             #   Pop and get the x'th (of coordinate `®`) row of the matrix
      D            #   Duplicate this row
       ®θè         #   Pop and get the y'th (of coordinate `®`) cell of this row
          i        #   If this value is 1:
           2®θǝ    #    Insert a 2 at this y'th cell of the row
               ®нǝ #    Insert this modified x'th row into the matrix
 s                 #    Swap so the list of coordinates is at the top again
  1Ý               #    Push [0,1]
    Â‚             #    Bifurcate (Duplicate & Reverse copy) and pair:
                   #    [[0,1],[1,0]]
      D(«          #    Duplicate, negate, merge: [[0,1],[1,0],[0,-1],[-1,0]]
         ε®+}      #    Add coordinate `®` to each pair:
                   #    [[x,y+1],[x+1,y],[x,y-1],[x-1,y]]
             ì     #    Prepend-merge it at the front of the coordinates-list
          ë        #   Else: the value was 0 or 2 instead:
           \       #    Discard the duplicated row
            s      #    And swap so the coordinates list is at the top again
]                  # Close the open if-statements and infinite loop
 \                 # Discard the empty coordinates list
                   # (after which the matrix is output implicitly as result)

Java, 112 bytes
int f(int[][]m,int x,int y){try{if(m[x][y]==0)f(m,x+f(m,x,y+f(m,x-f(m,x,y+--m[x][y]),y)),y);}finally{return 1;}}

Input as a matrix of 0s and 1s for empty spaces and borders respectively. Modifies the input-matrix directly, and flood-fills with -1s.
Uses the same flood-fill recursive method I've used in this answer, this answer, and this answer of mine.
Try it online.
Explanation:
// Recursive method with integer matrix & x,y parameters and integer return-type
int f(int[][]m,int x,int y){
  try{if(m[x][y]==0)   //  If the current cell-value is 0:
            --m[x][y]  //   Decrement the current cell-value to -1
           f(m,x,y+...)//   Recursive call west
          f(m,x-...,y) //   Recursive call north
         f(m,x,y+...)  //   Recursive call east
        f(m,x+...,y);  //   Recursive call south
  }finally{            //  Catch and swallow any ArrayIndexOutOfBoundsExceptions
                       //  (shorter than manual if-checks)
           return 1;}  //  Always result in 1, so we use it to our advantage to
                       //  save bytes here by nesting, instead of having four
                       //  loose calls to each direction)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Build a marginal tax calculator
There have been some tax rate calculator problems here that depend on defined rates (specifically US federal rates), but none that have done it for arbitrary lists.
Your task is to build a program or function that will take an arbitrary list of marginal tax brackets and calculate the effective amount of tax paid on a given amount of taxable income.
Your program will take as input:

N pairs of numbers in the form (amt, rate), each representing a tax bracket.

amt is the amount of taxable income above which at which the tax rate starts to apply. These amounts will all be integers, and appear in increasing order.
rate is the tax rate, expressed as a decimal percentage from 0 to 100 inclusive.

The amount of taxable income, as a nonnegative integer.

If no rate is specified for $0, the rate is assumed to be 0%.
Alternatively, your program can also take as input two lists (amt1, amt2, ...) and (rate1, rate2, ...), containing the amounts and rates in the same order.
Your program will then output the payable tax, either to two decimal places, or rounded down to the nearest whole currency unit.

An example input (the most recent Canadian tax brackets, from 2016, with the basic personal tax credit applied and nothing else):
11474 15
45282 20.5
90563 26
140388 29
200000 33

393216

And its corresponding output:
108357.07  or  108357

The shortest program in any language to do this wins.

Is input as [[amt,amt,amt],[rate,rate,rate]] OK? Or does it have to be pairs of [amt,rate] ?

Could input be 1 list of amounts, 1 list of rates and the tax income value (3 inputs in total)?

Well, I've specified (amt, rate), but it doesn't fundamentally change the problem to accept the other list, so I'll modify it so you can.

05AB1E, 35 24 bytes
vy³ï‚{0è)˜}³ï‚˜¥²ø€PTn/O

Explanation
vy                         # for each amount
  ³ï‚                      # pair with taxable income
     {0è                   # get min
        )˜}                # add to list
           ³ï‚˜            # add income to the end of the list
               ¥           # get deltas
                ²ø         # zip with tax rates
                  €P       # map product on each pair of [amount in tax bracket,rate]
                    Tn/    # divide by 100
                       O   # sum
                           # implicitly display result

Try it online

Do human beings actually read and understand 05AB1E code?

@DavidC: I've learned to understand most of it. I'll write up an explanation though. Would have done it already, but wasn't sure if both input methods were OK.

Haskell, 67 66 bytes
Thanks Damien for -1 byte.
This solution is in the form of an infix function, ?, of type (Integral b, RealFrac r) => [(r, r)] -> r -> b. The helper function, #, does the required calculations while ? serves to handle the IO specifications.
a?b=floor$reverse a#b
((m,p):r)#i|v<-min i m=p/100*(i-v)+r#v
_#_=0

((m,p):r)#i|v<-min i m=p/100*(i-v)+r#v saves 1 byte

Thanks @Damien! I didn't know you could assign values inside a guard like that.

Mathematica 85  82 bytes
Derived from Josh O'Brien's code in R.
d_~f~i_:=Tr@Thread[Differences@((i~Min~#&/@d[[All,1]]~Append~∞))d[[All,2]]/100.]

Usage
f[{{11474, 15}, {45282, 20.5}, {90563, 26}, {140388, 29}, {200000, 33}}, 393216]

108357.

So this has been asked before, just not on this particular site. Makes sense.

JavaScript (ES6), 60 bytes
(a,n)=>a.map(([b,r])=>{t+=n>b&&(n-b)*(r-p);p=r},p=t=0)|t/100

a is an array of arrays of band and rate, which would be [[11474, 15], [45282, 20.5], [90563, 26], [140388, 29], [200000, 33]] for the given example, and n is the income (393216).

Can you provide more information on the input format?

Matlab, 79 bytes
Assuming we can take amt and rate as separate column vectors:
function[]=f(a,b,c)
t=sort([0;a;c]);fix(sum(diff(t).*[0;b/100].*(t(2:end)<=c)))

If we can't (then a is a two-column matrix of amt and rate) it's 87 bytes.
function[]=f(a,c)
t=sort([0;a(:,1);c]);fix(sum(diff(t).*[0;a(:,2)/100].*(t(2:end)<=c)))

Explanation:
f(a,b,c)           -- takes amt, rate and income
[0;a;c]            -- gives a vector of amounts with 0 and the income amount
t=sort(...)        -- sort this vector
diff(t)            -- gives us amounts to be taxed in every bracket
diff(t).*[0;b/100] -- tax in every bracket
.*(t(2:end)<=c)    -- take only entries lower than the income
sum(...)           -- sum everything
fix(...)           -- round towards 0

Swift, 61 bytes
zip(zip(m+[i],[0]+m).map{$0-$1},[0]+r).map{$0*$1}.reduce(0,+)

Ungolfed, with test cases:
struct TaxContext {
    let marginLowerBound: [Double]
    let rates: [Double]
}

// ungolfed
extension TaxContext {
    func calcAfterTaxIncome(_ income: Double) -> Double {
        //drop first element (0), append income
        let upper = marginLowerBound + [income]
        let lower = [0] + marginLowerBound

        let incomeInEachMargin = zip(upper, lower)
            .map{ upperBound, lowerBound in upperBound - lowerBound }

        let taxInEachMargin = zip(incomeInEachMargin, [0]+rates)
            .map{ incomeInMargin, rate in incomeInMargin * rate }

        let totalTax = taxInEachMargin.reduce(0, +)

        print(upper)
        print(lower)
        print(incomeInEachMargin)
        print(rates)
        print(taxInEachMargin)

        return totalTax
    }
}

// golfed
extension TaxContext {
    // computed properties to serve as aliases for the golfed version
    var m: [Double] { return self.marginLowerBound }
    var r: [Double] { return self.rates }

    func f(_ i: Double) -> Double {
        return zip(zip(m+[i],[0]+m).map{$0-$1},[0]+r).map{$0*$1}.reduce(0,+)
    }
}

let testCase1 = TaxContext(
    marginLowerBound: [10_000, 20_000, 30_000],
    rates: [0.1, 0.2, 0.3, 0.4]
)
let result1 = testCase1.calcAfterTaxIncome(70_000)
print(result1)

let testCase2 = TaxContext(
    marginLowerBound: [11474 , 45282, 90563, 140388, 200000],
    rates: [0.15, 0.205, 0.26, 0.29, 0.33]
)
let result2 = testCase2.calcAfterTaxIncome(393216)
print(result2)


text:
Simplify a square root
Given a positive integer n, simplify the square root √n into the form a√b by extracting all square factors. The outputted a,b should be positive integers with n = a^2 * b with b as small as possible.
You may output a and b in either order in any reasonable format. You may not omit outputs of 1 as implicit.
The outputs for n=1..36 as (a,b):
1 (1, 1)
2 (1, 2)
3 (1, 3)
4 (2, 1)
5 (1, 5)
6 (1, 6)
7 (1, 7)
8 (2, 2)
9 (3, 1)
10 (1, 10)
11 (1, 11)
12 (2, 3)
13 (1, 13)
14 (1, 14)
15 (1, 15)
16 (4, 1)
17 (1, 17)
18 (3, 2)
19 (1, 19)
20 (2, 5)
21 (1, 21)
22 (1, 22)
23 (1, 23)
24 (2, 6)
25 (5, 1)
26 (1, 26)
27 (3, 3)
28 (2, 7)
29 (1, 29)
30 (1, 30)
31 (1, 31)
32 (4, 2)
33 (1, 33)
34 (1, 34)
35 (1, 35)
36 (6, 1)

These are OEIS A000188 and A007913.
Related: A more complex version.

var QUESTION_ID=83814,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/83814/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

We've had this before, and that was closed as a duplicate of the challenge linked here.

Jelly, 9 bytes
ÆE;0d2ZÆẸ

Try it online! or verify all test cases.
How it works
ÆE;0d2ZÆẸ  Main link. Argument: n

ÆE         Exponents; generate the exponents of n's prime factorization.
  ;0       Append 0 since 1ÆE returns [].
    d2     Divmod by 2.
      Z    Zip/transpose to group quotients and remainders.
       ÆẸ  Unexponent; turn the exponents of prime factorizations into integers.

In UTF-8, it is, but Jelly uses a custom code page. The bytes link in the header points to it.

You post that comment a lot, so maybe you should make the bytes like clearer (for example: [bytes](link-to-byes) (not UTF-8).

Jelly, 6 bytes
²×¥þœi

Try It Online!
TFW you outgolf Dennis by 33% :P
Outputs [b, a].
This does not use any prime factorization built-ins. Instead, it uses an array-oriented built-in œi (multi-dimensional index of), which is interestingly not found in any of APL/J/K/BQN.
How it works
²×¥þœi    Monadic link. Input: the positive integer n.
²×¥þ      Compute the table of (x^2 * y) for both x and y in 1..n
          For n = 3, this returns:
          × | 1  4  9
          --+--------
          1 | 1  4  9
          2 | 2  8 18
          3 | 3 12 27
    œi    Find the multi-dimensional index of n in the matrix above
          [3, 1]

Since it finds the first occurrence in the matrix, b (first index) is guaranteed to be minimized, and n always appears at least once in the matrix at the coordinates [n, 1].

Python 2, 43 bytes
k=n=input()
while n%k**2:k-=1
print k,n/k/k

Test it on Ideone.

PARI/GP, 12 bytes
n->core(n,1)

core returns the squarefree part of n by default, but setting the second argument flag to 1 makes it return both parts. Output order is (b, a), e.g. (n->core(n,1))(12) -> [3, 2].

MATL, 12 bytes
t:U\~f0)GyU/

Try it online!
Explanation
t     % Take input n implicitly. Duplicate
:U    % Push [1 4 9 ... n^2]
\~    % True for entries that divide the input
f0)   % Get (1-based) index of the last (i.e. largest) dividing number
G     % Push input again
y     % Duplicate index of largest dividing number
U     % Square to recover largest dividing number
/     % Divide input by that. Implicitly display stack

Julia, 32 bytes
\(n,k=n)=n%k^2>0?n\~-k:[k,n/k^2]

Try it online!

Mathematica 34 bytes
#/.{a_ b_^_:>{a, b},_[b_,_]:>{1,b}}&

This says to replace all the input (#) according to the following rules:
(1) a number, a,  times the square root of b should be replaced by {a, b}  and a function b to the power of whatever should be replaced by {1,b}
.  Note that the function assumes that the input will be of the form, Sqrt[n].
It will not work with other sorts of input.
This unnamed function is unusually cryptic for Mathematica. It can be clarified somewhat by showing its full form, followed by replacements of the original shorter forms.
Function[
   ReplaceAll[
      Slot[1],
      List[
         RuleDelayed[Times[Pattern[a,Blank[]],Power[Pattern[b,Blank[]],Blank[]]],List[a,b]],
         RuleDelayed[Blank[][Pattern[b,Blank[]],Blank[]],List[1,b]]]]]

which is the same as
   ReplaceAll[
      #,
      List[
         RuleDelayed[Times[Pattern[a,Blank[]],Power[Pattern[b,Blank[]],Blank[]]],List[a,b]],
         RuleDelayed[Blank[][Pattern[b,Blank[]],Blank[]],List[1,b]]]]&

and
ReplaceAll[#,
  List[RuleDelayed[
    Times[Pattern[a, Blank[]],
     Power[Pattern[b, Blank[]], Blank[]]], {a, b}],
   RuleDelayed[Blank[][Pattern[b, Blank[]], Blank[]], {1, b}]]] &

and
ReplaceAll[#,
  List[RuleDelayed[Times[a_, Power[b_, _]], {a, b}],
   RuleDelayed[Blank[][b_, _], {1, b}]]] &

and
ReplaceAll[#, {RuleDelayed[a_*b^_, {a, b}], RuleDelayed[_[b_, _], {1, b}]}]&

and
ReplaceAll[#, {a_*b^_ :> {a, b}, _[b_, _] :> {1, b}}] &

05AB1E, 14 bytes
Lv¹ynÖi¹yn/y‚ï

Explained
Lv              # for each x in range(1,N) inclusive
  ¹ynÖi         # if N % x^2 == 0
       ¹yn/y‚ï  # create [N/x^2,x] pairs, N=12 -> [12,1] [3,2]
                # implicitly output last found pair

Try it online

Python, 74 Bytes
def e(k):a=filter(lambda x:k/x**2*x*x==k,range(k,0,-1))[0];return a,k/a**2

Straightforward enough.

Pyth, 15 bytes
/Q^
ef!%Q^T2SQ2

Test suite.

Matlab, 51 bytes
x=input('');y=1:x;z=y(~rem(x,y.^2));a=z(end)
x/a^2

Explanation
x=input('')       -- takes input
y=1:x             -- numbers from 1 to x
z=y(~rem(x,y.^2)) -- numbers such that their squares divide x
a=z(end)          -- biggest such number (first part of output)
x/a^2             -- remaining part

JavaScript (ECMAScript 2016), 40 bytes
n=>{for(k=n;n%k**2;k--);return[k,n/k/k]}

Basically a JavaScript port of Dennis's Python 2 answer.
Try it on JSBin.
Note: it doesn't work in strict mode, because k is not initialized anywhere. To make it work in strict mode, k=n in the loop should be changed to let k=n.

Haskell, 43> 42 bytes
Brute force solution.
Saved 1 byte thanks to Xnor
f n=[(x,y)|y<-[1..],x<-[1..n],x*x*y==n]!!0

Nice solution, I like how it doesn't use mod or div. I think you can do y<-[1..] due to laziness.

Yes, you are right. It wasn't possible with my first solution last[(x,y)|x<-[1..n],y<-[1..n],x*x*y==n] but now it will work. Thanks. Do you have your own solution in Haskell?

APL, 25 chars
 {(⊢,⍵÷×⍨)1+⍵-0⍳⍨⌽⍵|⍨×⍨⍳⍵}

In English:

0⍳⍨⌽⍵|⍨×⍨⍳⍵: index of the largest of the squares up to n that divides completely n;
1+⍵-: the index is in the reversed array, so adjust the index
(⊢,⍵÷×⍨): produce the result: the index itself (a) and the quotient b (that is, n÷a*a)

Test:
     ↑{(⊢,⍵÷×⍨)⊃z/⍨0=⍵|⍨×⍨z←⌽⍳⍵}¨⍳36
1  1
1  2
1  3
2  1
1  5
1  6
1  7
2  2
3  1
1 10
1 11
2  3
1 13
1 14
1 15
4  1
1 17
3  2
1 19
2  5
1 21
1 22
1 23
2  6
5  1
1 26
3  3
2  7
1 29
1 30
1 31
4  2
1 33
1 34
1 35
6  1

JavaScript (ECMAScript 6), 35 bytes
f=(n,k=n)=>n/k%k?f(n,--k):[k,n/k/k]

JavaScript 1+, 37 B
for(k=n=prompt();n/k%k;--k);[k,n/k/k]

J, 19 bytes
(0|:0 2#:])&.(_&q:)

Try it online!
Same as the Jelly solution.

Vyxal, 9 bytes
K'∆²;t₍/√

Try it Online!
Very cool and good. Outputs as [constant, surd]
Explained
K'∆²;t₍√/
K        # from the factors of the input,
 '∆²;    # keep only square numbers
     t   # and keep the last.
      ₍√/ # Push [sqrt(^), input / ^]

Python 2.7 (ungolfed) - 181 Bytes
def e(n):
 for x in range(1,n+1):
  r=(1,x)
  for i in range(1,x+1):
   l=i**.5
   for j in range(1,x+1):
    if i*j==x and l%1==0 and j<r[1]:r=(int(l),j)
  print x,r

Run as: e(number) eg. e(24)
Sample output:
>> e(24)
1 (1, 1)
2 (1, 2)
3 (1, 3)
4 (2, 1)
5 (1, 5)
6 (1, 6)
7 (1, 7)
8 (2, 2)
9 (3, 1)
10 (1, 10)
11 (1, 11)
12 (2, 3)
13 (1, 13)
14 (1, 14)
15 (1, 15)
16 (4, 1)
17 (1, 17)
18 (3, 2)
19 (1, 19)
20 (2, 5)
21 (1, 21)
22 (1, 22)
23 (1, 23)
24 (2, 6)

Please attempt to golf your answer as much as possible, this is a code-golf