text:
Analyze overhanded shuffles
Rod is moderating a card game between two players: George and Tim. Currently, Tim is shuffling the cards. Rod suspects that Tim is trying to cheat, so he needs your help to check that the shuffle is fair.
Tim is doing the overhanded shuffle: he cuts a pile of cards from the bottom of the deck, then cuts various parts from the top of the pile onto the top of the deck, and repeats the process a few times.
Rod is eagle-eyed and can see exactly how many cards Tim is cutting each time, however he can't calculate and keep track of the cards as fast as Tim is shuffling. This is where you come in: Rod would like you to write a program or function that gets the detailed shuffling information and determines whether the shuffle is fair, weak or a trick.

If after shuffling, less than 25 pairs of adjacent cards remain adjacent (in the same order), then the shuffle is fair and the game can go on.
If at least 25 (but not all) pairs of adjacent cards remain adjacent, then the shuffle is weak and Rod will bonk Tim over the head and ask him to shuffle some more.
If all the cards remain in the same position at the end, then Tim is obviously cheating and Rod will whack him with a large trout.

This is code golf, so the shortest code wins.
Input:
You will get a series of numbers between 0 and 52 (both exclusive) separated by space, on several lines, where each line represents a round of shuffling that begins and ends with all the cards piled together.
On each line, the first number is the number of cards Tim cuts from the bottom of the deck, and each subsequent number is a number of cards he drops from his hand onto the top of the deck. If any cards remain after the last number on a line, you should assume that Tim puts them on top of the deck.
The input is guaranteed to be valid. There is at least one line of numbers, and each line contains at least 2 numbers. The first number on each line is not smaller than the sum of all the other numbers on the same line. A trailing newline is optional, you may assume that the input has one or that it doesn't have one.
Output:
Your program should print/return "fair" if the shuffle is fair, "weak" if the shuffle is weak and "trick" if Tim is keeping all the cards in the same order. A trailing newline is optional.
Example:
The deck is assumed to have 52 cards, but for demonstration purposes, I'll use a smaller deck of 10 cards.
Input:
5 3 1
4 2 2

Initial deck, viewed from the top: 0 1 2 3 4 5 6 7 8 9
5 ➜ 0 1 2 3 4 (5 6 7 8 9 in hand)
3 ➜ 5 6 7 0 1 2 3 4 (8 9 in hand)
1 ➜ 8 5 6 7 0 1 2 3 4 (9 in hand)
end of line ➜ 9 8 5 6 7 0 1 2 3 4
4 ➜ 9 8 5 6 7 0 (1 2 3 4 in hand)
2 ➜ 1 2 9 8 5 6 7 0 (3 4 in hand)
2 ➜ 3 4 1 2 9 8 5 6 7 0
4 pairs remain adjacent: (3 4) (1 2) (5 6) (6 7)
Test cases:
43 5 5 5 5 5 5 5 5
43 5 5 5 5 5 5 5 5
43 5 5 5 5 5 5 5 5

Output: fair

43 5 5 5 5 5 5 5 5
43 5 5 5 5 5 5 5 5
43 5 5 5 5 5 5 5

Output: weak

29 24
19 18
38 2 1 8 13 6 4
47 15 16 5 2 1 7
34 22 9 3
44 9 10 11 3 1 7
33 18 4 2 3 3

Output: fair

24 6 12 4
25 3 19
36 4 25 2
19 11 1 3
15 9 3
37 5 27

Output: weak

26 13
26 13
26 13
26 13

Output: trick

50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Output: weak

50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Output: trick

50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
49 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Output: fair
Requirements:

If you write a function, it can either read from the standard input or receive the input as a single string parameter. Also, the function can either print out the output or return it.
The program must be runnable in Linux using freely available software.
The source code must use only ASCII characters.
No standard loopholes.

Why the restriction to ASCII? Many languages (APL, machine code, TI-BASIC) don't use ASCII at all, so you're implicitly disallowing those.

@ThomasKwa Because I don't like the issues associated with displaying and counting non-ASCII characters. Some of those languages have ASCII representations or alternatives. I think it's not a very harsh restriction, and it slightly levels the playing field.

I think a scoring system like "Entries that use only printable ASCII characters will have their byte count multiplied by log(95)/log(256)" would be a better option if you want to fairly incentivize printable ASCII submissions. The reasoning is that the information content of entries with the same score would be equal. Personally, I would still prefer a plain scoring by bytes though.

@ThomasKwa Ok, how about this? Only printable unicode characters, counting bytes in UTF-8 encoding

Pyth, 62 bytes
@c"weak trick fair"d-!JlfhT-M.:us_cG.u+NYtKrH7-52hK.zU52 2>J26

Demonstration.

CJam, 76 75 bytes
52,qN/{[~](52\-@/(\e_@{/(@+\e_}/\+}/2ew::m2f/0-,_!\26>-"weak trick fair"S/=

Try it online in the CJam interpreter.

LOL, "trout" :)

JavaScript, 292 289 bytes
This could probably get some more bytes squeezed out of it, but it's a quick first pass for now:
d=[];for(i=0;i<52;i+=1)d[i]=i
s=prompt().split('\n')
s.forEach(function(e,i){s[i]=e.split(' ')
h=d.splice(-s[i][0],99)
for(j=1;j<s[i].length;j+=1)d.unshift.apply(d,h.splice(0,s[i][j]))
d.unshift.apply(d,h)})
for(c=0;i>1;i-=1)if(d[i-2]==d[i-1]-1)c+=1
alert(c<25?"fair":c<51?"weak":"trick")

EDIT: Saved 3 bytes by reusing the value of i from the deck-building loop when counting the number of adjacent cards.


text:
Chunky vs. Smooth Strings
Consider a string of length N, such as Peanut Butter with N = 13. Notice that there are N-1 pairs of neighboring characters in the string. For Peanut Butter, the first of the 12 pairs is Pe, the second is ea, the last is er.
When the pairs are mostly different characters, the string has a chunky quality, e.g. chUnky.
When these pairs are mostly the same character, the string has a smooth quality, e.g. sssmmsss.
Define the chunkiness of a string to be the ratio of the number of pairs with two different characters to the total number of pairs (N-1).
Define the smoothness of a string to be the ratio of the number of pairs with two identical characters to the total number of pairs (N-1).
For example, Peanut Butter only has one pair with identical characters (tt), so its smoothness is 1/12 or 0.0833 and its chunkiness is 11/12 or 0.9167.
Empty strings and strings with only one character are defined to be 100% smooth and 0% chunky.
Challenge
Write a program that takes in a string of arbitrary length and outputs either its chunkiness or smoothness ratio as a floating point value.

Take input via stdin or the command line, or you may write a function that takes a string.
You can assume the input string only contains printable ASCII characters (and hence is single-line).
Print the float to stdout to 4 or more decimal places, or you can choose to return it if you wrote a function. Decimal places that convey no information are not required, e.g. 0 is fine instead of 0.0000.
Choose chunkiness or smoothness as you prefer. Just be sure to say  which one your program outputs.

The shortest code in bytes wins.
Examples
Peanut Butter → Chunkiness: 0.91666666666, Smoothness: 0.08333333333
chUnky → Chunkiness: 1.0, Smoothness: 0.0
sssmmsss → Chunkiness: 0.28571428571, Smoothness: 0.71428571428
999 → Chunkiness: 0.0, Smoothness: 1.0
AA → Chunkiness: 0.0, Smoothness: 1.0
Aa → Chunkiness: 1.0, Smoothness: 0.0
! → Chunkiness: 0.0, Smoothness: 1.0
[empty string] → Chunkiness: 0.0, Smoothness: 1.0
Bonus question: Which do you prefer, chunky or smooth strings?

-1 No overhanded tag.

+1 Conclusive proof that chunky peanut butter should be the default.

Some languages have a hard time reading no input at all. Would it be admissible to assume that the input is newline-terminated?

@Dennis Yes, that's fine.

@BrainSteel Chunky should only be the default if you're a computer; they like having chunks available. Peanut butter made for people should hide those implementation details, and be smooth as silk for the user.

Hm.. with all the fully chunky chunkiness solutions, I wonder whether there are fully smooth smoothness solutions?

Will the input contain tabs?

@kirbyfan64sos Tabs aren't printable ASCII. So no.

APL, 10 bytes
This reads input from stdin and prints the chunkiness to stdout. The algorithm is the same one used for the J solution.
(+/÷⍴)2≠/⍞

CJam, 19 bytes
q_1>_@.=:!1b\,d/4mO

100% chunky source code that calculates chunkiness.
Try this chunky goodness online.
How it works
q_                  e# Read from STDIN and push a copy.
  1>_               e# Discard the first character and push a copy.
     @              e# Rotate the original on top.
      .=            e# Vectorized comparison (1 if equal, 0 if not).
        :!          e# Mapped logical NOT (0 if equal, 1 if not).
          1b        e# Base 1 conversion (sum).
            \,      e# Swap with the shortened string and push its length.
              d/    e# Cast to double and divide.
                4mO e# Round to four decimal places.

Obviously, NaN rounded to 4 decimal places is 0.

I don't think you need to round it to 4 digits. It says "4 or more", and trailing zeros are not needed. This is much more elegant than the 2ew approach I tried. The 0/1 letter special cases were killing me.

@RetoKoradi Rounding maps NaN to 0. I don't know a shorter way.

Yes, while playing with it some more, I just noticed that you get a NaN for 1-character inputs. The short inputs are by far the most painful part with this one. BTW, the online link has slightly different code than the version you posted. One _ moved. Not sure if it matters.

@RetoKoradi Sure does. The linked code wan't 100% chunky. :P

Curious that CJam doesn't have an equivalent of GS's or.

@PeterTaylor: It does, but 1e| is just as long as 4mO and I thought rounding NaN to 4 decimal places was more interesting.

Oh, is that what "logical or" means? I thought about it a bit more, and concluded that _1? was probably the intended idiom.

-1, jam is never chunky.

@AlexA. Jam with fruit chunks is at least 10% chunky.

@Dennis Fair point. +1.

Pyth, 13 12 bytes
csJnVztz|lJ1

Fully chunky code calculating chunkiness.
Demonstration. Test harness.
csJnVztz|lJ1
                 Implicit: z = input()
   nV            n, !=, vectorized over
     z           z
      tz         z[:-1]
                 V implitly truncates.
  J              Store it in J.
 s               sum J
c                floating point divided by
         |       logical or
          lJ     len(J)
            1    1

In the online version, I get an error when I leave the input empty. So as far as I can tell, it fails the last test case.

@RetoKoradi That's weird - it works fine in the offline version. It's probably a bug with the online website.

@RetoKoradi Confirmed  - the very use of z cause an error on the empty input online. I'll go and fix that bug. This code is fine, however.

It works if I hit return once in the input box. But other strings do not need a return at the end. With nothing typed in the input box, it seems to get no input at all, and your code blows up when it tries to use the input.

@RetoKoradi Thanks. I think I know the problem, shouldn't be hard to fix.

Just out of curiosity: What does the "2 character substrings" operator in Pyth do if the string is less than 2 characters? Produce an empty list? That would make sense to me. In CJam it fires an exception, which is very inconvenient when trying to use it for this problem.

Let us continue this discussion in chat.

TI-BASIC, 46 bytes
Input Str1
If 2≤length(Str1
mean(seq(sub(Str1,X,1)=sub(Str1,X-1,1),X,2,length(Str1
Ans

sub(x1,x2,x3 gives the substring of string x1 starting (one-based) at number x2 and ending at number x3, then seq( builds a sequence.
Gives the smoothness value. The Ans variable is 0 by default, so we don't need an Else to the If statement, or to store anything to Ans beforehand.

Matlab (37 36 bytes)
This can be done with the following anonymous function, which returns chunkiness:
f=@(x)nnz(diff(x))/max(numel(x)-1,1)

Comments:

In old Matlab versions (such as R2010b) you need + to cast the char array x to a double array:
f=@(x)nnz(diff(+x))/max(numel(x)-1,1)`

But that's not the case in recent versions (tested in R2014b), which saves one byte. Thanks to Jonas for his comment.
The expression with max handles the one-character and zero-character cases (for chunkiness)

Example:
>> f=@(x)nnz(diff(x))/max(numel(x)-1,1)
f =
    @(x)nnz(diff(x))/max(numel(x)-1,1)

>> f('Peanut Butter')
ans =
   0.9167

On R2014b, diff('abc') will not produce a warning.

><>, 40 36 bytes
00ii:0(?v:@=1$-{+{1+}}20.
~:0=+,n;>~

This program returns the chunkiness of a string.
Explanation
00i         Push 0 (# unequal pairs), 0 (length of string - 1) and read first char

[main loop]

i           Read a char
:0(?v       If we've hit EOF, go down a row
:@=1$-      Check (new char != previous char)
{+          Add to unequal pairs count
{1+         Increment length by 1
}}20.       Continue loop

[output]

~~          Pop last two chars (top one will be -1 for EOF)
:0=+        Add 1 to length if zero (to prevent division by zero errors)
,           Divide, giving chunkiness
n;          Output and halt

Previous submission (37 + 3 = 40 bytes)
l1)?v1n;
n,$&\l1-}0& \;
l2(?^$:@=&+&>

This program returns the smoothness of a string. Input is via the -s flag, e.g.
py -3 fish.py chunkiness.fish -s "Peanut Butter"

C#, 94 89 bytes
Sub 100 bytes, so I guess that's some form of victory in itself?
This is a function definition (allowed as per the spec) which returns the smoothness of the input string:
Func<string,float>(s=>s.Length>1?s.Zip(s.Skip(1),(a,b)=>a==b?1f:0).Sum()/(s.Length-1):1);

Pretty straightforward, if the length is 0 or 1 it returns 1, otherwise it compares the string to itself less the first character, then returns the number of identical pairs divided by the number of pairs.
Edit - replaced Substring with Skip. Rookie mistake!

J, 14 13 bytes
Computes the chunkiness. Kudos to J for defining 0 % 0 to be equal to 0.
(]+/%#)2~:/\]

Try it online
Here is an explanation:
   NB. sample input
   in =. 'sssmmsss'

   NB. all infixes of length 2
   2 ]\ in
ss
ss
sm
mm
ms
ss
ss

    NB. are the parts of the infix different?
    2 ~:/\ in
0 0 1 0 1 0 0

    NB. sum and item count of the previous result
    (+/ , #) 2 ~:/\ in
2 7

    NB. arithmetic mean: chunkiness
    (+/ % #) 2 ~:/\ in
0.285714

    NB. as a tacit verb
    (] +/ % #) 2 ~:/\ ]

    NB. 0 divided by 0 is 0 in J
    0 % 0
0

(]+/%#)2~:/\] saves 1 byte.

@FrownyFrog Cool!  How could I miss this?

Could you add a TIO-link with test code?

CJam, 23 bytes
q_,Y<SS+@?2ew_::=:+\,d/

Explanation:
q                           e# read input
 _,                         e# its length
   Y<                       e# is less than 2?
     SS+                    e# then a smooth string
        @?                  e# otherwise the input
          2ew               e# pairs of consecutive characters
             _::=           e# map to 1 if equal, 0 if not
                 :+         e# sum (number of equal pairs)
                   \,       e# total number of pairs
                     d/     e# divide

This outputs the smoothness ratio.

CJam, 16 bytes
1q2ew::=_:+\,d/*

Cheaty source code that calculates smoothness.
For inputs of length 0 or 1, this prints the correct result before exiting with an error. With the Java interpreter, error output goes to STDERR (as it should).
If you try the code online, just ignore everything but the last line of output.
How it works
1q               e# Push a 1 and read from STDIN.
  2ew            e# Push the overlapping slices of length 2.
                 e# This will throw an error for strings of length 0 or 1,
                 e# so the stack (1) is printed and the program finishes.
     ::=         e# Twofold vectorized comparision.
        _:+      e# Push a copy and add the Booleans.
           \,    e# Swap with the original and compute its length.
             d/  e# Cast to double and divide.
               * e# Multiply with the 1 on the bottom of the stack.

Nim, 105 96 91 bytes
proc f(s):any=
 var a=0;for i,c in s[.. ^2]:a+=int(s[i+1]!=c)
 a.float/max(s.len-1,1).float

Trying to learn Nim. This calculates the chunkiness of a string.
(If I try to read this as Python the indentation looks all messed up... Now it looks more like Ruby...)

Julia, 52 bytes
Smoothness!
s->(n=length(s))<2?1:mean([s[i]==s[i+1]for i=1:n-1])

This creates an unnamed function that accepts a string and returns a numeric value.
If the length of the input is less than 2, the smoothness is 1, otherwise we calculate the proportion of identical adjacent characters by taking the mean of an array of logicals.

Python 3, 63 Bytes
This is an anonymous lambda function which takes a string as the argument, and returns it's chunkiness.
lambda n:~-len(n)and sum(x!=y for x,y in zip(n,n[1:]))/~-len(n)

To use it, give it a name and call it.
f=lambda n:~-len(n)and sum(x!=y for x,y in zip(n,n[1:]))/~-len(n)
f("Peanut Butter") -> 0.08333333333333333
f("!")             -> 0
f("")              -> -0.0

Instead of the anonymous function, you can use: def f(n):, which has exactly the same number of characters as lambda n:.  This removes the need to name your function.

@TristanReid def f(n): also needs a return

Oops!  Good catch - I'm new to codegolf, I should assume more thought has gone into this and test locally.  Apologies!

Python 3, 52 bytes
lambda s:sum(map(str.__ne__,s,s[1:]))/(len(s)-1or 1)

This calculates chunkiness, and outputs -0.0 for the empty string. If don't like negative zeroes you can always fix that with an extra byte:
lambda s:sum(map(str.__ne__,s,s[1:]))/max(len(s)-1,1)

Haskell, 64 bytes
f[]=1
f[_]=1
f x=sum[1|(a,b)<-zip=<<tail$x,a==b]/(sum(x>>[1])-1)

Outputs smoothness. e.g. f "Peanut Butter" -> 8.333333333333333e-2.
How it works:
f[]=1                               -- special case: empty list
f[_]=1                              -- special case: one element list

f x=                                -- x has at least two elements
         (a,b)<-zip=<<tail$x        -- for every pair (a,b), drawn from zipping x with the tail of itself
                            ,a==b   -- where a equals b
      [1|                        ]  -- take a 1
   sum                              -- and sum it
              /                     -- divide  by
                   (x>>[1])         -- map each element of x to 1
               sum                  -- sum it
                           -1       -- and subtract 1

sum(x>>[1]) is the length of x, but because Haskell's strong type system requires to feed fractionals to /, I can't use length which returns integers. Converting integers to fractionals via fromInteger$length x is far too long.

Did you try working with Rationals?

@recursion.ninja: no, I didn't because I think a 18 byte import Data.Ratio is too expensive.

JavaScript (ES6), 55 bytes
Smoothness, 56 bytes
f=x=>(z=x.match(/(.)(?=\1)/g))?z.length/--x.length:+!x[1]

Chunkiness, 55 bytes
f=x=>(z=x.match(/(.)(?!\1)/g))&&--z.length/--x.length||0

Demo
Calculates smoothness, as that is what I prefer. Only works in Firefox for now, as it is ES6.

f=x=>(z=x.match(/(.)(?=\1)/g))?z.length/--x.length:+!x[1]

O.innerHTML += f('Peanut Butter') + '\n';
O.innerHTML += f('chUnky') + '\n';
O.innerHTML += f('sssmmsss') + '\n';
O.innerHTML += f('999') + '\n';
O.innerHTML += f('AA') + '\n';
O.innerHTML += f('Aa') + '\n';
O.innerHTML += f('!') + '\n';
O.innerHTML += f('') + '\n';

Ruby, 69 66 bytes
->s{(c=s.chars.each_cons(2).count{|x,y|x!=y}.to_f/~-s.size)>0?c:0}

Try it online!
Shaved of a few bytes with comments from IMP. Also, with the upcoming version 2.7.0 of Ruby it's possible to save some bytes by replacing |x,y|x!=y with @1!=@2

if you move the .to_f/~-s.size into the assignment of c, then you can shave a byte off with the ternary operation:
f=->s{(c=s.chars.each_cons(2).count{|x,y|x!=y}.to_f/~-s.size)>0?c:0}

Also, do you need the f=? I'm not 100% on the rules about that. The challenge says you can return a function that takes a string, which a stabby lambda is.

also, while the Perl answer might be the same length, it's not got that 100% chunkiness that this answer does.

KDB(Q), 30
Returns smoothness.
{1^sum[x]%count x:1_(=':)(),x}

Explanation
                         (),x    / ensure input is always list
                x:1_(=':)        / check equalness to prev char and reassign to x
   sum[x]%count                  / sum equalness divide by count N-1
 1^                              / fill null with 1 since empty/single char will result in null
{                             }  / lamdba

Test
q){1^sum[x]%count x}1_(=':)(),x}"Peanut Butter"
0.08333333
q){1^sum[x]%count x:1_(=':)(),x}"sssmmsss"
0.7142857
q){1^sum[x]%count x:1_(=':)(),x}"Aa"
0f
q){1^sum[x]%count x:1_(=':)(),x}"aa"
1f
q){1^sum[x]%count x:1_(=':)(),x}"chUnky"
0f
q){1^sum[x]%count x:1_(=':)(),x}"!"
1f
q){1^sum[x]%count x:1_(=':)(),x}""
1f

Python 3, 69 bytes
No one has posted a Python solution yet, so here's a fairly straightforward implementation of a "chunkiness" function. It short-circuits on a string of length 1, and prints 0 (which is an integer rather than a float but seems to be allowed according to the rules).
On an empty string, it outputs -0.0 rather than 0.0.  Arguably this is could be considered acceptable, as -0.0 == 0 == 0.0 returns True.
def c(s):l=len(s)-1;return l and sum(s[i]!=s[i+1]for i in range(l))/l

Examples:
>>> c(''); c('a'); c('aaa'); c("Peanut Butter")
-0.0
0
0.0
0.916666666667
>>> -0.0 == 0 == 0.0
True

(Python 3 is used for its default float division.)

C, 83 bytes
float f(char*s){int a=0,b=0;if(*s)while(s[++a])b+=s[a]!=s[a-1];return--a?1.*b/a:b;}

A function returning chunkiness.
Explanation
float f(char *s) {

Accept a C string, and return a float (double would work but is more chars).
int a=0, b=0;

Counters - a for total pairs, b for non-matching pairs.  Using int limits the "arbitrary length" of the string, but that's only a minor violation of the requirements and I'm not going to fix it.
if (*s)

Special case the empty string - leave both counters zero.
    while (s[++a])

Non-empty string - iterate through it with pre-increment (so first time through the loop, s[a] will be the second character.  If the string has only one character, the loop body will not be entered, and a will be 1.
        b += s[a]!=s[a-1];

If the current character differs from the previous, increment b.
return --a ? 1.*b/a : b;
}

After the loop, there are three possibilities: 'a==0,b==0' for an empty input, 'a==1,b==0' for a single-character input or 'a>1,b>=0' for multi-character input.  We subtract 1 from a (the ? operator is a sequence point, so we're safe), and if it's zero, we have the second case, so should return zero.  Otherwise, b/a is what we want, but we must promote b to a floating-point type first or we'll get integer division.  For an empty string, we'll end up with a negative zero, but the rules don't disallow that.
Tests:
#include <stdio.h>
int main(int argc, char **argv)
{
    while (*++argv)
        printf("%.6f %s\n", f(*argv), *argv);
}

Which gives:
./chunky 'Peanut Butter' chUnky sssmmsss 999 AA Aa '!' ''
0.916667 Peanut Butter
1.000000 chUnky
0.285714 sssmmsss
0.000000 999
0.000000 AA
1.000000 Aa
0.000000 !
-0.000000

as required.

Ignore my previous deleted comment.. 80 bytes: a,b;float f(char*s){if(*s)for(a=b=0;s[++a];)b+=s[a]!=s[a-1];return--a?1.*b/a:b;}

66 bytes using compiler flag (if you're into that sort of thing). edit: and I switched it to gcc

Perl, 69
Function returning smoothness:

sub f{($_)=@_;$s=s/(.)(?!\1)//sgr;chop;!$_||length($s)/length;}

Explanation
sub f {
    # read argument into $_
    ($_) = @_;

    # copy $_ to $s, removing any char not followed by itself
    # /s to handle newlines as all other characters
    $s = s/(.)(?!\1)//sgr;

     # reduce length by one (unless empty)
    chop;

    # $_ is empty (false) if length was 0 or 1
    # return 1 in that case, else number of pairs / new length
    !$_ || length($s)/length;
}

Tests
printf "%.6f %s\n", f($a=$_), $a foreach (@ARGV);

0.083333 Peanut Butter
0.000000 chUnky
0.714286 sssmmsss
1.000000 999
1.000000 AA
0.000000 Aa
1.000000 !
1.000000

Mathematica, 73 72 bytes
This doesn't win anything for size, but it's straightforward:
Smoothness
N@Count[Differences@#,_Plus]/(Length@#-1)&@StringSplit[#,""]&

In[177]:= N@Count[Differences@#,_Plus]/(Length@#-1)&@StringSplit[#,""] &@"sssmmsss"

Out[177]= 0.285714

Length[#] -> Length@# saves a stroke. So does eliminating N@ and changing 1 to 1.

@hYPotenuser yep. missed it.

Ruby, 63 Bytes
Outputs chunkiness.
f=->s{s.chars.each_cons(2).count{|x,y|x!=y}/[s.size-1.0,1].max}
Similar to @daniero's solution, but slightly shortened by directly dividing by the string length - 1 and then relying on .count to be zero with length 0 & 1 strings (the .max ensures I won't divide by 0 or -1).

GeL: 76 73 characters
Smoothness.
@set{d;0}
?\P$1=@incr{d}
?=
\Z=@lua{c=@column -1\;return c<1and 1or $d/c}

Sample run:
bash-4.3$ for i in 'Peanut Butter' 'chUnky' 'sssmmsss' '999' 'AA' 'Aa' '!' ''; do
>     echo -n "$i -> "
>     echo -n "$i" | gel -f smooth.gel
>     echo
> done
Peanut Butter -> 0.083333333333333
chUnky -> 0
sssmmsss -> 0.71428571428571
999 -> 1
AA -> 1
Aa -> 0
! -> 1
 -> 1

(GeL = Gema + Lua bindings. Much better, but still far from winning.)
Gema: 123 120 characters
Smoothness.
@set{d;0}
?\P$1=@incr{d}
?=
\Z=@subst{\?\*=\?.\*;@cmpn{@column;1;10;10;@fill-right{00000;@div{$d0000;@sub{@column;1}}}}}

Sample run:
bash-4.3$ for i in 'Peanut Butter' 'chUnky' 'sssmmsss' '999' 'AA' 'Aa' '!' ''; do
>     echo -n "$i -> "
>     echo -n "$i" | gema -f smooth.gema
>     echo
> done
Peanut Butter -> 0.0833
chUnky -> 0.0000
sssmmsss -> 0.7142
999 -> 1.0000
AA -> 1.0000
Aa -> 0.0000
! -> 1.0
 -> 1.0

(Was more an exercise for myself to see what are the chances to solve it in a language without floating point number support and generally painful arithmetic support. The 2nd line, especially the \P sequence, is pure magic, the last line is real torture.)

Java 8, 84 82 bytes
s->{float l=s.length()-1,S=s.split("(.)(?=\\1)").length-1;return l<1?1:S<1?0:S/l;}

Outputs Smoothness.
Try it online.
Explanation:
s->{                     // Method with String parameter and float return-type
  float l=s.length()-1,  //  Length of the input-String minus 1 (amount of pairs in total)
        S=s.split("(.)(?=\\1)").length-1;
                         //  Length of the input split by duplicated pairs (with lookahead)
  return l<1?            //  If the length of the input is either 0 or 1:
          1              //   Return 1
         :S<1?           //  Else-if `S` is -1 or 0:
          0              //   Return 0
         :               //  Else:
          S/l;}          //   Return duplicated pairs divided by the length-1

Coconut, 38 bytes
s->sum(map((!=),s,s[1:]))/-~len(s[2:])

Try it online!
A Python 3 port would be 50 bytes.

PowerShell, 55 bytes
Smoothness
%{$s=$_;@([char[]]$s|?{$_-eq$a;$a=$_;$i++}).count/--$i}

Seems a little bit silly to get a variable in stdin and then give it an identifier, but its quicker than having a function.

Python 3, 61 Bytes
calculate chunkiness:
f=lambda s: sum(a!=b for a,b in zip(s,s[1:]))/max(len(s)-1,1)

K (22)
tweaked WooiKent's Q solution:
{1^(+/x)%#x:1_=':(),x}

Mathematica, 107 bytes
Calculates chunkiness by taking half of the Levenshtein distance between each digraph and its reverse.
f[s_]:=.5EditDistance@@{#,StringReverse@#}&/@StringCases[s,_~Repeated~{2},Overlaps->All]//Total@#/Length[#]&

If you'd prefer an exact rational answer, delete .5 and place a /2 before the last & for no penalty. The program itself has chunkiness 103/106, or about .972.

K5, 24 bytes
{(r;1)@^r:(#&=':x)%#1_x}

Calculates smoothness. Seems to use a very different algorithm from K/Q/J/APL answers.

Jelly, 7 4 bytes
=ƝÆm
 Ɲ   // For all pairs of neighbouring elements,
=    // return 1 if they're equal, 0 otherwise.
  Æm // Take the arithmetic mean of the resulting list.

Computes smoothness.
Cut off three bytes thanks to Dennis.
Try it online!

Forth (gforth), 92 bytes
: f 1e dup 1 > if 1- dup s>f 0e 0 do dup i + dup 1+ c@ swap c@ = s>f f- loop fswap f/ then ;

Try it online!
Takes in a string (as the Forth standard combo of address and length) and returns the smoothness. Result is placed on the floating point stack
Explanation
1e                \ places 1 on the floating point stack, to use as a "default" value
dup 1 > if        \ duplicates the length of the string and checks if it's greater than 1
   1- dup s>f     \ subtract 1 from length and copy it to the floating point stack
   0e             \ places 0 on the floating point stack
   0 do           \ sets up a loop from 0 to length - 1
      dup i +     \ get the current character's address by adding index to string start
      dup 1+      \ copy address and add 1 to get the next character's address
      c@ swap c@  \ get the character at each of the addresses
      = s>f       \ compare the two characters and move to the floating point stack
      f-          \ subtract result from counter (true in Forth defaults to -1)
   loop           \ end the loop
   fswap f/       \ swap the counter and the total and divide to get result
then              \ end the loop

JavaScript, 46/47 bytes
f=x=>[...x].map(c=>n+=c!=x[L++],n=L=-1)|L>0&&n/L

f=x=>[...x].map(c=>n+=c==x[++L],n=L=0)|L<2||n/--L

F# (.NET Core), 100 bytes
Whew, exactly 100 bytes. Too bad it's a bit verbose, I want to get it below 100. Determines chunkiness.
fun s->Seq.pairwise s|>fun s->Seq.sumBy(fun(x,y)->if x=y then 0. else 1.)s/float(max(Seq.length s)1)

Try it online!

Kotlin, 52 bytes
Chunkiness:
{it.zipWithNext().count{(f,n)->f!=n}/(it.length-1f)}

Try it online!

Thunno 2, 7 bytes
ḣZ€Uḷḅm

Try it online!
Outputs smoothness. Change ḅ to 1Q for chunkiness.
Explanation
ḣZ€Uḷḅm  # Implicit input
ḣZ       # Get the overlapping pairs
  €U     # Uniquify each pair of characters
    ḷḅ   # Does the length of each equal one?
      m  # Take the mean of the list
         # Implicit output

source: Stack Exchange

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

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

sort: votes


text:
Rebuilding an ASCII City

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

The people of ASCIIville are rebuilding their city and are sketching out new blueprints. Your job is to draw their new city based on how many buildings they want.
The input will be how many buildings there are. Each building is half the hight of the input (rounded up if odd), not including the top and bottom of the building.
Let's draw a basic example of 4

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

As you can see here, there are two |s in every building because the input was four. But there's a catch! (meaning the example above is incorrect, and the example at the top of this post is the real output for 4)
For each building that isn't a prime number, its height goes down by one. If the number is divisible by 3, 5, or 10, it goes down one more. If it's divisible by two or more of those numbers, the amount deducted adds up (10 is divisible by 10 and 5, and it's not a prime, so it gets deducted by 3).
Let's look at an example with an input of 5.

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

Here's an example of 7

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

And an example of 10

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

And back to 6

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

Rules:

If a number gets deducted so much that it's height is less than or equal to zero, it is not shown but a space is left for it (I don't believe this is possible, 6 is the closest I've found to reaching zero).
Trailing spaces are allowed.
The width of each building must be 2.
Your input can be from stdin or encoded into the program.
Your program must be a full program, no functions.
Your program must be able 4-15 builds. 0-3 and negative numbers aren't needed and are not specified to do anything, meaning they can throw an error, print garbage, or do nothing.

@isaacg Yup! Just fixed it

1 is not a prime number. From the examples, it looks like you deduct 1 from the height if the (1-based) index is composite rather than non-prime.

Note that a standard 80-character console window will only fit 16 buildings, which could make the 20 building requirement a bit ugly.

@Hand-E-Food Thanks for mentioning that! I've change it so you put the buildings on new lines.

@Dennis I wasn't sure whether to do Fibonacci or prime numbers, so the one was kept from that. Just fixed it!

I doubt most languages have access to the terminal width. Also, the amended rule might open a loophole for narrow terminals where you can puts each building on a new line. Simply assuming a 80x24 terminal that can hold up to 16 buildings would be cleaner.

Does the output have to be horizontal? Or can we print it vertically

What are the rules on leading whitespace?

CJam, 68 66 58 55 bytes
This is too long for now. But a start.
ri:K"!;tK"206b4b<{S5*a*"+--+ "a:I+K)2/)"|  | "e]I+}%zN*

UPDATE: Now hardcoding for inputs till 15 instead of calculating the offset. Suggestion by Sp3000
Try it online here

Python 2, 247 245 237 229 bytes
I=input()
R=range
B=[(-~I/2)-(x%3<1)-(x%5<1)-(x%10<1)-(~all([x%a for a in R(2,x)]or[x==2])+2)for x in R(1,I+1)]
E='+--+'
O=['\n']*I
for r in R(I):
 for h in B:O[r]+=['|  |',' '*4,E][(r==h)+(r>=h)]
print ''.join(O[::-1])+'\n'+E*I

C#, 223 205 bytes
This takes advantage of the need to only go to 15 buildings.
class P{
    static void Main(string[]a){
        int w=int.Parse(a[0]),
            h=(w+3)/2,
            b,
            x,
            y=-1;
        for(;++y<=h;)
            for(x=-2;++x<w;)
                System.Console.Write(x<0?"\n":(b=y-("012021101211102"[x]&7))<0?"     ":b>0&y<h?"|  | ":"+--+ ");
    }
}

260 bytes
And a more generic answer that will work for any number of buildings.
class P{
    static void Main(string[]a){
        int w=int.Parse(a[0]),
            h=(w+3)/2,
            b,
            x,
            y=-1;
        for(;++y<=h;)
            for(x=-2;++x<w;){
                if(x<1)
                    b=-1;
                else
                    for(b=1;++b<x;)
                        if((x+1)%b<1)break;
                System.Console.Write(x<0?"\n":(b=y-x%3/2-x%5/4-x%10/9-(b<x?0:1))<0?"     ":b>0&y<h?"|  | ":"+--+ ");
            }
    }
}

Groovy, 234, 225, 223 219 bytes
Abusing the 15 building limit
b=args[0]as int
m={n->(n!=2&(2..n-1).any{n%it==0}?1:0)+([3,5,10].sum{n%it==0?1:0})}
(9..0).each{println((1..b).collect{d=((b/2)as int)+1-m(it);(0..9).collect{it!=d&it!=0?it<d?"|  |":"    ":"+--+"}}*.get(it).join(" "))}

Python 2, 163 bytes
n=input()
k=-~n/2
for i in range(k+2):
 s="";p=j=1
 while~n+j:a=(j%3<1)+(j%5<1)+(j%10<1)+(p%j<1);s+=" |+  -  - |+   "[(i>=a)+(i in{a,k+1})::3];p*=j*j;j+=1
 print s

The primality checking part borrows @xnor's algorithm from here.
If we hardcode the first 15 offsets, we can get 137 bytes:
n=input()
k=-~n/2
for i in range(k+2):
 s=""
 for j in range(n):a=881740113>>2*j&3;s+=" |+  -  - |+   "[(i>=a)+(i in{a,k+1})::3]
 print s

I'm assuming trailing spaces at the end of each line is okay, but if the question meant trailing spaces after the entire output then it's +9 bytes for .rstrip().

Swift, 375, 350 bytes
import Darwin;let(B,u,z,d)=(4.0,1.0,0.0,2.0);let H=ceil(B/d);func p(n:Double)->Double{var D=d;while D<n{if n%D==0{return 1};D++};return n==1 ?1:0};for var h=z;h<H+2;h++ {for var b=u;b<=B;b++ {var m=b%3==0 ?u:z+b%5==0 ?1:0;m=min(2,b%10==0 ?m+1:m);m += p(b);if h<m {print("     ")}else if h==H+1||h==m {print("+--+ ")}else{print("|  | ")}};print("\n")}

Here is the indented code
import Darwin
let(B,u,z,d)=(4.0,1.0,0.0,2.0)
let H=ceil(B/d)
func p(n:Double)->Double{
     var D=d
    while D<n{
        if n%D==0{
            return 1
        }
        D++
    }
    return n==1 ?1:0
}
for var h=z;h<H+2;h++ {
    for var b=u;b<=B;b++ {
        var m=b%3==0 ?u:z+b%5==0 ?1:0
        m=min(2,b%10==0 ?m+1:m)
        m += p(b)
        if h<m {
            print("     ")
        }
        else if h==H+1||h==m {
            print("+--+ ")
        }
        else{
            print("|  | ")
        }
    }
    print("\n")
}

B contains the number of buildings.
p returns 1 when a number is not prime.
I need to import Foundation in order to use the ceil function.
I didn't managed to optimize the code for just the fifteen cases, but I will eventually make it later.
edit: Taking @Kametrixom advice and optimize the mod part (I forgot to reduce var name length).

You can replace Foundation with Darwin to save some bytes

-1 with import UIKit instead of import Darwin.

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


text:
Print the map of a country with the weirdest code possible
It can be in any language, plus the map must be in the output only not in the source code.
This is my first question here, so please feel free to edit it. Also, there might be some rules about scoreboard which I'm not familiar how to put it here.
Cheers!

Questions that ask to do a task in creative or odd way tend not to fare well here. Creativity is better gotten by constraints and challenges rather than outright asking for it. I'd suggest trying some of the existing questions to get a feel for the site before posting your own.

Vatican
In CJAM:
46c

You can test it here

lol


text:
Integral triangles and integral medians
Consider a triangle ABC where each side has integer length (an integral triangle). Define a median of ABC to be a line segment from a vertex to the midpoint of the opposing side. In the figure below, the red line segments represent the medians. Note that any given triangle has three medians.

Let n be some positive integer. How many non-degenerate integral triangles with each side length less than or equal to n have at least one integral median?
Challenge
Write a program to compute the number of integral triangles with at least one integral median for a given maximum side length n. The order of the side lengths does not matter, i.e. <6,6,5> represents the same triangle as <5,6,6> and should be counted only once. Exclude degenerate triangles such as <1,2,3>.
Scoring
The largest n for which your program can generate the number of triangles in 60 seconds on my machine is your score. The program with the highest score wins. My machine is a Sony Vaio SVF14A16CLB, Intel Core i5, 8GB RAM.
Examples
Let T(N) be the program with input N.
T(1) = 0
T(6) = 1
T(20) = 27
T(22) = 34

Note that T(1) = T(2) = T(3) = T(4) = T(5) = 0 because no combination of integral sides will yield an integral median. However, once we get to 6, we can see that one of the medians of the triangle <5,5,6> is 4, so T(6) = 1.
Note also that T(22) is the first value at which double-counting becomes an issue: the triangle <16,18,22> has medians 13 and 17 (and 2sqrt(85)).
Computing the medians
The medians of a triangle can be calculated by the following formulas:

Current top score: Sp3000 - 7000 points - C

Comments are not for extended discussion; this conversation has been moved to chat.

C, brute force - n=6080
This is more a baseline than a serious contender, but at least it should get things started.
n=6080 is as high as I got in a minute of runtime on my own machine, which is a MacBook Pro with an Intel Core i5. The result I got for this value is:

15041226

The code is purely brute force. It enumerates all the triangles within the size limit, and tests for the condition:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

static inline int isSquare(int v) {
    int s = (int)(sqrtf((float)v) + 0.5f);
    return s * s == v;
}

static inline int isMedian(int v) {
    return v % 4 == 0 && isSquare(v / 4);
}

int main(int argc, char* argv[]) {
    int n = atoi(argv[1]);
    int nTri = 0;
    int a, b, c;

    for (c = 1; c <= n; ++c) {
        for (b = (c + 1) / 2; b <= c; ++b) {
            for (a = c - b + 1; a <= b; ++a) {
                if (isMedian(2 * (b * b + c * c) - a * a) ||
                    isMedian(2 * (a * a + c * c) - b * b) ||
                    isMedian(2 * (a * a + b * b) - c * c)) {
                    ++nTri;
                }
            }
        }
    }

    printf("%d\n", nTri);

    return 0;
}

Depending on the compiler, you can get faster + better round-to-nearest from using lrintf() or (int)roundf() instead of adding 0.5f and using the default truncation.  Sometimes you need to use -ffast-math to get it to compile to a single cvtss2si instruction, though.  gcc inlines lrintf() and sqrtf with only -fno-math-errno, so you get efficient asm: https://godbolt.org/g/E3hncQ.  (I used -march=ivybridge because that's the OP's CPU).  With -ffast-math, clang turns the sqrt into a rsqrt + Newton iteration; IDK if that's a win.

Oops, usually not roundf.  Use (int)nearbyintf() if lrintf() doesn't inline, because it uses the current rounding mode instead of a specific weird one.  http://stackoverflow.com/questions/37620659/merit-of-inline-asm-rounding-via-putting-float-into-int-variable/37624488#37624488

C, approx 6650 6900
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

static inline int is_square(int n) {
    if ((n&2) != 0 || (n&7) == 5 || (n&11) == 8) {
        return 0;
    }

    int s = (int) (sqrtf((float) n) + 0.5f);
    return (s*s == n);
}

int main(int argc, char **argv) {
    int n = atoi(argv[1]);
    int count = 0;

    for (int a = 1; a <= n; ++a) {
        if (a&1) {
            for (int b = (a+1)/2; b <= a; ++b){
                if (b&1) {
                    for (int c = a-b+2; c <= b; c += 2) {
                        if (is_square((a*a + b*b)/2 - (c*c)/4)) {
                            ++count;
                        }
                    }
                } else {
                    for (int c = a-b+2; c <= b; c += 2) {
                        if (is_square((a*a + c*c)/2 - (b*b)/4)) {
                            ++count;
                        }
                    }
                }
            }
        } else {
            for (int b = (a+1)/2; b <= a; ++b){
                if (b&1) {
                    for (int c = a-b+2; c <= b; c += 2) {
                        if (is_square((b*b + c*c)/2 - (a*a)/4)) {
                            ++count;
                        }
                    }
                } else {
                    for (int c = a-b+2; c <= b; c += 2) {
                        if (is_square((b*b + c*c)/2 - (a*a)/4) ||
                            is_square((c*c + a*a)/2 - (b*b)/4) ||
                            is_square((a*a + b*b)/2 - (c*c)/4)) {
                            ++count;
                        }
                    }
                }
            }
        }
    }

    printf("%d\n", count);
    return 0;
}

I don't really use C often, but with the amount of arithmetic going on it seemed like a good choice of language. The core algorithm is brute force like @RetoKoradi's answer, but with a few simple optimisations. I'm not sure our values are comparable though, because @RetoKoradi's computer seems to be faster than mine.
The major optimisation is bypassing the % 4 check completely. An integer square n*n is either 0 or 1 modulo 4, depending on whether n itself is 0 or 1 modulo 2. Thus, we can take a look at all possibilities for (x, y, z) % 2:
x%2  y%2  z%2    (2*(x*x+y*y) - z*z) % 4
----------------------------------------
 0    0    0              0
 0    0    1              3
 0    1    0              2
 0    1    1              1
 1    0    0              2
 1    0    1              1
 1    1    0              0
 1    1    1              3

Conveniently, there are only two cases to consider: (0, 0, 0) and (1, 1, 0), which, given the first two sides a, b, equates to the third side c having parity a^b:
 a%2   b%2         c%2 must be
 -----------------------------
  0     0               0
  0     1               1
  1     0               1
  1     1               0

a^b is the same parity as a-b, so rather than searching from c = a-b+1 and going up by 1s, this lets us search from c = a-b+2 and go up by 2s.
Another optimisation comes from the fact that, for the (1, 1, 0) case, we only need to call is_square once since only one permutation works. This is special cased in the code by unrolling the search.
The other optimisation included is simply a quickfail in the is_square function.
Compilation was done with -std=c99 -O3.
(Thanks to @RetoKoradi for pointing out that the 0.5 in is_square needed to be 0.5f to avoid a double conversion taking place.)

Very minor, but you may want to use 0.5f instead of 0.5 in is_square(). 0.5 is a constant of type double, so the expression will produce a double value when you add 0.5, including type conversion from float to double for the other term.

@RetoKoradi Ah thanks - that was one surprisingly not-minor f, actually.

Felix, unknown
fun is_square(v: int) => let s = int$ sqrt$ v.float + 0.5f in s*s == v;
fun is_median(v: int) => v % 4 == 0 and (v/4).is_square;

proc main() {
    n := int$ System::argv 1;
    var ntri = 0;

    for var c in 1 upto n do
        for var b in (c+1)/2 upto c do
            for var a in c - b + 1 upto b do
                if is_median(2*(b*b+c*c)-a*a) or
                   is_median(2*(a*a+c*c)-b*b) or
                   is_median(2*(a*a+b*b)-c*c) do ++ntri; done
            done
        done
    done

    ntri.println;
}

main;

Basically a port of the C answer, but it's faster than it, tested with clang -O3 and icc -O3. Felix and Nim are literally the only two languages I know of that can beat C and C++ at benchmarks. I'm working on a parallel version, but it'll be a bit till it's finished, so I decided to post this ahead.
I also put "unknown" because my computer isn't necessarily the fastest on earth...
Command used to build:
flx --usage=hyperlight -c --static -o sl0 sl0.flx

The generated C++ is pretty interesting to look at:
//Input file: /home/ryan/golf/itri/sl0/sl0.flx
//Generated by Felix Version 15.04.03
//Timestamp: 2015/7/16 20:59:42 UTC
//Timestamp: 2015/7/16 15:59:42 (local)
#define FLX_EXTERN_sl0 FLX_EXPORT
#include "sl0.hpp"
#include <stdio.h>
#define comma ,

//-----------------------------------------
//EMIT USER BODY CODE
using namespace ::flxusr::sl0;

//-----------------------------------------
namespace flxusr { namespace sl0 {

//-----------------------------------------
//DEFINE OFFSET tables for GC
#include "sl0.rtti"
FLX_DEF_THREAD_FRAME
//Thread Frame Constructor
thread_frame_t::thread_frame_t(
) :
  gcp(0),
  shape_list_head(&thread_frame_t_ptr_map)
{}

//-----------------------------------------
//DEFINE FUNCTION CLASS METHODS
#include "sl0.ctors_cpp"
//------------------------------
//C PROC <61624>: _init_
void _init_(FLX_APAR_DECL_ONLY){
  int _i63436_v63436_s;
  int _i63435_v63435_s;
  int s;
  int a;
  int b;
  int c;
  int ntri;
  int n;
      n = static_cast<int>(::std::atoi((::std::string(1<0||1>=PTF argc?"":PTF argv[1])).c_str())); //assign simple
      ntri = 0; //assign simple
      c = 1; //assign simple
    _63421:;
      if(FLX_UNLIKELY((n < c))) goto _63428;
      b = (c + 1 ) / 2 ; //assign simple
    _63422:;
      if(FLX_UNLIKELY((c < b))) goto _63427;
      a = (c - b ) + 1 ; //assign simple
    _63423:;
      if(FLX_UNLIKELY((b < a))) goto _63426;
/*begin match*/
/*match case 1:s*/
      s  = static_cast<int>((::std::sqrt(((static_cast<float>(((2 * (b * b  + (c * c ) )  - (a * a ) ) / 4 ))) + 0.5f ))))/*int.flx: ctor*/; //init
/*begin match*/
/*match case 1:s*/
      _i63435_v63435_s  = static_cast<int>((::std::sqrt(((static_cast<float>(((2 * (a * a  + (c * c ) )  - (b * b ) ) / 4 ))) + 0.5f ))))/*int.flx: ctor*/; //init
/*begin match*/
/*match case 1:s*/
      _i63436_v63436_s  = static_cast<int>((::std::sqrt(((static_cast<float>(((2 * (a * a  + (b * b ) )  - (c * c ) ) / 4 ))) + 0.5f ))))/*int.flx: ctor*/; //init
      if(!((((2 * (b * b  + (c * c ) )  - (a * a ) ) % 4  == 0) && (s * s  == (2 * (b * b  + (c * c ) )  - (a * a ) ) / 4 )  || (((2 * (a * a  + (c * c ) )  - (b * b ) ) % 4  == 0) && (_i63435_v63435_s * _i63435_v63435_s  == (2 * (a * a  + (c * c ) )  - (b * b ) ) / 4 ) ) ) || (((2 * (a * a  + (b * b ) )  - (c * c ) ) % 4  == 0) && (_i63436_v63436_s * _i63436_v63436_s  == (2 * (a * a  + (b * b ) )  - (c * c ) ) / 4 ) ) )) goto _63425;
      {
      int* _tmp63490 = (int*)&ntri;
      ++*_tmp63490;
      }
    _63425:;
      if(FLX_UNLIKELY((a == b))) goto _63426;
      {
      int* _tmp63491 = (int*)&a;
      ++*_tmp63491;
      }
      goto _63423;
    _63426:;
      if(FLX_UNLIKELY((b == c))) goto _63427;
      {
      int* _tmp63492 = (int*)&b;
      ++*_tmp63492;
      }
      goto _63422;
    _63427:;
      if(FLX_UNLIKELY((c == n))) goto _63428;
      {
      int* _tmp63493 = (int*)&c;
      ++*_tmp63493;
      }
      goto _63421;
    _63428:;
      {
      _a12344t_63448 _tmp63494 = ::flx::rtl::strutil::str<int>(ntri) + ::std::string("\n") ;
      ::flx::rtl::ioutil::write(stdout,_tmp63494);
      }
}

//-----------------------------------------
}} // namespace flxusr::sl0
//CREATE STANDARD EXTERNAL INTERFACE
FLX_FRAME_WRAPPERS(::flxusr::sl0,sl0)
FLX_C_START_WRAPPER_PTF(::flxusr::sl0,sl0,_init_)

//-----------------------------------------
//body complete

C# (about 11000?)
using System;
using System.Collections.Generic;

namespace PPCG
{
    class PPCG53100
    {
        static void Main(string[] args)
        {
            int n = int.Parse(args[0]);
            Console.WriteLine(CountOOE(n) + CountEEE(n));
        }

        static int CountOOE(int n)
        {
            // Maps from a^2 + b^2 to (b - a, a + b), which are the exclusive bounds on c.
            IDictionary<int, List<Tuple<int, int>>> pairs = new Dictionary<int, List<Tuple<int, int>>>();

            for (int a = 1; a <= n; a += 2)
            {
                int k = 2 * a * a;
                for (int b = a; b <= n; b += 2, k += 4 * (b - 1))
                {
                    List<Tuple<int, int>> prev;
                    if (!pairs.TryGetValue(k, out prev)) pairs[k] = prev = new List<Tuple<int, int>>();
                    prev.Add(Tuple.Create(b - a, a + b));
                }
            }

            int max = 2 * n * n;
            int count = 0;
            for (int x = 1; x <= n >> 1; x++)
            {
                int k = 4 * x * x;
                for (int y = x; y <= n; y++, k += 4 * y - 2)
                {
                    if (k > max) break;
                    List<Tuple<int, int>> ab;
                    if (pairs.TryGetValue(k, out ab))
                    {
                        foreach (var pair in ab)
                        {
                            // Double-counting isn't possible if a, b are odd.
                            if (pair.Item1 < x << 1 && x << 1 < pair.Item2)
                            {
                                count++;
                            }
                            if (x != y && y << 1 <= n && pair.Item1 < y << 1 && y << 1 < pair.Item2)
                            {
                                count++;
                            }
                        }
                    }
                }
            }

            return count;
        }

        static int CountEEE(int n)
        {
            // Maps from a^2 + b^2 to (b - a, a + b), which are the exclusive bounds on c.
            IDictionary<int, List<Tuple<int, int>>> pairs = new Dictionary<int, List<Tuple<int, int>>>();

            for (int a = 2; a <= n; a += 2)
            {
                int k = 2 * a * a;
                for (int b = a; b <= n; b += 2, k += 4 * (b - 1))
                {
                    List<Tuple<int, int>> prev;
                    if (!pairs.TryGetValue(k, out prev)) pairs[k] = prev = new List<Tuple<int, int>>();
                    prev.Add(Tuple.Create(b - a, a + b));
                }
            }

            // We want to consider m in the range [1, n] and c/2 in the range [1, n/2]
            // But to save dictionary lookups we can scan x in [1, n/2], y in [x, n] and consider both ways round.
            int max = 2 * n * n;
            int count = 0;
            for (int x = 1; x <= n >> 1; x++)
            {
                int k = 4 * x * x;
                for (int y = x; y <= n; y++, k += 4 * y - 2)
                {
                    if (k > max) break;
                    List<Tuple<int, int>> ab;
                    if (pairs.TryGetValue(k, out ab))
                    {
                        foreach (var pair in ab)
                        {
                            // (c1, m1) = (2x, y)
                            // (c2, m2) = (2y, x)

                            int a = (pair.Item2 - pair.Item1) / 2, b = (pair.Item2 + pair.Item1) / 2;
                            int c1 = 2 * x;

                            if (pair.Item1 < c1 && c1 < pair.Item2)
                            {
                                // To deduplicate: the possible sets of integer medians are:
                                //     m_c
                                //     m_a, m_c
                                //     m_b, m_c
                                //     m_a, m_b, m_c
                                // We only want to add if c is (wlog) the shortest edge whose median is integral (or joint integral in case of isosceles triangles).

                                if (c1 <= a) count++;
                                else if (!IsIntegerMedian(b, c1, a))
                                {
                                    if (c1 <= b || !IsIntegerMedian(a, c1, b)) count++;
                                }
                            }

                            int c2 = 2 * y;
                            if (c1 != c2 && c2 <= n && pair.Item1 < c2 && c2 < pair.Item2)
                            {
                                if (c2 <= a) count++;
                                else if (!IsIntegerMedian(b, c2, a))
                                {
                                    if (c2 <= b || !IsIntegerMedian(a, c2, b)) count++;
                                }
                            }
                        }
                    }
                }
            }

            return count;
        }

        private static bool IsIntegerMedian(int a, int b, int c)
        {
            int m2 = 2 * (a * a + b * b) - c * c;
            int s = (int)(0.5f + Math.Sqrt(m2));
            return ((s & 1) == 0) && (m2 == s * s);
        }
    }
}

n is taken as a command-line argument.
Explanation
We can rewrite \$m = \sqrt{(2a^2 + 2b^2 - c^2) / 4}\$ as \$2a^2 + 2b^2 = 4m^2 + c^2\$, whence it's obvious that \$c^2\$ must be even, and so \$c\$ is even. Let \$c = 2C\$ and we rewrite again as \$a^2 + b^2 = 2(m^2 + C^2)\$. Therefore \$a^2 + b^2\$ must be even, so \$a\$ and \$b\$ must have the same parity.
The equation \$a^2 + b^2 = 2(m^2 + C^2)\$ is the basis for the meet-in-the-middle algorithm employed here.
If \$a\$ and \$b\$ are odd then we have no risk of double-counting, because only one of the three medians can possibly be integral. If all three are even then we need to beware double-counting. Therefore I handle the two cases separately so that the odd-odd-even case can be processed faster than the even-even-even case.

I can't build Felix on my machine, but my times for n=5000 are 67 seconds for Reto Koradi's answer, 48 seconds for Sp3000's answer, and 13 seconds for my answer.

Axiom, n=269 in 59 sec
isq?(x:PI):Boolean==perfectSquare?(x)

f(a:PI,b:PI,c:PI):Boolean==
    c rem 2=1=>false
    t:=a^2+b^2
    t rem 2=1=>false
    x:=(2*t-c^2)quo 4
    isq?(x)

h(n)==
   cnt:=0  -- a:=a   b:=(a+2*k)  c:=
   r:List List INT:=[]
   for a in 1..n repeat
     ke:=(n-a)quo 2
     for k in 0..ke repeat
         d:=(a+k)^2+k^2 -- (a^2+b^2)/2=(a+k)^2+k^2   m^2+c^2=d
         l:=reduce(min,[sqrt(d*1.), n/2.,a+k-1])
         kc:=floor(l)::INT
         for c in k+1..kc repeat
             if isq?(d-c^2) then
                            bb:=a+2*k; cc:=2*c
                            if bb>cc and f(a,cc,bb) then iterate   -- 2<->3
                            if  a>cc and f(cc,bb,a) then iterate   -- 1<->3
                            cnt:=cnt+1
                            --r:=cons([a,a+2*k,2*c],r)
   r:=cons([cnt],r)
   r

If a,b,cx are length of the sides of one triangle of max lenght side n...
We would know that m:=sqrt((2*(a^2+b^2)-cx^2)/4)
(1) m^2=(2*(a^2+b^2)-cx^2)/4

As Peter Taylor had said, 4|(2*(a^2+b^2)-cx^2) and because 2|2*(a^2+b^2) than 2|cx^2 =>
cx=2*c. So from 1 will be
(2) m^2=(a^2+b^2)/2-c^2

a, and b has to have the same parity, so we could write b in function of a
(3) a:=a   b:=(a+2*k)

than we have that
(4)(a^2+b^2)/2=(a^2+(a+2*k)^2)/2=(a+k)^2+k^2

so the (1) can be rewritten see (2)(3)(4) as:
m^2+c^2=(a+k)^2 + k^2=d         a:=a  b:=(a+2*k)  cx:=2*c

where
a in 1..n
k in 0..(n-a)/2
c in k+1..min([sqrt(d*1.), n/2.,a+k-1])

results
(16) -> h 269
   (16)  [[14951]]
                                                  Type: List List Integer
        Time: 19.22 (IN) + 36.95 (EV) + 0.05 (OT) + 3.62 (GC) = 59.83 sec

C, n=3030 here
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define R     return
#define u32 unsigned
#define F        for
#define P     printf

int isq(u32 a)
{u32 y,x,t,i;
 static u32  arr720[]={0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400,441,484,529,576,625,676,180,241,304,369,436,505,649,160,409,496,585,340,544,145,601,244,580,481,640,385,265};
 static char barr[724]={0};
 if(barr[0]==0)F(i=0;i<(sizeof arr720)/sizeof(unsigned);++i)
                if(arr720[i]<720) barr[arr720[i]]=1;
 if(barr[a%720]==0) R 0;
 y=sqrt(a);
 R y*y==a;
}

int f(u32 a, u32 b, u32 c)
{u32 t,x;
 if(c&1)R 0;
 t= a*a+b*b;
 if(t&1)R 0;
 R isq((2*t-c*c)/4);
}

int h(u32 n)
{u32 cnt,a,c,k,ke,kc,d,v,l,aa,bb,cc;

 cnt=0;
 F(a=1;a<=n;++a)
   {ke=(n-a)/2;
    F(k=0;k<=ke;++k)
        {v=a+k;
         d=v*v+k*k;
         l=sqrt(d);
         v=n/2;
         if(l>v)l=v;
         v=a+k-1;
         if(l>v)l=v;
         F(c=k+1;c<=l;++c)
           {if(isq(d-c*c))
                {bb=a+2*k;cc=2*c;
                 if(bb>cc && f(a, cc,bb)) continue;
                 if( a>cc && f(cc,bb, a)) continue;
                 ++cnt;
                 //P("|a=%u b=%u c=%u", a, bb, cc);
                }
           }
        }
   }
 R cnt;
}

int main(int c, char** a)
{time_t  ti, tf;
 double   d;
 int     ni;
 u32    n,i;

 if(c!=2||a[1]==0){P("uso: questo_programma.exe  arg1\n ove arg1 e\' un numero positivo\n");R 0;}
 ni=atoi(a[1]);
 if(ni<=0){P("Parametro negativo o zero non permesso\n");R 0;}
 n=ni;
 if(n>0xFFFFF){P("Parametro troppo grande non permesso\n"); R 0;}
 F(i=3;i<33;++i)if(i<10||i>21)P("T(%u)=%u|",i, h(i));
 ti=time(0);
 P("\nT(%u)=%u\n", n, h(n));
 tf=time(0);
 d=difftime(tf,ti);
 P("Tempo trascorso = %.2f sec\n", d);
 R 1;
}

results:
C:\Users\a\b>prog 3030
T(3)=0|T(4)=0|T(5)=0|T(6)=1|T(7)=1|T(8)=2|T(9)=3|T(22)=34|T(23)=37|T(24)=42|T(25)=
45|T(26)=56|T(27)=59|T(28)=65|T(29)=67|T(30)=74|T(31)=79|T(32)=91|
T(3030)=3321226
Tempo trascorso = 60.00 sec

the above code would be the traslation in C of the Axiom answer
(if we not count the isq() function).
My compiler not link a function others use sqrtf()... here there is no sqrt function for float...
Are they sure that sqrtf it is a C standard function?

(since C99)

APL NARS, n=239 282  in 59 seconds
f←{(a b c)←⍵⋄1=2∣c:0⋄t←+/a b*2⋄1=2∣t:0⋄0=1∣√4÷⍨(2×t)-c*2}

∇r←g n;cnt;c;a;k;kc;ke;d;l;bb;cc
    r←⍬⋄cnt←0
    :for a :in 1..n
       ke←⌊(n-a)÷2
       :for k :in 0..ke
          d←((a+k)*2)+k*2
          kc←⌊⌊/(n÷2),(a+k-1),√d
          →B×⍳kc<k+1
          :for c :in (k+1)..kc
            →C×⍳∼1e¯9>1∣√d-c*2
               bb←a+2×k⋄cc←2×c
               →C×⍳(bb>cc)∧f a  cc bb
               →C×⍳( a>cc)∧f cc bb  a
               cnt+←1
               ⍝r←r,⊂a bb cc
   C:     :endfor
   B:  :endfor
    :endfor
    r←r,cnt
∇

(i traslate the Axiom answer one, in APL) test:
  g 282
16712
  v←5 6 10 20 30 41
  v,¨g¨v
5 0  6 1  10 4  20 27  30 74  41 166

VBA 15,000 in TEN seconds!
I expected much less after these other posts.  On an Intel 7 with 16 GB RAM I get 13-15,000 in TEN seconds.  On a Pentium with 4 GB RAM, I get 5-7,000 in TEN seconds.  The code is below.  Here is the latest result on the Pentium
abci= 240, 234, 114, 7367, 147
abci= 240, 235, 125, 7368, 145
abci= 240, 236, 164, 7369, 164
abci= 240, 238, 182, 7370, 221
abci= 240, 239, 31, 7371, 121

It got up to a triangle with sides 240, 239, 31 and a medium of 121.  The count of mediums is 7,371.
Sub tria()
On Error Resume Next
Dim i As Long, a As Integer, b As Integer, c As Integer, ma As Double, mb As Double, mc As Double, ni As Long, mpr As Long
Dim dtime As Date
dtime = Now
Do While Now < DateAdd("s", 10, dtime)  '100 > DateDiff("ms", dtime, Now) '
    a = a + 1
   ' Debug.Assert a < 23
    b = 1: c = 1
    Do
        ma = 0
        If a < b + c And b < a + c And c < a + b Then
            ma = ((2 * b ^ 2 + 2 * c ^ 2 - a ^ 2) / 4) ^ 0.5
            If ma <> 0 Then ni = i + 1 * -1 * (0 = ma - Fix(ma))
                If ni > i Then
                If ma <> mpr Then
                i = ni
                mpr = ma
                    Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & ma
                    GoTo NextTri  'TO AVOID DOUBLE COUNTING
                End If
            End If
       'End If

        mb = 0
        'If b < a + c Then
            mb = ((2 * a ^ 2 + 2 * c ^ 2 - b ^ 2) / 4) ^ 0.5
            If mb <> 0 Then ni = i + 1 * -1 * (0 = mb - Fix(mb))
            If ni > i Then
            If mb <> mpr Then
                i = ni
                mpr = mb
                Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & mb
                GoTo NextTri  'TO AVOID DOUBLE COUNTING
            End If
            End If
        'End If

        mc = 0
        'IfThen
            mc = ((2 * b ^ 2 + 2 * a ^ 2 - c ^ 2) / 4) ^ 0.5
            If mc <> 0 Then ni = i + 1 * -1 * (0 = mc - Fix(mc))
            If ni > i Then
            If mc <> mpr Then
            i = ni
            mpr = mc
                Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & mc
            End If
            End If
        End If
NextTri:
        Do While c <= b
            'c = c + 1
            ma = 0
            If a < b + c And b < a + c And c < a + b Then

                    ma = ((2 * b ^ 2 + 2 * c ^ 2 - a ^ 2) / 4) ^ 0.5
                    If ma <> 0 Then ni = i + 1 * -1 * (0 = ma - Fix(ma))
                            If ni > i Then
                    If ma <> mpr Then
                        mpr = ma
                i = ni
                    End If
                    Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & ma
                    GoTo NextTri2  'TO AVOID DOUBLE COUNTING
                End If
            'End If

            mb = 0
            'If b < a + c Then
                mb = ((2 * a ^ 2 + 2 * c ^ 2 - b ^ 2) / 4) ^ 0.5
                If mb <> 0 Then ni = i + 1 * -1 * (0 = mb - Fix(mb))
                        If ni > i Then
                If mb <> mpr Then
                mpr = mb
                i = ni
                    Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & mb
                    GoTo NextTri2  'TO AVOID DOUBLE COUNTING
                End If
                End If
            'End If

            mc = 0
            'If c < b + a Then
                    mc = ((2 * b ^ 2 + 2 * a ^ 2 - c ^ 2) / 4) ^ 0.5
                    If mc <> 0 Then ni = i + 1 * -1 * (0 = mc - Fix(mc))
                            If ni > i Then
                    If mc <> mpr Then
                    mpr = mc
                i = ni
                    Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i & ", " & mc
                    End If
                End If
            End If
       ' Debug.Print "abci= " & a & ", " & b & ", " & c & ", " & i
            c = c + 1
        Loop 'While c <= a
NextTri2:
        b = b + 1
        c = 1
    Loop While b <= a
Loop
Debug.Print i

End Sub

Welcome to PPCG!

Rust, brute force, 4500
On my computer, the program calculated that the answer at n=4500 is 7844386, within 60 seconds.
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use rayon::prelude::*;

#[inline]
fn is_square(v: i32) -> bool {
    let s = (f32::sqrt(v as f32) + 0.5).floor() as i32;
    s * s == v
}

#[inline]
fn is_median(v: i32) -> bool {
    v % 4 == 0 && is_square(v / 4)
}

#[inline]
fn calculate_triangles(n: i32) -> i32 {
    (1..=n)
        .into_par_iter()
        .map(|c| {
            let mut count = 0;
            for b in (c + 1) / 2..=c {
                for a in (c - b + 1)..=b {
                    if is_median(2 * (b * b + c * c) - a * a)
                        || is_median(2 * (a * a + c * c) - b * b)
                        || is_median(2 * (a * a + b * b) - c * c)
                    {
                        count += 1;
                    }
                }
            }
            count
        })
        .sum()
}

fn main() {
    let n: i32 = 4500;
    let (tx, rx) = mpsc::channel();

    let _computation_thread = thread::spawn(move || {
        let n_tri = calculate_triangles(n);
        tx.send(n_tri).unwrap();
    });

    match rx.recv_timeout(Duration::from_secs(60)) {
        Ok(n_tri) => println!("Result: {}", n_tri),
        Err(_) => println!("Timed out after 60 seconds."),
    }

    // The thread will be terminated when the main function ends, regardless of whether it has finished its computation.
}


text:
The Venerable Bede, 21st Century Style
1300 years ago, the English theologian Bede earned the honorific by which he is now known ("The Venerable Bede") by, among other things, convincingly computing the date of Easter for a number of years. This required reconciling the old, Jewish, lunar calendar with the newer solar one, a task made all the more challenging by the fact that Bede did all his math using Roman numerals.
Challenge
In honor of this, your challenge is to produce code that takes a year in Roman numerals, computes the date of Easter for that year and returns it, again in Roman numerals.
Rules

No pre-computing and caching the dates, calling a built-in 'date of easter' or 'holiday dates' function or library, or looking them up online.
Your code should work for any year between MCM and MMXCIX
Helpful algorithms can be found at https://en.wikipedia.org/wiki/Computus
Output can be in YEAR-MONTH-DAY format, or {YEAR, MONTH, DAY} or any similar arrangement as is convenient in your programming language of choice.
You can assume that the input year has already been assigned to a variable x.
Your code should not crash if this input is invalid as a Roman numeral. Quit gracefully.
Where proper Roman representation is ambiguous (as with "IV" vs. "IIII"), follow the guidelines at http://literacy.kent.edu/Minigrants/Cinci/romanchart.htm

Scoring
Shortest program in bytes wins, subject to the following adjustment: if you do your internal math in Roman numerals, in addition to input and output, subtract 90% off of your byte count. I believe that this bonus will suffice to make this question more interesting than a normal 'find the date of easter' question.

Example input/output would probably be good here, especially since there will be discrepancies in the output depending on which calendar you follow. Also, can we assume additive form like IIII instead of IV?

Also, I don't think the bonus makes any sense. It's almost impossible to do the arithmetic without using ints in there somewhere, whether it be working out that V -> 5 or counting the number of Is in the input string... (I guess you could define "I" + "I" = "II", "I" + "II" = "III"... but that'd be far too long)

Why is the year needed in the output, when it is given as the input?

@SP3000 the math was originally done, 1300 years ago, without arabic numerals. Surely modern computer hardware can match the feat of early medieval monks.

@SP3000 clarified IIII vs IV and a few other things.

The core calculation is Calculate the date of Easter, and changing I/O formats doesn't generally distinguish a question enough to not count as a dupe. In this case, it's a non-trivial format change, but the format change is also a dupe of existing questions.

@Sp3000 The way I read the bonus rule, the code can be 10 times as long if you operate in roman. While it looks painful, the amount of the bonus is generous enough to potentially make it interesting.


text:
Most efficient table storage for determining recurrence
The goal of this challenge is to implement a storage and retrieval pattern that will most quickly determine if a set of recurrence definitions fall within a date range.
Consider the schema:  Event -|--has one or many--<- Schedules
Schedule is a record defining a recurrence, e.g. (these are just samples)

Monthly, every month
Monthly, first Wednesday of every month
Monthly, Monday and Tuesday of every 3rd month from start date
Monthly, Monday and Tuesday of every May, June and July
Weekly, every Tuesday through Saturday
Weekly, Monday every 3rd week from start date

The types of supported schedules should be (definitive list):
Pattern

Daily
Weekly, every [X] weeks on [set of 1-7 days]
Monthly, every [Xth] day of every [Y] months
Monthly, every [1st-4th-last] [weekday] of every [Y] months
Yearly, on [month] [day of month] every [X] years
Yearly, on [1st-4th-last] [weekday] of [month]
Monthly, every [Xth] day of [set of months]
Monthly, every [1st-4th-last] [weekday] of [set of months]

End date (Start is always a single date)

No end date (for simplicity, you could omit this since we can use year 2999)
A single date
A number of [X] occurences

To win, the answer must define:

Table schema
SQL query or function (any RBDMS) to test a date range against the entire table

Determination of winner:

test data: 10,000 events will be created randomly; 20 special test cases will be added as well
test case: 100 random date ranges (min:1 max:32 days), 5 fixed date ranges (min:1 max:32 days)
test execution: Test will be repeated 3 times
proof of correctness: All answers must be correct
6: speed: Quickest execution wins

Example test case:
---------
Schedules
---------
Event A: Weekly, Every Monday starting 1 Jan 2015
Event A: Monthly, Every [31st] day of every [1] month starting 1 Jan 2015
  (e.g. Event A is a backup schedule)
Event B: Monthly, Every [1st] day of every [1] month starting 1 Jan 2015
Event C: Yearly, Every [10th] day of every [3] months starting 1 Jan 2015
  (e.g. quarterly summary report)
Event D: Weekly, Every [Tue,Wed,Fri] starting 1 Jan 2015
Event E: Weekly, Every [Tue,Wed,Fri] starting 1 Jan 2015 ending 3 July 2015
(assume no end dates unless stated)

-----
Query
-----
What events occur between 1 July 2015 and 31 July 2015 (inclusive)

---------------
Expected Result
---------------
(shown in date order)
01 July: Event B
01 July: Event E
03 July: Event E  << last occurrence due to end date
06 July: Event A
10 July: Event C
13 July: Event A
20 July: Event A
27 July: Event A
31 July: Event A
(a lot of event D's every Tue/Wed/Fri in July)

Welcome to PPCG stack exchange! This is an interesting challenge - we haven't had many database challenges recently. To be clear, is the challenge to return a boolean saying whether or not any of the events are in the date range, or is it to return all overlapping recurrences?

The challenge is only to return a boolean, or in other words, the set of events with schedules that intersect the date range queried.

The two things you said in that answer are very different. Do you want a True or False result, or a set of events? Either way, please add the clarification to your answer.

"E.g."? Please specify precisely what needs to be supported.

@MickyT Thank you for the suggestion, I have edited the question with test data and an example expected result

@isaacg You are right - I wasn't thinking clearly. I have added a test case at  the end of the question.

@PeterTaylor The definite list of recurrence patterns to be supported is now listed in full.

When you say quickest execution wins.  Is that from go to whoa, including building schema importing data and querying.  Or is it just the query?

@MickyT I mean just the query (or set of test queries), having created as many tables as your design requires, and loaded it with a volume of data.

Sorry to be a pain, but I've started looking at putting something together for this and a couple of things have come up during building a parser.  Your samples don't match your patterns especially for the weekly events.  The sample also seems to swap between  full and abbreviated days/months, does this need to be handled or can we specify formats?

@MickyT The textual descriptions are not the intended way of setting them up! They are my attempts at describing samples. The events generated seem right. I have a sample implementation in MySQL here: http://pastebin.com/C66LXswr Hopefully that makes it more clear

T-SQL

Given that the speed of the query is the most important part of the challenge, I have created a table that is an expansion of the events so that each event has all of it's occurrence dates stored.  The query is then just a simple WHERE DATE BETWEEN query and will perform extremely quickly.
This of course is built towards the query speed and not for the maintenance of the data.  Building and populating the table will take a fair amount of time depending on the amount of dates that the events cover.
The parsing of the records assume the the Days and Months are all abbreviated
View
A simple view to give a list of numbers up to 1e8
CREATE View [dbo].[Tally] as
WITH
    E1(N) AS (select 1 from (values (1),(1),(1),(1),(1),(1),(1),(1),(1),(1))dt(n)),
    E2(N) AS (SELECT 1 FROM E1 a, E1 b), --10E+2 or 100 rows
    E4(N) AS (SELECT 1 FROM E2 a, E2 b), --10E+4 or 10,000 rows max
    E8(N) AS (SELECT 1 FROM E4 a, E4 b), --10E+4 or 100,000,000 rows max
    cteTally(N) AS
    (
        SELECT  ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM E4
    )
SELECT N FROM cteTally;
GO

Functions
A couple of inline table functions to parse and expand the Event input records.
CREATE FUNCTION ParseEvent (@InputString VARCHAR(1000)) RETURNS TABLE AS RETURN
    -- Parse rest of the components
    SELECT
        EventName,
        ScheduleType,
        StartDate,
        EndDate,
        CASE WHEN ScheduleType = 'Weekly' THEN
            SUBSTRING(Remainder,7,CHARINDEX(' weeks ',Remainder)-7)
        END WeeklyX,
        CASE WHEN ScheduleType = 'Weekly' THEN
            SUBSTRING(Remainder,CHARINDEX(' on ',Remainder)+4,999)
        END WeeklyDays,
        CASE WHEN ScheduleType = 'Monthly' and Remainder like '% day of %' THEN
            SUBSTRING(Remainder,7,CHARINDEX(' day ',Remainder)-7)
        END MonthlyDayOfMonth,
        CASE WHEN ScheduleType = 'Monthly' and Remainder like '% of every %' THEN
            REPLACE(SUBSTRING(Remainder,CHARINDEX(' of every',Remainder)+10,999),' months','')
        END MonthlyX, -- Y
        CASE WHEN ScheduleType = 'Monthly' and Remainder not like '% of every %' THEN
            SUBSTRING(Remainder,CHARINDEX(' of ',Remainder)+4,999)
        END MonthlyMonths,
        CASE WHEN ScheduleType = 'Yearly' THEN
            CASE WHEN Remainder like '% every %' THEN
                SUBSTRING(Remainder,4,CHARINDEX(' ',Remainder,4)-4) -- length 3 ?
            ELSE
                SUBSTRING(Remainder,CHARINDEX(' of ',Remainder)+4,999) -- Right(Remainder,3) ?
            END
        END YearlyMonth,
        CASE WHEN ScheduleType = 'Yearly' and Remainder like '% every %' THEN
            SUBSTRING(Remainder,CHARINDEX(' ',Remainder,4)+1,CHARINDEX(' ',Remainder,CHARINDEX(' ',Remainder,4)+1)-CHARINDEX(' ',Remainder,4)-1) -- Can we assume 3 ??
        END YearlyDayOfMonth,
        CASE WHEN ScheduleType = 'Yearly' and Remainder like '% every %' THEN
            REPLACE(SUBSTRING(Remainder,CHARINDEX(' every ',Remainder)+7,9999),' years','')
        END YearlyX,
        CASE WHEN (ScheduleType = 'Yearly' and Remainder like '% of %') OR
            (ScheduleType = 'Monthly' and remainder not like '% day %') THEN
            SUBSTRING(Remainder,CHARINDEX(' ',Remainder)+1,CHARINDEX(' of ',Remainder)-CHARINDEX(' ',Remainder)-1)
        END WeekDayOccurance
        FROM
        -- Get the start and end dates
        (SELECT
            EventName,
            ScheduleType,
            CAST(SUBSTRING(Remainder, CHARINDEX('Starting',Remainder)+9, IIF(CHARINDEX('Ending',Remainder)=0,999,CHARINDEX('Ending',Remainder) - (CHARINDEX('Starting',Remainder) + 9))) AS DATE)  StartDate,
            CAST(IIF(CHARINDEX('Ending',Remainder)=0,'31 Dec 2999',SUBSTRING(Remainder, CHARINDEX('Ending',Remainder) + 7, 999)) AS DATE) EndDate,
            RTRIM(STUFF(Remainder,CHARINDEX('Starting',Remainder),999,'')) Remainder
        FROM
            -- Get the schedule type
            (SELECT EventName,
                LTRIM(LEFT(Remainder, CHARINDEX(',',Remainder)-1)) ScheduleType,
                LTRIM(STUFF(Remainder, 1, CHARINDEX(',',Remainder), '')) Remainder
            FROM
                -- Get the event name
                ( SELECT
                    LEFT(@InputString, CHARINDEX(':',@InputString)-1) EventName,
                    STUFF(@InputString, 1, CHARINDEX(':',REPLACE(@InputString,'Daily ','Daily, ')), '') Remainder
                ) EventName
            ) ScheduleType
        ) StartEndDate
;
GO

CREATE FUNCTION ExpandEvent (
        @EventName VARCHAR(100),
        @ScheduleType VARCHAR(20),
        @StartDate DATE,
        @EndDate DATE,
        @WeeklyX VARCHAR(10),
        @WeeklyDays VARCHAR(50),
        @MonthlyDayOfMonth VARCHAR(10),
        @MonthlyX VARCHAR(10),
        @MonthlyMonths VARCHAR(50),
        @YearlyMonth VARCHAR(50),
        @YearlyDayOfMonth VARCHAR(10),
        @YearlyX VARCHAR(10),
        @WeekDayOccurance VARCHAR(50)
    ) RETURNS TABLE RETURN
WITH AllDays AS (
    SELECT *
    FROM (
        SELECT
            DENSE_RANK() OVER (ORDER BY DATEPART(year,D)) - 1 YearCount
            ,DENSE_RANK() OVER (ORDER BY DATEPART(year,D), DATEPART(month,D)) - 1 MonthCount
            ,DENSE_RANK() OVER (ORDER BY DATEPART(year,D), DATEPART(week,D)) - 1 WeekCount
            ,CASE DATEPART(month,D)
                WHEN 1 THEN 'Jan'
                WHEN 2 THEN 'Feb'
                WHEN 3 THEN 'Mar'
                WHEN 4 THEN 'Apr'
                WHEN 5 THEN 'May'
                WHEN 6 THEN 'Jun'
                WHEN 7 THEN 'Jul'
                WHEN 8 THEN 'Aug'
                WHEN 9 THEN 'Sep'
                WHEN 10 THEN 'Oct'
                WHEN 11 THEN 'Nov'
                WHEN 12 THEN 'Dec'
            END MonthAbrev
            ,DATEPART(day,D) MonthDay
            ,CASE DATEPART(weekday,D)
                WHEN 1 THEN 'Sun'
                WHEN 2 THEN 'Mon'
                WHEN 3 THEN 'Tue'
                WHEN 4 THEN 'Wed'
                WHEN 5 THEN 'Thu'
                WHEN 6 THEN 'Fri'
                ELSE 'Sat'
            END DayOfWeek
            ,DENSE_RANK() OVER (PARTITION BY DATEPART(year,D),DATEPART(month,D),DATEPART(weekday,D) ORDER BY D) DayWeekMonthOccurance
            ,COUNT(*) OVER (PARTITION BY DATEPART(year,D),DATEPART(month,D),DATEPART(weekday,D)) DayWeekMonthMax
            ,D
        FROM (
            SELECT DATEADD(day,t.N,@StartDate) D
            FROM (SELECT TOP(DATEDIFF(day,@StartDate,@EndDate) + 1) N - 1 N FROM Tally) T
            ) Days
        ) AllDays
    )
SELECT @EventName E, D FROM AllDays
WHERE (@ScheduleType = 'Daily')
    OR (WeekCount % @WeeklyX = 0 and @weeklyDays like '%'+DayofWeek+'%' and @ScheduleType = 'Weekly')
    OR (MonthDay = SUBSTRING(@MonthlyDayOfMonth,1,LEN(@MonthlyDayOfMonth)-2) and MonthCount % @MonthlyX = 0 and @ScheduleType = 'Monthly' and @MonthlyDayOfMonth IS NOT NULL and @MonthlyX IS NOT NULL)
    OR (MonthDay = SUBSTRING(@MonthlyDayOfMonth,1,LEN(@MonthlyDayOfMonth)-2) and @MonthlyMonths like '%'+MonthAbrev+'%' and @ScheduleType = 'Monthly' and @MonthlyDayOfMonth IS NOT NULL and @MonthlyMonths IS NOT NULL
    OR (DayWeekMonthOccurance = CASE WHEN @WeekDayOccurance like 'last %' THEN DayWeekMonthMax ELSE LEFT(@WeekDayOccurance,1) END and DayOfWeek = RIGHT(@WeekDayOccurance,3) and MonthCount % @MonthlyX = 0 and @ScheduleType = 'Monthly' and @WeekDayOccurance IS NOT NULL and @MonthlyX IS NOT NULL)
    OR (DayWeekMonthOccurance = CASE WHEN @WeekDayOccurance like 'last %' THEN DayWeekMonthMax ELSE LEFT(@WeekDayOccurance,1) END and DayOfWeek = RIGHT(@WeekDayOccurance,3) and @MonthlyMonths like '%'+MonthAbrev+'%' and @ScheduleType = 'Monthly' and @WeekDayOccurance IS NOT NULL and @MonthlyMonths IS NOT NULL)
    OR (@YearlyMonth like '%'+MonthAbrev+'%' and MonthDay = @YearlyDayOfMonth and YearCount % @YearlyX = 0 and @ScheduleType = 'Yearly' and @YearlyMonth IS NOT NULL and @YearlyDayOfMonth IS NOT NULL and @YearlyX IS NOT NULL)
    OR (DayWeekMonthOccurance = CASE WHEN @WeekDayOccurance like 'last %' THEN DayWeekMonthMax ELSE LEFT(@WeekDayOccurance,1) END and DayOfWeek = RIGHT(@WeekDayOccurance,3) and @YearlyMonth like '%'+MonthAbrev+'%' and @ScheduleType = 'Yearly' and @WeekDayOccurance IS NOT NULL and @YearlyMonth IS NOT NULL)
;
GO

Table
The search table for the event dates
CREATE TABLE SearchEvents (
    ID BIGINT IDENTITY (1,1) NOT NULL PRIMARY KEY,
    EventName VARCHAR(100) NOT NULL,
    EventDate DATE NOT NULL
    );

Table Population
An example of populating the SearchEvents table.  This example shows each of the Event patterns that are acceptable and will likely error if that format is deviated from.  Note the Months and Days are abbreviated.  The ending date is not required and will default to 31 Dec 2999.  But I would suggest that it is set.
INSERT INTO SearchEvents
SELECT Ex.E, Ex.D
FROM (VALUES
    ('Event A: Daily, Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event B: Weekly,  every 2 weeks on Mon,Tue Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event C: Monthly, every 2nd day of every 2 months Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event D: Monthly, every 3rd day of Jun,Jul,Dec,Jan Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event E: Monthly, every 2nd Tue of every 3 months Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event F: Monthly, every last Wed of Jun,Nov Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event B: Yearly, on Jun 10 every 1 years Starting 3 Jun 2010 Ending 5 Dec 2020')
    ,('Event H: Yearly, on 3rd Wed of Jun Starting 3 Jun 2010 Ending 5 Dec 2020')
)A(S) CROSS APPLY (SELECT * FROM parseEvent(S)) P
    CROSS APPLY (SELECT * FROM ExpandEvent(
        EventName,
        ScheduleType,
        StartDate,
        EndDate,
        WeeklyX,
        WeeklyDays,
        MonthlyDayOfMonth,
        MonthlyX,
        MonthlyMonths,
        YearlyMonth,
        YearlyDayOfMonth,
        YearlyX,
        WeekDayOccurance
    )) Ex

Indexing
The important part, indexing of the date field
CREATE INDEX SE_EventDate_IDX ON SearchEvents(EventDate) INCLUDE (EventName);
GO

Query
An example query
SELECT EventName, EventDate
FROM SearchEvents
WHERE EventDate BETWEEN CAST('1 Jan 2015' AS DATE) AND CAST('31 Dec 2015' AS DATE)
ORDER BY EventDate

This executed with the following stats on my machine.  1 years worth of events from ten years of data.
SQL Server parse and compile time:
   CPU time = 0 ms, elapsed time = 1 ms.

(435 row(s) affected)
Table 'SearchEvents'. Scan count 1, logical reads 5, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 98 ms.
SQL Server parse and compile time:
   CPU time = 0 ms, elapsed time = 0 ms.

 SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 0 ms.

It turns out it is pretty efficient with almost negligible cost to calculate at query time the events that will occur in a date range. Scales linearly against both number of days as well as number of schedules defined. Compared with the cost of calculating and storing 36500 records per "daily" event projected for 100 years, it's a clear winner. I'll give it a few days before sharing it.