text:
Can I Choose Not to Fly?
Inspired by a chat conversation I lurked.
I am an adventurer on the far away land of Zendikar. I truly enjoy traveling the land. Bushwhacking, weathering the roil and encountering strange and exotic flora and fauna are the highlights of any good adventure. Unfortunately, my duties as an adventurer do not always allow me to stop and smell the lotuses. Occasionally I am crunched for time and must hop on my kitesail and fly to my destination. I just glide over the land without being able to enjoy it.
The Challenge
Write a program that will let me know if I can choose not to fly. The program will take three inputs: my current location, my destination, and the maximum permitted travel time in days. Using the information below, determine if my travel time on foot is less than my maximum allowed travel time. If it is and I can travel on foot, return a truthy value. If the land travel time is as long as or longer than the maximum time, return a falsey value.
Guul Draz is two days away from Sejiri, its only neighboring territory.
Sejiri is one day away from Murasa and two days from Guul Draz.
Murasa is one day from Bala Ged,  one day from Akoum, two days from Tazeem, and one day from Sejiri.
Bala Ged is two days from Akoum and one day from Murasa.
Akoum is one day from Ondu, one day from Murasa and two days from Bala Ged.
Ondu is one day from Akoum, its only neighboring territory.
Tazeem is two days from Murasa, its only neighboring territory.
Every location is connected, but not always directly. For example, going from Tazeem to anywhere requires you to travel to Murasa first. There are no real branches in the path either. Protip: Only go to Bala Ged if it is one of your endpoints. Here is a rough map if you're lost:
                        Bala Ged --
                           |       \
Guul Draz ---- Sejiri -- Murasa -- Akoum -- Ondu
                            |
                            |
                         Tazeem

Scoring
This is code golf, so shortest program wins. Standard loopholes apply.
Test Cases
Guul Draz
Ondu
5

False

Bala Ged
Akoum
3

True

Tazeem
Sejiri
1

False

Wait, I actually won this one? Someone who knows an actual golfing language could win in like 20 bytes.

@ThomasKwa Well it's been a while and nobody's done it. If a shorter one comes along I'll change the accepted answer.

TI-BASIC, 84 82 bytes
Prompt Str1,Str2,X
"GSMAOBT->Str3
{-3,-1,0,1,2,i,-2i
Ans(inString(Str3,sub(Str1,1,1))-Ans(inString(Str3,sub(Str2,1,1
X>real(Ans-iAns

I store the positions of each city on the complex plane, then calculate the Manhattan distance. Bala Ged is at 0+1i, Guul Draz is at -3+0i, and so on.
There would be a 75-ish byte solution if quotes could be in strings, but one of TI-BASIC's limitations prevents that.

How can "GSMAOBT"allow you to establish which locations are directly connected to which?

@DavidCarraher The travel time happens to be equal to the Manhattan distance between some positions I assign them. So Guul Draz can be at (-3,0), Sejiri at (-1,0) and so on.

Clever idea!  Congrats.

Mathematica 153
This checks whether the required time to travel (the GraphDistance in Edgeweights, i.e. days), is less than or equal to the available time to travel, also in days.  This sort of approach should work with much larger graphs, corresponding to a great many locations and connections.
s=StringTake;g=Graph[UndirectedEdge@@@Partition[Characters@"GSSMMBMAMTBAAO",2],
EdgeWeight->{2,1,1,1,2,1,1}]
f[a_,b_,n_]:=GraphDistance[g,a~s~1,b~s~1]<=n

Ruby 113/112
More bytes than TI Basic, but less characters.
v=0
a=(0..1).map{c=gets[0];(d="BT".index(c))&&v+=1+d;"GGSMAO".index(c.tr('BT',?M))}
p gets.to_i>(a[0]-a[1]).abs+v

v=0
a=(0..1).map{c=gets[0];(d="BT".index(c))&&v+=1+d;"OAMSSGGGBBBBBBT".index(c)%6}
p gets.to_i>(a[0]-a[1]).abs+v

Two slightly different solutions, on the same principle:
There's no point in considering the direct route between Bala Ged and Akoum, because the route via Murasa is the same length.
The main left-right string of places can be considered by taking the indices in a string and finding the difference between them.
For B and T, we need to add an extra 1 or 2. This is held in the variable v. The two versions differ in the way that B and T are made to give the same index in the main string as M. In the first, it's done by replacement B or T --> M in the input. In the second it's done by modulo (I prefer the first one, but the second one's a byte shorter.)

05AB1E, 44 bytes
"GSMAOBT"D2FsIнk])εyy0Qi¼ëy4›i2¼y5-½]`α¾+³-d

Try it online!
A little too long to be proud of
"GSMAOBT"   push the first letters of each city
D           duplicate this
2F          do 2 times:
  s           swap the two previous stack entries
  I           get next input
  н           get the first letter of that
  k           push the index of that letter in "GSMAOBT"
]
)           push both indexes in a list

ε           for each entry of that list
  y           push the current value for that entry
  y0Qi        if current entry == 0 (Guul Draz)
  ¼           increment counter (will be added to the distance in the end)
ë           else
  y4›i        if current entry > 4 (Bala Ged or Tazeem)
    2           set current list entry = 2 (Murasa)
    ¼           increment counter
    y5-½        if entry = 4 (Tazeem), increment counter another time
]
`           push both indexes on the stack separated
α           get absolute difference of them
¾+          add the counter variable to that
³-d         check, if it's equal or smaller than the maximum time

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


text:
Monday Mini-Golf #2: Truncating long text
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
Many web applications (especially social media) automatically truncate long passages of text so they fit within the app's formatting. In this challenge, we're going to create an algorithm to automatically trim a passage of text to a certain length.
Challenge
The goal of the challenge is to write a program or function that takes in two arguments:

T, the text to truncate.
L, the maximum length to return.

And returns T, truncated with the following logic:

If the length of T is less than or equal to L, no truncation is needed. Return the original string.
Truncate T to length L-2. If this contains no spaces or hyphens, return T truncated to exactly L-3 characters, followed by an ellipsis ....
Otherwise, trim the end of the result up to the last space or hyphen. Add an ellipsis ... and return the result.

Details

T and L may be taken in either order and any format.
You may assume that 3 < L < 231.
You may not use U+2026 Horizontal Ellipsis …; you must use three periods.
The input will not start with a space or a hyphen.
The input will not contain any whitespace other than regular spaces. (No tabs, newlines, etc.)

Test-cases
Inputs:
"This is some very long text." 25
"This-is-some-long-hyphen-separated-text." 33
"Programming Puzzles & Code Golf is a question and answer site for programming puzzle enthusiasts and code golfers." 55
"abcdefghijklmnopqrstuvwxyz" 20
"a b c" 4
"Very long." 100

Outputs:
"This is some very long..."
"This-is-some-long-hyphen..."
"Programming Puzzles & Code Golf is a question and..."
"abcdefghijklmnopq..."
"a..."
"Very long."

(Note that the quotes are just to specify that these are strings; they need not be included.)
Scoring
This is code-golf, so shortest valid code in bytes wins. Tiebreaker goes to submission that reached its final byte count first. The winner will be chosen next Monday, Oct 5. Good luck!
Edit: Congrats to your winner, @Jakube with Pyth again, with 25 bytes!

Answers to this challenge should be a standard feature in their respective languages. Too often I have seen UI that feature bad trunca...

... "Otherwise, trim the end of the result up to and "
NOT
" including the last space or hyphen."
Right?

Will the text have any tabs?

@anatolyg No, because then the final space or hyphen would appear before the ellipsis.

@kirbyfan64sos Nope. I'll add that to the Details section.

@ETHproductions .trim() returns the trimmed text. trim including the space implies the trimmed text should have the space in it; abc!def trimmed up to the exclamation is abc, trimmed up to and including the exclamation is therefore abc!...

@TessellatingHeckler Thanks for the info; I've fixed that sentence.

Can T start with a space or hyphen? In this case, if we were to truncate it, and it didn't contain any other space or hyphen, would we want to simply return ...? Yeah old challenge...

@EriktheOutgolfer I'll say you don't have to handle that case. (Is there some hat awarded for answering old questions? :p)

Pyth, 25 bytes
+WnzK<zeo}@zN" -"-Q2K"...

Try it online: Demonstration or Test Suite
Explanation:
+WnzK<zeo}@zN" -"-Q2K"...  implicit: z = input string, Q = input number
        o        -Q2       order the indices N in [0, 1, ..., Q-3] by
         }@zN" -"            z[T] in " -"
                           (hyphen-indices get sorted to the back)
       e                   take the last such number
     <z                    reduce z to length ^
    K                      save this string to K
+WnzK               K"...  print (K + "...") if z != K else only K

I like the way the code trails off at the end...

Perl, 69 59 52 bytes
51 bytes code + 1 byte command line. Assumes numerical input is allowed to be given with -i parameter.
s/.{$^I}\K.*//&&s/(^([^ -]*).|.*\K[ -].*)..$/$2.../

Usage:
echo "This-is-some-long-hyphen-separated-text." | perl -p -i"33" entry.pl

JavaScript (ES6), 123 78 67 61 bytes
I didn't expect to be able to cut this down so much, but it turns out the splice/replace combo is able to cover every case where truncation is needed.
(T,L)=>T[L]?T.slice(0,L-2).replace(/([ -][^ -]*|.)$/,'...'):T

First argument is the string, second is the length. Special thanks to edc65 for the length check optimization!
Here's the original code (123 bytes):
(T,L)=>(T.length>L?(S=T.slice(0,L)).slice(0,(m=Math.max(S.lastIndexOf` `,S.lastIndexOf`-`))<0?L-3:Math.min(L-3,m))+'...':T)

Clever! +1. Tip: often you don't need .length to check the length of a string (T,L)=>T[L]?T.slice(0,L-2).replace(/([ -][^ -]*|.)$/,'...'):T score 61

@edc65 Doh! I had been looking for an optimization on the length check, thinking there had to be some way to trim that down, but your method hadn't occurred to me. Excellent suggestion! :D

You can replace [ -][^ -] with  \s\S to save 5 more bytes

Great solution! @ShaunH, if he does that it won't work for the hyphens, surely?

@Jarmex Silly brain, yeah it most definitely does not.

Python 2, 78 73 bytes
t,l=input()
u=t[:l-2]
print(t,u[:max(map(u.rfind,' -'))]+'...')[l<len(t)]

Input format follows the example input.

A familiar name from Anarchy Golf. Welcome!

TI-BASIC, 87 bytes
Prompt L,Str1
For(X,1,L
{inString(Str1," ",X),inString(Str1,"-",X
max(I,max(Ans*(Ans≤L-3->I
End
Str1
If L<length(Ans
sub(Ans,1,I+(L-3)not(I))+"...
Ans

TI-BASIC doesn't have many string manipulation commands, so we need to find the last index manually: if the string doesn't contain the string to search for, inString( returns 0. We search for hyphens and spaces starting at every position from 1 to L, and record the greatest number less than or equal to L-3. If that number I is still 0, we use L-3 as the ending index instead.
Due to the calculator's limitations, the largest addressable index of a string is 9999; therefore, this will fail for larger strings.
I rely on the calculator's behavior of automatically initializing the variable I to 0, so delete I or clear your calculator's memory before running.

There's a shorter solution using lists to find the greatest index, but then the size limit would be ~500, not 9999.

Python 2, 105 bytes
def t(s,l):a=s[:l-2];return s[:max(a.rfind(' '),a.rfind('-'))]+'...'if' 'in a or'-'in a else a[:-1]+'...'

Called with
>>> print t("This is some very long text.", 25)
This is some very long...

C# .NET, 187 169 bytes
Hmm...
string f(string T,int L){if(T.Length<=L)return T;T=T.Substring(0,L-2);return T.Substring(0,T.Contains(" ")||T.Contains("-")?T.LastIndexOfAny(new[]{' ','-'}):L-3)+"...";}

yes of course, I just removed spaces to decrease bytes.

C# (157):
Based on the answer of Salah Alami, but shorter. The string class derives from IEnumerable<char>, so instead of T.Contains(" ")||T.Contains("-"), I use " -".Any(x=>T.Contains(x)).
Solution:
string f(string T,int L){if(T.Length<=L)return T;T=T.Substring(0,L-2);return T.Substring(0," -".Any(T.Contains)?T.LastIndexOfAny(new[]{' ','-'}):L-3)+"...";}

Ungolfed:
string f (string T, int L)
{
    if (T.Length <= L)
        return T;

    T = T.Substring(0, L - 2);

    return T.Substring(0, " -".Any(T.Contains) ? T.LastIndexOfAny(new[]{' ', '-'}) : L - 3) + "...";
}

Update:
Saved 6 bytes thanks to the comment of SLuck49, using Any(T.Contains) instead of Any(x=>T.Contains(x)).

For .Any(x=>T.Contains(x)) you can directly use the method instead of a lambda like .Any(T.Contains) to save 6 bytes

@SLuck49 thanks, updated my answer.

POSIX shell + GNU sed, 65 bytes
sed -re "s/(.{$1}).+/\1/;T;s/(.*)[- ]...*/\1.../;t;s/...$/.../;:"

This is a job made for sed!  But I needed shell to get the length limit in (perhaps Perl would be better).  The sed part expands out to a fairly simple sequence, with conditional jumps when we finish:
s/(.{$1}).+/\1/
T
s/(.*)[- ]...*/\1.../
t
s/...$/.../
:

GS2, 29 bytes
This program takes standard input.  The first line is the string, and the second is the target length number.
2a 0e 56 3c 40 a0 74 20 22 22 04 5d 2e 2a 3f 5b
20 2d 5d 7c 2e 07 2e 2e 2e 9d 20 e4 35

GS2 code can be a bit hard to read sometimes. :)  Here's some commentary.
2a         # lines - split input on newlines yielding a two element array
0e         # extract-array - pop array, push both elements
56         # read-num - convert length string to number
3c         # take - truncate the string to specified length
40         # dup - duplicate truncated string on stack
a0         # junk1 - push the last popped value, the un-truncated string
74         # ne - test for inequality
    20     # reverse string
    22 22  # tail tail - remove first two characters

    # regex replace first occurrence of ".*?[ -]|." with "..."
    04 5d 2e 2a 3f 5b 20 2d 5d 7c 2e 07 2e 2e 2e 9d

    20     # reverse string
e4         # block5 - make a block out of last 5 instructions
35         # when - conditionally execute block

Groovy, 95 bytes
a={T,L->F=T.size()<=L?T:T[0..L-3]
m=F=~'(.*[- ])'
F==T?F:m?m[0][0].trim()+'...':F[0..-2]+'...'}

Pretty straightforward, can probably be golfed further

CJam, 34 bytes
q~1$<_@={-2<_W%{" -"&}#~We|<'.3*}|

Try it online: Chrome | Firefox

T-SQL,145 bytes
create proc a(@t varchar(max),@l int)as if LEN(@t)<=@l return @t;set @t = LEFT(@t,@l-3) select LEFT(@t,LEN(@t)-CHARINDEX('-',REVERSE(@t)))+'...'

usage:
exec a("This is some very long text.", 25)
 exec a("This-is-some-long-hyphen-separated-text.", 33)

Groovy, 56 bytes
Copied Kleyguerth's answer first, hence the same variable names...
Trim the string down by 2 chars, then most of the work is done by the regex, replace a dash or a space followed by any number of chars that are not a dash or a space at the end of the string with a "." OR replace any character at the end of the string if all the chars before it are neither a dash or a space with a ".". Harder to put into words than to write the regex...
a={T,L->T.size()<=L?T:T[0..L-3].replaceAll("([- ][^ -]*|(?<=[^- ]*).)\$",".")+".."}

Edit: Actually, can just remove the part of the string that matches the regex and add "..." at the end:
a={T,L->T.size()<=L?T:T[0..L-3]-~/[- ][^ -]*$|.$/+"..."}

rs, 116
(\d+)$/(_)^^(\1)
___$/
\t
+\t(.)(.*) (_)(_*)$/\1\t\2 \4
\t(.*?)_+$/\1\t
\t( ?).+/\1
[- ][^- \t]*$/
(?<!\t)$/...
 \t/

At least it's shorter than C#...
Live demo and test cases.

Ceylon 386 333 252 230 222 216 171 153 131 111
String t(String s,Integer l)=>s.size<l then s else s[0:(s[0:l-2].lastIndexWhere(" -".contains)else l-3)]+"...";

Ungolfed Original:
String truncate(String text, Integer length) {
    if(text.size < length) {
        return text;
    }
    Boolean spacePredicate(Character char) {
        return char == ' ' || char == '-';
    }
    Integer? spaceIndex = text[0:length-2].lastIndexWhere(spacePredicate);
    if(exists spaceIndex) {
        return text[0:spaceIndex] + "...";
    }
    return text[0:length-3]+"...";
}

This is 386 bytes/characters.
Some interesting features here:
The x[y:z] syntax is syntactic sugar for x.measure(y, z), and returns a subrange of x starting at y with length z – for strings, this is a substring. (There is also x[y..z] syntax, which is a span from index y to z, both inclusive, as well as half-open spans x[...z] and x[y...].)
List.lastIndexWhere takes a predicate (i.e. a function taking a list element and returning a boolean, i.e. here a Callable<Boolean, [Character]>), and gives the index of the last list element where the predicate is fulfilled (or null, if it's never fulfilled). As strings are lists, this works for strings too.
The result of this, spaceIndex is of type Integer|Null, or Integer? for short – i.e. it can either be an Integer or null (the only value of type Null). (The name spaceIndex comes from when I didn't realize that - was also special – I guess breakIndex would be better.)
With exists spaceIndex we can check if spaceIndex is non-null, and do something different then. (Inside this if-block the compiler knows that it is non-null ... without that it would have complained if I used spaceIndex to access the string.)
Instead of the local function spacePredicate we can also use an anonymous function
(Character char) => char == ' ' || char == '-'

This brings us to 333 characters:
String truncate(String text, Integer length) {
    if(text.size < length) {
        return text;
    }
    Integer? spaceIndex = text[0:length-2].lastIndexWhere(
        (Character char) => char == ' ' || char == '-');
    if(exists spaceIndex) {
        return text[0:spaceIndex] + "...";
    }
    return text[0:length-3]+"...";
}

Next optimization is to use shorter variable and function names, which brings us down by 81 bytes to 252:
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    Integer? i = s[0:l-2].lastIndexWhere(
        (Character e) => e == ' ' || e == '-');
    if(exists i) {
        return s[0:i] + "...";
    }
    return s[0:l-3]+"...";
}

The predicate function actually doesn't need its argument type declared, that can be inferred by the compiler. Same for the type of i (where we still have to write value to mark it as a declaration). Now that declaration is short enough to fit on one line, bringing us down to 230:
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    value i = s[0:l-2].lastIndexWhere((e) => e == ' ' || e == '-');
    if(exists i) {
        return s[0:i] + "...";
    }
    return s[0:l-3]+"...";
}

Instead of e == ' ' || e == '-' we can also write e in [' ', '-'] (or e in {' ', '-'}, this is an iterable constructor instead of a tuple one).
The in operator maps to the method Category.contains, which brings us to the idea that we can pass that tuple's contains method directly (it is a callable taking any object, so also accepting character), without the (e) => ... boilerplate (222 bytes):
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    value i = s[0:l-2].lastIndexWhere([' ', '-'].contains);
    if(exists i) {
        return s[0:i] + "...";
    }
    return s[0:l-3]+"...";
}

Actually, another category containing the same two characters is the two-character string " -". (In addition it also contains its substrings, but that doesn't hurt here). 216 bytes.
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    value i = s[0:l-2].lastIndexWhere(" -".contains);
    if(exists i) {
        return s[0:i] + "...";
    }
    return s[0:l-3]+"...";
}

I guess we got the most out of this line, let's turn to the others ... the last two return statements have some similarity which we can exploit – they just differ in i vs. l-3, and are using i just when it is not null, otherwise l-3. Fortunately this is exactly what the else operator is made for!
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    value i = s[0:l-2].lastIndexWhere(" -".contains);
    return s[0:(i else l-3)] + "...";
}

(The parentheses seem to be needed here, as else has a lower precedence than [:].) This is 171 characters. Now i is used just once, so we can inline it, bringing us to 153 characters:
String t(String s, Integer l) {
    if(s.size < l) {
        return s;
    }
    return s[0:(s[0:l-2].lastIndexWhere(" -".contains) else l-3)] + "...";
}

We can also replace this if-return-return combination by a combination of the then and else operators in one return. (then returns is second operand when the first one is true, otherwise null, which then allows else to return its second operand.`) 131 bytes (although some of the savings are the white spaces which we'll get rid off anyways):
String t(String s, Integer l) {
    return s.size < l then s else s[0:(s[0:l-2].lastIndexWhere(" -".contains) else l-3)] + "...";
}

A function which contains just one return with an expression can alternatively be written with the "fat arrow" notation, giving 123:
String t(String s, Integer l) =>
    s.size < l then s else s[0:(s[0:l-2].lastIndexWhere(" -".contains) else l-3)] + "...";

Removing the unneeded whitespace gives us the final 111 bytes:
String t(String s,Integer l)=>s.size<l then s else s[0:(s[0:l-2].lastIndexWhere(" -".contains)else l-3)]+"...";
As an addition, here is a function which prints the examples from the question (using the name t which is used after step two):
shared void testTruncate() {
    value testInputs = {
        ["This is some very long text.", 25],
        ["This-is-some-long-hyphen-separated-text.", 33],
        ["Programming Puzzles & Code Golf is a question and answer site for programming puzzle enthusiasts and code golfers.", 55],
        ["abcdefghijklmnopqrstuvwxyz", 20],
        ["a b c", 4],
        ["Very long.", 100]
    };
    for(input in testInputs) {
        print(t(*input));
    }
}

Mathematica 192 bytes
t=With[{r=StringTake[#,Min[#2-2,StringLength[#]]],p={"-",Whitespace},e="..."},
  Which[StringLength[#]<=#2,#,StringFreeQ[r,p],StringDrop[r,-1]<>e,
   True,StringTake[r,Max[StringPosition[r,p]]-1]<>e]]&

Called as
t["This is some very long text.", 25]

><>, 74 bytes
l$-:1)?\~r05.
/?=0:~$<-1
\}:0=  ?\::"- "@=@=+?
>~"..."r\}
/!?     <
>ol?!;

This solution requires the string to be truncated and L to already be on the stack, in that order.
There's 7 wasted bytes caused by alignment issues, still trying to golf those out.

Jelly, 29 bytes
ḣṖṖe€⁾ -œṗƊṖȯ$Ẏḣ⁹_3¤”.⁺⁺ðL>¥¡

Try it online!
Full program.

Clean, 89 bytes
import StdEnv
$n l|size l>n=l%(0,last[n:[i\\i<-[2..n]&c<-:l|c==' '||c=='-']]-3)+++"..."=l

Try it online!
As a function $ :: Int String -> String

C# (Visual C# Interactive Compiler), 117 bytes
a=>b=>a.Length>b?a.Substring(0,(" -".Any(x=>a.IndexOf(x,0,b-2)>-1)?a.LastIndexOfAny(new[]{' ','-'},b-2):b-3))+"...":a

Based off of @Abba's, which is based off of @Salah Alami's answer. Instead of using Contains and an unnecessary Substring call, it uses IndexOf to check if a hyphen or space exists in the truncated string.
Try it online!

source: Stack Exchange

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

sort: votes


text:
3-D Antiferromagnetism
A while ago, we had a challenge related to antiferromagnetism (AF) in two dimensions.  Now, on a  2-d square lattice, antiferromagnetic is antiferromagnetic, and that is all there is to it.  Moving to other lattice types or higher dimensionality, things get more interesting.  Here, we will explore the second route: magnetic order on the 3-d cubic lattice1.
We will consider the following spin patterns, as illustrated in the figure.  The cubes are repeated periodically in every direction (“periodic boundary conditions”).

G-type is the most straightforward generalization from 2-D AF: antiferromagnetic in all directions
A-type: antiferromagnetically coupled ferromagnetic planes
C-type: ferromagnetically coupled antiferromagnetic planes (a.k.a “checkerboard”)
D-type: criss-crossing stripes
E-type and F-type: “ferrimagnetic planes”?
B-type is ferromagnetic (FM) order

adapted from E. Dagotto, Nanoscale phase separation and colossal magnetoresistance
The challenge
Your code should take a string as input specifying a magnetic order and a lattice plane, and output the spin arrangement on that plane, in the orientation specified below.  Output should be “drawn“ in some sense: writing to STDOUT, graphical output, or similar; a function returning a string is not enough.
You must support at least A-, C-, and G-type (the more familiar AF arrangements); B-, E-, and F-type may be supported optionally.  Your score will be code length per order type supported.
Input
Input will be of the form S (a b c), i.e., a token S specifying the order type, a space, and three integers a,b,c defining a lattice plane, enclosed in parentheses and delimited by spaces.
The string S will be either “AF-T” with T ∈ {A, C, D, E, F, G} for the antiferromagnetic cases, or “FM” in the ferromagnetic case (B).
We define the following coordinate system relative to the figure: the x-axis points to the right, the y-axis into the screen, and the z-axis upwards;  the origin is the lower left front corner of the cube, and the lattice parameter (the side length of the cube) will be 1.
For simplicity, exactly one of the integers a,b,c will be nonzero.  The plane of projection is perpendicular to the corresponding axis and displaced from the origin by that number of  unit cells.2  To get the proper orientation, look along the axis of displacement in positive/negative direction according to the displacement, and rotate such that the first in-plane axis (alphabetically: y for the yz-plane, x otherwise) increases to the right.  Examples are given below.
Output
On the selected plane, the spins are arranged on a square lattice.  Your code should draw 2×2 spins (the “magnetic unit cell”) on this plane, taking into account the periodicity and the proper orientation.
A ↑ by any other name …
Spin “up” and “down” are just names,3 and I do not want to limit your artistic freedom.  Choose any (visually distinguishable) symbols for the spin directions you like, they only have to be consistent and laid out on a “square” lattice (as rectangular as necessary according to output format).  You can use ASCII/Unicode art, graphical output, what have you.  Leading or trailing white space does not matter.
Examples of input, valid output, and orientation
A (0 0 1)  C (1 0 0)  D (0 0 2)  E (0 1 0)  F (0 -2 0)  G (0 0 7)
   - -       ↓  ↑        ud         0 1       ->  ->        •
   - -       ↓  ↑        ud         1 0       ->  <-       •

  --> x      --> y      --> x      ^ z         --> x       --> x
  |          |          |          |           |           |
  V y        V z        V y        --> x       V z         V y

Scoring
Your score is B/O, the length B of your code in bytes divided by the number of patterns O your code supports (O is between 3 and 7).  Smallest score wins.
In your answer, please indicate (i) code length, (ii) supported orders, and (iii) sample output, and (iv) the correspondence of your symbols with + and - in the figure, if yours are different.
1. Which is the analogue of the square lattice in three dimensions.  The general term would be “hypercubic”.
2. They are a perverted variation of Miller indices.
3. We are being strictly non-relativistic here.

Ruby Rev 1, 176/7 = 25.14
Problem with negative inputs fixed: m>>9&2 shifts the characters by 2 when m is negative.
Magic strings with non-ASCII characters proved problematic: they produced syntax errors. So I just compressed the data to a hexadecimal number instead.
a=gets.delete("()").split
m=e=0
4.times{|i|m+=b=a[i].to_i;b>0&&e=i-1}
4.times{|c|print 0xFFF9935871769>>568-a[0].ord*8+(" j\204\316"[c-(m>>9&2)].ord>>e*3&7^m%2<<e)&1,"
"[c%2]}

Ruby Rev 0, 174/7 = 24.86
work in progress. I just realized I missed a rule: I have to flip the output vertically when the input is negative. Once checked and clarified I will golf the magic strings / arrays down to single characters.
a=gets.delete("()").split
m=e=0
4.times{|i|m+=b=a[i].to_i;b>0&&e=i-1}
" j\204\316".bytes{|c|print [15,255,153,53,135,23,105][a[0].ord-65]>>(c>>e*3&7^m%2<<e)&1,c==106?"\n":''}

The first magic string contains 4 bytes, corresponding to the first, second, third and 4th symbol to be printed. Each is a 3-digit octal number indicating which bit of the data in the array should be displayed. The table looks like this. Note that the odd values differ from the even ones by a power of 2 so only the even values need be stored. Fortunately the z values never exceed 3, so it's possible to get the 3 octal digits into 1 byte.
nonzero digit    x    y    z
                02   45   01
even            46   01   23

                13   67   45
odd             57   23   67

Output
I use 1 for +, 0 for - . I didnt bother with the output for B because it's just plain 1's.
A 1 0 0
11
00
A 2 0 0
11
00
A 0 1 0
00
11
A 0 2 0
00
11
A 0 0 1
00
00
A 0 0 2
11
11

C 1 0 0
01
01
C 2 0 0
10
10
C 0 1 0
01
01
C 0 2 0
10
10
C 0 0 1
10
01
C 0 0 2
10
01

D 1 0 0
00
10
D 2 0 0
11
10
D 0 1 0
00
10
D 0 2 0
11
10
D 0 0 1
11
00
D 0 0 2
10
10

E 1 0 0
10
01
E 2 0 0
11
00
E 0 1 0
01
10
E 0 2 0
00
11
E 0 0 1
00
01
E 0 0 2
11
10

F 1 0 0
10
00
F 2 0 0
11
10
F 0 1 0
00
10
F 0 2 0
10
11
F 0 0 1
10
00
F 0 0 2
11
10

G 1 0 0
01
10
G 2 0 0
10
01
G 0 1 0
10
01
G 0 2 0
01
10
G 0 0 1
01
10
G 0 0 2
10
01

Octave, 809/7 ≈ 115.57
This is a reference implementation supporting all 7 order types (not quite, since it does not parse the input string), ungolfed.
Output for all distinct inputs is available for download.  Assuming the implementation is correct, there are 13 distinct outputs, two of which are unique; one more occurs twice; all others at least four times.
format plus "+-."

A = ones(2,2,2);
A(:,:,2) = -1;

B = ones(2,2,2);

C(:,:,1) = [ 1 -1; -1  1];
C(:,:,2) = C(:,:,1);

D(:,:,1) = [ 1  1; -1 -1];
D(:,:,2) = D(:,:,1)';

E(:,:,1) = [ 1  1;  1 -1];
E(:,:,2) = -E(:,:,1);

F(:,:,1) = E(:,:,1);
F(:,:,2) = [ 1 -1; -1 -1];

G(:,:,1) = C(:,:,1);
G(:,:,2) =-G(:,:,1);

function SP = afmproj(S, idx)
  dim = find(idx)(1);
  idx = idx(dim);
  sgn = sign(idx);
  idx = mod(idx, 2) + 1;

  switch dim
    case 1
      SP = S(idx,:,:); flp = sgn==+1;
    case 2
      SP = S(:,idx,:); flp = sgn==-1;
    case 3
      SP = S(:,:,idx); flp = sgn==+1;
  endswitch

  SP = rot90(reshape(SP,2,2));

  if flp
    SP = flipud(SP);
  endif
endfunction

function afmproj_pretty(Str, S, idx)
  printf('%s (%2i %2i %2i)\n', Str, idx);
  disp(afmproj(S, idx));
  disp('')
endfunction

Cool. I've looked through your outputs for A and F, that's where i realised I'd missed the rule about looking along the axis in the positive/negative direction. Could you provide the outputs in an easier format? Individual 6-bit files take about 10-15 seconds each to preview, a single file / document would be easier to manage.

@steveverrill I added a file to the link containing all the inputs and outputs in a table, I hope that works for you.  I guess I was thinking more of automated than manual checking (note that you can download the whole shebang in a zip file).

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


text:
Generating Picture Mazes
Challenge
Write a program/function that accepts an "image" and outputs a picture maze formed from that image.
Input
Your program should accept two arguments:

I, the image to form the maze from
S, a boolean specifying whether or not to display the solution to the maze

I is given in the following form:
.......
.#####.
.#####.
#######
.#####.
.#####.
.......

where #'s are cells to be included in the solution path and .'s are cells to be excluded.
You may swap out the .'s, #'s and newlines with any character of your choosing as long as they differ from each other.
Alternatively, you may accept an actual bitmap of the input image.
Output
Your resulting maze should be in the following form:
###############
#             #
# ### ####### #
# #.........# #
# #.#######.# #
# #.#.......# #
###.#.#########
....#.#........
#####.#.#######
#  ...#.....  #
# #.#######.# #
# #.........# #
# ####### ### #
#   #       # #
###############

where #'s denote walls, .'s denote portions of the path that are part of the solution, and spaces are paths excluded from the solution. The .'s may be replaced by spaces if S is false. Again, characters may be swaped with other characters of your choosing or you may output an actual bitmap of the maze with the solution highlighted.
Additional Details

Paths must be one cell wide (cannot have giant pool of empty space be the path)
The maze must not contain any loops
The maze must be fully connected (all cells must be reachable from the entrance/exit)
The maze must be surrounded by walls (unless its an entrance/exit)
The solution path must not include dead-ends
There must be exactly 1 entrance and 1 exit for the maze
The entrance and exit must be aligned to the edge of the grid and adjacent to a cell included in the solution path
You may choose where the entrance and exit are placed
You may assume that a valid path can be formed from the given input image

(Added for clarification) The diagram below shows how the solution path is correlated to the input image:
Input (I): |    Output:            |    Corresponding Cells:
           |                       |    (@'s denote #'s from I)
           |                       |
.......    |    ###############    |    ###############
.#####.    |    #             #    |    #             #
.#####.    |    # ### ####### #    |    # ### ####### #
#######    |    # #.........# #    |    # #@.@.@.@.@# #
.#####.    |    # #.#######.# #    |    # #.#######.# #
.#####.    |    # #.#.......# #    |    # #@#@.@.@.@# #
.......    |    ###.#.#########    |    ###.#.#########
           |    ....#.#........    |    .@.@#@#@.@.@.@.
           |    #####.#.#######    |    #####.#.#######
           |    #  ...#.....  #    |    #  @.@#@.@.@  #
           |    # #.#######.# #    |    # #.#######.# #
           |    # #.........# #    |    # #@.@.@.@.@# #
           |    # ####### ### #    |    # ####### ### #
           |    #   #       # #    |    #   #       # #
           |    ###############    |    ###############
           |                       |

Test Cases
Watering can example from Wikipedia:
Input:
..................
..................
.......####.......
......##..##......
.....##....##....#
.....#......#...##
.#############.##.
##..############..
#...###########...
#...##########....
#...##########....
#...##########....
#...##########....
....##########....
....##########....
....##########....
..................
..................

Output (S=false):
#####################################
#   #     #   #   #     #           #
# ### ### ### # # ##### ### ### ### #
#     # #   # # #         # #   # # #
# ### # ##### # ########### # ### # #
# # #         #           # # #   # #
# # # ### ##### # ### ### # ### ### #
#   # # #   #   # # #   # #   # #   #
# ### # ##### ##### ### ##### # # ###
# #   #       #   #   #       # # #
### ####### ### ### # ### ##### ### #
#   #     # #   #   #   # #   # #   #
# ### ##### # ### ####### # # # # # #
# #       #             #   # #   # #
# # ##### ############# ### ### ### #
#   #   #       #     #   # #   # # #
# ### # ####### # ### ### # # ### # #
# # # #         #   # #   #   #     #
# # # ### ######### # # ##### # #####
# #   # # #       # #   #   # # #   #
# ##### # # ##### # ##### # # ### # #
#       # #   #   # #     # #   # # #
# ### ### ### # ### # ##### ####### #
#   # # #     # #   # #       #     #
# # # # ####### # ### # ##### # ### #
  # # # #   #   #     #     # #   # #
### # # # # # ############# # ### # #
#   # # # #   #         #   # #   # #
##### # # ##### ####### # ### ##### #
#     # # #   #       # #   #       #
##### # # # # ####### # ### #########
#     #     #         #       #     #
# ### ######### ############# # #####
# # #   #     # #       #     #     #
# # ######### # ####### ####### ### #
#             #                 #   #
#####################################

Output (S=true):
#####################################
#   #     #   #   #     #           #
# ### ### ### # # ##### ### ### ### #
#     # #   # # #         # #   # # #
# ### # ##### # ########### # ### # #
# # #         #.......    # # #   # #
# # # ### #####.# ###.### # ### ### #
#   # # #   #...# # #...# #   # #   #
# ### # #####.##### ###.##### # # ###
# #   #    ...#   #   #...    # # #..
### #######.### ### # ###.##### ###.#
#   #     #.#   #   #   #.#   # #...#
# ### #####.# ### #######.# # # #.# #
# #.......#.............#...# #...# #
# #.#####.#############.###.###.### #
#...#   #.......#.....#...#.#...# # #
#.### # #######.#.###.###.#.#.### # #
#.# # #  .......#...#.#...#...#     #
#.# # ###.#########.#.#.##### # #####
#.#   # #.#.......#.#...#...# # #   #
#.##### #.#.#####.#.#####.#.# ### # #
#.      #.#...#...#.#.....#.#   # # #
#.### ###.###.#.###.#.#####.####### #
#.  # # #.....#.#...#.#.....  #     #
#.# # # #######.#.###.#.##### # ### #
..# # # #...#...#.....#.....# #   # #
### # # #.#.#.#############.# ### # #
#   # # #.#...#.........#...# #   # #
##### # #.#####.#######.#.### ##### #
#     # #.#...#.......#.#...#       #
##### # #.#.#.#######.#.###.#########
#     #  ...#.........#.....  #     #
# ### ######### ############# # #####
# # #   #     # #       #     #     #
# # ######### # ####### ####### ### #
#             #                 #   #
#####################################

Bitmap example (same maze as above):
Input:  Output (S=false):  Output (S=true):

It might just be me, but I don't see the input picture in the output maze.

@mike-bufardeci Added a diagram showing the input picture in the output maze. Hope that helps!

There doesn't seem to be a rule requiring that the maze is connected. Would this be a valid solution? There also doesn't seem to be a rule that the grid must be surrounded by walls (unless every non-wall is considered an entrance or exit). Would this be a valid solution?

Also, please add some more test cases.

@MartinBüttner The maze should be fully connected and surrounded by walls, edited the question clarifying these points.

@flawr Added more test cases.

Python 3, 1491 Bytes
I found this to be a fun project and very interesting (and somewhat lengthy). When I saw this, I was reminded of the summer I spent exclusively writing and improving a maze generation algorithm and instantly got to work on this.
After a while, I had an initial draft around 6000 bytes long and I spent the next couple of hours condensing it into the following program:
import random;R=range;L=len;T=sorted;P=print;N=random.randint;d='#';A=abs
def M(I,S):
 I=I.rsplit('\n');G=[[0]*(1+L(I[0])*2)for i in R(1+L(I)*2)]
 for i in R(L(I)):*G[1::2][i][1::2],=I[i]
 l=L(G[0])-2;c=E(G,l,-2);G[c][-1]=1;e=[c,l];c=E(G,1,2);G[c][:2]=1,1;s=[c,1]
 while s!=e:
  o=[];Q(G,s,e,-2,0,o,0);Q(G,s,e,0,2,o,1);Q(G,s,e,2,0,o,2);Q(G,s,e,0,-2,o,3);o=T(o,key=lambda x:(x[2],-x[1]))[0][0]
  if o==0:G[s[0]-1][s[1]]=1;s[0]-=2
  elif o==1:G[s[0]][s[1]+1]=1;s[1]+=2
  elif o==2:G[s[0]+1][s[1]]=1;s[0]+=2
  else:G[s[0]][s[1]-1]=1;s[1]-=2
  G[s[0]][s[1]]=1
 while 1 in['.'in x for x in G]:
  r=N(1,L(I))*2-1;c=N(1,L(I[0]))*2-1
  if G[r][c]in[1,2]:
   o=[];F(G,r-2,c,o,0);F(G,r,c+2,o,1);F(G,r+2,c,o,2);F(G,r,c-2,o,3)
   try:
    if o[0]==0:G[r-1][c]=2;G[r-2][c]=2
    elif o[0]==1:G[r][c+1]=2;G[r][c+2]=2
    elif o[0]==2:G[r+1][c]=2;G[r+2][c]=2
    else:G[r][c-1]=2;G[r][c-2]=2
   except:0
 *s,='#  '
 if S:s[1]='.'
 for x in G:P(*[s[y]for y in x],sep='')
def Q(G,s,e,x,y,o,a,n=0):
 c=lambda x,y:G[s[0]+x][s[1]+y]is d
 try:
  if c(x,y):
   try:n+=c(2*x,2*y)
   except:0
   try:n+=c(x+A(x)-2,y+A(y)-2)
   except:0
   try:n+=c(x-A(x)+2,y-A(y)+2)
   except:0
   o+=[[a,((s[0]+x-e[0])**2+(s[1]+y-e[1])**2)**.5,n]]
 except:0
def F(G,r,c,o,a):
 try:
  if G[r][c]is'.':o+=[a]
 except:0
def E(G,y,z):
 c=[]
 for x in R(1,L(G)-1,2):
  n=0
  try:n+=G[x-2][y]==d
  except:0
  try:n+=G[x+2][y]==d
  except:0
  n+=G[x][y+z]==d
  if G[x][y]==d:c+=[[x,n]]
 if L(c)>1:c=T(c,key=lambda x:x[1])
 return c[0][0]

Which is about as non-sensical to look at as an ascii-art maze is...
It's worth noting that, since the random function is not used until after the correct path has been found, no matter how many times the same input is given, the route from the start to the end will be the same and, while this program does work for the above examples, sometimes it will be unable to find a solution if it 'drives itself into a wall' so to speak.
When running the above examples, it gives this:
>>> M('''.......
.#####.
.#####.
#######
.#####.
.#####.
.......''',True)
###############
# # #   # #   #
# # # ### # # #
# #...#.....# #
# #.#.#.###.###
#  .#.#.#...# #
###.#.#.#.### #
....#.#.#.#....
# ###.#.#.#.###
# #...#.#.#.  #
# #.###.#.#.# #
# #.....#...# #
### ####### # #
#         # # #
###############
>>>

this:
>>> M('''..................
..................
.......####.......
......##..##......
.....##....##....#
.....#......#...##
.#############.##.
##..############..
#...###########...
#...##########....
#...##########....
#...##########....
#...##########....
....##########....
....##########....
....##########....
..................
..................''',False)
#####################################
# #     #   # # #   # #   # # # # # #
# ### ##### # # # ### # ### # # # # #
#   # # #   #   # # # #   # # #   # #
### # # ### # ### # # # ### # ### # #
# #     #   # #         # # # # # # #
# ### ##### # # ##### ### # # # # # #
# # #   #   #     # #   # # # # # # #
# # # ##### # ##### ### # # # # # # #
# # # #         # # #         #
# # # # # # ##### # ### # ######### #
# #   # # # #   # # # # # # # # #   #
# # ####### # ### # # ### # # # # # #
#         # #           #   #     # #
### ##### # # ######### ### ### ### #
#     #   # # #   #   #     #   # # #
# ### ### # # # # # # ####### ### # #
#   # #   # # # # # # #   #       # #
# ##### # # # # # # # # # # # ##### #
#   #   # # # # # # # # #   #     # #
# ####### # # # # # # # #############
#   #     # # # # # # #         #   #
# ####### # # # # # # ##### ##### # #
#   #     # # # # # #           # # #
# ### ### # # # # # ######### ### ###
    # #   # # # # #         #   #   #
# ### # # # # # # ######### ##### ###
#   # # # # # # #                 # #
# # # ### # # # ################### #
# # # # # # # #               #     #
# ### # # # # ############# ### ### #
# # # #     #                     # #
# # ##### # # # ##### # # ##### ### #
# # #     # # #     # # #     #   # #
### ##### # ### # # # ##### # ### # #
#         #   # # # #     # #   # # #
#####################################
>>>

and this:
>>> M('''..................
..................
.......####.......
......##..##......
.....##....##....#
.....#......#...##
.#############.##.
##..############..
#...###########...
#...##########....
#...##########....
#...##########....
#...##########....
....##########....
....##########....
....##########....
..................
..................''',True)
#####################################
#     #     # #   # # # # # # #     #
##### # # ### ### # # # # # # ### # #
# # # # # # # #     # # # # # # # # #
# # # ### # # ##### # # # # # # # ###
#   # #   # # #.......# #     #   # #
### # ### # # #.#####.# # ####### # #
#   # #   # #...#   #...#   # #   # #
### # ### # #.# # ### #.# ### ### # #
# # # # # #...# #   # #...  # #   #..
# # # # # #.# ### #######.### ### #.#
# #     #  .# #   # # #  .    # #...#
# # #######.##### # # ###.##### #.# #
#  .......#.#...........#...# #...# #
###.# ###.#.#.#########.###.# #.### #
#...# #  .#.#.#...#...#.....#...  # #
#.#######.#.#.#.#.#.#.#######.#######
#.    #  .#.#.#.#.#.#.#...#...#     #
#.#######.#.#.#.#.#.#.#.#.#.### #####
#.    #  .#.#.#.#.#.#.#.#...        #
#.#######.#.#.#.#.#.#.#.#############
#.    # #.#.#.#.#.#.#.#.....        #
#.##### #.#.#.#.#.#.#.#####.#########
#.  #    .#.#.#.#.#.#.......  # #   #
#.# # ###.#.#.#.#.#.########### # ###
..# # #  .#.#.#.#.#.........#   # # #
# # #####.#.#.#.#.#########.# ### # #
# # #    .#.#.#.#...........        #
#########.#.#.#.############### #####
#   #    .#.#.#.............# #     #
### # ###.#.#.#############.# ##### #
#     #  ...#...............      # #
##### # # ### # # # # ### # # ##### #
#     # #   # # # # #   # # #   #   #
####### # ### # # # ##### # ####### #
#       # #   # # #     # #       # #
#####################################
>>>

For anyone who'd like to try running this program themselves, use the command M(Image, Show solution). I would recommend using the triple-quotes to input the image since otherwise there'll be a lot of back slashes or newline characters involved.

Accurate nickname :p

Nice work! Some tips: Use 0 instead of pass, l.append(a);l.append(b) -> l+=a,b, l.append(a) -> l+=[a], it might be worth assigning '#' to a variable, and def E(G,y,z):\n c=[] -> def E(G,y,z,c=[]):

Also, if G[r][c]==1 or G[r][c]==2: -> if 0<G[r][c]<3:, s=[0]\n for x in R(L(I[0])*2):s+=[0] -> s=[0]*(1+L(I[0])*2) and (I think, haven't tested it though) G=[s] -> *G=s.

@Loovjo Thanks for the advice, the except:0, l+=a,b and s=[0]*(1+L(I[0])*2) really helped. Unfortunately, for whatever reason, assigning c in the function call doesn't reset it over multiple calls which meant it stopped working, G[r][c] can be a string so I can't use < or > on it and the *G=s gave me a syntax error. Still, great advice.

@AnonymousNoLifer No problems. Also, if G[r][c] can be a string, G[r][c]in[1,2] should work.

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


text:
Write two programs that compress and decompress data
Challenge:
Create a program that compresses a semi-random string, and another program that decompresses it. The question is indeed quite similar to this one from 2012, but the answers will most likely be very different, and I would therefore claim that this is not a duplicate.
The functions should be tested on 3 control strings that are provided at the bottom.
The following rules are for both programs:
The input strings can be taken as function argument, or as user input. The compressed string should either be printed or stored in an accessible variable. Accessible means that at the end of the program, it can be printed / displayed using disp(str), echo(str), or the equivalent in your language.
If it's not printed automatically, a command that prints the result should be added at the end of the program, but it will not be included in the byte count. It's OK to print more than the result, as long as it's obvious what the result is. So, for instance in MATLAB, simply omitting the ; at the end is OK.
Compressing a string of maximum length should take no more than 2 minutes on any modern laptop. The same goes with decompression.
The programs may be in different languages if, for some reason, someone wants to do that.
The strings:
In order to help you create an algorithm, an explanation of how the strings are made up follows:
First, a few definitions. All lists and vectors are zero-indexed using brackets []. Parentheses (n) are used to construct a string/vector with n elements.
c(1) = 1 random printable ascii-character (from 32-126, Space - Tilde)
c(n) = n random printable ascii-characters in a string (array of chars ++)
a*c(1) = 1 random printable ascii-character repeated a times
r(1) = 1 random integer
r(n) = n random integers (vector, string, list, whatever...)
c(1) + 2*c(1) + c(3) = 1 random character followed by a random character repeated 2
                       times followed by 3 random characters

The string will be made up as follows:
 N = 4       // Random integer (4 in the following example)
 a = r(N)    // N random integers, in this example N = 4
 string = a[0]*c(1) + c(a[1]) + a[2]*c(1) + c(a[3])

Note: repeated calls to c(1) will give different values each time.
As an example:
N = 4
a = (5,  3,  7,  4)
string: ttttti(vAAAAAAA=ycf

5 times t (random character), followed by i(v (3 random characters), followed by 7 times A (random character) followed by =ycf (4 random characters).
For the purpose of this challenge, you may assume that N > 10 and N < 50, every second random number in A is larger than 50 and less than 500, while the other random numbers can be from 1 to 200. As an example:
N = 14
a = (67, 48, 151, 2, 51, 144, 290, 23, 394, 88, 132, 53, 77, 31)

The score will be the combined length (bytes) of the two programs, multiplied be the compression rate squared.
The compression rate is the size of the compressed data divided by the size of the original data. The average rate for all three strings is used.
score = (Bytes in program 1 + Bytes in program 2)*(Compression rate)^2

The winner will be the one with the lowest score two weeks from today.
Test strings:
String 1 (5022 chars):
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTX_w}yo7}vWL$Y@qNR*Xxqt|oqmwr4+32ejdnaKdEf1<a?<iEKswv)HcNyF/pGc).SPpCF-j$& 1**(NNZ.>Zy0e-`a)i$1Z,X[hcR5JX18wG|`9:H;Qi&nluCKC:b! Q+)i77B28/j/4ZYT1=FN!>DR7'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyeDW,FmJh.%AgO&<CIO|Z>gSmszi/I?nL3P8)se$cbNit%['G<X9VW/)+Xg%$Y}E98\X o;y<Jf8(,8=i`v\e B\7\?<\!Pht(U7FFg\!\L_&bh=G*IJLPLpKGc@ 3j9E%{z^+'3bFmM3q"|c2Gt#ed%-U+y?<bB'/[I]o}bmyE=Y$h!oo/H,9$&^*7Rbzd.L;KGN-Wllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllgk4D:*\(Kt);&^0:RL.KB)IqS79Xj)c8qhf5+S=Up%y0xj%1lA=C<.^F*!UuE2u4wbZ[1#?Q)wz*E;;_5 w\{VUBqH}0(tE& HV(4eZ}S@7xi_s]nzwtP2$8_v`)BDFEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEzgGFo9b8`U':3H<;;K)D'B4:L'}7x;3d]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*'wt#^or$m_F{@D"`[n?x1Ow3H1bh$5Z@yzRJ4=my&%X+bc6Or/Bw`Zx,VO{Ss10}[fKFLX}Rh9W?_k7)\&j\`Z.BABUy'q8\VP5D_n-f|v3Y$cLe;;7r{5lD@uc?r/c+&O=0{Hr!5&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&9<OIozM4dNlw9N-MUW<kwD/E]XB^1/(?)?C4x)%p,K)p#<cG&PMV"10"&+vN-/oKw9FsubG=*&c'A)a Tu)uZD,S{c|<QO}w+[Pdc=$}3f(!73W?Ko!z:gPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP(!B"n}ydQP W^]2!$,0,ym! cVy4U>hmsNbdU}b-T`n'B^:L#Z}pI5l+46(1LCS>:BAp8+?[ ?}}1mtpo3\[{I]!7T33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333FzE klH&6Cj[VPd: HB\e9FvH_./lxP*Z\LD-,Y``IegX+=1T_:B>VJ{Ikq>'_>k5>rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"EI5K,%OB??_{"fNG>Ql6"jJ4m[S{I_/`P000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000=K#Gc-0ai'N"zDO[roJAJOPPY!%C#+J7"xd0V^teUZX$QW!<\s 3kuuXS'W`F mUvkzr7R ET"(2Y9c}M-a&shkT9j>*x+KDprC'9WFXl(`I{AfsCffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffvKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK#v>boc"..................................................................................................................................................................................................a#,uAOemp[b5CPOzI85g:a[|:]<Ss=`JuIB]+Sg$b'>PJ=%:zM#I$,YM1eX)Ja=P5x^WhuVt1?$ZU5qoM68P?n;T]R-RZ0PMH^pS%W*so-v!=2Z=9J^p,j$4)"'mXvWFF]IQN^MqG:^Lr&V?is6A%N${wNjCXpJE+F^wBG4@c`c^/CU-}8TIYJHu$|KGq=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\l7G7DK9Nq+'{=>.^a"I<ytX0(HsP'x:I4enw5'^kjQ{ZQta\FL|zOC2C[d4y\z8'z<OgHw3+XZ_nSq@B9m)Yu"|JkOTP*L3T"t\<'sh,y*{0%*NBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBl,OuBGl;X(Yxx._o0Jv8a_]`]j=u6-W^Ve%&meh`]PmR}c>3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP+GZ-jP@U#$K.}zTy^J(@9"LZ<,Dm}LkKn'>>ZBn:fn?o_o>LT1{2{t0r4$M-GnV;?/M^P-#uzJ=PnBhYo<,uyXNJ#yiZ;R29ta5 >.D0_$\BWWO%3=|#W:c8^VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV%'r`CdgOv(WZ_y2*/sW|$Mmut0CX>Mw+109!Ky$;o`eKqd1D2Kh9x=y8{;(p)xpuIVT+9JS<T>/UIWB< T5$hs|V.$(>$J6j}@\WtWM3\>dvc{O!<(mzw@<xeRkhCIE7L;z7_OFx|nbxfIxu|hhBiN!d"`5;vxnpk3juf;J2})#r!]AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF<7#0%Uj,b<WrAK?I%kPx![bJBF}RE'j>`f>U]*f%gDY?aa]O3>sL.V\.3#u/%O;xHIl<A4#6zO}umALe*B5P'*`kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkINNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNIv%x1QT@:A`TeVc"AVnFzfPGN%^</a=G=#P/G/oAS^ZPI-8yhu0T8>V5kF80Gh;QU=SC>ymTH{Onh/)[kN+:y .iRj[yK!V HDFW<<fU&zmm2.OY-H^Gf)yH{R%>5DNI]'AX7-kpEJr`+IM-cUn S{co^]ir%J,(P/[q1 h},R",d\Kg%(*HpGDEq`=ubhTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTgeQ_!6|Qj$L77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777>JV8&V]xq4k#U)5e^8VTJPRzD)HeT6STV:WgqwBbF61R/{_x=diD{<5jKf/Yds7.;Eu}[bYDyA1wRA{-S:1l[%5dHHVOgWMQBy">VO^fJ4yn>oN.,1LEzxT.)>cHk!PbB|$#."Jg^;8}\% D>*8e))=OnSNhRQ

String 2 (2299 chars):
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV`]e!oO{=i&}\o8^('MDPC`VCI`(@3AFa"A3Dhc<h2Rhc99F^$<LpAOdzC6Y%dTm:!iHH@&&OCV?y)Vv [`wq=?0-YjXSPx1t3k&=>(6^EW?%pH3y6Rb8="2tG%$Jo6A<X^nS4K\v@nZ(Bi1jCW4?p]aIv}<26gXQ%'GKa*<$aPOnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn.$$}.HK{It43ltY"H&:VcTkq+C3.g2VB`Ui-P=8I^%9\TN5=[&@;YOR0`[sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssZz_qnx9wqa'caEfvlp,;c0't70I8'>|W=SHQx\{#ed9)WFM!:l[24.qU,UV^0gARZYW4}n<.6HJdK:{]8,QOO]KbZ'Tugd9{9>X1q.-[adNHmMP*+"<]XIIf>7>Rp/,sQ0QHTO$jduG3O>AV/,GY++$AOBDepNz9qIPzr\G$.NtKLD=j8?8ia*@y34GgmtM%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%]"0'-roq!u`Aw/EYlk< R>-AsSmJ3D w}Pp;Rpi`r755VI,Ao(uVA%)v0]WC/XW{-v7k+37y5QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`9q;^dn#byX+NvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvaY#. xKADce75y7E]`(m'cAg.$N5j{,u!v%Pc(6D?"axU*VQ,n^bWomxD.`LA:I1nvX=^VGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGtOnQL:PKI':C}q.:6|aHiYII*C7{kGa,9aSE8D}h#S%[^:P&e^:kazo,"W]e--\bW=],xD44\@,Z;Q7$RPKA0b6yO_7&h}b/c4@nE.CvI}0.-ySF2zWy_3gwpmcqWZZ'Y))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))X']&p]icj|RFj'ci2*1jXg%* Eu&9QZEWwGpen1Pa,Gti_?FUL)&=r<YL-Th"]f%jV<Kx);@L^)mw'g S(nry%kbZp pGD]R@j3{idSHH<!X{%(/T,ow]$259a P-6_AX*o?4g^>(n<v^:/U@cmh9nOG|ot=8Rw5FfvU/'IGD(gm++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++K#&U4RN$dR*rv1p5t`<n7XpvpVz#uncF647sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssYl?CCkw#e?#be5,c0GttH}N j:$5AHa Xz[<z-=CdX)@}fHmk7L-k&hZHOP5o9^yU%%:g|TD1b=7G !HKGMN|}/l:}2Ia^fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff56&4i{38sY*]<DTT#:5>RJm*\c&|kM+K\s^"055%FL5Fl&X|{q+4N6t^(<\gt@;v?z}xly?Bi_!mSA+8r/6n4)Kdh4)P8'|oK&-7tFNO:]mr$nl6L1jr):uC(vh`Ei)19MfumB<VtL]"Vc

String 3 (10179 chars):
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""":=P,W$WS.vBP9d89L65VeuKY27|*-Ih1x/nY}p09Sq$PQ%4z!l*)@wmbP3b;C3E8#*?2-T`W"0&::+kA:`.OrjmD-u(oDpE:{x0 ttb13yO"q6U:1N@/[R2g}#y}d,7)_STJ^0hb]4]hSd9%L#]Bimmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm+HuOde&d,uX?B??|AJ)h.}D<HouV7NXUP0!.,HmhBaar7(c.)A#%8aPc{g8iE.hw0H)P5B^zQT('wG7Vu(|M>lo.5EM3Z/o&[Pfd}A{Vsi,+lAlam*K}69zlNWJv)|u0<e#+:l![((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((G#zx B)=N\[hRY8Dm`x@SPG=3ZRJ^SkywE:U/[\Z?q[fjY9gxO.]TiH)xKw}%*Tb[JhlD]2D4:(CE:#Zre/}9:z2*G)u)O,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,It)UnqhJ_XIzXNlT%C*Mq%R6KNTg=Q(4G)}=Q2Fp.A>Tuz?y4,wvh%,qQS5gb`6E>^6M]1FV/*4s%LDf%bwEr!oH.G/////////////////////////////////////////////////////////////////////////////////////////////////////JfITfs\Bp{8uJmAE@qW>QT!"R\q\q}2Rwo3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333q Kxp"zbN(am%qRC"bc#]zzD,sr]=H)yMS"0X&_/|yqs!kZ)`MY[C%3j`6$D!(Qk4x."e,m]                                                                                ;B|S)E{BQT:%eSr0j7Gqx0&u7c7.lT]P?.&&mV2ZT^.k^"0)4K*#E4d!z/$#[-?zi8a(S?iIU9|q?lfy3T"}fh)oWfO5^{sAXu`CB*LStW5(KCe3I]-|oE^>!VL<#Pd$PLDBqZfQ)QPCWja7&7HtM7uM9*..................................................................................................................................................................v/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\sh*_l7Tk`b7KQueol'sWCC,5|\=H>v0I4c\PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP4q.r!#H?yY/-t2:iDRwn,TwSR6 v@lBv\jjO!Kz+1NT>ksfbl=hq)/y1q<}3"kYHLJ&&m'NS'lhqaPYJW3}3Qjh)|ZnAQvb^v=6TIw%Ry{!M,aBIzd9QLhB%cjXOoc*C\S0!(f :NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNv(9%9@j.1yF&fw@L9edFP3#7tuHlxpCk8]hD.ky{V6bS#?rEz5PERx_"V:\TN {2_"pE/T:X<#&<\V%IQISzo6w5vO%lvPx)|wO!"+>\t-SzP\wWXFQrmXp`JGJ/sIoVyns2u=yU`26&A1]vrpEXHD/K1HjnN4-t";S*****************************************************************************************************************************************************************a&.z "aV6]K"JhyO;/`UOpAkb}zP53=$AD:Io3lkjdUMjw1w!rL2Za3Dk:,`]AsG!L[3e^ECxxqx[I_{|qe)z;zZ#V&HZ:J4g+2U>}y!Oazq`qY_]'n=egXV9*IaFbtRZGVQG!ojmkTkStrbzFnd|7Keu [7$2f7Npb]ne=wuAg\9*4Rd/cqcDApSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS[OTjad;#l+*>m&fFSS{rc|xb?MTV$Z2I>)l8QfAUB"wNHhMNpvaz_TnvM:2Ck>*2=jWS2)a/$dP\,"pB9#L^1lSir+m%oG@YA/G#M3T10gF+xdJDqe"8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888":6Y<zLVYm@aQ-.\-u\M_.7<}L`(w!+7lm@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<aJHBA#?>9cSxN5HZ:$Z{Kr15x>cZ?!NACujxBVAu;->*BxS)wu dA:2#Sq:FaGgr5,mKLv&_ms"s1:NXEVVX)`y#ekL4H$;%{xrU$ai&9J5C8eqyQE(E|;+3tf^csoENQJG#}X81VE2m1xY 2SI d[*Eozzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz7/+M6f *n*GBp_/+rpBX@]%OpIgfkF":Cc"xzIGYw5H{LVBWFKg\1j{S duWiWB[-%'z7)NGE)QR >"t4#N1{(EntG)$u^o/J(*IaBAB<D\iE?gWj)ccWk-[OToXKjQZTWIji%^] ,Z#:_5Rsk e`s-bxrLW|(,c!>mmin\w5lcLO`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````+b"0@z2a@N^IO}K{uefxE%pgz'!7GoJ2mLaOZh3#I$tSEZ/=x9S6]Y0[5T@qRftKeXuBFr_ \)-?-2">0r*=MB'hhf4x"%g8Y\[kmPx><6ejGL; s:yp@5af+rg=/`W(xm,{OKLzj dY/3PC)Ea]LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLcqGx?cJ"y,>w5jkIbja_qUNv#-r_G 86[090^^F@x|4(8@dWy`"MnL5<+Mf{IsyVO32xy@ZKS4.o2T`G$gNJbCddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd:>WH*?#n+7oFZQ\gLEzvR8LS6u&0^pR[;n`x&D9m"YFf````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````G=Z^o74rpXU<`',;JPl|}/>8f<ir3M6;&O)Y4rV5T2^+AJ>QvlE([bozzb,ifw=BG7+P((lS$g{c!N*&_K<);rx,2&9@7QJi6Q*(.qFQys>EB['1a4(`?htRwJ"a+<j6*>.Lm}F)`:M3;=^n+Bp&\HZI[sv1FGI93\6VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV O}h4W!dP?}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}Z'lC(E *d#-Ub?y". r:D{n--gCk&=IpmT{\I-;2vQ18xtU'2u1<qAN<IF!YEwx)ZKvY_)D%CU;l1bC%$>u|W.(2=dC!{_e?bc32]DYC?m}<{vdZKnZ <.VhO?EYwINo7lS36Ir1p4Q%cG*7RX#)iVIu..............................................................................NuF1uxKoCH5[cn,,7uj "6aoUK_7hV|lb;u8Piim!{f4 dASS'mtQ&L_-jZ=a?=YwO%Q?y240o".T*]k",5]S*f(P?Rp?T1=V7[^T=w8_h>(:O%f?iZuaJ=3d`f[dI;8S@'Gz]zn%{_OAw7&T%-44444444444444444444444444444444444444444444444444444444444444444444uSz;a(-U)o.xYDgr0,Kyo+jsMrB^oQJ=V}U`nEB>Eqo}S]sUil-sAurUOxxU.+S#f.lvO>Q_SN71{(3"eXt.%$z2Y%Gk8WFTCBz;\`2-eis.*pQ"q^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^vbAbVM q5#3gqC[FPb%7[jHR(o!jK[B)-!FD+.6Pu-(-ccyOsQPKug;]M8R5c'IK>O4EuxI8nr#Ab\EXRK+fP'KHb@-J=51g?/?<H\-BWq1s-Rb:5TuB5kb;eG3Sp/]h5Y{E+T\#i\.&+Q#%*G&O1o-sRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR'%*P|wj/I!ThsIYvh&#$W3\.]4[RTuwFOF#8y+TA7%B@u1T)l!:VFW;i.-{w6Gebq3JaMn7X9cwj3eg8Kf!HaME[<f2*w',ji0t0sDj>n+,=WN *k#[a3XKg!"0Mg$`vP\Fvjup*@8TV@ly{k{4Z2[@a:N)SWQ?Lxxv}dJ?WUmFYPBcG>Z;r_[6Kw$n2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'ja3@b''Ol'{i3K`wB5(kIOVg9'/R`I6=la;cV=ajQbf1+o3J&B{>(hUQE+g.YMv#q3&i5s/2mB|U^h2.A3U;(rxB{6DQb)`_/Sx/:!URO&49eSAm'B\GP8)9RdPO9FrqGI\^1j*'7Rgfpi&zgX52GU%%h<)h1)KG/Uu:un{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{W02fvj%BMP=H:dSNif}w[lZ@gF,O]w3O R"+g3G[7i*8y,n>1]u 5G!)nulS^S064#?y=/E1_QBDM`i`M5kzH0au24xQNB^u4;4ipll}IP1%V3yEC+2Oq83Y$iezSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSqQd$I49 o;w_%&90L/ckdHY8TeRWLFZNvi3aGwN3&HRuU$Vgt9(_R\FmT9}Aj#VQp"oUoXW=s*vS6SKP ]x<[IA2M2I`2Vy=a3&Jc,n:}qTboygX6pp,L?\ff{zE#9D-?-jgPrKwd6V{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{jB8OKx6j]=oPzb;pL(<A8`%g7+<O6*)W1m8(SiC+4n(775\g8$[?I\`Cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)/.%\4TZ1%Eq!chTOC|#Tbx(m}"@u>Bw&L*hz=Px4?yM}`4s>uGL,U0x@-JPIc.Kq-tx/h:Qr7r*t:6>#q 6O+doZQvl#kr:]VM `z%(&<`yhME|B;2Tjm$^N^,0\h)rVEVT\rp@T>>0U:KoFAsZ'_rZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZaI}`I/T;Qk/dyY_96VxX6=EGn%{'uzDF}.k!\}O^NG1p7PI<_C'/3%d70'@;\6n)wydLj}bZfWP9 zei[;J:^;BRwKcBFdFld3IRrRY9oBJ<#ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ/e{hh'&wP3jknjfma}v:*__SLUIg\@*_`m:fcbfj((6:1)..?,Xx6<%bi.9Z>)xC`Jbwv#mo_[O0z8>@Exm^>b.&2)[Eyg\Y{UZA9:+SuwhG(<w***********************************************************************************************************************************************************************s4NBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBJ_ h\ xgC46py]Wh'|,LnG2dgl1\*ZG2HWA0Z%26_zB(Y{:;2zxS?>5NJrX8j^*9bt$UQ\PD95El;e'EU6K.[:a&zn]$]`g^Wl;Q(o9oWI3HwTj}NR_:OAdJ@!M8#twm6+tN!*%ldWyOZpnGBeOyz\CiH9w>FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFVRA"MafX,*ZvJvhH{]BrDX">v}pMz2ze.q#$U1c_ XA207Zof^cE,(R`LgHdYY&etOFaShx`F])18.O#\go/-Q#!%6%O0)W`v$fX)7VSTUYau9TC|%a_'bI&i1i7Z3,om_'9(2m-ihn jCh5VrJPD9gm@EoAP*[.!5e{5BJ_>_ut^Hu\:^kJS0IOn+ 555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555gp_;VbIVS>7)S?V.!Qgx7T/Ik33tV.M>/[l/8HiS1L1tX<P_2,rR(R&+-#^rl=b8GgJP^y:!/`+-:_sWyzD56jqu0/N-)].j`*q9$csBoIl CyC]3j+^DT-Ra|LN*TesCL*-Z;OdO^m#{rp8rAaFB.N-''n:\p?O5bPgT{eD9^3[S7&E,n%/VFiz>K(VXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXEFm-T"2Ny{`4Jt7kv2fTpcsn=U.XCpppppppppppppppppppppppppppppppppppppppppppppppppppHr5aL@FX.UBLt$Um68vRs;Fw)Ymm>=^;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++JczE.=iK'CWH`]_Xf3G*Nb*ExFAKl;|ssZsBC 2s4jz=GR9y>`X8(M;2/BI3h75[[Yfr]txi5}i{np "p}H*.&3o(e>6I)`/;]`[7Oq{=Y4_2jUl}M)jWn&aX&h'dOUrZ),5>Rr2J<UF&{.vJNB?v{Hyp8sK`\J+;%_WTm__________________________________________________________________________________________________________________________3|+lq,Eb6.3HKu}g;La3'x$%?4tgQhIsR'9 c@i<5(LW'$[)YBE rA}BcWFWswnk_h(Z_ a`tQ)IorJ(!>0=c)/-t.n8rL|Php0!tjtI^r=GMN)GU4k?E oQc4|x#y;AU2hW

Note that the strings can be much longer than this, but there's a character limit (30000) on posts, so I had to restrict it. The functions should work for codes up to the maximum size.

Will N always be even? (It is in all four of your examples.)

@MartinBüttner, No, it can also be odd. That's just a coincidence. If it's odd, the string should end on repeated letters.

"The compression rate is the size of the original data divided by the size of the compressed data." Did you mean the opposite of that? Otherwise, better compression gives a larger score.

CJam, 40 bytes + 13 bytes, rate 0.48697, score 12.5682
Just a baseline solution which compresses the long runs.
Compression (Test it here with length calculation):
qe`{(S*\_{0=K>}#)_{(/(e~\L*}:F&N\}h;;_,F

Decompression (Test it here):
r{~l1>(@*\r}h

The lengths of the three test strings compressed are 2296, 1208 and 4917 respectively. This score could probably be vastly improved by making use of base encoding.

Awk, 74.9 = (199 + 115) * 0.48853^2
The compression replaces the characters repeated over 4 times, by character & total, enclosed by tabs.  For example:  &&&&& becomes \t&5\t. While dddd remains dddd.
The decompression script uses the tabs as the record separator and restores the repeated characters.
Compression
{split($0,s,"");for(i=1;i<=length($0);i++){c=s[i];f=s[i+1];if(c==p||c==f){n++}else{printf("%s",c)}if(n>1&&c!=s[i+1]){if(n>4){printf("\t%s%d\t",c,n)}else{for(j=0;j<n;j++){printf("%s",c)}};n=0}p=s[i]}}

Decompression
BEGIN{RS="\t"}{if($0~/^.[0-9]+$/){for(i=0;i<int(substr($0,2));i++)printf("%s",substr($0,1,1))}else printf("%s",$0)}

(note that this script would be more efficient if the substring calculations are first put in variables. But codegolfing often trades efficiency for bytes.)
Test
$ for s in string1 string2 string3; do cat $s.txt|awk -f compress.awk >$s.compressed.txt; done
$ for s in string1 string2 string3; do cat $s.compressed.txt |awk -f uncompress.awk >$s.uncompressed.txt; done

$ wc -c string[1-3].txt string[1-3].uncompressed.txt string[1-3].compressed.txt
 5022 string1.txt
 2299 string2.txt
10179 string3.txt
 5022 string1.uncompressed.txt
 2299 string2.uncompressed.txt
10179 string3.uncompressed.txt
 2296 string1.compressed.txt
 1208 string2.compressed.txt
 4916 string3.compressed.txt
43420 totaal

$ md5sum string[1-3].[ut]*xt
ea7076dd2f24545e2b1d1a680b33e054 *string1.txt
ea7076dd2f24545e2b1d1a680b33e054 *string1.uncompressed.txt
dd69a92cb06fa5e1d49b371efb425e12 *string2.txt
dd69a92cb06fa5e1d49b371efb425e12 *string2.uncompressed.txt
9e6eaf10867da7d0a8d220d429cc579c *string3.txt
9e6eaf10867da7d0a8d220d429cc579c *string3.uncompressed.txt

Perl, 113 bytes + 80 bytes, rate 0.497325, score 47.735
This is my first golf ever, and a first draft. For now all it does is count the length of repeated sequences and replace the repetitions with an integer representing the number of repetitions. E.g. "aaaaa" → "a{{5}}"
Compression:
$d=<>;push@d,$1while$d=~/((.)\2*)/g;map{$l=length;($o)=/(.)*/;$_="$o\{\{$l\}\}"if$l>4;}@d;print length(join'',@d);

Decompression:
map{($o)=/^(.)/;$_="$o"x$lif($l)=/\{\{([0-9]+)\}\}/;}@d;print length(join'',@d);

Double curlies ({{ }}) are probably redundant, but I want to be on the safe side.
Compressed lengths are 2340, 1230 and 4998 respectively.

Mathematica, 9 bytes + 11 bytes, rate: 0.565899. Score: 6.40483
Mathematica, of course, has builtins for this. This makes this answer a bit of a cheat, but I thought I should include it anyway.
Compress@

and
Uncompress@

PowerShell 5 (invalid), 37 bytes + 35 bytes, rate 0.43121, score 13.3878
This entry is currently invalid and theoretical only, as I don't have access to a machine equipped with PowerShell 5 to verify, and/or I'm not sure if this counts as "using an external source." More of a theoretical "what-if" scenario than actual submission.
.
Compression (the Get-Content displays the results and doesn't add to the byte count)
$args|sc .\t;compress-archive .\t .\c
Get-Content .\c -Raw

Gets command-line input, uses Set-Content to store that as a file .\t, then uses Compress-Archive to zip it to .\c
Decompression (again Get-Content doesn't count)
$args|sc .\c;expand-archive .\c .\t
Get-Content .\t -Raw

PowerShell 5, introduced with Windows 10, includes a new feature that lets you use the built-in-to-Windows zip/unzip functionality. Previously, you would need to create a new shell and explicitly execute a zip.exe command with appropriate command-line arguments - yuck. Now, it's just a simple command away.
Note that this is likely also not valid if you're expecting to copy-paste the string output from the compression algorithm into the decompression algorithm, as the PowerShell console doesn't handle non-ASCII characters very well ... Piping from one to the other should work OK, though.

PowerShell's pipes can be a bit odd too. I don't know about PS5, but certainly with PS2 I've had trouble with it converting the data in the pipes to UTF-16.


text:
Let us play the ocarina
As we all know, the Zelda series are one of the best game series ever made. In honor of that, let us play some songs on the ocarina.
Challenge:
Write a program which, given a song, outputs the score to stdout for that particular song.
Input:
The song which you will have to output the score of will be given by a unique three character combination as seen below:
zel - Zelda's Lullaby
sas - Saria's Song
eps - Epona's Song
sos - Sun's Song
sot - Song of Time
sst - Song of Storms

Bonus songs, -7 % each:
mof - Minuet of Forest
bof - Bolero of Fire
sow - Serenade of Water
nos - Nocturne of Shadow
ros - Requiem of Spirit
pol - Prelude of Light

Bonus song 2, -8 %:
scs - Scarecrow's song

As we all know, the Scarecrow's song is a song you compose yourself.
This song needs to have eight notes. Output a score you compose yourself which is different from all the other scores.
If you decide to include all songs, it will total to a -50 % bonus to your byte score.
Output:
The notes in the output are symbolized by the following characters:
^
<
>
V
A

Output a score on the following format:
-^-^-^-^-^-^-^-^-
-<-<-<-<-<-<-<-<-
->->->->->->->->-
-V-V-V-V-V-V-V-V-
-A-A-A-A-A-A-A-A-

Only one note per column is allowed.
For simplicity's sake I've added another row to the original four rows.
Each note correspond to a different row:
^: ----------------
<: ----------------
>: ----------------
V: ----------------
A: ----------------

Output shall be written to stdout. Trailing newlines are allowed.
Examples:
Input (Zelda's Lullaby):
zel

Output:
---^-----^-------
-<-----<---------
----->----->-----
-----------------
-----------------

Input (Bolero of Fire):
bof

Output:
-----------------
-----------------
--------->--->---
-V---V-----V---V-
---A---A---------

Note cheat sheet:
zel
<^><^>
sas
V><V><
eps
^<>^<>
sos
>V^>V^
sot
>AV>AV
sst
AV^AV^
mof
A^<><>
bof
VAVA>V>V
sow
AV>><
nos
<>>A<>V
ros
AVA>VA
pol
^>^><^

Since we play the ocarina code golf, the shortest program in bytes wins!
Song references:
http://www.thonky.com/ocarina-of-time/ocarina-songs
http://www.zeldadungeon.net/Zelda05-ocarina-of-time-ocarina-songs.php

Perhaps you should use a % bonus rather than a byte bonus. It's practically impossible to encode any of these songs in <7 bytes, so none of the bonuses would currently be worth it. You should also mention that the Scarecrow song should be composed of 8 actual notes; otherwise someone could just print an empty score. But other than that, nice challenge!

The fact that I can hear these songs in my head reading this question makes me wonder what I'm doing with my life. I mean, I'm at work when I could be playing OoT...

I hope this doesn't invalidate any existing answers, but note that in the original Zelda the scarecrow's song must be composed of two different notes, so e.g. AAAAAAAA would not be a valid scarecrow's song.

I think lowercase v would look better.

Suggesting tag kolmogorov-complexity. Some people do encode this!

I'm really waiting to see is anyone solve this problem in vellato or fugue and play it on ocarina

Does anyone here even have an ocarina and can play it?

Pyth, 56.5 (113 bytes − 6 × 7% − 8%)
VtJ" ^<>VA"+K\-sm+?qNdNKK@LJj@jC"þØí§V^G¤×¹z1«bëë¶ñRõr¤çM"1391423xcs@LGjC"cc0Á:xqç÷\rS  Íó×º:9"lG3z6

It contains unprintable characters, so here is a reversible xxd hexdump:
0000000: 5674 4a22 205e 3c3e 5641 222b 4b5c 2d73  VtJ" ^<>VA"+K\-s
0000010: 6d2b 3f71 4e64 4e4b 4b40 4c4a 6a40 6a43  m+?qNdNKK@LJj@jC
0000020: 2207 fe85 d880 ed0e a756 5e47 8ba4 d7b9  "........V^G....
0000030: 7a9e 0531 ab1b 62eb ebb6 f112 52f5 72a4  z..1..b.....R.r.
0000040: e74d 2231 3339 3134 3233 7863 7340 4c47  .M"1391423xcs@LG
0000050: 6a43 229a 6317 6330 c13a 9278 71e7 10f7  jC".c.c0.:.xq...
0000060: 5c72 5309 87cd f3d7 ba3a 3922 6c47 337a  \rS......:9"lG3z
0000070: 36                                       6

You can also try it online.
Explanation
I store the songs in base-6 numbers, re-encoded to base 1391423 and then base 256 to save space. I had to choose base 6 since some of the songs start with ^, and numbers can't really start with a 0 after decoding.
  J" ^<>VA"                                                      save characters in J
 t                                                               discard the space
V                                                                loop over all characters
                               C"..."                            parse base256 string (songs) to int
                              j      1391423                     convert to base 1391423 (separate songs)
                                                   C"..."        parse base256 string (codes) to int
                                                  j      lG      convert to base-26
                                               @LG               replace indices by corresponding letters
                                              s                  concatenate
                                             c             3     chop to 3-character codes
                                            x               z    find index of input code
                             @                                   get correct song
                            j                                6   convert to base 6
                         @LJ                                     replace indices by corresponding ^<>VA
                m                                                map d over the above
                  ?qNdNK                                         take the current character if at its row,
                                                                 otherwise a dash
                 +      K                                        add a dash
               s                                                 concatenate
           +K\-                                                  add a dash and print

Funciton, 4322 − 50% = 2161
Not really trying to golf here. Going more for the beauty angle. I think the main program looks really neat, a perfect rectangular box tucked away on the right.
As always, you can get a better rendering by executing $('pre').css('line-height',1) in your browser console.
                 ┌─────────────────────────┐
               ┌─┴─╖                     ┌─┴─╖
      ┌────────┤ · ╟─────────────────────┤ · ╟─────────────┐    ╔═════════╗   ╔════╗  ╔════╗
      │        ╘═╤═╝     ╔═════════╗     ╘═╤═╝ ╓───╖       │    ║ 1257283 ║ ┌─╢ 40 ║  ║ 25 ║
      │          │       ║ 2097151 ║       ├───╢ ʫ ╟───┐   │    ║ 6456094 ║ │ ╚════╝  ╚══╤═╝
    ┌─┴─╖        │       ╚════╤════╝     ┌─┴─╖ ╙─┬─╜ ┌─┴─╖ │    ║ 8219021 ║ │  ┌───╖   ┌─┴─╖
┌───┤ · ╟────────┴────┐       └─────┬────┤ · ╟───┴───┤ · ╟─┤    ║ 4660190 ║ └──┤ × ╟───┤ % ║
│   ╘═╤═╝             │            ┌┴┐   ╘═╤═╝       ╘═╤═╝ │    ╚════════╤╝    ╘═╤═╝   ╘═╤═╝
│     │               │            └┬┘     │           │   │    ╔═══╗  ┌─┴─╖  ┌──┴─╖   ╔═╧═╗
│     │  ╔═══╗ ┌────╖ │           ┌─┴─╖ ┌┐ │           │   │    ║ 8 ╟──┤ ʫ ╟──┤ >> ║   ║   ║
│     │  ║ 1 ╟─┤ >> ╟─┘       ┌───┤ ? ╟─┤├─┤           │   │    ╚═══╝  ╘═╤═╝  ╘══╤═╝   ╚═══╝
│     │  ╚═══╝ ╘══╤═╝         │   ╘═╤═╝ └┘ │           │   │    ╔════════════════╧═════════╗
│     │         ┌─┴─╖ ┌───╖ ┌─┴─╖ ┌─┴─╖  ╔═╧═╗         │   │    ║ 609678112368778425678534 ║
│   ┌─┴─────────┤ ʫ ╟─┤ ‼ ╟─┤ · ╟─┤ ‼ ║  ║ 1 ║         │   │    ║ 616189712722605554111376 ║
│   │           ╘═╤═╝ ╘═╤═╝ ╘═╤═╝ ╘═╤═╝  ╚═══╝         │   │    ║ 461573643915077926310571 ║
│   │             │     │     │   ╔═╧══╗               │   │    ║ 355541007599150245813976 ║
│   │   ╔══════╗  │     │     └───╢ 45 ║               │   │    ║ 426564826002362964111793 ║
│   │   ║ 2097 ║  │   ┌─┴─╖ ┌───╖ ╚════╝               │   │    ║ 714054902293682079346275 ║
│   │   ║ 1565 ║  └───┤ · ╟─┤ ♭ ╟─┐                    │   │    ║ 663973372550500581508544 ║
│   │   ╚═╤════╝      ╘═╤═╝ ╘═══╝ ├────────────────────┘   │    ║ 874263187322344354338195 ║
│   │   ┌─┴─╖         ┌─┴─╖       │                        │    ║ 642609790172899326178321 ║
│   │   │ ‼ ╟─────────┤ ? ╟───────┘                        │    ║ 071643306454414932126243 ║
│   │   ╘═╤═╝         ╘═╤═╝                                │    ║ 308860823981077902637848 ║
│ ┌─┴─╖ ┌─┴─╖ ╔═══╗   ┌─┴─╖                                │    ║ 322657399386789617074176 ║
└─┤ · ╟─┤ ʫ ╟─╢ 8 ║ ┌─┤ ? ╟────────────────────────────────┘    ╚══════════════════════════╝
  ╘═╤═╝ ╘═╤═╝ ╚═══╝ │ ╘═╤═╝
    │ ┌───┴╖ ╔════╗ │ ╔═══╗
    └─┤ >> ╟─╢ 21 ║ └─╢ 0 ║
      ╘════╝ ╚════╝   ╚═══╝

Continuing in the tradition of giving Funciton functions names consisting of a single, strange, rarely-used Unicode character, I thought about what could best represent this challenge, and it occurred to me that Link and Zelda (or, if you want, Legend of Zelda) give you LZ, so the lower-case digraph ʫ (U+02AB, ʟᴀᴛɪɴ sᴍᴀʟʟ ʟᴇᴛᴛᴇʀ ʟᴢ ᴅɪɢʀᴀᴘʜ) seems appropriate.
Explanation
As explained in the esolangs article, the Funciton program receives the input encoded as what I would call “UTF-21”, but as a single humongous integer. If I wanted to use this number as a key to a hashmap (dictionary, associative array), I’d need a hash function that satisfies two criteria: one, it’s simple enough to implement in Funciton, and two, all of the 13 expected input strings give a different hash value. The simplest hash function I could think of was input % m for some value of m. Therefore, I tried m = 13, 14, 15, etc. until I got to the smallest integer for which all the hash values are unique. Turns out this number is 25.
The hash values are:
zel =  6
sas = 19
eps = 10
sos = 22
sot =  1
sst =  9
mof = 14
bof =  3
sow = 13
nos = 17
ros = 21
pol = 16
scs = 23

We encode each song by having one bit represent the presence or absence of a note. For example, Zelda's Lullaby would be encoded as follows:
---^-----^------- = 01001000
-<-----<--------- = 10010000
----->----->----- = 00100100
----------------- = 00000000
----------------- = 00000000

except that the bits are in the opposite order; the top left cell is in the least significant bit. This means every song is 40 bits long.
We thus create a (moderately sparse) hash table by taking a 40×25 = 1000-bit number and placing the bit pattern for each song in the right place according to its hash value. The monstrous number in the program is exactly this hash table.
Here’s what each of the remaining numbers mean:

45 = 0x2D is the Unicode for -.
1257283645609482190214660190: This is the string ^<>VA in UTF-21. In hindsight I could have used 7 bits per character here, making the number shorter, but UTF-21 is so deeply traditional in Funciton that it simply didn’t occur to me.
2097151 = 0x1FFFFF = (1 << 21) − 1. Used to get the first character from the above string.
20971565: This is the string -\n, which is appended to the end of each line.

It may seem curious that this number and the previous look so similar, but if you think about it, it’s because we’re using decimal and the Unicode for \n happens to be 10. That last number is (10 << 21) + 45.

The program now proceeds as follows:

The main program calls ʫ with the following 3 parameters:

B: The hash table, shifted right by 40 bits times the hash value of the input. The song we want to output is now in the 40 least significant bits.
c: The string ^<>VA.
a: The number 8.

In each iteration of ʫ,

if c is not empty,

if a is not zero, look at the bottom bit of B. Output -, followed by another - if it is zero or the first character of c otherwise. Shift right B by one to remove one bit and decrement a.
if a is zero, output -\n, then chop off the first character from c and start another loop with a = 8.

if c is empty, we are done.

Well done, that's impressive!

That dang musical flat... throwing off the monospacing...

@iAmMortos: Agreed. For this reason, I avoided the ♭ character for a long time and convinced myself that I could just bitwise-not, then ♯, then bitwise-not. But now I use Deja Vu Sans Mono to edit Funciton and it has ♭. So now all we need is for StackExchange to switch to that font for code too ;-)

Also, you surely must admit that there’s no better fitting Unicode character for decrement and increment than ♭ and ♯. They’re just perfect.

Haha, totally. I don't know anything about Function, but that makes total sense!

And, at least from an iPhone, the correct mono spacing is preserved as well.

Python 2, 143.5 (287 bytes - 50%)
i='^<>VA'
u=dict(zel="<^>"*2,sas="V><"*2,eps="^<>"*2,sos=">V^"*2,sot=">AV"*2,sst="AV^"*2,mof="A^<><>",bof="VAVA>V>V",sow="AV>><",nos="<>>A<>V",ros="AVA>VA",pol="^>^><^",scs="<"*8)[raw_input()]
r=[17*['-']for _ in[1]*5]
x=0
for g in u:r[i.find(g)][x*2+1]=g;x+=1
for h in r:print''.join(h)

The grid is generated with dashes; then indexed and replaced with notes.

Haven't looked into it too much but you can save bytes in the declaration of j by replacing each comma with a space and calling split with no arguments

I don't think you needed to do that, it's still your algorithm so I think you deserve the rep, but anyway I managed to get rid of range. Sadly you can't just multiply the inner list by 5 because they are all the same object and changing one changes the others :/ We beat perl (for now) though!

Couldn't you eliminate 6 bytes (1 for each of the first six songs) by doing stuff like "<^><^>" => "<^>"*2?

scs="<"*8  I don't like your Scarecrow song.

When I try to run this it just halts on line 2 and never finishes.

Perl 5, 125 (320 260 250 Bytes -6x7% bonus songs -8% scarecrow song)
Yay, finally an opportunity to experiment with that Perlish hash syntax.
$_=pop;@B={qw(zel <^><^> sas V><V>< eps ^<>^<> sos >V^>V^ sot >AV>AV sst AV^AV^ mof A^<><> bof VAVA>V>V sow AV>>< nos <>>A<>V ros AVA>VA pol ^>^><^ scs <^V>>V^<)}->{$_}=~/./g;map{@L=('-')x17;for$i(0..@B){$L[1+2*$i]=$_,if$B[$i]eq$_}say@L}qw(^ < > V A)

Test
$ perl -M5.010 ocarina.pl scs
---^---------^---
-<-------------<-
------->->-------
-----V-----V-----
-----------------

Use the qw() syntax instead of the fat commas ( %h=qw(zel <^><^> sas >'V><' ...) to save some bytes

@mob That advice shaved more than just "some" bytes. :)  Thanks!

@L can be written more succinctly as @L=('-')x17. Also, the main hash can be left anonymous as @B={qw(zel <^><^> ... scs <^V>>V^<)}->{$_}=~/./g.

I see, those are nice tricks to avoid the slightly verbose split function. Ten more bytes were sacrified to the void. tumbs up

Perl, 75 (150 bytes - 50%)
#!perl -nl
$i=vec~$_,0,32;print+qw(- - ^ < > V A)[0,map{vec('w2$$W4F4w7DeweTFwR$Ew$C2wVdeVe3cw4B#EEVVwC5Tw44bwR&e',$i/480%15*8-$_,4)==$.&&$.,0}1..8]while$.++<6

Counting the shebang as 2, input is taken from stdin.
Sample usage
$ echo zel | perl zelda.pl
---^-----^-------
-<-----<---------
----->----->-----
-----------------
-----------------

$ echo bof | perl zelda.pl
-----------------
-----------------
--------->--->---
-V---V-----V---V-
---A---A---------

$ echo scs | perl zelda.pl
-----------------
---<-<-<---------
-----------------
-----------V-V---
-A-------A-----A-

Using the bitshifting vec function for this? Amazing.

@LukStorms I wish it could do 3 bits, rather than only powers of 2 ;)

PHP: 130 bytes (260 270 279 bytes − 6 × 7% − 8%)
Thanks to Ismael Miguel and Blackhole for some great ideas to save more bytes!
<?php $f=str_split;for($z='*^<>VA';++$i<6;print"-
")foreach($f(base_convert(substr(current(preg_grep("/^$argv[1]/",$f(bofttmmeps8jf0mofvff0nosfnfopol99d0rosyxt0sasrgk0scs8m8msosm9p0sotnry0sowylc0sstybp0zeldk90,7))),-4),36,6),1)as$c)echo$i-$c?'--':'-'.$z[$c-0];

After the print"-, this is a literal insertion of a carriage return. It may translate to two bytes in Windows.
All bonus songs including the Scarecrow's song are included.
Each song is represented in seven bytes of code. I like the new scoring because with the old scoring I would have gained just one meager bonus point overall!
The recent edits make PHP generate a lot of warnings, so to keep things nice and tidy, those are diverted to /dev/null.
Save as zelda.php and run on the command line:
$ php zelda.php zel 2> /dev/null
---^-----^-------
-<-----<---------
----->----->-----
-----------------
-----------------

$ php zelda.php bof 2> /dev/null
-----------------
-----------------
--------->--->---
-V---V-----V---V-
---A---A---------

$ php zelda.php scs 2> /dev/null
-^-------^-------
---<-------<-----
----->------->---
-------V-------V-
-----------------

Did you mean "save as main.php"?

@ZachGates - Thanks for catching that, changes made.

You don't need the () around ($i-$c) on echo($i-$c)?'--':'-'.$z[$c-0];. Also, your string inside your split can be used without '. And '/^'.$argv[1].'/' can be written as "/^$argv[1]/"

Thank you! I think it's allowed in CGSE to pipe warnings to /dev/null to clean up the output?

@Blackhole - thank you! It's tied with the Perl 5 submission, doing pretty good...

Python 3 - 138.5 (292 280 277 bytes - 50%)
Shaved a few bytes off the current Python leader while doing the print-as-you-go method rather than the replace method.
Try Online
s=dict(zel="<^><^>",sas="V><V><",eps="^<>^<>",sos=">V^>V^",sot=">AV>AV",sst="AV^AV^",mof="A^<><>",bof="VAVA>V>V",sow="AV>><",nos="<>>A<>V",ros="AVA>VA",pol="^>^><^",scs="AV><^AV>")[input()]
s+=" "*8
for c in "^<>VA":
 o="-"
 for x in range(8):o+=["--",c+"-"][s[x]==c]
 print(o)

Run:
> python3 loz.py
bof [return]

Output:
-----------------
-----------------
--------->--->---
-V---V-----V---V-
---A---A---------

You can save a few bytes by using ['--',c+'-'][s[x]==c] instead of the conditional

Ooh, good call, thank you!

Haskell, 344 - 50% = 172 bytes
import Data.List
s"zel"=82
s"sas"=69
s"eps"=86
s"sos"=48
s"sot"=128
s"sst"=50
z"mof"=11055
z"bof"=373854
z"sow"=1720
z"nos"=73217
z"ros"= -12730
z"pol"=4791
z"scs"=304236
z n=s n*126
p n|n*n== -n="   "|0<1="A^<>V"!!(n`mod`5):p(n`div`5)
o=putStr.unlines.transpose.(l:).concatMap(\c->[map(e c)"^<>VA",l]).take 8.p.z
e c d|c==d=c|0<1='-'
l="-----"

o does the job.
Thought I could beat Python by using these encodings (took me a long time ._.), but no. They don't really save a lot of bytes yet. Any suggestions?
Yes, that is a minus in front of the encoding for "ros". Thats because its 'sheet' ends with the character that means 0 in my base-5, because this negative trick wouldn't work for the 'easy songs' encoded by doubling what's encoded in s. Unless you use quot maybe, but then you can't handle p (-1) specially, since quot (-5) = 0, so the negativity would vanish. Whatever.

Ruby, rev 1, 192 - 50% = 96
Golfing includes:
removal of whitespace between groups of letters in the magic string (and revision of the denominator at the end of the line to /4.) Removal of some other unnecessary whitespace.
conversion of the escape sequences into single characters (stack exchange will not display them, so I have put ? as a placeholder)
redefinition of g as a single string containing five runs of 17 - followed by newlines, instead of an array of five strings of 17 -
s=gets.chop
s[?s<=>s[0]]=''
n=("owEkrswuns=;gcsbfbYuze33as&&es77os??otaast??mf?9pl
?"=~/#{s}/)/4
g=(?-*17+'
')*5
(n<4? n+5:6).times{|i|x=$'[i/3].ord/5**(i%3)%5;g[x*18+i*2+1]='^<>VA'[x]}
puts g

Ruby, rev 0, 223 - 50% = 111.5 (ungolfed)
The input code is reduced to 2 letters. If it begins with an s, the s is deleted, if it begins with a letter after s (only applicable to zel the last letter is deleted, and if it begins with a letter before s the middle letter is deleted.
The magic string (which in the ungolfed version contains spaces for clarity) contains the 2-letter codes followed by the music data. It is searched using the match operator =~ which returns the position in the string.
There is exactly one song each of 5, 7, and 8 notes (plus scs which also has 8 notes.) These, along with one arbitrary 6-note song ros are bundled at the beginning of the magic string so that the value of n given by the position in the string can be used to calculate the number of notes to play. cs is squeezed in before bf, and with the truncation when the number in n is rounded down we just get away with the correct calculation for both. After the fourth cluster, all songs have 6 notes so if n is large the number of notes is reduced to a default of 6.
An array of - is set up for output and the notes are substituted in one by one. The required music data is extracted from the variable $' which contains the part of the original magic string to the right of the match. In this way, irrelevant data is ignored.
The notes are encoded 3 at a time into the magic string, just after the relevant 2-letter song code. They are extracted with division by 5**(i%3) and a character in g is updated accordingly. At the end of the program g is printed.
s=gets.chop
s[?s<=>s[0]]=''
n=("owEk rswu ns=;g csbfbYu ze33 as&& es77 os\21\21 otaa st\23\23 mf\35\71 pl\n\a"=~/#{s}/)/5

g=(0..4).map{'-'*17}
(n<4? n+5 : 6).times{|i|x=$'[i/3].ord/5**(i%3)%5;g[x][i*2+1]='^<>VA'[x]}
puts g

Python 2, 141.5 Bytes -50% (283 Bytes)
s='D  2)AE0*  A2)D  AD )2 A  )D2A 0,"!A D2) A  (2EA"4H !A )2D A 1F`(A)2D  A  p\xc5*'.split("A")['sst pol zel sos sot sow sas ros mof scs nos eps bof'.split().index(raw_input())]
for c,n in zip(s,"^<>VA"):print"-".join([("-"+n)[i>"0"]for i in bin((ord(c)-32)%255)[2:].zfill(8)][::-1])

Stores each note as a byte as each line is 8 notes long. Recalls the binary representation and then replaces with the right characters.

Lua, 249 bytes - 50% = 124.5
w=io.write for j=1,5 do n={sst=41881,pol=44915,zel=30814,sos=42315,sot=17577,sow=5953,sas=35588,ros=11065,mof=29335,nos=122170,eps=29729,bof=719576,scs=999999}[...]for i=1,8 do d=n%6 n=(n-d)/6 c=d==6-j and'AV><^':sub(d,d)or'-'w('-',c)end w('-\n')end

Pretty simple, just reads back songs encoded as base-6 numbers.


text:
Generate a Monotonic Function
Overview
In this challenge, your task is to randomly generate a monotonic mathematical function between two sets.
Input
Your inputs are two positive integers s and n.
After getting these inputs, your program shall generate a random mathematical function f from the set {0,1,...,s-1}n to {0,1,...,s-1}.
In other words, f is a "rule" that takes in an n-tuple of integers between 0 and s-1, and returns one such integer.
Additionally, f should be monotonic in the following sense.
If A and B are two n-tuples such that A[i] ≥ B[i] holds for every coordinate i, then f(A) ≥ f(B).
The exact distribution of the monotonic functions f doesn't matter, as long as each such function has a positive probability of being generated (assuming a perfect RNG).
Output
Your output shall be an enumeration of the inputs and outputs of f.
It shall contain all n-tuples of integers between 0 and s-1 in some order, each one being followed by the corresponding output of f.
The exact output format is flexible (within reason).
Examples
The inputs s = 3 and n = 2 might produce the output
(0, 0) 0
(0, 1) 1
(0, 2) 2
(1, 0) 0
(1, 1) 1
(1, 2) 2
(2, 0) 1
(2, 1) 1
(2, 2) 2

It contains all the pairs over the set {0, 1, 2} exactly once, and each one is followed by its f-value.
The monotonicity condition is also satisfied.
The tuples are given here in lexicographical order, but this is not necessary.
As another example, s = 2 and n = 4 might produce
(0, 0, 0, 0) 0
(0, 0, 0, 1) 0
(0, 0, 1, 0) 0
(0, 0, 1, 1) 0
(0, 1, 0, 0) 1
(0, 1, 0, 1) 1
(0, 1, 1, 0) 1
(0, 1, 1, 1) 1
(1, 0, 0, 0) 0
(1, 0, 0, 1) 1
(1, 0, 1, 0) 0
(1, 0, 1, 1) 1
(1, 1, 0, 0) 1
(1, 1, 0, 1) 1
(1, 1, 1, 0) 1
(1, 1, 1, 1) 1

The following are all possible outputs for s = 2 and n = 2 (up to reordering the tuples); your program should randomly output one of them:
(0,0) 0
(0,1) 0
(1,0) 0
(1,1) 0
-------
(0,0) 0
(0,1) 0
(1,0) 0
(1,1) 1
-------
(0,0) 0
(0,1) 0
(1,0) 1
(1,1) 1
-------
(0,0) 0
(0,1) 1
(1,0) 0
(1,1) 1
-------
(0,0) 0
(0,1) 1
(1,0) 1
(1,1) 1
-------
(0,0) 1
(0,1) 1
(1,0) 1
(1,1) 1

Rules and Scoring
You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Code with explanation is preferred.
There are no restrictions on time complexity, but I'll give a bonus of -15 % if your solution is always guaranteed to finish in a certain amount of time (depending on the inputs, and assuming a perfect RNG that runs in constant time).

It might help if you completely enumerate all of the possible functions for a tiny case such as s=2 n=2. I had to read the description a few times to grasp how the randomness would come into play.

@Sparr Good idea; edited.

is bounded runtime a requirement? I'm contemplating a solution that produces random functions until it finds a monotonic one.

@Sparr I think I'll add a bonus for bounded runtime, so such a solution won't be disqualified.

@Zgarb - perhaps you should make a large bonus for solutions that are both bounded and likely to finish within an hour.

Pyth, 35 bytes (38 - 15% = 31.45 farther down)
#I!sm><FhMds<MCeMd^JC,mOQK^UQvzK2JB

Demonstration
Input is in the format:
n
s

Output is in the format:
[[value, tuple], [value, tuple], ...]

Simply generates random possibilities and tests them.

Alternative 37 byte version which I believe qualifies for the bonus:
Of!sm><FhMds<MCeMd^T2mC,d^UQvz^UQ^Qvz

Demonstration
This starts by generating all possible monotonic functions, then outputs one at random. It is much slower, and tops out at 2,2.

Nice example with input 3, 2. Unfortunately, I didn't even get a response for 3, 3 in the online pyth executor. Is there an endless loop for this combination?!

@bobbel The online executor has a timeout, I think. I try it locally.

@bobbel It's not so much an infitie loop has a very slow one. It also works for 2, 4, but not much else.

@bobbel I added something even slower.

CJam, 40 bytes - 15% = 34 bytes
q~1$\m*\1$,m*{W$\.+2m*{:.<2b}%1&!},mR]zp

This approach generates all valid functions and then selects on at random. Run time is at least O(s2sn), but constant for a given input.
I doubt this is what the OP had in mind, but it is guaranteed to finish in a certain amount of time (depending on the inputs[...]) and therefore qualifies for the bonus.
Try it online in the CJam interpreter.

Julia, 64 bytes (-15% = 54.4)
g(s,n)=(K=rand(0:s-1,ntuple(n,i->s));for i=1:n K=sort(K,i)end;K)

Ungolfed:
function g(s,n)
  # Generates a random n-dimensional array with s per dimension
  # and all values being integers between 0 and s-1
  K=rand(0:s-1,ntuple(n,i->s))
  # Loop over the various dimensions
  for i=1:n
    # Sort in the current dimension
    K=sort(K,i)
  end
  return K
end

This will run quickly, with the only possible issue being with memory for large enough s and n (g(10,10) has to produce a 10^10 array, so obviously it's going to run out of memory - even if each number is one byte, that's 10 gigabytes of data).
Output is 1-based indexing, so to determine the result for a given input, you need to add one to each input value. For example, to find f(1,2,6,0,3), you need to examine K[2,3,7,1,4].