text:
Are the brackets fully matched?
You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format.
Rules and definitions:

For the purpose of this challenge, a "bracket" is any of these characters: ()[]{}<>.

A pair of brackets is considered "matched" if the opening and closing brackets are in the right order and have no characters inside of them, such as
()
[]{}

Or if every subelement inside of it is also matched.
[()()()()]
{<[]>}
(()())

Subelements can also be nested several layers deep.
[(){<><>[()]}<>()]
<[{((()))}]>

A string is considered "Fully matched" if and only if:

Every single character is a bracket,

Each pair of brackets has the correct opening and closing bracket and in the right order, and

Each bracket is matched.

You may assume the input will only contain printable ASCII.

Test IO
Here are some inputs that should return a truthy value:
()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]

And here are some outputs that should return a falsy value:
(               Has no closing ')'
}{              Wrong order
(<)>            Each pair contains only half of a matched element
(()()foobar)    Contains invalid characters
[({}<>)>        The last bracket should be ']' instead of '>'
(((()))         Has 4 opening brackets, but only 3 closing brackets.

As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins.

Related.

Note to potential close voters: The challenge I linked also includes a priority order for the bracket types so they cannot be nested in an arbitrary order. I think that makes it sufficiently different.

Is [} a match? And if not, where is it excluded by these rules?

@EJP No, it is not. Each pair of brackets has the correct opening and closing bracket and in the right order.

I will upvote the first solution in Brackets

Does no output (i.e. program not terminating) count as falsey?

@CᴏɴᴏʀO'Bʀɪᴇɴ I think according to the consensus that would be undefined, so I'll say no. Although that might be worth a meta post.

@DrGreenEggsandHamDJ Thanks. I don't find that a clear enough statement, and I'm a compiler writer.

05AB1E, 19 bytes
Input is given in quotes. Code:
"[](){}<>"2÷)"":g2Q

Well crap, a lot of bugs and unimplemented features were found. Explanation:
"[](){}<>"           # Push this string
          2÷         # Split into pieces of two
            )        # Wrap it into an array (which should not be needed)
             ""      # Push an empty string
               :     # Infinite replacement

This is actually a tricky part. What this looks like in pseudocode is:
input().replace(['[]', '()', '{}', '<>'], "")

This is covered by this part from the 05AB1E code:
if type(b) is list:
    temp_string = temp_string_2 = str(a)
    while True:
        for R in b:
            temp_string = temp_string.replace(R, c)
        if temp_string == temp_string_2:
            break
        else:
            temp_string_2 = temp_string
    stack.append(temp_string)

As you can see, this is infinite replacement (done until the string doesn't change anymore). So, I don't have to worry about setting the replacement into a loop, since this is already builtin. After that:
                g    # Take the length of the final string
                 2Q  # Check if equal with 2 (which are the quotes at the end)

Uses CP-1252 encoding. Try it online! (slightly modified because the above version is deprecated).

Nicely golfed !

Was this before õ was added?

@Zacharý Yes, that is correct

This could be 8 bytes now (žu2ôõ:g_) utilizing the constant žu = "()<>[]{}", but apparently there is a bug in the : builtin for the new 05AB1E version.. :S Try it online.

Brain-Flak, 1101, 1085, 981 bytes
{(<(({}))((((()()()()()){}){}){})({}[{}]<(())>){((<{}{}>))}{}>{({}<>)(<>)}{}<(({
}))((((()()()()()){}){}){}())({}[{}]<(())>){((<{}{}>))}{}>{({}<>)({}[{}](<()>)){
{}{}(<(())>)}{}{<>{{}}<>{{}}((<()>))}{}(<>)}{}<(({}))(((((()()()()()){}){})){}{}
)({}[{}]<(())>){((<{}{}>))}{}>{<({}()<>)>()(<>)}{}<(({}))(((((()()()()()){}){})(
)){}{})({}[{}]<(())>){((<{}{}>))}{}>{<({}()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{
<>{{}}<>{{}}((<()>))}{}(<>)}{}<(({}))((((()()()){}){}()){({}[()])}{})({}[{}]<(()
)>){((<{}{}>))}{}>{<({}()()<>)>()(<>)}{}<(({}))((((((()()()()()){})){}{}())){}{}
)({}[{}]<(())>){((<{}{}>))}{}>{<({}()()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{<>{{
}}<>{{}}((<()>))}{}(<>)}{}<(({}))((((((()()()()()){}){}){}())){}{})({}[{}]<(())>
){((<{}{}>))}{}>{<({}()()()<>)>()(<>)}{}<(({}))((((((()()()()()){}){}){}())()){}
{})({}[{}]<(())>){((<{}{}>))}{}>{<({}()()()<>)>()({}[{}](<()>)){{}{}(<(())>)}{}{
<>{{}}<>{{}}((<()>))}{}(<>)}{}<{}>[()]){<>{{}}(<()>)<>{{}}(<()>)}{}}<>([]<>)({}<
(())>){((<{}{}>))}{}

Try it online!
This is 980 bytes of source code, and +1 for the -a flag allowing ASCII input (but decimal output)
This is an answer I've been wanting to write for a very very long time. At least 6 months. I waited to post this because I knew that answering this challenge would be extra hard in brain-flak. But it's worth it for one very important reason: The source code itself is a truthy input, which is the entire point of this language itself.
And as I wrote about here, this question was what inspired me to write brain-flak.

Shortly after I wrote Are the brackets fully matched?, it made me wonder how much information you can store with only matched brackets. One thing that stood out to me, was that even though you only have 4 "atoms" of sorts:
(){}[]<>

you really have 8 units of information to convey, since each of these bracket types can be empty, or have other brackets in between, which are fundamentally different pieces of information. So, I decided to write a language that only allowed for matched brackets, and where empty brackets convey something different than brackets with other brackets inside of them.

This answer took roughly two hours to write. I'll admit it's pretty poorly golfed, mostly because a lot of the code is repeated for each bracket type. But I'm mostly amazed that I was able to write an answer at all, especially given that Brain-Flak is

A minimalist esolang designed to be painful to use

I'm going to attempt to golf it down later, but I wanted to get this out there anyway.
I have a detailed explanation, but it's about 6 thousand characters long, so I think it would not be wise to paste the entire thing into this answer. You can read through it here if you want. I'll add a shorter explanation here.
The basic idea, is that we repeat the following steps for every character on the stack:

We check each character to see if it matches any bracket. If it is an opening bracket, we push a number onto the other stack according to the following mapping:
( = 1
< = 2
[ = 3
{ = 4

Then we check to see if it matches any closing bracket. If it does, we push the equivalent number onto the alternate stack, just like for opening brackets. Then, we check if the top two numbers are equal. If they are, the both get popped and the program continues as normal. If they are not, we clear both stacks (to stop the looping) and push a one onto the alternate stack. This is essentially a "break" statement.
After checking the 8 bracket types, we push the value of this run through the loop. Since we zero out most of it, the only snippets that have any value are the conditionals when we compare against brackets. So if any bracket is matched, the whole loop has a value of 1. If none of them did, the whole loop has a value of 0. In this case, we will clear both stacks and push a 0 onto the alternate stack. Again, this is like a "break" statement.

After this main loop is running, the rest is fairly simple. We are on the (empty) main stack, and the alternate stack is empty (if the brackets were matched) or non-empty if they were not. So we run this:
#Toggle to the alternate stack
<>

#Push this stack-height onto main-stack
([]<>)

#Logical not
({}<(())>){((<{}{}>))}{}

This will push a 0 or a 1 onto the main-stack, and when the program ends it is implicitly printed.

Thanks to @WheatWizard for coming up with a good stack-clean "equals" and "logical not" snippet, and for regularly updating the github wiki with useful examples.
Thanks to @ASCII-only for writing an online integer metagolfer which helped immensely in writing this program

revisions

Removed some push pop redundancy
Changed my zero counter logic

Awwwwwweeeeesommmmeeeee!

Brain-Flak, 204 196 190 bytes
{({}<>)<>((((()()()()()){})(({}){})())({}(({})((({}){})(<()>))))())(({<({}<>[({})])>[()]{()(<{}>)}{}<>}{}()<({}<>[({})]){(<{}({}())>)}{}<>>)){(<({}{}<>[{}]{}<>)>)}{}{<>{{}}}{}}<>((){[()]<>})

Try it online!
-8 bytes thanks to Wheat Wizard.  -6 bytes thanks to Jo King.
Explanation
This program stores the character codes of all current unclosed brackets on the second stack.  The bracket pairs <>, [], and {} each have character codes that differ by exactly 2, so there is no need to check for them specifically.  The pair () only differs by 1, so we check for ( specifically, and effectively decrement that byte (actually increment every other byte) before continuing.
# While there are bytes left to process
{

 # Move byte to second stack
 ({}<>)<>

 # Push 40, 0, 40, 60, 91, 123: (, then null, then all four opening brackets
 ((((()()()()()){})(({}){})())({}(({})((({}){})(<()>))))())

 ((

   # For each opening bracket type:
   {

    # Evaluate as zero
    <

     # Compute difference between bracket type and input byte
     ({}<>[({})])

    >

    # Evaluate loop iteration as -1 if equal, 0 otherwise
    [()]{()(<{}>)}{}<>

   }

   # Remove the 0 that was inserted to terminate that loop
   {}

   # Add 1 to result
   ()

   # Evaluate rest of this expression as zero
   <

    # Determine whether the byte is open parenthesis
    ({}<>[({})])

    # If not:
    {

     # Add 1 to byte and break if
     (<{}({}())>)

    }{}

    # Return to main stack
    <>

   >

 # Push result twice (0 if matched an opening bracket, 1 otherwise)
 ))

 # If byte was not an opening bracket:
 {

  # Push zero to break out of if
  (<

    # Push (open bracket + 2 - byte) below that zero
    ({}{}<>[{}]{}<>)

  >)

 }{}

 # If byte was neither an opening bracket nor the appropriate closing bracket:
 {

  # Clear alternate stack and stay there to break out of main loop early
  <>{{}}

 }{}

# End of main loop
}

# If a prefix was invalid, the top of the other stack is the same nonzero value
# that made us break out in the first place. If the string was a valid prefix,
# the other stack contains every unclosed bracket.  If the string is balanced,
# there are none of these. Thus, the other stack is empty if the
# brackets are balanced, and has a nonzero value on top otherwise.

# Push 1 on other stack if empty, and 0 on current stack otherwise
<>((){[()]<>})

"logical not of difference" (also known as equals) could be shorter as ([{}]<>({}))((){[()](<{}>)}{})

I think you can replace that last check with ({<>[()]}()) for -6 bytes

@JoKing Thanks. I don't think I ever would have spotted that.

Yeah, I figured it out in my own answer and realised it was applicable to yours as well

JavaScript (ES6), 52 50 bytes
f=s=>(t=s.replace(/\(\)|\[]|{}|<>/,''))==s?!s:f(t)

Repeatedly remove brackets until the result is the same as the original, then return false unless the string is now empty.
Edit: Saved 2 bytes thanks to @edc65.

how to pass input?

@Aravin The recursive function f that this expression creates takes a single parameter which is the string to be tested.

Python, 67 bytes
lambda s:eval("s"+".replace('%s','')"*4%([],(),{},'<>')*len(s))==''

Generates and evals an expression that looks like
s.replace('[]','').replace('()','').replace('{}','').replace('<>','').replace('[]','').replace('()','').replace('{}','').replace('<>','')

and checks if the result is empty.
Sp3000 saved 8 bytes by pointing out that [],(),{} can be subbed in without quotes because they're Python objects, and that two parens were unneeded.

Retina, 20 bytes
+`\(\)|\[]|{}|<>

^$

Try it online

CJam, 25 24 23 21 bytes
Thanks to Sp3000 for saving 2 bytes.
Thanks to jimmy23013 for saving 2 bytes.
q_,{()<>}a`$2/*{/s}/!

Test suite.
Works essentially the same as the other answers: we repeatedly remove (), [], <> and {} from the string and check if we end up with the empty string. To avoid having to check when we're done, we remove the pairs N times where N is the length of the string, which is always sufficient (since each iteration will remove at least two characters, unless we're done). I'm glad to see that this doesn't beat Retina. :) (Although Pyth or Jelly might...)
There's one fun golfing trick here: to get the string ()<>[]{} we use the following:
{()<>}a`$

The, {()<>} is just a block (i.e. a function), which contains the other brackets as code. With a we wrap the block in an array. The ` stringifies that array, which gives "[{()<>}]". Finally, we sort the string with $, which rearranges the brackets to ()<>[]{}.

I'm not familiar with your language, but your description of your golfing trick makes it sound like `()<>[]{}`` would work just as well, and be the same number of bytes, right?

@MooingDuck No because ()<> are four operators (decrement, increment, and then comparison or truncation depending on the operands), which would be executed immediately, whereas {} denotes a block (CJam's equivalent of a function), i.e. a piece of code that is just pushed onto the stack without evaluating it immediately. That's why I need {} to wrap the () and <>, but then using a for putting everything in an array is shorter than [...].

Yacc, 119 bytes
Does not use regex/replace.
%%input:r;r:%empty|'['r']'r|'{'r'}'r|'('r')'r|'<'r'>'r;%%yylex(){return getchar();}main(){return yyparse();}yyerror(){}

Ungolfed
%%                              # Grammar in BNF
input:
  r;
r:
  %empty
| '['r']'r
| '{'r'}'r
| '('r')'r
| '<'r'>'r;
%%                              # Minimal parser invocation and lexer
yylex(){return getchar();}
main(){return yyparse();}
yyerror(){}

Compilation
yacc -o bracket.c bracket.y
cc -o bracket bracket.c

Usage
~/ % echo -n "<()[]>" | ./bracket
~/ %
~/ % echo -n "{" | ./bracket
~/ 1 %                                                                         :(

Pyth, 31 25 24 bytes
Golfed down to 25 bytes thanks to FryAmTheEggMan
Removed 1 byte
VQ=:Q"<>|\[]|{}|\(\)"k;!

Try it here: Test suite !
I'm still a Pyth newbie, any help is appreciated.
Explanation
VQ                         For N in range(0, len(z)), with Q being the evaluated input.
                           Optimal solution would be to use range(0, len(z)/2) instead, but it add two bytes.
  =:Q"<>|\[]|{}|\(\)"k     assign Q without {}, [], <> nor () (regex replacement) to Q
                      ;    End of For loop
                       !   Logical NOT of Q's length (Q is the input, but has gone several times through y, and Q is implicit).
                           This last operation returns True if len(Q) is 0 (which means all brackets were matched), False otherwise

BTW, congrats to the other Pyth answer (which is currently 20 bytes)

Welcome to Programming Puzzles and Code Golf!

@Adnan Thank you ! This is my first golf !

Nice first golf! With some rearranging and stuff, you can get to 25: Vz=:z"<>|\[]|{}|\(\)"k;!z. Particularly of note, you basically never need to use l if you don't actually need the number, and = automatically guesses the first variable used in an expression. Let me know if you would like me to explain anything else in the Pyth chatroom :)

@FryAmTheEggman Thanks ! I didn't know l was unnecessary, that's good to know. At first, I declared a function because my logic was different, and forgot to remove it. Shall I include your answer to mine ? (I'm a newbie >.<)

Generally, if it's posted in a comment then the comment author wants you to use it. So go right ahead! :)

Pyth, 20 bytes
!uuscNTc"[](){}<>"2G

Try it online: Test Suite
Repeatedly removes occurrences of [], (), <> and {} by splitting and re-merging. Checks if the resulting string is empty or not.

Javascript ES6, 54 bytes
f=_=>_.match(x=/\(\)|\[]|{}|<>/)?f(_.replace(x,'')):!_

Uses a recursive replace implementation. Simple enough.

can you explain this?

Brain-Flak, 204 bytes
(()){{}{({}<>)<>}<>({<(<(({})<>)>)(((((((([(())()()()]){}){}){}())(()))(((())()){}()){})){})(({<(({}<>{}[()]))>(){[()](<{}>)}{}<>}{}))<>{}<>{{}({}[({})]<>({})){(<>)(<>)}{}{}(<>)}{}>{}<>}<>)}{}((){<>[()]})

Try it online!
Not quite as short as Nitroden's answer, but uses a very different approach. This one runs through the input repeatedly, removing neighbouring matching pairs of brackets each time until there are none left. At that point if there is anything left on the stack, then the string was not fully matched.
Explanation:
(())  Push 1 to simulate the check at the start of the loop
{  While check
	{}           Pop check
	{({}<>)<>}<> Reverse input
	({           Loop over input
		< Don't push the values of these calculations
		(<(({})<>)>)  Create a copy of the top of the input and push to the other stack
		(((((
		((([(())()()()]){}){}){}())
		(()))
		(((())()){}()){})
		){})          Push the differences in values of the end brackets
		(({<(({}<>{}[()]))>(){[()](<{}>)}{}<>}{}))  If the copy is the same as any of these, push the difference between the other bracket twice
		<>{}<>  Pop copy
		{  If this character is a start bracket
			{}({}[({})]<>({}))  Check if the next character is the end bracket
			{(<>)(<>)}{}          If not, push a 0 to each stack as buffer
			{}       Pop the top of the input stack, either the start bracket if they matched or the buffer 0
			(<>)     Push 0 to other stack to end check
		}{}>
		{}   Pop the top of the other stack
		         If the character was not an end bracket, pop the copy of check, which is 0
		         If it was, but didn't match the next character, pop the buffer 0
		         If the brackets matched, pop the end bracket and add it to the loop total
	<>}	Repeat with the rest of the input
	<>)	Push the loop total
		If any brackets were matched, the loop total is non zero
}{}
((){<>[()]}) If there is anything left on the stack, push 0 to the other stack, otherwise push 1

Regex (PCRE flavor), 41 37 bytes
^((<(?1)>|{(?1)}|\[(?1)]|\((?1)\))*)$

Just a standard solution with recursive regex.
Thanks jimmy23013 for shaving off 4 bytes

Perl, 34 33 bytes
Includes +2 for -lp
Run with input on STDIN:
./brackets.pl <<< "{<>()}"

brackets.pl:
#!/usr/bin/perl -lp
s/\(\)|\[]|<>|{}//&&redo;$_=!$_

Finds the first bracket pair without anything between them and removes it as long as there are any. Then checks if the final string is empty.

Wouldn't s/\(\)|\[]|<>|{}//&&redo;$_=!$_ work? :)

It would be great if you can provide explanation also.

@Dada Of course. I must be getting senile..

Brainfuck, 132 bytes
+>,[[<->>+>[-]<<-]<[>+>[<+<+>>>+<-]+++++[>--------<-]>[<<+>++++[>-----<-]>[<++++
+[>------<-]>-[<++++[>--------<-]>[,>]]]]<],]<<[>]>.

Formatted:
+>,
[
  [<-> >+>[-]<<-]
  <
  [
    not matching closing bracket
    >+>[<+<+>> >+<-]
    +++++[>--------<-]
    >
    [
      not open paren
      <<+>
      ++++[>-----<-]>
      [
        not open angle bracket
        <+++++[>------<-]>-
        [
          not open square bracket
          <++++[>--------<-]>
          [
            not open brace
            ,>
          ]
        ]
      ]
    ]
    <
  ]
  ,
]
<<[>]
>.

Expects input without a trailing newline. Prints \x00 for false and \x01 for true.
Try it online.
Approach: Maintain a stack starting with \x01, and push the corresponding closing bracket whenever an opening bracket is encountered. Before checking whether the current character is an opening bracket, first check whether it's equal to the closing bracket at the top of the stack, and if so pop it. If it's neither the proper closing bracket nor an opening bracket, consume the rest of the input while moving the pointer to the right. At the end, check whether the pointer is next to the initial \x01.

Java 7, 156 151 bytes
class A{public static void main(String[]a){for(int i=0;i<-1>>>1;++i,a[0]=a[0].replaceAll("<>|\\[]|\\(\\)|\\{}",""));System.out.print(a[0].isEmpty());}}

I'm not expecting this to win any awards but I didn't see a Java answer yet. Additionally, I like to lurk around PPCG and I would enjoy being able to vote/comment on other answers.
Input is given as program parameters. This follows the same format as many other answers here in that it preforms a regex replacement in a loop. Originally I had it loop N times where N is the length of the original string but looping to Integer.MAX_VALUE is shorter :]. This should be ok because Integer.MAX_VALUE is the maximum length of a String in Java so there's an implicit assumption that the length of input is something that is handle-able by Java. The runtime is pretty bad (took about 20 minutes on my lappytop) on account of the loop but I didn't see any restriction on that.

Haskell, 151 bytes
infix 1#
'(':x#y=x#')':y
'<':x#y=x#'>':y
'[':x#y=x#']':y
'{':x#y=x#'}':y
')':x#')':y=x#y
'>':x#'>':y=x#y
']':x#']':y=x#y
'}':x#'}':y=x#y
""#""=1
_#_=0

Try it online!

A few things: As the function (#) needs to be called with the empty string as second argument, you need to count (#"") towards your byte count. Also only True and False are considered truthy/falsy, see the Guide to Golfing Rules.

However the four lines with the closing parentheses can be replaced by a:x#b:y|a==b=x#y, bringing the bytes down to 113: Try it online!

109 bytes: Try it online!

88 bytes

C, 121 122 114 bytes
Shaved of 8 bytes thanks to @xsot!
a[99],i,k;main(c){for(;read(0,&c,!k);c%7&2?k|=a[i--]^c/9:(a[++i]=c/9))k|=!strchr("()[]{}<>",c);putchar(48+!k*!i);}

Uses a stack.

I like the c%7&2. Actually, you don't need k. Instead, you can simply increment i where you would modify k since you need to check if i is zero eventually anyway. Something like this (untested code): a[99],i;main(c){for(;read(0,&c,1);c%7&2?i+=a[i--]^c/9:(a[++i]=c/9))i+=!strchr("()[]{}<>",c);putchar(48+!i);}.

@xsot - Will incrementing i work? We also need to avoid subscripting the array with a negative value, so we have to test either i or k in the for.

Ah I see. There's still room for improvement though: a[99],i,k;main(c){for(;read(0,&c,!k);c%7&2?k|=a[i--]^c/9:(a[++i]=c/9))k|=!strchr("()[]{}<>",c);putchar(48+!i*!k);}

@xsot - Thank you! To sum up the savings, read saved 5 bytes, ^ saved one and the middle operand of the conditional operator saved 2. I am surprised that the middle operand of the conditional operator can be an assignment. I thought that there would be an error, something like "missing : before = ".

@xsot - I tried incrementing i instead of using k, as you first suggested: a[99],i;main(c){for(;read(0,&c,1);c%7&2?i+=a[i]^c/9?1:-1:(a[++i]=c/9))i+=!strchr("()[]{}<>",c);putchar(48+!i);} But this does not work yet for input like ())), since "popping" from the stack does not actually zero the values in the array.

Grime v0.1, 34 bytes
M=\(M\)|\[M\]|\{M\}|\<M\>|MM|_
e`M

Prints 1 for a match and 0 for no match.
Try it online!
Explanation
Grime is my 2D pattern-matching language designed for this challenge; it can also be used to match 1D strings.
This is my first answer with it.
I did modify Grime today, but only to change the character of one syntax element (` instead of ,), so it doesn't affect my score.
M=                         Define pattern called M that matches:
\(M\)|\[M\]|\{M\}|\<M\>      a smaller M inside matched brackets,
|MM                          or two smaller Ms concatenated,
|_                           or the empty pattern.
e`M                        Match the entire input against M.

PowerShell v2+, 63 62 bytes
param($a)for(;$a-ne$b){$a=($b=$a)-replace"\[\]|\(\)|<>|{}"}!$a

Can't quite catch JavaScript, but is currently edging out the other non-esolangs.
Similar approach as other answers: a simple loop that continues so long as we can remove one of [], (), or <> (with several extraneous characters because we need to escape the regex specials). We use $b as a helper along the way to remember what our previous loop's $a was set as. An uninitialized variable is $null, so the first time the loop is encountered, $a is obviously not equal to $null.
At the end of the loop, $a is either empty or not, and the Boolean-not of that string is either True or False.
Example
PS C:\Tools\Scripts\golfing> .\are-the-brackets-fully-matched.ps1 "[({})]"
True

PS C:\Tools\Scripts\golfing> .\are-the-brackets-fully-matched.ps1 "[({])}"
False

Reng v.3.3, 137 bytes, noncompeting
Try it here!
aií0#zl2,q!~1ø
:"]"eq!v:"}"eq!v:">"eq!v:")"eq!v)1z+#z
ve¤[2-2<       <       <     +1<
>]?v$$$zÀ0#z >ðq!vlqv¤l2%[1Ø
   \$2+)1z+#z/   ~n1/

There's a bit more golfing to be done, but at least it works. I added a command ð to keep track of stacks after this challenge in order for this to be remotely possible/easily. I'll explain this in a bit, but it generally keeps track of all strings iterated over and looks for repeats; if there is a repeat, then the string is irreducible. Otherwise, the string will be reduced to the empty string/stack, and will output 1. Otherwise, no output will be produced.

Python 2.7, 96 bytes
def r(s):i=max(map(s.find,['()','[]','{}','<>']));return not len(s)if i<0 else r(s[:i]+s[i+2:])

Welcome to the site!

R, 298
function(.){s=strsplit;u=paste0;.=s(.,"")[[1]];p=s("><)(}{][","")[[1]];.[!.%in%p]="§";for(i in 1:4*2){.[.==p[i]]=sprintf("S('%s',{",p[i]);.[.==p[i-1]]=sprintf("},'%s');",p[i])};S=function(H,B,T)if(H!=T)stop();r=try(eval(parse(,,u(.,collapse=""))),1);if(inherits(r,"try-error"))FALSE else TRUE}

The approach here is to convert the sequence into R code, and then try to parse and evaluate it. If that gives an error, then return FALSE.
But there is a minor problem ... R's rules for brackets are different, so < and > are not brackets at all, and the other types have rules of their own. This is solved by a revolutionary approach -- a squeaking function, whose only function is to signal an error if its head and tail squeak in different ways.
For example, [] is transformed into S('[', {}, ']'), where S is defined as ...
S=function(H,B,T)if(H!=T)stop()

Because the head squeak and tail squeak match, no error is thrown.
A few other examples (the left part is a sequence of brackets and right part is its transformation into valid R code that can be evaluated):
[}     -->  S('[', {}, '}')     # squeaks an error
[()]   -->  S('[', {S('(',{},'(')}, "[")
({[]}) -->  S('(',{S('{',{S('[',{},'[');},'{');},'(');

Some other sequences of brackets will result in parse errors:
[[)    -->   S('[',{S('[',{},'(');

So the remaining part just catches the errors and returns FALSE if there are any, and TRUE if there are none.
The human-readble code:
 sqk <- function(.){
   s=strsplit;u=paste0
   .=s(.,"")[[1]]            # break the argument up into 1-character pieces
   p=s("><)(}{][","")[[1]]   # vector of brackets
   .[!.%in%p]="§"            # replace anything besides brackets by § (--> error)
   for(i in 1:4*2){
     .[.==p[i]]=sprintf("S('%s',{",p[i])    # '<' -->   S('<',{     ... etc
     .[.==p[i-1]]=sprintf("},'%s');",p[i])  # '>' -->   },'<');     ... etc
   }
   S=function(H,B,T)if(H!=T)stop()          # define the working horse
   r=try(eval(parse(,,u(.,collapse=""))),1) # evaluate the sequence
   if(inherits(r,"try-error"))FALSE else TRUE   # any errors?
   }

Applying it on sample cases:
truthy<-readLines(textConnection("()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]"))
falsy<-readLines(textConnection("(
}
(<2)>
(()()foobar)
[({}<>)>
(((()))"))
> sapply(truthy,sqk)
                      ()                 [](){}<>                 (((())))
                    TRUE                     TRUE                     TRUE
                ({[<>]})             [{()<>()}[]] [([]{})<{[()<()>]}()>{}]
                    TRUE                     TRUE                     TRUE
> sapply(falsy,sqk)
           (            }        (<2)> (()()foobar)     [({}<>)>      (((()))
       FALSE        FALSE        FALSE        FALSE        FALSE        FALSE

Julia, 51 bytes
~z=z==(n=replace(z,r"\(\)|\[]|{}|<>",""))?z=="":~n

The least insane of several options. Unsurprisingly, leveraging the power of regex is the shortest path to string matching, but this really only applies if the pattern to match is regular. Trying to do PCRE recursive patterns ends up ballooning the size of the code, either by seeing if the whole string is the match or by anchoring the ends and then creating a construct to specify the inner body for regex recursion. Neither of which are pretty or conducive to code golf.
Explanation:
~z=                            # Define ~z to be the following:
    z==(                       # If z is equal to
        n=replace(z,           # z with the replacement of
            r"\(\)|\[]|{}|<>", # adjacent matching brackets ((),[],{}, or <>)
            ""                 # with empty strings
        )                      # (which is assigned to n)
    )?z==""                    # whether z is an empty string
    :~n                        # else ~ applied to the substituted string

The function repeatedly removes adjacent pairs of parentheses from its only argument, and returns true if it can derive an empty string this way.

Lua (92 bytes)
The older Lua answer is everything but golfing code. There's my proposal instead:
function x(s)m=""return s:gsub("%b<>",m):gsub("%b[]",m):gsub("%b{}",m):gsub("%b()",m)==m end

Stax, 11 10 bytes
é:råvm∟&1Γ

Run and debug it
Got lucky, as stax has a literal constant in it with matched pairs of brackets.

How did I miss that..

Curry, 64 56 bytes
Tested to work in both PAKCS and KiCS2
f(x:a++y:b)|elem[x,y]["{}","<>","[]","()"]=f a*f b
f""=1

Try it on Smap!
Try it online!
This returns 1 if string is balanced and nothing otherwise.
Explanation
Our definition of f then matches the empty string as balanced for a base case:
f""=1

Then we have the main logic:
f(x:a++y:b)|[x,y]=:=anyOf["{}","<>","[]","()"]=f a*f b

Here * is used like a logical and.  Since the only value we can get back is 1, this always gives back 1 when it finds results.  But when it doesn't this doesn't give any result.
With that this pattern matches strings with a pair of matching brackets so that they divide the input into two balanced strings.

C, 258 bytes
#define E else if(a==
#define D(v) {if (b[--p]!=v)z=1;}
#define F b[p++]=
main(a, v) char* v[]; {char b[99],p=0,z=0;for(;*v[1];v[1]++) {a=*v[1];if(a=='(')F 0;E '[')F 1;E '{')F 2;E '<')F 3;E '>')D(3)E '}')D(2)E ']')D(1)E ')')D(0)else z=1;}puts(z|p?"0":"1");}

Degolfed, macro-substituted, commented

int main(int a, char* v[]) {
//           ^ this variable is used as a general purpose int variable and not as its intended purpose (argc)

    char b[99], // create a 99 byte array for storing bracket types
        p = 0, // pointer within the array
        z = 0; // error flag

    // loop through every byte of input (argv[1])
    for(;*v[1];v[1]++) {
        a=*v[1];// a is the current byte

        if(a=='(') b[p++] = 0; // record bracket type
        else if(a== '[') b[p++] = 1;
        else if(a== '{') b[p++] = 2;
        else if(a== '<') b[p++] = 3;
        else if(a== '>') {
            if (b[--p] != 3) z = 1; // error: bracket type mismatch
        } else if(a== '}') {
            if (b[--p] != 2) z = 1;
        } else if(a== ']') {
            if (b[--p] != 1) z = 1;
        }else if(a== ')') {
            if (b[--p] != 0)z = 1;
        }else z = 1; // error: invalid character
    }

    // if either z or p is not 0 print a '0', otherwise print a '1'
    // if p is not zero that means not all brackets were closed
    // if z is not zero that indicates an erro
    puts(z|p ? "0":"1");
}

```

Kotlin, 100 89 86 bytes
-11 bytes: Use any instead of firstOrNull
-3 bytes: Use chunked instead of split (thanks to @leo848)
fun f(s:String):Boolean="()<>[]{}".chunked(2).any{it in s&&f(s.replace(it,""))}||s==""

Try it online!

You can use String::chunked instead of String::split to save 3 bytes.

Python 2, 80 bytes
def m(s,i=0):exec's=s.replace("[({<])}>"[i%4::4],"");i+=1;'*4*len(s);return"">=s

sed, 39 36 bytes (34 for code, 2 for -r)
:a
s/\(\)|\[]|<>|\{}//;ta
/./c0
c1

Try it online!
sed version of what appears to be the standard approach.  Requires extended regular expressions (sed -r)
Saved 3 bytes thanks to Cows quack

You can remove the a is :a and ta to save bytes

@KritixiLithos Apparently that was a bug in GNU sed that was removed in 4.3.  I'd probably drop those characters if this entry was close enough to the leader for it to have a chance of winning, but since it isn't, I'll just leave it in the more portable form so it doesn't stop working as more systems upgrade to 4.3.

Looking back at this, I'm sure you can drop the q from /./ and drop the braces there too. Try it online! This is because of how change works

@Cowsquack Thanks. Edited.

05AB1E, 9 bytes
žu2ôõ:g2Q

Input is given in quotes.
Try it online!
Explanation:
žu          # Push "()<>[]{}"
  2ô        # Split into pieces of size 2
    õ       # Push empty string
            # Implicit input
      :     # Infinite replacement
       g2Q  # Is length equal to 2?
            # Implicit print

K (ngn/k), 32 29 bytes
-3 bytes thanks to @coltim
~#{x{""/y\x}/4 2#"()[]{}<>"}/

Try it online!
{ } a function with argument x
4 2#"()[]{}<>" split to 4 strings of length 2: ("()";"[]";"{}";"<>")
x{..}/ starting with x, go through the list of pairs and apply the function in { } with the previous result as x and the current pair as y
{""/y\x} split x on occurrences of y and join with "" - effectively remove all occurrences of y
# length
~ is 0? (logical not)

I think 3 bytes can be saved with ~#{x{""/y\x}/4 2#"()[]{}<>"}/

Unix TMG, 83 bytes
Another compiler-compiler solution (in addition to Yacc).
p:s parse((any(!<<>>)|={<1>}));s:b s/d;d:;b:<[>x<]>|<{>x<}>|<(>x<)>|<<>x<>>;x:s|();

Unlike Yacc, it works by recursive-descent parsing. It outputs "1" on success, nothing – otherwise.
Expanded:
p: s parse((any(!<<>>)|={<1>}));
s: b s/d;d:;
b: <[>x<]>|<{>x<}>|<(>x<)>|<<>x<>>;
x: s|();

Stax, 19 12 bytes
æöT┴S○♂èα ôG

Run and debug it
Link is to unpacked code.
-7 using a brackets builtin.
Explanation
c%{Vb2/{z:rF}*!
c%              get the input's length
  {         }*  execute this block that many times:
   Vb           take the brackets
     2/         groups of 2
       {   F    for each:
        z:r     replace the brackets with nothing
              ! logical not

Husk, 23 18 bytes
Edit -5 bytes thanks to Leo
¬ω`Ḟ`σøC2"()[]{}<>

Try it online!
How?
¬ωλ◄Lmλσ⁰ø²)C2"()[]{}<>
¬                     # logical NOT of (note NOT of a non-empty string is 0):
 ωλ                   # result of repeating the following operation
                      # until it reaches a periodic (in this case fixed) resut:
   `Ḟ                 # fold over
         C2           # each pair x from
           "()[]{}<>  # the string "()[]{}<>",
                      # with starting value equal to the (implicit) input,
                      # and using the function:
      `σø             # substitute x to null in the last value

Very nice! You can save a bunch of bytes by folding over the list rather than mapping and then taking the shortest result, and by getting rid of the lambdas with some clever flips https://tio.run/##yygtzv6f@6ip8f@hNec7Ex7umJdwvvnwDmcjJQ3N6NjqWhu7////RwM5SjpK0bEamiARIFMDCDSBAMSsjraxi60FK6jW0LSx09CsjY6NBXE1QCZo2lRHA4U1NIGKgER1LUgKpA@Ia6tBDBtNiJGaGppp@flJiUVgszRAVmkiWaYUCwA

@Leo - that's fantastic!  Thanks!  The flips are definitely clever (subtext: I'm still scratching my head to really understand them...).

JavaScript (Node.js), 97 bytes
Solution without regex, so it can't really compete in terms of shortness.
s=>[...s].every(c=>(i="([{<)]}>".indexOf(c))<0?0:i<5?a+=i:a%10-i+4==0?a=""+(a/10|0):0,a="")&&a<1

Try it online!

This solution uses a string as if it were a stack.
We push by concatenating 1, 2, 3 or 4 for ([{< respectively, we check the last value by using modulo 10, and pop it by dividing by 10 if there is a match between the last opening bracket seen and the current closing bracket (an opening bracket is kept forever in the stack if it's not matched).

If there is any closing bracket that doesn't match or if there is any unauthorized character at all, the entire result will be falsed.

The unprintable SOH character is used as padding to never have a 0 in the stack (OP guaranteed that no unprintable character would be in the input). It's necessary to avoid confusing the empty stack "" with a stack potentially full of zeroes, in the condition below.

The a<1 is to check that all the necessary closing brackets have been encountered (which is equivalent to checking if the stack has been successfully emptied at the end).

Clojure, 153 bytes
Longer than even C and Brainfuck answers :o
(defn f[[s & r]](if s(let[[a b](split-at(.indexOf(reductions + 1(for[c r](get(zipmap[s({\(\)\[\]\{\}\<\>}s)][1 -1])c 0)))0)r)](and(not=()a)(f(butlast a))(f b))))1)

Doesn't use regex, instead uses the first character to determine what the closing tag is and finds the first index where that bracket is balanced (cumulative sum is zero). Then iteratively checks that what is within brackets and after brackets are valid.
Gotta see if there is a better approach...

Japt v2.0a0 -!, 16 bytes
e/\[]|<>|\(\)|{}

Try it

Lua, 295 bytes
f = false g = string.gsub t=table s={}b=io.read()for c in b:gmatch('.')do if c:find("[%[<{%(]")then s[#s + 1] = g(g(g(g(c,"<",">"),"{","}"),"%[","]"),"%(",")")elseif c:find("[%]>}%)]")then if t.remove(s)~=c then print(f)return end else print(f)return end end if#s>0 then print(f)else print(1)end

Ungolfed Version
f = false
g = string.gsub
t=table
s={} --Define a stack of opening brackets
b=io.read() --get the input
for c in b:gmatch('.') do   --for every character
    if c:find("[%[<{%(]") then
        s[#s + 1] = g(g(g(g(c,"<",">"),"{","}"),"%[","]"),"%(",")") --if the current character is an opening bracket, push the closing bracket onto the stack
    elseif c:find("[%]>}%)]") then
        if t.remove(s)~=c then
            print(f) --if the character is a closing bracket, pop the closing bracket off the stack and test if they match, if not print false
            return
        end
    else
        print(f) --if the character is not a bracket print false
        return
    end
end
if #s>0 then
    print(f) --if there are still brackets on the stack print false
else
    print(1) --print 1 there are no brackets on the stack
end

Try it online!

Pascal (FPC), 137 126 bytes
var s,t:string;i:word;begin read(s);repeat t:=s;for i:=1to 4do Delete(s,pos('([{<'[i]+')]}>'[i],s),2)until s=t;write(s='')end.

Try it online!

Haskell, 138 Bytes
f x=let g z x=case x of{[]->z;a:b->if a==z!!0then g(tail z)b else g(case a of{'('->')';'['->']';'{'->'}';'<'->'>';_->' '}:z)b}in" "==g" "x
de-golfed:
f x=                                                                      --define a function f
  let g z x=case x of{                                                    --define a function which takes two parameters: z (the remaining input) x (the characters that need to be matched)
    []->z;                                                                --handle end of input
    a:b->if a==z!!0                                                       --if the input matches the characters that need to be matched
      then g (tail z) b                                                   --calls itself for the remaining input
      else g (case a of{'('->')';'['->']';'{'->'}';'<'->'>';_->' '} : z) b--otherwise adds the character to the list of ones that need to be matched
  }
  in g " " x == " "                                                       --runs the matching function

R, 104 bytes
f=function(x,y=x)`if`(nchar(x),{for(e in c("{}","[]","()","<>"))y=gsub(e,"",y,f=T)
`if`(y==x,F,f(y))},T)

Try it online!
Shorter, but sadly much more boring and uninventive than the previous R answer, which I feel more-deserves appreciation...  please upvote it instead!

Vyxal, 15 bytes
λkḂ2ẇk<J(no);Ẋ¬

Try it Online!
λ           ;Ẋ  # While result changes
        (  )    # For each of
 kḂ2ẇk<J        # Pairs of brackets
         no     # Remove it
              ¬ # If something remains, it's unbalanced.

PHP5.4 (84 chars)
Given $argv[1] as a command line argument, it doesn't take a regex to print 0 or 1 :
for($s=$argv[1];"$s"!=$s=str_replace(['()','[]','{}','<>'],'',$s););echo$s===''?1:0;

The same process is 87 chars long using a function :
function f($s){for(;"$s"!=$s=str_replace(['()','[]','{}','<>'],'',$s););return$s==='';}

Try it Online - Usage :
var_dump(f('[([]{})<{[()<()>]}()>{}]')); // bool(true)
var_dump(f('0(()())')); // bool(false)

Info : Only the array declaration break the PHP4 compatibility.

Lexurgy, 38 bytes
While the input changed last iteration, replace pairs of adjacent brackets with an empty string.
a propagate:
{\(\),\[\],\{\},\<\>}=>*

Haskell, 59 bytes
null.foldr(%)""
c%(a:b)|elem(c,a)$zip"([{<"")]}>"=b
c%s=c:s

Try it online!

Rust, 95 bytes
Straightforward recursive solution based on the replacement approach.
fn f(s:String)->bool{s==""||"(),<>,{},[]".split(",").any(|c|s.contains(c)&&f(s.replace(c,"")))}

Try it online!


text:
Simulate Cookie Clicker
Intro
Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies!
The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it.
Challenge
This challenge will not be about clicking a cookie. It will be about automating the cookie.
The player starts off with 0 cookies, and will gain cookies on every game tick. The goal of the challenge is to calculate the amount of ticks it takes to reach a certain amount of cookies.
Input
Your program or function will have 2 input parameters.
The first parameter is the goal, which is simply the amount of cookies you need to finish.
The second parameter is a list of upgrades the player can buy. The format of the list will be explained in further detail in the paragraph Upgrades - List format.
For sake of convenience, you may assume that the input is always in the correct format. You don't have to deal with bad input.
Output
Your program or function should print or return the amount of ticks it takes before the player has reached the goal amount of cookies.
Upgrades
Every game-tick will earn the player some cookies. These are based on the upgrades of the player. If a player has no upgrades, the cookie production will be 1 cookie per tick. Once the player reaches enough cookies to buy an upgrade, he will automatically purchase it (before the next tick happens).
When the player has enough cookies after a tick to buy multiple upgrades, he will attempt to buy all possible upgrades, starting with the cheapest.
List format
[[100, '+', 1],[1000, '*', 2],[10000, '*', 10]
This is an unordered list which contains 3 upgrades. The first parameter of an upgrade is the price of the upgrade. The second parameter is the effect of the upgrade and the third parameter is the effect amount.
The input list will contain no upgrades with the same price.
The only possible effects are + (addition) and * (multiplication).
[100, '+', 1] means that the cookie production will increase by 1 at a cost of 100 cookies.
Golden cookies
Every 1000 ticks, the player will find a golden cookie. When this happens, the player will receive a bonus of 10% (rounded down) of his cookie amount. If the player has 1000 cookies at tick 1000, he will have 1100 cookies before tick 1001 happens.
Order of events
After every tick a couple of actions can occur.

If the player has enough cookies, end the game
If the player has enough cookies, purchase upgrades
If the amount of ticks is a multiple of 1000; Golden cookie

Example input + output
(0    , [])                              -> 0
(100  , [])                              -> 100
(1    , [[10, '+', 1]])                  -> 1
(10   , [[10, '+', 1]])                  -> 10
(1000 , [[100, '*', 2], [10, '+', 1]])   -> 310
(10000, [[10, '+', 1], [100, '*', 2]])   -> 2263

Detailed example
(1000 , [[100, '*', 2], [10, '+', 1]])   -> 310

ticks: 8, cookies: 8, production: 1
ticks: 9, cookies: 9, production: 1
ticks: 10, cookies: 0, production: 2
ticks: 11, cookies: 2, production: 2
ticks: 58, cookies: 96, production: 2
ticks: 59, cookies: 98, production: 2
ticks: 60, cookies: 0, production: 4
ticks: 61, cookies: 4, production: 4
ticks: 70, cookies: 40, production: 4
ticks: 80, cookies: 80, production: 4
ticks: 260, cookies: 800, production: 4
ticks: 280, cookies: 880, production: 4
ticks: 300, cookies: 960, production: 4
ticks: 309, cookies: 996, production: 4
ticks: 310, cookies: 1000, production: 4 -- done

Disclaimer
I will not be held responsible for any addictions caused by this challenge.
Happy golfing!

Totally unrelated, but if anyone gets really, really adicted to CC: https://github.com/niwhsa9/Cookie-Clicker-Bot

Related problem at the Google Code Jam. Google got me addicted to the game :p

Some questions: are the upgrades ordered by cost? Can multiple upgrades be bought together in one tick? If there are multiple upgrades to choose from at a certain time, which one should be bought first?

@aditsu the input list isn't ordered. They can, but the player will always attempt to buy the cheaper upgrades first. Edited the OP

Ok, so the upgrades can be listed in any order. Can there be 2 upgrades with the same cost? If so, which one to buy first?

@aditsu There will be no upgrades with the same cost.

Ahh, I thought this might be the sandboxed one that I'd played with already!

Is the 10% golden cookie bonus added before or after dealing with upgrades? (when both happen in the same tick)

@aditsu this behaviour is described in Order of events. Golden cookie bonus is added in the 3rd and final step of a tick.

Python2, 177 Bytes
def f(g,u):
 c=t=0;r=1
 while c<g:
    c+=r;t+=1
    if c>=g:break
    u=sorted(u)
    if u[0][0]<=c:
        h=u.pop(0);c-=h[0]
        exec('r'+h[1]+'=h[2]')
    if t%1000<1:c+=c//10
 return t

You should be able to golf it further by only using 1-space indents. Also, for ==0, use <1.

@Blue He probably used tabs, but SE converts them to 4 spaces.

Also, exec'r'+h[1]+'=h[2]' is shorter than your if/else statement.

And if you use python 2, the // can be replaced with /.

And c,t,r=0,0,1 can become c=t=0;r=1.

In Python 2, you can mix indents, so space and tab can be used for two different indentation levels for only one byte each.

CJam, 66
q~1$aa+$0{_W$<{{_2$0=0=<!}{\(~X@~:X;@\-}wT):T1e3%{_A/+}|X+}0?}h];T

Try it online
Explanation:
q~            read and evaluate the input (the goal and the array of upgrades)
1$aa+         append a dummy upgrade with the cost equal to the goal
               (to avoid the array becoming empty)
$             sort the upgrades lexicographically (so first by cost)
0             push 0, the initial number of cookies
{…}h          do-while loop, checking the last value as the condition
  _W$<        duplicate the number of cookies and check if it's smaller
               than the goal (at the bottom of the stack)
  {…}         if true… ("<condition><then part><else part>?" is an if statement)
    {…}       while… ("{condition}{block}w" is a while loop)
      _2$     duplicate the number of cookies and the array of upgrades
      0=0=    get the cost (first item) of the first upgrade
      <!      check if the number of cookies is not smaller than it
    {…}       do…
      \(      bring the array of upgrades to the top and take out the first upgrade
      ~       dump the price, effect (operator) and amount onto the stack
      X@      push X (cookie production) and bring the operator to the top
      ~:X;    evaluate the operator and store the result back in X
      @\-     subtract the price from the number of cookies
    w         (end) while
    T):T      increment T (the number of ticks, initially 0)
    1e3%      calculate T % 1000
    {…}|      if false (0) then…
      _A/+    add cookies/10 to the number of cookies (A=10)
    X+        add X (cookie production, initially 1) to the number of cookies
               to go to the next step
               since the result is not 0, the do-while loop continues
  0           else (if we reached the goal) push 0 to exit the loop
  ?           (end) if
];            pop everything left on the stack after the do-while loop
T             push T, the final number of ticks

Lua, 220 Bytes
Can't think of a way to golf it down for the moment, it's still pretty long mostly because lua doesn't let you use loops carelessly regarding the bit count ^^'
function f(g,u)c=0t=0r=1while(c<g)do c=c+r t=t+1if(c>=g)then break end
for i=1,#u do x=u[i]if(c>=x[1])then c=c-x[1]r=x[2]=="+"and r+x[3]or r*x[3]table.remove(u,i)break
end end c=t%1000<1 and c+c/10or c end return t end

Ungolfed
function f(g,u)
  c=0                       -- cookie counter
  t=0                       -- tick counter
  r=1                       -- cookie gain rate

  while(c<g)                -- iterate while cookie < goal
  do                        -- prevent returning 1 tick when the goal is 0
    c=c+r                   -- gain cookies
    t=t+1                   -- increment the tick counter
    if(c>=g)then break end  -- if we have enough cookies, exit
    for i=1,#u              -- iterate over the upgrades
    do
      x=u[i]                -- alias the current upgrade
      if(c>=x[1])           -- if we can, afford it
      then
        c=c-x[1]            -- deduce its price from our cookies
        r=x[2]=="+"         -- if it was an additive bonus
          and r+x[3]        -- add its value to the rate
          or r*x[3]         -- else multiply the rate by it
        table.remove(u,i)   --remove it from the list of upgrades
        break               -- exit the shop :D
      end
    end
    c=t%1000<1              -- every thousand ticks
      and c+c/10            -- get a golden cookie
      or c                  -- every other ticks does nothing
  end
  return t                  -- return the number of ticks it took
end

Test Suite
You can copy paste the following code into this online compiler to run all the test cases.
function f(g,u)c=0t=0r=1while(c<g)do c=c+r t=t+1if(c>=g)then break end
for i=1,#u do x=u[i]if(c>=x[1])then c=c-x[1]r=x[2]=="+"and r+x[3]or r*x[3]table.remove(u,i)break
end end c=t%1000<1 and c+c/10or c end return t end
print(f(0,{}))
print(f(100,{}))
print(f(1,{{10,'+',1}}))
print(f(10,{{10,'+',1}}))
print(f(1000,{{10,'+',1},{100,'*',2}}))
print(f(10000,{{10,'+',1},{100,'*',2}}))

Javascript ES6, 138 bytes
f=(g,s,p=1,c=-1,t=0)=>(c+=p)<g?f(g,s[b=0]?s.slice(b=(z=s.sort()[0])[0]<=c):s,b?eval(`p${z[1]}${z[2]}`):p,(b?c-z[0]:c)*(t%1e3?1:1.1),t+1):t

Ungolfed:
p = 1;  // production
c = -1; // cookies, -1 to account for the first tick
t = 0;  // ticks
f = function(g, s, p, c, t) { // goal, upgrades, production, cookies, ticks
    c += p;        // add production to cookies
    if (c < g) {   // cookies < goal
        b = 0;     // reset buy flag to false

        var upgradeArray;
        if (s[0]) { // our upgrade array isn't empty
            var sortedArray = s.sort();
            var upgrade = sortedArray[0];
            b = upgrade[0] <= c;       // price <= cookies
            upgradeArray = s.slice(b); // if we buy something, we remove the upgrade from the array because [1,2,3].slice(1) -> [2,3]
        } else {                       // our upgrade list is empty
            upgradeArray = s;
        }

        var newProduction;
        if (b) {    // we buy something
            newProduction = eval('p' + upgrade[1] + upgrade[2]) // evaluate p+10 for example
        } else {
            newProduction = p; // production is unchanged
        }

        var newCookies;
        if (b) {    // we buy something
            newCookies = c - upgrade[0]; // substract price from cookies
        } else {
            newCookies = c;
        }

        if (t % 1e3 == 0) {    // ticks % 1000 == 0
            newCookies *= 1.1; // golden cookie
        }

        return f(  // recursive call
            g,     // the goal doesn't change
            upgradeArray,
            newProduction,
            newCookies,
            t+1    // add a tick
        )
    } else {       // we have enough cookies, so we
        return t;  // return the amount of ticks
    }
}

Try it here

f=(g,s,p=1,c=-1,t=0)=>(c+=p)<g?f(g,s[b=0]?s.slice(b=(z=s.sort()[0])[0]<=c):s,b?eval(`p${z[1]}${z[2]}`):p,(b?c-z[0]:c)*(t%1e3?1:1.1),t+1):t

D.innerHTML= [
    f(0    , []),
    f(100  , []),
    f(1    , [[10, '+', 1]]),
    f(10   , [[10, '+', 1]]),
    f(1000 , [[100, '*', 2], [10, '+', 1]]),
    f(10000, [[10, '+', 1], [100, '*', 2]])
].join(`<br>`)
<div id=D>

source: Stack Exchange

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

sort: votes


text:
Snakify a String
A snakified string looks like this:
T AnE eOf ifi ing
h s x l A k e r
isI amp Sna dSt

Your Task
Take a string s and a size n, then output the snakified string. The inputs ThisIsAnExampleOfaSnakifiedString and 3 would produce the example above.
Specifications

s will only contain ASCII characters between code points 33 and 126 inclusive (no spaces or newlines).
s will be between 1 and 100 characters long.
n is an integer representing the size of each output string segment. Each line of characters (up/down or left/right) that make up the curves in the "snake" is n characters long. See the test cases for examples.
n will be between 3 and 10 inclusive.
The output string always starts pointing downwards.
Trailing spaces on each line are allowed.
Trailing newlines at the end of the output are also allowed.
Leading spaces are not allowed.
code-golf means shortest code in bytes wins.

Test Cases
a 3

a

----------

Hello,World! 3

H Wor
e , l
llo d!

----------

ProgrammingPuzzlesAndCodeGolf 4

P  ngPu  Code
r  i  z  d  G
o  m  z  n  o
gram  lesA  lf

----------

IHopeYourProgramWorksForInputStringsWhichAre100CharactersLongBecauseThisTestCaseWillFailIfItDoesNot. 5

I   gramW   tStri   100Ch   gBeca   CaseW   DoesN
H   o   o   u   n   e   a   n   u   t   i   t   o
o   r   r   p   g   r   r   o   s   s   l   I   t
p   P   k   n   s   A   a   L   e   e   l   f   .
eYour   sForI   Which   cters   ThisT   FailI

----------

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

!        <=>?@ABCDE        `abcdefghi
"        ;        F        _        j
#        :        G        ^        k
$        9        H        ]        l
%        8        I        \        m
&        7        J        [        n
'        6        K        Z        o        ~
(        5        L        Y        p        }
)        4        M        X        q        |
*+,-./0123        NOPQRSTUVW        rstuvwxyz{

I'm guessing the next challenge will be to convert a snakified string back to the original 2 parameters ...

@abligh I had no further plans, but that actually sounds like a decent idea. There could be some form of duplicate though, so I'll need to check that first. Stay tuned!

the reverse challenge would be more fun if the snake can be an arbitrary shape ...

@abligh That's exactly what I was planning on doing haha!

@abligh Done!

Guess what: Mathematica will have a built-in for that.

Pyth, 48 45 44 43 42 bytes
=Y0juXGZX@G~+Z-!J%/HtQ4q2J~+Y%J2@zHlzm*;lz

Try it online.
This approach does the same trailing whitespace abuse as the Ruby answer.

Crossed out 44 is still 44... still.

Ruby, 87 bytes
->s,n{p=0
a=(' '*(w=s.size)+$/)*n
w.times{|i|a[p]=s[i];p+=[w+1,1,-w-1,1][i/(n-1)%4]}
a}

Some minor abuse of the rule Trailing spaces on each line are allowed. Each line of output is w characters long, plus a newline, where w is the length of the original string, i.e. long enough to hold the whole input. Hence there is quite a lot of unnecessary whitespace to the right for large n.
Ungolfed in test program
f=->s,n{
  p=0                            #pointer to where the next character must be plotted to
  a=(' '*(w=s.size)+$/)*n        #w=length of input. make a string of n lines of w spaces, newline terminated
  w.times{|i|                    #for each character in the input (index i)
    a[p]=s[i]                    #copy the character to the position of the pointer
    p+=[w+1,1,-w-1,1][i/(n-1)%4] #move down,right,up,right and repeat. change direction every n-1 characters
  }
a}                               #return a

puts $/,f['a',3]

puts $/,f['Hello,World!',3]

puts $/,f['ProgrammingPuzzlesAndCodeGolf',4]

puts $/,f['IHopeYourProgramWorksForInputStringsWhichAre100CharactersLongBecauseThisTestCaseWillFailIfItDoesNot.',5]

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

JavaScript (ES6), 143 bytes
(s,n)=>[...s].map((c,i)=>(a[x][y]=c,i/=n)&1?y++:i&2?x--:x++,a=[...Array(n--)].map(_=>[]),x=y=0)&&a.map(b=>[...b].map(c=>c||' ').join``).join`\n`

Where \n represents a literal newline. Ungolfed:
function snakify(string, width) {
    var i;
    var result = new Array(width);
    for (i = 0; i < width; i++) result[i] = [];
    var x = 0;
    var y = 0;
    for (i = 0; i < string.length; i++) {
       result[x][y] = string[i];
       switch (i / (width - 1) & 3) {
       case 0: x++; break;
       case 1: y++; break;
       case 2: x--; break;
       case 3: y++; break;
    }
    for (i = 0; i < width; i++) {
        for (j = 0; j < r[i].length; j++) {
            if (!r[i][j]) r[i][j] = " ";
        }
        r[i] = r[i].join("");
    }
    return r.join("\n");
}

Pyth, 85 74 59 bytes
Kl@Q0J0=Y*]d-+*@Q1K@Q1 1FNr1@Q1=XY-+*KNN1b;VK=XYJ@@Q0N=+J@[+K1 1-_K1 1).&3/N-@Q1 1;sY
=G@Q1=H@Q0KlHJ0=Y*]dt+*GKGFNr1G=XYt+*KNNb;VK=XYJ@HN=+J@[hK1t_K1).&3/NtG;sY
Klz=Ym;+*QKQVQ=XYt+*KhNhNb;VK=XYZ@zN=+Z@[hK1_hK1).&3/NtQ;sY

Thanks to @FryAmTheEggman for greatly helping me !
Golfed as much as I could. Try it here !
For some reason, line wrapping make the output weird. You may want to have a look at the output on full page
Explanation
Breathe a second, and focus.
This can be broken down in three sections, like almost any "classic" algorithm.
The first section
It's where variables are initialized. It can be splitted into two parts :
Klz=Ym;+*QKQ
Klz                Assign len(input[0]) to K. (length of input String)
   =Ym;+*QKQ       Assign an empty list to Y of length K*input[1]-input[1]-1, where input[1] is the size of the snake
                   (thus the height of the final string)

the second part :
VQ=XYt+*KhNhNb;
VQ                       For N in range(0, input[1]), where input[1] is the size of the snake
  =                        Assign to Y. Y is implicit, it is the last variable we used.
   XYt+*KhNhNb               Y[K*N+N-1]="\n". Can be broken down in four parts :
   X                           Replace function. X   <C: any> is A[B]=C
    Y                          A: The array we initialized in the first section.
     t+*KhNhN                  B: K*(N+1)+N+1 (N is the for loop variable)
             b                 C: Newline character ("\n")
              ;          End the loop.

The second section
It contains the actual logic.
VK=XYZ@zN=+Z@[hK1_hK1).&3/NtQ;
VK                                         For N in range(0, K), where K is the length of the input string (see first section)
  =                                          Assign to Y. Y is implicit, it is the last variable we used.
   XYZ@zN                                    Same as in section 2. This is a replacement function. Y[Z] = input[0][N]. Z is initially 0.
         =+Z@[hK1_hK1).&3/NtQ                Again this can be broken down :
         =+Z                                   Add to Z
             [hK1_hK1)                         Array containing directions. Respectively [K+1, 1, -K-1, 1]
            @         .&3/NtQ                  Lookup in the array, on index .&3/N-@Q1 1:
                      .&3                        Bitwise AND. .& <int> <int>
                         /NtQ                    (input[1]-1)/N, where input[1] is the size of the snake
                             ;             End the loop

The third section
This is the output part. Not really interesting...
sY    Join the array Y. Implicitly print.

BONUS
I wrote the pyth program from this python script.

input=["ThisIsAnExampleOfASnakifiedString", 4];
width=len(input[0]);
height=input[1];
pointer=0;
directions = [width+1,1,-width-1,1] #Respectively Down, right, up, right (left is replaced by right because of snake's nature. Doesn't go left).
output=[' ' for i in range(0, width*height+height-1)];
for N in range(1, height):
    output[width*N+N-1]="\n";
for N in range(0, len(input[0])):
    output[pointer]=input[0][N];
    pointer+=directions[3&(N/(height-1))];
print "".join(output);

JavaScript (ES6), 122 bytes

document.write("
"+(

// --- Solution ---
s=>n=>[...s].map((c,i)=>(a[p]=c,p+=[l+1,1,-l-1,1][i/n%4|0]),p=0,a=[...(" ".repeat(l=s.length)+`
`).repeat(n--)])&&a.join``
// ----------------

)("IHopeYourProgramWorksForInputStringsWhichAre100CharactersLongBecauseThisTestCaseWillFailIfItDoesNot.")(5))

Same algorithm as @LevelRiverSt's answer.

C, 138 bytes
char*h[]={"\e[B\e[D","","\e[A\e[D",""},t[999];i;main(n){system("clear");for(scanf("%s%d",t,&n),--n;t[i];++i)printf("%c%s",t[i],h[i/n%4]);}

This uses ANSI escapes. Works in linux terminal.
Ungolfed:
char*h[]={"\e[B\e[D","","\e[A\e[D",""},
    /* cursor movement - h[0] moves the cursor one down and one left,
    h[2] moves the cursor one up and one left. */
t[999];i;
main(n){
    system("clear");
    for(scanf("%s%d",t,&n),--n;t[i];++i)
        printf("%c%s",t[i],h[i/n%4]);
}

JavaScript (ES6), 131
Algorithm: mapping the position x,y in output to the index in the input string, somehow like this (unrelated) answer.
I borrowed from @LevelRiverSt the trick of keeping the horizontal width equal to the input length.
a=>m=>eval('for(--m,t=y=``;y<=m;++y,t+=`\n`)for(x=0;a[x];)t+=a[2*(x-x%m)+((h=x++%(2*m))?h-m?!y&h>m?h:y<m|h>m?NaN:m+h:m-y:y)]||`.`')

Less golfed
This was the first working draft before golfing
f=(a,n)=>{
  l=a.length
  m=n-1
  s=m*2 // horizontal period

  b=-~(~-l/s)*m // total horizontal len, useless in golfed version
  t=''
  for(y=0;y<n;y++)
  {
    for(x=0;xm)
        c=k*s+h
      else if (y == m && h<m)
        c=k*s+m+h
      else
        c=-1
      t+=a[c]||' '
    }
    t+='\n'
  }
  return t
}

Test

F=a=>m=>eval('for(--m,t=y=``;y<=m;++y,t+=`\n`)for(x=0;a[x];)t+=a[2*(x-x%m)+((h=x++%(2*m))?h-m?!y&h>m?h:y<m|h>m?NaN:m+h:m-y:y)]||` `')

function test()
{
  var n=+N.value
  var s=S.value
  O.textContent=F(s)(n)
}

test()
#S {width:80%}
#N {width:5%}
<input id=N value=5 type=number oninput='test()'>
<input id=S 5 oninput='test()'
value='IHopeYourProgramWorksForInputStringsWhichAre100CharactersLongBecauseThisTestCaseWillFailIfItDoesNot.'>

Pyth, 122 bytes
=k@Q0J-@Q1 1K*4J=T*@Q1[*lkd;Vlk=Z+*%NJ/%N*J2J*/N*J2J=Y.a-+**/%N*J2J!/%NK*J2J*%NJ!/%N*J2J**!/%N*J2J/%NK*J2J XTYX@TYZ@kN;jbT

I've made a formula to calculate the x, y positions of each character based on the segment size / modulo, but they got larger than I expected :c
Explanation:
=k@Q0                                                                                # Initialize var with the text
     J-@Q1 1                                                                                # Initialize var with the segment size (minus 1)
            K*4J                                                                                # Initialize var with the "block" size (where the pattern start to repeat)
                =T*@Q1[*lkd;                                                                                # Initialize output var with an empty array of strings
                            Vlk                                                                                # Interate over the text
                               =Z+*%NJ/%N*J2J*/N*J2J                                                                      # Matemagics to calculate X position
                                                    =Y.a-+**/%N*J2J!/%NK*J2J*%NJ!/%N*J2J**!/%N*J2J/%NK*J2J                # Matemagics to calculate Y position
                                                                                XTYX@TYZ@kN;    # Assign the letter being iterated at x,y in the output
                                                                                jbT # Join with newlines and print the output

Test here
For the Math formulas, I used mod to generate 0/1 flags and then multiplied by a factor based on the input n, added the spreadsheet with each step on the snippet bellow

td{padding-top:1px;padding-right:1px;padding-left:1px;color:black;font-size:11.0pt;font-weight:400;font-style:normal;text-decoration:none;font-family:Calibri,sans-serif}.x1{text-align:general;vertical-align:bottom;white-space:nowrap}.x2{text-align:general;vertical-align:bottom;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid gray;white-space:nowrap}.x3{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid windowtext;white-space:nowrap}.x4{text-align:general;vertical-align:bottom;border:.5pt solid gray;white-space:nowrap}.x5{text-align:general;vertical-align:bottom;border:.5pt solid gray;background:#c5d9f1;white-space:nowrap}.x6{text-align:general;vertical-align:bottom;border:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x7{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid windowtext;border-bottom:.5pt solid gray;border-left:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x8{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid windowtext;background:#d9d9d9;white-space:nowrap}.x9{text-align:general;vertical-align:bottom;border:.5pt solid gray;background:#d9d9d9;white-space:nowrap}.x10{text-align:right;vertical-align:bottom;border:.5pt solid gray;white-space:nowrap}.x11{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid windowtext;background:#d9d9d9;white-space:nowrap}.x12{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;background:#d9d9d9;white-space:nowrap}.x13{text-align:right;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;white-space:nowrap}.x14{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;white-space:nowrap}.x15{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;background:#c5d9f1;white-space:nowrap}.x16{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid gray;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x17{text-align:general;vertical-align:bottom;border-top:.5pt solid gray;border-right:.5pt solid windowtext;border-bottom:.5pt solid windowtext;border-left:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x18{text-align:general;vertical-align:bottom;border-right:.5pt solid gray;border-bottom:0;border-left:.5pt solid gray;white-space:nowrap}.x19{text-align:general;vertical-align:bottom;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid windowtext;white-space:nowrap}.x20{text-align:general;vertical-align:bottom;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid gray;background:#c5d9f1;white-space:nowrap}.x21{text-align:general;vertical-align:bottom;border-right:.5pt solid gray;border-bottom:.5pt solid gray;border-left:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x22{text-align:general;vertical-align:bottom;border-right:.5pt solid windowtext;border-bottom:.5pt solid gray;border-left:.5pt solid gray;background:#ebf1de;white-space:nowrap}.x23{text-align:center;vertical-align:bottom;border:.5pt solid windowtext;white-space:nowrap}.x24{text-align:center;vertical-align:bottom;border-right:.5pt solid windowtext;border-bottom:0;border-left:.5pt solid windowtext;white-space:nowrap}

<colgroup><col style="width:16pt" width="21">
<col style="mso-width-alt:2742;width:56pt" span="2" width="75">
<col style="width:23pt" width="31">
<col style="width:50pt" width="67">
<col style="width:60pt" width="80">
<col style="width:85pt" width="113">
<col style="width:26pt" width="35">
<col style="width:41pt" width="54">
<col style="width:29pt" width="39">
<col style="width:41pt" width="55">
<col style="width:104pt" width="138">
<col style="width:29pt" width="39">
<col style="width:41pt" width="54">
<col style="width:65pt" width="87">
<col style="width:39pt" width="52">
</colgroup>

d
e
f

h
i
j
k
l
m
n
o
p
q
r
s

i
expected x
expected y

pos % seg
pos/(seg*2)
pos%(seg*2)/seg
not j
seg*i+h
i*seg
j*l+k*m
pos%(seg*4)/(seg*2)
not o
j*p*seg
abs(o*seg-h)
q*j+r*k

0
0
0

0
0
0
1
0
0
0
0
1
0
0
0

1
0
1

1
0
0
1
1
0
0
0
1
0
1
1

2
0
2

2
0
0
1
2
0
0
0
1
0
2
2

3
0
3

0
0
1
0
0
0
0
0
1
3
0
3

4
1
3

1
0
1
0
1
0
1
0
1
3
1
3

5
2
3

2
0
1
0
2
0
2
0
1
3
2
3

6
3
3

0
1
0
1
3
3
3
1
0
0
3
3

7
3
2

1
1
0
1
4
3
3
1
0
0
2
2

8
3
1

2
1
0
1
5
3
3
1
0
0
1
1

9
3
0

0
1
1
0
3
3
3
1
0
0
3
0

10
4
0

1
1
1
0
4
3
4
1
0
0
2
0

11
5
0

2
1
1
0
5
3
5
1
0
0
1
0

12
6
0

0
2
0
1
6
6
6
0
1
0
0
0

13
6
1

1
2
0
1
7
6
6
0
1
0
1
1

14
6
2

2
2
0
1
8
6
6
0
1
0
2
2

15
6
3

0
2
1
0
6
6
6
0
1
3
0
3

16
7
3

1
2
1
0
7
6
7
0
1
3
1
3

17
8
3

2
2
1
0
8
6
8
0
1
3
2
3

18
9
3

0
3
0
1
9
9
9
1
0
0
3
3

19
9
2

1
3
0
1
10
9
9
1
0
0
2
2

20
9
1

2
3
0
1
11
9
9
1
0
0
1
1

21
9
0

0
3
1
0
9
9
9
1
0
0
3
0

22
10
0

1
3
1
0
10
9
10
1
0
0
2
0

23
11
0

2
3
1
0
11
9
11
1
0
0
1
0

Can you explain the Matemagics ? i.e write them in a more human-fashion way ?

@FliiFe done c:

PHP, 127 126 124 120 119 118 117 110 106 bytes
Uses ISO-8859-1 encoding.
for(;($q=&$o[$y+=$d]||$q=~ÿ)&&~Ï^$q[$x+=!$d]=$argv[1][$a];$a++%($argv[2]-1)?:$d-=-!$y?:1)?><?=join(~õ,$o);

Run like this (-d added for aesthetics only):
php -r 'for(;($q=&$o[$y+=$d]||$q=~ÿ)&&~Ï^$q[$x+=!$d]=$argv[1][$a];$a++%($argv[2]-1)?:$d-=-!$y?:1)?><?=join(~õ,$o);' "Hello W0rld!" 3 2>/dev/null;echo

Ungolfed:
// Iterate over ...
for (
    ;
    // ... the characters of the input string. Prepend `0` so a 0 in the input
    // becomes truthy.
    0 . $char = $argv[1][$a];

    // Use modulo to determine the end of a stretch (where direction is
    // changed).
    // Change direction (`0` is right, `-1` is up and `1` is down). When
    // y coordinate is `0`, increment the direction, else decrement.
    $a++ % ($argv[2] - 1) ?: $direction += $y ? -1 : 1
)

    (
        // Increase or decrease y coordinate for direction -1 or 1 respectively.
        // Check whether the array index at new y coordinate is already set.
        $reference =& $output[$y += $direction] ||
        // If not, create it as a string (otherwise would be array of chars).
        // Null byte, won't be printed to prevent leading char.
        $reference = ~ÿ;

        // Increment x coordinate for direction 0. Set the output char at the
        // current coordinates to the char of the current iteration.
    ) & $reference[$x += !$direction] = $char;

// Output all lines, separated by a newline.
echo join(~õ, $output);

Tweaks

Saved a byte by using < instead of !=
Saved 2 bytes by setting the string to 0 at first, so I don't have to prepend another 0 (in case the first output in a line was a 0), yielding truthy 00.
Saved 4 bytes by using a reference instead of repeating $o[$y]
Saved a byte by using modulo instead of == for comparing direction with 1 to change x coordinate
Saved a byte by removing type cast null to int for string offset, as string offset is cast to int anyway
Saved a byte by using short print tag
Saved 7 bytes by improving the direction logic
Saved 4 bytes by directly assigning the char to prevent intermediate $c

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


text:
Magic number of a given length
Your program must take an input (n for the purpose of description) and output all permutations of a number that is n digits long with no repeating digits, where each of the digits preceding and including its index are divisible by the place in the number that it falls.
You can read about magic numbers here.
Rules:

1 <= n <= 10
No digits may be repeated
The leading 0 must be present (if applicable)
The 1st through xth digit of the number (starting with the first character as 1) must be divisible by x, i.e. in 30685, 3 is divisible by 1, 30 is divisible by 2, 306 is divisible by 3, 3068 is divisible by 4, and 30685 is divislbe by 5.
The program must take an integer as input (through the command line, as a function argument, etc.) and print all permutations that satisfy the rules.
Output must be separated by 1 or more white space character
Permutations may start and with zero (so they're not technically magic numbers).
The order of output does not matter
You do not need to handle unexpected input
Least characters in bytes wins

Examples
Given 1:
0
1
2
3
4
5
6
7
8
9

Given 2:
02
04
06
08
10
12
14
16
18
20
24
26
28
30
32
34
36
38
40
42
46
48
50
52
54
56
58
60
62
64
68
70
72
74
76
78
80
82
84
86
90
92
94
96
98

Given 10:
3816547290

Credit to Pizza Hut & John H. Conway for the original puzzle (Option A).
Thanks to @Mego and @sp3000 for their links.

Related: http://codegolf.stackexchange.com/q/63183/42854

@Nathan Merill whups, sorry

@Dopapp I don't think that's the same thing

It means it's related, but not a duplicate. So don't worry about that :)

@DavisDude "Related" doesn't mean "duplicate". The purpose of posting a related link is for that challenge to show up as "Linked" in the sidebar.

Related reading: polydivisible numbers

Do leading 0's need to be included output numbers that have them?

You mention printing and whitespace when it comes to output, but for a function, the most natural form of output would probably be returning a list. Is that allowed?

@xbor yes @Dennis♦ Yes. I mean there must be white space separating the output.

@Dennis♦ The characters must be output to the command line or in some other format to be read

Jelly, 20 17 16 bytes
QḣQV%S
ØDṗçÐḟRj⁷

This is very slow and memory intensive... Try it online!
How it works
ØDṗçÐḟRj⁷  Main link. Input: n (integer)

ØD         Yield d := '0123456789'.
  ṗ        Compute the nth Cartesian power of d.
      R    Range; yield [1, ..., n].
    Ðḟ     Filter false; keep strings of digits for which the following yields 0.
   ç         Apply the helper link to each digit string and the range to the right.
       j⁷  Join the kept strings, separating by linefeeds.

QḣQḌ%S     Helper link. Arguments: s (digit string), r (range from 1 to n)

Q          Unique; deduplicate s.
 ḣ         Head; get the prefixes of length 1, ..., n or less.
           If s had duplicates, the final prefixes fill be equal to each other.
  Q        Unique; deduplicate the array of prefixes.
   V       Eval all prefixes.
    %      Compute the residues of the kth prefixes modulo k.
           If s and the array of prefixes have different lengths (i.e., if the
           digits are not unique), some right arguments of % won't have corr. left
           arguments. In this case, % is not applied, and the unaltered right
           argument is the (positive) result.
     S     Add all residues/indices. This sum is zero iff all digits are unique
           and the kth prefixes are divisible by k.

If this is slow... my answer is a sleepy slug

JavaScript (Firefox 30-57), 77 bytes
f=n=>n?[for(s of f(n-1))for(c of"0123456789")if(s.search(c)+(s+c)%n<0)s+c]:[""]

Edit: Saved 1 byte thanks to @edc65.

A gem! just save 1 byte with ...of"012...

@edc65 Ugh, I can't believe I overlooked that.

MATL, 30 bytes
4Y2Z^!"@Sd@!U10G:q^/kPG:\~h?@!

Try it online!
It's very slow. For input 3 it takes a few seconds in the online compiler. To see the numbers appearing one by one, include a D at the end of the code.
Explanation
4Y2       % predefined literal: string '0123456789'
Z^        % implicit input. Cartesian power: 2D char array. Each number is a row
!         % transpose
"         % for each column
  @       %   push current column
  Sd      %   sort and compute consecutive differences (*)
  @!U     %   push current column. Convert to number
  10G:q^  %   array [1 10 100 ... 10^(n-1)], where n is the input
  /k      %   divide element-wise. Round down
  P       %   reverse array
  G:      %   array [1 2 ... n]
  \~      %   modulo operation, element-wise. Negate: gives 1 if divisible (**)
  h       %   concatenate (*) and (**). Truthy if all elements are nonzero
  ?       %   if so
    @!    %     current number as a row array of char (string)
          %   implicitly end if
          % implicitly end if
          % implicitly display stack contents

Something is wrong with your code; It stops producing output for me after 5, and with 5 the last number (the only one I've bothered to check) is incorrect. 986 is not divisible by 3

Update: for 2 it skips 10, 12, 32, 34, 54, 56, 76, 78

I think you misunderstood the prompt. Looking at 3 I can see you have a couple indications (e.g. 026). Also an explanation would be appreciated

This still doesn't work- 3 skips 021, 024, etc. The first correct number is 063.

@DavisDude Edited, now that I read the challenge more carefully

Pyth, 19 bytes
jf!s%VsM._TS;.PjkUT

Demonstration
A brute force solution. Explanation to follow. Inspiration thanks to FryAmTheEggman

22 bytes
juf!%sThH{I#sm+LdTGQ]k

Demonstration
Numbers are built and stored as strings, and only converted to ints to check divisibility.
Explanation:
juf!%sThH{I#sm+LdTGQ]k
 u                 Q]k    Apply the following input many times, starting with ['']
             m    G       For each string at the previous step,
              +LdT        Append each digit to it
            s             Concatenate
         {I#              Filter out strings with repeats
  f                       Filter on
     sT                   The integer
    %  hH                 Mod the 1 indexed iteration number
   !                      Is zero.
j                         Join on newlines.

I'm curious: just how masochistic do you have to be to learn Pyth? /s

@DavisDude I think it is easier than what people think when they see it. The scariest part is beginning. Once you're in, you're in.

It's fairly easy, imho, because of how much the debug mode helps you. The docs are also pretty good, and explain what you need to know.

Just for reference, I wound up with one more using ._ and some other stuff, but it's waaay slower for big inputs: jjLkf!s.e%ib10hk._T.PUT

Ruby, 87 bytes
Basic recursive solution.
f=->n,x="",j=1{j>n ?puts(x):([*?0..?9]-x.chars).map{|i|f[n,x+i,j+1]if((x+i).to_i)%j<1}}

If you're allowed to return a list of the permutations instead of printing, 85 bytes:
f=->n,x="",j=1{j>n ?x:([*?0..?9]-x.chars).map{|i|f[n,x+i,j+1]if((x+i).to_i)%j<1}-[p]}

Python, 132 bytes
lambda n:[x for x in map(("{:0%s}"%n).format,(range(10**n)))if all(int(x[:i])%i<1and len(set(x))==len(x)for i in range(1,len(x)+1))]

Dropped 26 bytes by getting rid of itertools, thanks to Sp3000 for making me realize I shouldn't be using it.
Dropped 2 bytes by using a list comprehension rather than filter, thanks again to Sp3000 for the tip.
Try it online: Python 2, Python 3


text:
Average an image
Here is an image:
%%%%%%%%%%%%%
% Hello,    %
%    world! %
%%%%%%%%%%%%%

But it is too confusing for our undersized brains to compute. So we average it like this:

Split it into 2 x 2 sections. If the picture ends before a section is complete, imagine that there are spaces there.
Average the values of the ASCII characters in each section.
Round this average and convert it to an ASCII character.
Finally, replace all characters in the section to the average character.

Repeat this for all sections.
So the average of the image above looks like this:
$$>>II99######
$$>>II99######
$$##88KKGG####
$$##88KKGG####

Your task: Write  a program that takes an ASCII image as input and outputs its average.
Note Integers are rounded by function floor(x+0.5) or similar function - in other words, round halves upwards.

What happens if the width is odd?

@KennyLau " If the picture ends before a section is complete, imagine that there are spaces there." I think that cover the case when the width is odd ;)

Can we assume the height will always be even ?

If not, will the height always be greater than one?

Can we just truncate decimal places instead of rounding up or down?

@DenkerAffe No. That would be cheating. :P

I think the outoput # in the example should be $. Can you check all values?

@LevelRiverSt Nice catch. Will fix...

@Solver 34.5 rounds to 35, not to 34

What about two % and a two spaces? That's 34.5. Conventionally, if it's exactly half way you should round up to 35 #  but you have 34 " Which is allowable? # or " or both?

@LevelRiverSt Is this better now?

Just to clarify with expected behavior, a 7x7 image would act as an 8x8 image with spaces on the bottom and right edge? Therefore our output would also be 8x8?

JavaScript (ES6), 159 bytes

document.write("<pre>"+(

// --- Solution ---
s=>s.replace(/./g,(c,i)=>(a=String.fromCharCode([t=0,1,l=s.search`
`+1,l+1].map(o=>t+=(n=s.charCodeAt(p=i+o-i%l%2-(i/l|0)%2*l))>32?n:32)|t/4+.5))+(++p%l?"":a))
// ----------------

)(`%%%%%%%%%%%%%
% Hello,    %
%    world! %
%%%%%%%%%%%%%`))

Takes a multiline string as input.

Running on Firefox, this produces incorrect output.

@Trebuchette Ah, I misinterpreted the space rule. It's fixed now.

MATL, 32 30 bytes
2thZCO32XEoYmYocGZy2/Xke2t3$Y"

Input is a 2D char array, with rows separated by ;.
Try it online!
Explanation
2th     % push array [2 2]
ZC      % take input implicitly. Arrange distinct 2x2 blocks as columns, padding with 0
O32XE   % replace 0 by 32 (space)
oYm     % convert to number. Take mean of each column
Yoc     % round. Convert to char
GZy     % size of input in the 2 dimensions
2/Xk    % divide each dimension by 2, and round up to account for the padding
e       % reshape into image with half original size in each dimension
2t3$Y"  % replicate by a factor of 2 in each dimension. Display implicitly

Pyth, 58 bytes
J2A,lQlhQV:0GJ
Ksm*C+csmsm?&<kG<bHC@@Qkb32hBdhBN4 .5J:0HJK

Try it online!

The bonus is not there anymore

Lua, 382 376 367 353 348 bytes
r="\n"o=... n=o:find(r)-1
l=n+n%2
a=o:gsub(r,(n~=l and" "or"")..r).." "..(#o//(l+1)%2<1 and r..(" "):rep(l)or"")print(a:gsub("()([^\n])(.)",function(p,m,c)t=p//(l+1)%2==0return string.char(math.floor((m:byte()+c:byte()+(t and a:sub(p+l+1,p+l+1)or a:sub(p-l,p-l)):byte()+(t and a:sub(p+l+2,p+l+2)or a:sub(p-l-1,p-l-1)):byte())/4+.5)):rep(2)end).."")

Works on the command line; accepts a string like the test case.

Care to include an ungolfed version?

Ruby, 235 230 bytes
->i{i=i.split($/).map{|s|s.bytes+[s.size%2>0?32:0]}
w=i[0].size;h=i.size;h+=h%2;r=[[]]*h
(h/2).times{|y|y*=2
(w/2).times{|x|x*=2
c=((i[y][x,2]+(i[y+1]||[32]*w)[x,2]).inject(:+)/4.0).round.chr
r[y+1]=r[y]+=[c,c]}}
r.map(&:join)*$/}

Python, 319 bytes
def f(A):
 L,R,S=len,range,A.split('\n')
 if L(S[0])%2:S=[s+' 'for s in S]
 m=L(S[0])
 if L(S)%2:S+=[' '*m]
 C=[chr(int(sum(map(ord,[S[i][j],S[i+1][j],S[i][j+1],S[i+1][j+1]]))/4.0+0.5))for i in R(0,L(S),2)for j in R(0,m,2)]
 f=t='';i=0
 while i<L(C):
    t+=C[i]*2
    i+=1
    if i%(m/2)<1:f+=(t+'\n')*2;t=''
 f=f[:-1]
 print f

2nd indentation is tabs.
Stuff before C is padding, C is the averaging process to single letters and rest is output

Ruby, 180 158 148 128 + 4 124 + 4 = 128 bytes
Run with $ ruby -nl (+4 bytes for -nl flags). Takes input on STDIN.
y,x=x,$_.scan(/..?/)
(puts [x.zip(y).map{|c|(("%2s"*2%c).bytes.reduce(:+)/4.0).round.chr*2}*""]*2
y,x=x,[])if$.%2<1||$<.eof?

See it on ideone: http://ideone.com/brmP3L
Ungolfed & explanation
Per man ruby, the -n flag "[c]auses Ruby to assume the following loop around your script ... while gets ... end". The special variable $_ contains the last line read by gets. The -l flag removes the \n from each line, equivalent to $_.chop!.
y, x = x, $_.scan(/..?/)

( puts [
    x.zip(y).map {|c|
      (("%2s" * 2 % c).bytes.reduce(:+) / 4.0).round.chr * 2
    } * ""
  ] * 2
  y, x = x, []
) if $. % 2 < 1 || $<.eof?

The special variable $. is the number of lines that have been read so far, and $< is STDIN. The pairs of characters from every second line gets zipped with the previous line's. The format string %2s%2s combines the characters and pads it with spaces, then the characters are averaged.

w=s=~/$/ is shorter for calculating initial width. Also just return the calculated string instead of printing because that counts as output

R, 433 399 bytes
y=scan(,'',sep="\n")
h=nchar(y[1])
v=length(y)
p=function(x)paste(x,collapse="")
if(h%%2){y=sapply(y,function(x)paste0(x," "));h=h+1}
if(v%%2){y=c(y,p(rep(" ",h)));v=v+1}
z=matrix(unlist(lapply(y,function(x)strtoi(charToRaw(x),16))),ncol=h,byrow=T)
a=array(,c(v,h))
for(i in 1:(v/2)){for(j in 1:(h/2)){r=2*i-1:0;s=2*j-1:0;a[r,s]=rawToChar(as.raw(floor(mean(z[r,s])+.5)))}}
cat(apply(a,1,p),sep="\n")

I am getting desperate because this thing seems to be non-competing as heck. It prints
$$>>II99######
$$>>II99######
$$##88KKGG####
$$##88KKGG####

for the test case.
If you feed in the 7×3
%%%%%%%
Example
%%%%%%%

the output will be
BBFFJJ33
BBFFJJ33
######!!
######!!

because of the divisibility by 2 etc. etc.
Ungolfed:
y <- scan(, '', sep="\n") # Read STDIN and make it a character vector
h <- nchar(y[1]) # Get line width: how many chars per line
v <- length(y)   # Get array height: how many lines
p <- function(x) paste(x, collapse="") # A function that merges a vector of strings
if (h%%2) {y <- sapply(y, function(x) paste0(x, " ")); h=h+1} # If height is odd, add an empty line
if (v%%2) {y <- c(y, p(rep(" ", h))); v=v+1} # If width is odd, add an empty column
z <- matrix(unlist(lapply(y, function(x) strtoi(charToRaw(x), 16))), ncol=h, byrow=T)
# z now stores ASCII codes in a matrix; analogous to C strtol
a <- array(, dim=c(v,h)) # Reserve an array for the final result
for (i in 1:(v/2)) {
  for(j in 1:(h/2)) {
    r <- 2*i - 1:0 # Range of rows to average
    s <- 2*j - 1:0 # Range of columns to average
    a[r, s] <- rawToChar(as.raw(floor(mean(z[r, s]) + .5))) # Average, round, convert the ASCII codes
  } # and write them to the same place as in the original array
}
cat(apply(a, 1 , p), sep="\n") # Prints the array row-wise (index 1 for rows)

Just look how it handles this one gorgeous example (courtesy of chris.com):
                                                M$$$$$$$$$$$$$$$$RMMMMM8MMX
                                               <$$$$$$$$$$$$R????!!?MMMR$RMMh.
                                              :M$$$$$$$R?!!~~~~!!!!!!!MMM$$$$X
                                             :M$$$$$$$X!~~~   ~~~~~!!MM8$MM$$M!
                                           :!XM$$$$$$R!~~~~~  ~~~~~!!M$$$$$$$R!
                                          <!XM$$$$$$MR!~~~~ ~~ ~:!!<:!M$$$$$$$!
                                         '<!XMBQQRMMMMX:::~~~<!?!!~~!!!!$$$M!$X
                                         ~!!MM$$$$$M8R!!!?!:~!!M$f?!~~~!M$8HXX?
                                       <!!!XMM$$$$$MMRM$$!~!~~~~~~~~~~~!XM?!!M!
                                      <!!!!XMM$$M$$MM$M!!~~~ ~~~ ~  :~!!!X!~~R!
                                      !!!!XMMM$MMMMMMMM!!~~~ ~~~~  ~~~!!!X~~X!~
                                      '~~!!MMMM@MMMX!!MM!:~!!!~~  `~~~~!!XXXX~
                                        ~!!!XMMMMMMMM!MMM!~~~~:: <<~~~~!!$$R!
                                        '!!!!MM888M$MXMMM!!!!()!!~~~~~<!X$$$>
                                         ~!!!M???M$MRRMM$X<~!!!!~~~~~:!XN$$M
                                          ~!!!!!M$$$$@$@$$!!~~'  ~~:XH8$$$WR
                                          !!!!MM$RM$RRMMMM?t!:::XX8$$$$$$$$>
                                         ~~!!MMM$$$$$WX!!!!!!$$$$$$$RR$$$R"
                                       '  <!!MT!!!~~~!#BX!!!~~?T#?!!!M$$$X.
                                         <!!!!~~~~~~~~~?$!!!~~~~~~:!M$$$$MXH:
                                         ~~~~~~~~~~~ ~~!M&!!!~~~<!!X$$$$$$$R$W>
                                        <~~~~~~~~    '~~!$!!!!!!!!MMRM$R?#!!$N!
                                       x~~~~~~~~~    ~~~!MX!!!!!!?!M!M!~~:!!$B!
                                      M!~~~~~~~~~~  <~~:!$R!!!!!!!X!!!~~!!~!RR!
                                    :M!~~~~~~~~~~~ `~~~!X$R!!!!!!!!~~~:!!~~tMM!
                                   dR!!~~~~~~~~~~~~~~~~!M$R!!!!!!!~!!!!!!~~@$@~
                                  tR!!!~~~~~~~~~~~~~~~!!M$R!!!!!!!!!!!!!~~!$$E~
                                 d!~~~~~~~~~~~~~~~~~~~!!$$X!!!!!!!!!!!!~~~X$$!~
                                8R~~~~~~~~~~~~~~~~~~~<!X$$!!!!!!!!!!!<~~~!MR$~~
                               8$~~~~~~~!~~~~~~~~~~~<!!$$R!!!MX!!!!~~~~~<XR$!~<
                             :$$!~~~~~~!!~~~~~~~~~~~!!M$$!!!!MM!!!~~~~~<!8$F~<!
                          .x8$$$!~~~~::!~~~~~~~~~~~!!X$$$!!!!MM!!~~~~~!!M$R~~~!
               .::xxxnHW8$$$$$$$$$$$$$$!!~~~~~~~~~~<!@$$X!!!!MM~~~~~<!!X$E~~~~!
          :t$$$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~~!X$$$X~!!!MX~~~~~!!X$$~~~~!!
       ~~~~#R$$$$$RR8$$$$$$$$$$$$$$$$$$!!~~~~~~~~~<!M$$$B~!!!M!~~~~~!X$$!~~~~!!
     ~~~~~~~~?$$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~~!!$$$$$X!!X$!~~~~!X$$R~~~~<!f
  :~~~~~~~~~`~?$$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!X$$$$$$X!M$~~~<!W$$R~~~~~!!
 ~~~~~~~~~~  ~~M$$$$$$$$$$$$$$$$$$$$$$$!!~~~~~~~~!!M$$$$$$$$$Bid$$$$$$!~~~~~!!
!~~~~~~~~~~~~~~~$$$$$$$$$$$$$$$$$$$$$$$!~~~~~~~~~!!$$$$$$$$$$$$$$$$$$!~~~~~~!~
!~~~~~~~~~~~~~~~M$$$$$$$$$$$$$$$$$$$$$$!:~~~~~~~<!X$$$$$$$$$$$$$$$$$!~~~~~~!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!!:~~~~~~!!M$$$$$$$$$$$$$$"XR~~~~~~~!!
~~~~~~~~~~~~~!!!!$$$$$$$$$$$$$$$$$$$$$R!<!~~~~~!!!X$$$$$$$$$$$P~  !~~~~~~~!!
~~~~~~~~~~~<!!!!!$$$$$$$$$$$$$$$$$$$$$X!!~~~~~<!!!@#""`           ~~~~~~~~!!
~~~~~~~~~~~!!!!!X$$$$$$$$$$$$$$$$$$$$$X!~~~~~~!!!                '~~~~~~~!!
~~~~~~~~~~~<!!!!M$$$$$$$$$$$$$$$$$$$$$X!~~~~~!!!f                '~~~~~~<!!
~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$$$$$R!~~~~~~!!!                 '~~~~~<!!>
~~~~~~~~~~~~~~!!M$$$$$$$$$$$$$$$$$$$" !~~~~~!!!!                 ~~~~~~!!!
~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$$$$$R~ .!~~~~~!!!                  ~~~~~!!!!
~~~~~~~~~~~~~~~!!!$$$$$$$$$$$$$*?!!!~!!~~~~<!!~                  ~~~~!!!!!
~~~~~~~~~~~~~~~~!!!$$$$$$$$*"~!!!!!!!!!~~~~!!!                  <~~~:!!!!!
!~~~~~~~~~~~~~~~~!!M$$$$#~~~~~~~~~~~!!~~~~~!!                   ~~~~~~~!!!
!<~~~~~~~~~~~~~~~!!!R"~~~~~~~~~~~~~!!!~~~~<!!                  '~~~~~~<!!
!<~~~~~~~~~~~~~~~~!!!~~~~~~~~~~~~~~!!~~~~~!!!X:                ~~~~~~~!!~
!!~~~~~~~~~~~~~~~~!!!!~~~~~~~~~~~~<!!~~~~!!!9$MX:              ~~~~~~<!!
!!!!!~~~~~~~~~~~~~!!!!:~~~~~~~~~~~!!~~~~~!!X$$$X!~            '~~~~~~!!~
!!!!!!~~~~~~~~~~~<!!!!!!~~~~~~~~~~!!~~~~!!!M$$R!~~~~          ~~~~~~!!!
!!!!!!!<~~~~~~~~~~~!!!!!!!:<:~~~~~!!~~~~!!X$$R!~~~~~~         ~~~~~~!!
!!!!!!!!~~~~~~~~~~<!!!!!!!!!!!!!<!!!~~~~!!@$$!~~~~~~~~        ~~~~~!!~
!!!!!!!!!~~~~~~~~:<!!!!X!!!!!!!!!!!!~~~!!X$$!~~~~~~~~~~~~:   '~~~~~!!
'!!!!!!!!!!~~~~~~~!!!!!!?!!!!!!!!!!!~~<!!M$M!~~~~~~~~~~~~~~~ '~~~~~!~
 !!!!!!!!!!\~~~~~~~>!!!!  `"MMMHX!!~~~<!!$R!~~~~~~~~~~~~~~~~~<~~~~!!
  !!!!!!!!!!<~~~~~<!!!!!   .::<!!!!<~~!!X8X!~~~~~~~~~~~~~~~~~~~~~~!!
  `X!!!!!!!!~~~~~!<!!!!!!!!!!!!~~!!\~~!!M$MX!:~~~~~~~~~~~~~~~~<!~~!>
  !X!!!!!!!!~!!:!!!!!!!!!!~!!!:~~!!~~~!!$M!~~!!<~~~~~~~~~~~~~~~!!!!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:!!~~:!9R!~~~~~~!~~~~~~~~~~~~~~<!!f
 'CHAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!~~~!!MX~~~~~~~~~~~~~~~~~~~~~~!!X

After:
                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                              ''..$$$$$$$$$$662266??MMIIDDEE66
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                            ''>>$$$$$$<<WWOOOOggPP88,,HH99..;;
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                          ..HH..$$$$EEPP~~ggOOggVV??22..$$$$00!!
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                        99((PP77;;CCII5555VVVV4433WWPP88..<<==66
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ..!!==MM$$..99DD8899gggg~~ggOOmm88HH@@PP!!
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                      ::88EEMM@@MMPP77BB??gg88~~88__~~88==kkTT88
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        ::!!EEHHCCCCEEMM77PPQQ00??nn~~??0000((
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,00??..BB@@11??PP""ggmmVV55//GG
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                        8888,,MM00..HHEE77==((//>>));;$$00))
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                      ""''((,,\\PP~~ggII00!!~~ddXX''88$$;;<<''
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                        VV~~~~~~ggOO99gg..!!88PP((EE::00++..;;((
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                      BB~~~~~~~~gg  VVmm--;;!!!!))::,,gg??88CC!!
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                  11??PP~~~~~~~~~~__~~PP;;::!!!!!!PPPP''PPll@@88
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                                11YYPPgg~~~~~~~~~~~~~~!!..;;!!!!!!!!!!88~~00,,OO
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                              &&KK~~~~~~gg~~~~~~~~~~FF0000!!,,//!!88VV~~MMEEPP??
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
                          ::..$$PP~~mm??gg~~~~~~~~gg//..##!!777788~~~~??33OOnn!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
          <<""&&//NNLL::))$$$$$$$$$$$$##PP~~~~~~~~VV77$$TT!!77hh~~~~((==CC~~gg!!
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
    88gg~~ggMM$$$$;;))$$$$$$$$$$$$$$$$##PP~~~~~~~~((..$$OO!!;;PP~~gg==00gg~~??22
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
88mm~~~~~~gg__LL$$$$$$$$$$$$$$$$$$$$$$##PP~~~~~~PP::$$$$$$0066rrAA00$$\\~~~~!!
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
PP~~~~~~~~~~~~~~..$$$$$$$$$$$$$$$$$$$$##mm~~~~~~??00$$$$$$$$$$$$$$$$99~~~~gg88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~~~gg!!##$$$$$$$$$$$$$$$$$$$$::..~~~~gg!!;;$$$$$$$$$$FF""RR~~~~~~88
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~VV!!!!00$$$$$$$$$$$$$$$$$$$$==gg~~~~((!!))!!00        ""~~~~~~gg!!
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~nn88!!..$$$$$$$$$$$$$$$$$$00FF~~~~PP!!22              $$~~~~nn((((
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~!!..$$$$$$$$$$$$$$$$FF$$PP~~~~!!!!                OO~~~~88!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
~~~~~~~~~~~~~~gg!!##$$$$$$&&::$$))!!88PP~~VV!!88                VV~~??!!!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
??~~~~~~~~~~~~~~PP,,//QQgg~~~~~~~~gg!!~~~~??!!                ""~~~~~~??!!
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
((~~~~~~~~~~~~~~~~!!88~~~~~~~~~~~~??PP~~gg!!66@@''            OO~~~~nn!!88
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!88~~~~~~~~~~nn!!!!??~~~~~~~~~~!!~~~~88::$$<<ggOO          hh~~~~8888
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
!!!!!!((~~~~~~~~~~??!!!!!!..??PPVV!!~~~~!!88//gg~~~~gg        ~~~~gg88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
##!!!!!!88gg~~~~mm((!!//))!!!!!!!!!!~~??::..PP~~~~~~~~~~mmOO$$~~~~PP88
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  !!!!!!!!00nn~~~~FF!!!!  44DD==//??~~((55;;~~~~~~~~~~~~~~~~nn~~~~!!
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
  LL!!!!!!!!ggVV88((!!!!!!88!!VVPPGG~~!!99QQ??VV~~~~~~~~~~~~~~??PP((
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22
""3366!!!!!!!!!!!!!!!!!!!!!!!!!!''ggVV22RR~~~~~~gg~~~~~~~~~~~~VV//22