text:
The lost pawn problem
The lost pawn problem
After the chess game ended, a surviving pawn was left behind enemy lines. let's help him find the shortest way back home.
The original problem describes a nXn "chess" board, and a function f: {1,..,n-1}X{1,..,n}X{-1,0,1} => R+ of weights. the goal is to find the best path from some square in the buttom line, to some other square in the top line, where the possible moves are: left-up,up,right-up, and you may not exit the board.
The problem is relatively easy to solve in O(n^2) using dynamic programming, but this is codegolf, and we don't care about useless stuff like running time complexity...
The Problem
input: a 3-dimentional array (or some other collection of your choice, received through stdin, or as a function argument), corresponding to a regular chess board, exactly in size: 7X8X3 (#linePasses X #rowSize X #movesPerPass) containing non-negative integers.
the moves cost from some position (i,j) where i is the row index, and j is the column index, are:

a[i][j][0] for the cost to travel up-left to square (i+1,j-1), or graphically: \.
a[i][j][1] for the cost to travel up to square (i+1,j), or graphically: |.
a[i][j][2] for the cost to travel up-right to square (i+1,j+1), or graphically: /.

you may assume it will not contain a path that sums greater than MAX_INT.
output: an 8X8 ascii output showing the best (shortest, i.e. minimum sum of weights) path (if there is more than 1 optimal result, you may show an arbitrary path of your choice). the path is drawn bottom to top, where in each line, the character corresponding to the pawn's position in the path, is the one it about to make. e.g. if the pawn is about to move up-left from column 3 (to column 2), the you should draw:
#?######
##\#####

where ? should be replaced with the next move. final position needs to be drawn as X.
Examples
input:
[
  [[1,1,1],[1,1,1],[0,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,0,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,1,1],[1,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,1,1],[1,1,1],[1,0,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,1,1],[1,1,1],[1,0,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
  [[1,1,1],[1,1,1],[1,1,1],[0,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1]]
]

output:
##X#####
###\####
###|####
###|####
##/#####
#/######
#|######
##\#####

input:
[
  [[41,27,38],[12,83,32],[50,53,35],[46,32,26],[55,89,82],[75,30,87],[2,11,64],[8,55,22]],
  [[56,21,0],[83,25,38],[43,75,63],[56,60,77],[68,55,89],[99,48,67],[94,30,9],[62,62,58]],
  [[23,18,40],[24,47,61],[96,45,72],[71,6,48],[75,63,98],[93,56,51],[23,31,30],[49,34,99]],
  [[20,47,42],[62,79,72],[32,28,44],[68,61,55],[62,39,57],[4,17,49],[97,85,6],[91,18,12]],
  [[51,50,11],[32,39,56],[12,82,23],[33,88,87],[60,55,22],[29,78,14],[70,11,42],[63,94,67]],
  [[75,64,60],[27,79,86],[70,72,56],[55,45,32],[95,67,12],[87,93,98],[81,36,53],[38,22,93]],
  [[31,80,50],[77,71,22],[59,46,86],[64,71,53],[41,19,95],[62,71,22],[92,80,41],[26,74,29]]
]

output:
######X#
#####/##
####/###
#####\##
#####|##
######\#
######|#
#######\

this is code-golf, so shortest code wins.
play fair. no loopholes...
EDIT:
Iv'e written an un-golfed straight forward solution in scala you can look at. There's also a site you can play with scala code on-line: scalafiddle (just copy&paste the gist to scalafiddle, and hit the play button)

Q: 199 Bytes
f:{m::x;n::{@/[+/-1 0 1_\:/:(x;m[y;;|!3]);0 2;(0W,),{x,0W}]};i:*<*|r:{&/n[x;y]}\[8#0;!7];  s:{-1+{*<x}'+n[y;z]}\[();(,8#0),-1_r;!7];j:i,{x+y x}\[i;|s];-1(@[8#"#";;:;]'[j;"X","/|\\"1+s'[|!7;-1_j]]);}

NOTES

Q interpreter (kx.com) free for non-commertial use (versions for
Windows, Linux, Mac)
This solution uses inner core of Q (internally named k4), so we need
a scripting file with k extension, or interactive interpreter in k
mode (\ command at first prompt). By contrast, 'verbose' (legible)
version of the language requires script with q extension, and is the
default mode at interactive interpreter.

TEST
f ((1 1 1; 1 1 1; 0 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 0 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 1 0; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 1 1; 1 1 0; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 1 1; 1 1 1; 1 0 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 1 1; 1 1 1; 1 0 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1)
   (1 1 1; 1 1 1; 1 1 1; 0 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1))

##X#####
###\####
###|####
###|####
##/#####
#/######
#|######
##\#####

f ((41 27 38; 12 83 32; 50 53 35; 46 32 26; 55 89 82; 75 30 87;  2 11 64;  8 55 22)
   (56 21  0; 83 25 38; 43 75 63; 56 60 77; 68 55 89; 99 48 67; 94 30  9; 62 62 58)
   (23 18 40; 24 47 61; 96 45 72; 71  6 48; 75 63 98; 93 56 51; 23 31 30; 49 34 99)
   (20 47 42; 62 79 72; 32 28 44; 68 61 55; 62 39 57;  4 17 49; 97 85  6; 91 18 12)
   (51 50 11; 32 39 56; 12 82 23; 33 88 87; 60 55 22; 29 78 14; 70 11 42; 63 94 67)
   (75 64 60; 27 79 86; 70 72 56; 55 45 32; 95 67 12; 87 93 98; 81 36 53; 38 22 93)
   (31 80 50; 77 71 22; 59 46 86; 64 71 53; 41 19 95; 62 71 22; 92 80 41; 26 74 29))

######X#
#####/##
####/###
#####\##
######\#
######|#
######|#
#######\

EXPLANATION
For ilustration purpose, we assume second test (matrix ((41 27 38; 12 83 32; ....)
We transform original matrix (m at code level): instead of orginimal matriz with a triplet for each coordinate, we define matrix for left, up, and right displacements. Left matrix contains 7x7 values (we drop first column), Up matrix 7x8, and right matrix 7x7 (we frop last column).
left                           up                         right
12 50 46 55 75 2  8       27 83 53 32 89 30 11 55     38 32 35 26 82 87 64
83 43 56 68 99 94 62      21 25 75 60 55 48 30 62     0  38 63 77 89 67 9
24 96 71 75 93 23 49      18 47 45 6  63 56 31 34     40 61 72 48 98 51 30
62 32 68 62 4  97 91      47 79 28 61 39 17 85 18     42 72 44 55 57 49 6
32 12 33 60 29 70 63      50 39 82 88 55 78 11 94     11 56 23 87 22 14 42
27 70 55 95 87 81 38      64 79 72 45 67 93 36 22     60 86 56 32 12 98 53
77 59 64 41 62 92 26      80 71 46 71 19 71 80 74     50 22 86 53 95 22 41

To calculate final position we need to evaluate minimum-cost path. We assume initial cost 0 0 0 0 0 0 0 0 (cost to arrive at each column of first row), and iterates with each next row. At each column i, we calculate three values:

cost of previous i+1 value plus left[i+1]. We drop first component of cost (shifts and alineates columns to add) and sum component to component
cost of previous i   value plus up[i]. We sum component to component
cost of previous i-1 value plus right[i-1]. We drop last component of cost (shifts and alineates columns to add) and sum component to component

To calculate minimum we complete left cost prepending infinite and right cost appending infinite: with 3 vectors of eight components, calculate minimum component to component. Resulting value is the base cost for new iteration
For first iteration we obtain values (0W is infinite in Q)
0W 12 50 46 55 75 2  8
27 83 53 32 89 30 11 55
38 32 35 26 82 87 64 0W

and calculates minimum of each column
27 12 35 26 55 30 2 8

After all iterations, we have the minimum cost to arrive to each square (assuming row 0 at top, 7 at bottom). We are only interested in last column, but i draw all intermediate results for ilustrative purposes
0   0   0   0   0   0   0   0
27  12  35  26  55  30  2   8
27  37  78  82  110 78  11  70
45  61  123 88  173 129 34  104
87  123 151 143 212 133 40  122
98  155 163 176 234 147 51  185
158 182 219 208 246 234 87  207
208 204 265 261 265 256 128 233

Now we found minimum value at last row (128, at column 6). That's the end of the path (X character in ouput).
We repeat cost calculation again, but now we annotate the direction from we obtain each minimum (wich of the 3 values used to calculate minimum is the selected value).
\|/|\///
\\\\\/|/
\\\|//|/
\\|\//|/
\\|//|\/
\\//|\|/
\|/|/|\/

We reverse rows, put 'X' at pos 6, and preserves only path that ends at column 6 (the others are substituted by #)
######X#
#####/##
####/###
#####\##
######\#
######|#
######|#
#######\

Iv'e never heard of Q, but thanks for such a detailed response :)

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


text:
Sinusoidal text
Goal: Write a program or function which prints an input string in a sinusoidal shape.
The ASCII sinusoid
Here is one period of the sinusoid:
         .......
      ...       ...
    ..             ..
   .                 .
  .                   .
 .                     .
.                       .                       .
                         .                     .
                          .                   .
                           .                 .
                            ..             ..
                              ...       ...
                                 .......

Note that there is exactly one dot on each column.

Each character in the input string will replace a dot in the shape above, from left to right.
Spaces in the input have to be outputted like normal characters, in place of a dot.
The starting character corresponds to the leftmost dot in the figure above.
This is only one period, inputs can be longer than the number of dots above.

Input

Inputs are ASCII strings that contain only characters between ASCII decimal 32 (space) and ASCII decimal 126 (Tilde ~).
Inputs will always be one line only (no linebreaks).
Inputs can be taken via STDIN, function parameters, command line arguments, or anything similar.

Output

Output must be printed exactly like they are in the test cases given.
Trailing spaces on lines are allowed as long as the length of the line with those trailing spaces does not exceed the length of the longest line (the one with the last character on it).
No leading/trailing line allowed.

Test cases

Input: .................................................

Output:
         .......
      ...       ...
    ..             ..
   .                 .
  .                   .
 .                     .
.                       .                       .
                         .                     .
                          .                   .
                           .                 .
                            ..             ..
                              ...       ...
                                 .......

Input: Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Output:
         ng Puzz                                         ion and                                         siasts                                          stratio
      mmi       les                                   est        an                                   thu       and                                   egi       n r
    ra              &                               qu             sw                               en              c                                r             eq
   g                                                                 e                                               o                             o                 u
  o                   C                           a                   r                           e                   d                           n                   i
 r                     o                                                                         l                     e                                               r
P                       d                       s                       s                       z                                               ,                       e
                         e                     i                         i                     z                         g                     e                         d
                                                                          t                   u                           o                   e                           .
                           G                 e                             e                 p                             l                 r
                            ol             ng                                f             g                                fe              f
                              f S       cha                                   or        min                                   rs.       00%
                                 tack Ex                                         program                                          It's 1

Input: Short text.

Output:
         t.
      tex
    t
   r
  o
 h
S

Input: The quick brown fox jumps over the lazy dog

Output:
          brown
      ick       fox
    qu              j
                     u
  e                   m
 h                     p
T                       s

                          o
                           v
                            er
                               th       dog
                                 e lazy

Scoring
This is code-golf, so the shortest program or function in bytes wins.

This is what I was thinking of

Oh I see it is indeed somewhat similar.

Incidentally, your wave is not quite sinusoidal. (Naturally I tried using a sin function to reproduce it but the positions are a little off.)

@DavidZ That doesn't surprise me, I eyeballed the ASCII shape. Can you even get something sinusoidal without any "gap" in the columns (i.e. exactly one dot per column)?

Sure, it's like plotting: you can calculate the height of a sine wave at each 1/48th of a period, round it, and put the letter at that height. It only differs from yours by one spot in each of a few columns.

Taking sin(x*pi/24)^a*b and rounding away from infinity generates the right wave for some 0 < a < 1 and 5 < b < 6!

Also related

I spent a couple minutes entertaining myself by moving the scroll bar on test case 2's output back and forth really fast.

What should you output for the input "Short"? Should there be two leading newlines?

@FryAmTheEggman That would be acceptable I guess. This edge case is not in the test cases so I can't change the rules since there are already a lot of answers.

Just like Lynn noticed (and some people in answers) it is not invalid sinusoid. To look like this it just requires proper rounding method and amplitude (eg: amplitude 5.6 and rounding towards +inf). And by magic of quantization you have requiered shape. Although it would be nice to have that information in the question itself.

Pyth, 59 bytes (57 characters)
Xjb.sC.>V+R*12\ Xz\ C9*+-L12K+JsM._+6jC\཈2tP_JKlz]*dlzC9d

Demonstration.
A binary lookup table is encoded inside ཈, which has value 3912. This is converted to binary, giving [1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0]. This is treated as the differences between consecutive heights. By prepending a 6, forming all prefixes and mapping each to its sum, the first quarter of the wave is generated.
sM._+6jC\཈2 evaluates to [6, 7, 8, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12] as described above. Then, the code concatenates on the reverse of this string to form the first half of the wave, and then subtracts it from 12 to give the entire wave.
Then, we form lines of each input character followed by 12 spaces. This line is rotated to the right by the wave height parameter corresponding to that location, and then the lines are transposed and joined on newlines.
Then, we strip off leading and trailing blank lines. However, we can't strip off leading or trailing blank lines that have spaces from the input. This is implemented by replacing spaces in the input with tabs (C9), which can't be in the input, stripping blank lines, and turning the tabs back into spaces.

@FryAmTheEggman Fixed, at the cost of 16 bytes.

Python 2, 156 bytes
l=map(int,"654322111%08d1122345"%1);l+=[12-c for c in l]
def f(t):
 h=len(t);o=bytearray(' '*h+'\n')*13;i=0
 for c in t:o[i-~h*l[i%48]]=c;i+=1
 print o[:-1]

Explanation

The whole code simply makes a block of spaces (o) and replaces the right spaces with the letters of the input t.
The variable l stores a list of offsets from the top. So that the nth character of t should be on line l[n].
The bytearray o serves as a mutable string, since strings are immutable in python.
-~h is the same as h+1 but saves space because I don't need parentheses.

Java, 219 209 199 bytes
void p(char[]s){int r=6,c;String t="";for(;r>-7;r--,t+='\n')for(c=0;c<s.length;c++)t+=(s(c%48)==r?s[c]:' ');System.out.println(t);}int s(int a){return a<4?a:a<6?4:a<9?5:a<15?6:a<24?s(24-a):-s(a-24);}

I'm still a newbie here, and hope that it is compliant to the rules to introduce a sub-function (when the bytes of this function are counted, of course). If not, I'll try to convert the sin function into some clever array lookup...
public class SinusText
{
    public static void main(String[] args)
    {
        SinusText s = new SinusText();
        s.p(".................................................".toCharArray());
        s.p("Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.".toCharArray());
        s.p("Short text.".toCharArray());
        s.p("The quick brown fox jumps over the lazy dog".toCharArray());
    }
    void p(char[]s){int r=6,c;String t="";for(;r>-7;r--,t+='\n')for(c=0;c<s.length;c++)t+=(s(c%48)==r?s[c]:' ');System.out.println(t);}int s(int a){return a<4?a:a<6?4:a<9?5:a<15?6:a<24?s(24-a):-s(a-24);}
}

For some string-based challenges it also saves if you take input as a char[]. Here, it would get rid of the () on length and eliminate charAt() as well. If I'm reading it right, you can also use print() instead of println() to save a couple more.

@Geobits These are the degrees of freedom that I was not aware of. The task description talks about a "String", so I thought that it had to be "THE" String representation of the respective language. ...

Yea, I asked about it on meta some time back. Here's a link for reference: http://meta.codegolf.stackexchange.com/q/2214/14215

Thanks, it's 209 then. (Maybe I'll try to squeeze out a few more bytes later. The "sin" function still looks too verbose...)

Hmm, not a huge improvement, but you can cut 10 by doing the whole thing modulus 48. Change the end to ...a<24?s(24-a):-s(a-24); and call it with s(c%48).

Yes, with things like that. 10 bytes are not much absolutely, but relatively ;-) I thought that it should also be possible to exploit the symmetry of the curve (actually, one only needs the "shape" of the first quarter of the curve!), but I'll have to fiddle around a bit more here to get this right...

Perl 5 + -lF -Mbigint -M5.10.0, 97 bytes
Coming back to this after a while it's nice to see how much my approach to this kind of thing has improved, -123 bytes!
eval's!.!(@l=654322111000000011122345=~/./g,map{12-$_}@l)[pos()%48]-$-?$":$F[pos]!ge;$-+=say;'x13

Try it online!
Explanation
Input is implicitly placed in $_ (due to -n, and -a, being implicitly set by -F being set) and is split into chars in @F. Then the code in 's is evaled 13 times. This code substitues every char (s!.!...!) in the input (s/// works on $_ by default) with either the char at the current position from @F ($F[pos]) or a space ($") depending on whether or not the current value of $- (which starts as 0) is equal to the value in the in the list of values, modulo 48. This list is constructed from the 24-digit integer (654322111000000011122345), which represents the first set of rows in which the char should be displayed for the waveform, which is split into digits (=~/./g) and the second part is created in the immediately following map which subtracts the values from 12, resulting in a list of 48 values that indicate where chars should be displayed. $- is incremented using the return from say (which outputs the current value of $_ with a trailing newline) which is 1.

JavaScript, 251 243 224 220 217
Really simple implementation: it uses a string of characters to represent the y-position of each character on the wave (offset by a, which is ASCII code 97). It then iterates through all possible rows; if the y-value of the current row is the same as the y-position on the wave, it writes a character from the string. There's also a cleanup at the end to remove the row if it turned out to be completely blank.
Note that the output will appear wonky in the alert() window if it's not using a monospaced font, you can change it to console.log() to verify the output is correct.
s=prompt(o=[])
for(y=i=0;y<13;++y){o[i]=""
for(x=0;x<s.length;++x)o[i]+=y=="gfedccbbbaaaaaaabbbccdefghijkklllmmmmmmmlllkkjih".charCodeAt(x%48)-97?s[x]:" "
if(o[i++].trim().length<1)o.splice(--i,1)}
alert(o.join("\n"))

EDIT1: ++ and -- exist.
EDIT2: Blank line removal is now done in the same loop as the rest, saving 17 characters. Didn't need those brackets either, for an extra 2 characters.
EDIT3: No need to declare the waveform as a variable, saving 4 characters.
EDIT4: As pointed out by Dom Hastings in the comments, the byte count included the carriage return as well as the newline character, updated the byte counts for all revisions to exclude the carriage return.
EDIT5: Saved 3 bytes courtesy of Dom Hastings. I haven't implemented the o.splice fix as this fails to remove the blank lines (on my end, at least).

Nice work! A few places you can save a couple more bytes:
Replace: if(o[i++].trim().length<1)o.splice(--i,1) with o.splice(i-(t=!o[i++].match(/\s/)),t), for -4, s=prompt() o=[] with: s=prompt(o=[]), -1 and for(y=0,i=0;y<13;++y){o[i]="" with for(y=i=0;y<13;++y){o[i]="", -2. It's probably possible to combine your for loops too to save more... One last thing, it's worth noting as well that I only have 220 for your current byte count, so your 225 might be windows \r\n instead of just \n which I assume you can ignore (please correct me if I'm wrong)...

Good catch on the carriage return! Next time I won't trust Notepad++ so much :)

I think I have it reduced to 166. Can anyone else verify? I changed the array behavior to a log throughout the program. i used a short circuit instead of an if statement, and got rid of the brackets by putting the log at the end of the first for loop. for(s=prompt(),y=0;y<13;y++,v.trim()&&console.log(v))for(v="",x=0;x<s.length;x++)v+=y=="gfedccbbbaaaaaaabbbccdefghijkklllmmmmmmmlllkkjih".charCodeAt(x%48)-97?s[x]:" "

using falsy zero to replace == with subtraction, 165 char
for(s=prompt(y=0);y<13;y++,v.trim()&&console.log(v))for(v="",x=0;x<s.length;x++)v+="gfedccbbbaaaaaaabbbccdefghijkklllmmmmmmmlllkkjih".charCodeAt(x%48)-97-y?" ":s[x]

I'm having trouble pasting it from my comment so heres a pastebin http://bit.ly/1VQgGXw 217->166 = 76%

Good work, though I think you should post it as your own answer considering how different it is from my implementation!

Matlab, 133, 130 bytes
The one liner:
s=input('');y=ceil(5.6*sin(0:pi/24:pi-.1).^.9);l=[-y y]+7;n=numel(s);t=repmat(' ',13,n);for k=1:n;t(l(mod(k-1,48)+1),k)=s(k);end;t

And the expanded version:
function f(s)
    y=ceil(5.6*sin(0:pi/24:pi-.1).^.9);l=[-y y]+7;  %// calculate the line number for each column position
    n=numel(s);                                     %// number of character in input
    t=repmat(' ',13,n);                             %// Create a blank canvas of whitespace characters
    for k=1:n
        t(l(mod(k-1,48)+1),k)=s(k);                 %// place each input character where it should be
    end
    t                                               %// force the output display

The one liner takes input from the console (stdin) and is 130 bytes. The expanded version replace the console input by a function definition (+1 byte) but is much more comfortable to use for the test case in a loop:

Description:
The line index of each character is calculated for a half period, then mirrored and concatenated to have a full period.
We create a blank background of whitespace character (same length as the input string.
We place each character according to its position in the relevant line. If the input string is longer than one period, the mod (modulo) operator wraps that so we don't get out of bound when requesting the line number.

Test case:
Save the function version under textsine.m in your path, then run:
s = {'.................................................';...
    'Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It''s 100% free, no registration required.';...
    'Short text.';...
    'The quick brown fox jumps over the lazy dog'};

for txtcase=1:4
    textsine(s{txtcase,1})
end

will output:
t =

         .......
      ...       ...
    ..             ..
   .                 .
  .                   .
 .                     .
.                       .                       .
                         .                     .
                          .                   .
                           .                 .
                            ..             ..
                              ...       ...
                                 .......

t =

         ng Puzz                                         ion and                                         siasts                                          stratio
      mmi       les                                   est        an                                   thu       and                                   egi       n r
    ra              &                               qu             sw                               en              c                                r             eq
   g                                                                 e                                               o                             o                 u
  o                   C                           a                   r                           e                   d                           n                   i
 r                     o                                                                         l                     e                                               r
P                       d                       s                       s                       z                                               ,                       e
                         e                     i                         i                     z                         g                     e                         d
                                                                          t                   u                           o                   e                           .
                           G                 e                             e                 p                             l                 r
                            ol             ng                                f             g                                fe              f
                              f S       cha                                   or        min                                   rs.       00%
                                 tack Ex                                         program                                          It's 1

t =

         t.
      tex
    t
   r
  o
 h
S

t =

          brown
      ick       fox
    qu              j
                     u
  e                   m
 h                     p
T                       s

                          o
                           v
                            er
                               th       dog
                                 e lazy

if you want to test the one liner version with input from stdin, your input has to be entered as one single string, so you'd have to enclose your input between ' characters.
Example:
'Short text.'   %//   valid input
Short text.     %// INVALID input

Thanks Luis Mendo for shaving up 3 bytes ;-)

@LuisMendo, thanks for the 3 bytes saved :-). I explained how to input a proper string so the simple s=input(''); would still work.

s=input('');y=ceil(5.6*sinpi(0:1/24:.97).^.9);l=[-y y]+7;n=nnz(s);t=repmat(' ',13,n);for k=1:n;t(l(mod(k-1,48)+1),k)=s(k);end;t -3 bytes; nnz can be used instead of numel because input can't contain zeros, saves 2 bytes; sinpi(0:1/24:.97) saves one byte compared with sin(0:pi/24:pi-.1)

Scala 377 characters
first cut. probably can get a better formula to translate x to y
(s:String)⇒s.zipWithIndex.map(t⇒(t._1,t._2,t._2%48 match{
case i if i<5⇒6-i
case 5|19⇒2
case 6|7|8|16|17|18⇒1
case i if i<16⇒0
case i if i<29⇒i%20+2
case 29|43⇒10
case 30|31|32|40|41|42⇒11
case i if i<40⇒12
case i if i>43⇒10-i%44
})).groupBy(_._3).toSeq.map{case(y,xs)⇒(""→0/:xs.sortBy(_._2)){case((p,l),(c,x,_))⇒(p+" "*(x-l-1)+c)→x}._1→y}.sortBy(_._2).map(_._1).mkString("\n")

Common Lisp, 205 bytes
(lambda(s &aux p v o)(dotimes(r 13)(setf o 0 p v v(round(*(/ 24 pi)(+(asin(-(/ r 6)1))pi))))(when p(map()(lambda(c)(princ(if(some(lambda(k)(<= p(mod k 48)(1- v)))`(,o,(- 23 o)))c" "))(incf o))s)(terpri))))

Tests
See http://pastebin.com/raw.php?i=zZ520FTU
Remarks
Print the output line by line, computing the indices in the strings that should be printed using the inverse sine function asin. The output do not match exactly the expected inputs in the question, but since OP acknowledges that the example outputs are not real sine, I guess this is ok. At least, there is always only one character written for each column.

Python 2, 172 bytes
This isn't as good as Alex L's answer, but it's pretty close. Takes input from standard input and works best in a .py file.
l=map(int,bin(9960000)[2:]);l+=[-c for c in l];s=6;o=[];i=9
for c in raw_input():b=[' ']*13;b[s]=c;o+=[b];s+=l[i%48];i+=1
print''.join(sum(zip(*o+['\n'*13])[::-1],())[:-1])

I decided to build the output transposed (each column is a row) and then transpose the result, since in python the transpose of a matrix is map(*m).

l: The binary representation of 9960000 (after chopping off the "0b" from bin) is 100101111111101001000000. This is the "step" of the sine wave each column, starting at the very last character of the very lowest point. I copy this list, negate each number, and tack it onto the end of itself to form what is effectively a derivative of the function.
s: This is the variable that keeps track of which row (column in the transpose) the next character gets inserted into.
o: End output, transposed
i: Keeps track of sine wave period. Starts at 9 since l is shifted slightly.

In the for loop, I create a list of 13 spaces (I was using bytearrays but lists of characters turn out to have a shorter print statement), then replace the sth character with the input character. Append b to the end of o, add the appropriate step to s, and increment i.
I had hoped the print statement would be as simple as \n'.join(*zip(o)), but no such luck. zip(*o+['\n'*13])[::-1] appends a column of newlines and then reverses and transposes the whole thing (without the reversing, the sine wave is upside down), sum(...,()) concatenates the tuples together into one tuple of characters, and then ''.join(...) concatenates the characters and prints it.
Other things I tried were making a 12-character array of spaces and inserting the new character into the appropriate place, and replacing l+=[-c for c in l]; with some sort of math with some sort of multiplication of 1 and -1 with the result of indexing into l, but nothing I could come up with ended up being shorter.

Mathematica, 131 bytes
i=[input string];c=Characters@i;l=Length@c;StringJoin@Riffle[StringJoin@@@SparseArray[Table[{7-Round[6 Sin[.13(x-1)]],x},{x,l}]->c,{13,l}," "],"\n"]

That's 131 characters, including the three for i=foo;. That seemed a reasonable way to take the input; I could have put it straight into the definition of c and saved a few strokes, but that feels unfair.
It's pretty straightforward -- almost even readable. It splits the string into a list of characters, and then puts those characters into a sparse array at the positions determined from the Table (any spot in the array not given a character defaults to a space). The lines are assembled separately, then newlines sprinkled between them. The final StringJoin stitches it all up.
NB: Like some other solutions, this may not actually be valid because it produces a real sinusoid rather than the (beautiful) handcrafted example.
Tests:
(*i=Programming Puzzles...*)
         ng Puzz                                          on and                                          iasts                                           tration
       mi       le                                     sti       a                                      us      and                                     is        r
     am           s                                   e           ns                                  th            c                                 eg           eq
    r               &                               qu              we                              en               o                               r               u
  og                  C                                               r                                               d                            o                  ir
 r                     o                          a                                               e                    e                          n                     e
P                       d                       s                       si                       l                       g                                               d
                         e                     i                          t                    zz                         o                     ,                         .
                           G                                               e                  u                            lf                 ee
                            o               ge                               f               p                               e               r
                             lf           an                                  or           g                                  rs            f
                                St      ch                                       p      min                                     .        0%
                                  ack Ex                                          rogram                                          It's 10
(*i=.... ...*)
         .......
       ..       ..
     ..           ..
    .               .
  ..                 ..
 .                     .
.                       .                       .
                         ..                    .
                           .                  .
                            .               ..
                             ..           ..
                               ...      ..
                                  ......
(*i= Short text.*)
         t.
       ex
      t
    t
  or
 h
S

(*i=The quick...*)
          brown
       ck       fo
     ui           x
    q               j
  e                  um
 h                     p
T                       s
                          o
                           v
                            e
                             r            g
                               the      do
                                   lazy

source: Stack Exchange

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

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

sort: votes


text:
"Write" a simple calculator without writing a single line of code
It's very easy:
Create a program without writing a single line of code. The code may only consist of existing Stack Overflow questions and answers.
The program should create two random numbers and output the numbers

added to,
subtracted from,
multiplied with and
divided by

each other.
Rules
You must include links to the questions/answers you used in your answer.
You may not modify the code you find, with the following exceptions:

You may rename variables, functions, and methods. (This doesn't mean you can change a method invocation, by changing, say scanner.nextInt() to scanner.nextLine() and claiming that you're changing a method name. The change must be in the definition or reference to the same entity.). The solution should still work if variables, functions or methods would be renamed again.
You may adjust indentation appropriately.
You can assume that the proper modules are loaded for the code snippets to work. (e.g., import statements for Java and Python, using statements for C# and C++, and their equivalents in all languages) If the code snippet includes the imports for you, you can move them to the top of the code.
If the language requires the code to be in some kind of method body to execute (e.g., public static void main(String[] args) for Java, static int Main(string[] args) for C#, and so on), you can wrap your code in the appropriate method. But the contents of that main method must remain unmodified.
You must supply an explicit list of any variable/method/function/class renamings performed.
You can't take snippets of snippets (meaning if you take a code block from a post, you take the whole thing)
Provide a brief description of what the code does for people who aren't intimate with the language you're using.
You must use snippets posted before this challenge was started.

Popularity contest, so the most upvotes wins!
Deadline
I will accept the the submission that has the most votes around the end of August, 6.

Hi michael, and welcome to PPCG stack exchange! One of the rules for code challenges on this site is that they must have an objective winning condition, so you should pick such a condition for this one. This is a similar challenge which might give you some ideas.

Hi @isaacg, thank you. I'll have a look and delete/edit this one.

@isaacg, hope it's okay now. You are more experienced than me here, is the deadline too close/far?

It's much better. The deadline is much too close however, standard is about 1-2 weeks.

I'm waiting for the one guy that will go through all the ridiculous RegEx questions on SO to get a working Retina answer...

Haha, me too. @Fatalize

Are we allowed to use both answers AND questions? Or just answers?

You can use both!

J, 7 questions/answers, none about J
echo a%b[echo a*b[echo a-b[echo a+b[b=:?2147483647 [a=:?2147483647

It's a pretty damn cheap way to do it, I'm not gonna lie. Here are the SO answers I used:

echo
This answer

+, -, * and %
This question

?
This answer

[
This answer

= and :
This community wiki question

2147483647
This answer

foo
This answer

I renamed variable foo as a and b in the code.

I imagine taking this approach would be much harder in APL, but there's still a good chance of finding the characters in a code block by themselves.

@JohnE That's the advantage of being ASCII noise!

I like this answer, but the question states "You can't take snippets of snippets" - which this is doing, right?

@unclemeat "if you take a code block from a post, you take the whole thing". To me it sounds like if there are multiple code blocks in a post, you can take just one, but you can't take part of a code block.

All of these come from complete code blocks - take a look at the sources.

Using other languages answers to get the keywords is kind of genius...

@mbomb007 "You must include links to the questions/answers you used in your answer.". I actually didn't see that questions were not included in that first sentence, but they are further down. So I don't know for sure if this fits what OP wants.

Python 2, 7 6 references
Creating this solution wasn't as easy as it looked. Searching Stack Overflow for specific code is difficult, since symbols are not included in the search.
I had found a way to do this with 2000-bit random numbers, using a different answer in place of Ref #1, but I couldn't test it on the online environments I use since it involves getrandbits, which calls os.urandom, giving me a NotImplementedError, so I went this way instead. This could actually be used now, with TIO.
Try it online
#assumed to be loaded
import random

n1 = []
n1.append(random.randint(1, 100))

n2 = []
n2.append(random.randint(1, 100))

r1 = map(sum, zip(n1, n2))
r2 = map(lambda t: t[0] - t[1] ,zip(n1, n2))

ab = [n1[i]*n2[i] for i in range(len(n1))]

r1, last = r1[0], r1[-1]
r2, last = r2[0], r2[-1]
ab, last = ab[0], ab[-1]
n2, last = n2[0], n2[-1]

print r1
print r2
print ab
ab = float(ab) / n2
ab = float(ab) / n2
print ab

References
import random is assumed to be loaded, since the question says that's allowed.

lst = [] and lst.append(random.randint(1, 100)) - Here
map(sum, zip(r1, r2)), map(lambda t: t[0] - t[1] ,zip(r1, r2)), r1, and r2 - Here
result = float(a) / b - Here
ab = [a[i]*b[i] for i in range(len(a))] - Here
first, last = some_list[0], some_list[-1] - Here
print x - Here

Renamed

lst renamed to n1 and n2 (Ref #1: I used the entire code twice)
r1 and r2 renamed to n1 and n2 (Ref #2: I used the separate variables later though, to assign the maps and to divide in the last print, since the answer included them. )
result and a renamed to ab, and b renamed to n2 (Ref #3)
a and b renamed to n1 and n2 (Ref #4)
first and some_list both renamed to r1, r2, ab, or n2, depending on which line. (Ref #5: I used this four times. Note that only the first assignment is used, so I don't rename last)
x is renamed to r1, r2, or ab, depending on which line. (Ref #6)

Decimal, 2 references
82D82D00D30001D30041D301212010D301200D30001D30042D301212010D301200D30001D30043D301212010D301200D30001D30044D30122

Commands used:

0 SET (default stack index)
1 PUSH

2 CHAR

2 POP
3 I/O

00 duplicate stack
01 from stack to STDOUT

4 MATH

1 ADD
2 SUBTRACT
3 MULTIPLY
4 DIVIDE

8 BUILTIN

2 push random integer to stack

Explained version:
82D       ; push random INT    - stack contains {r1}
82D       ; push random INT    - stack contains {r1, r2}

00D300    ; duplicate stack[0] - stack contains {r1, r2, r1}
01D300    ; duplicate stack[1] - stack contains {r1, r2, r1, r2}
41D       ; math +             - stack contains {r1, r2, r1+r2}
301       ; print from stack to output
2         ; pop                - stack contains {r1, r2}

12010D3012; print newline

00D300    ; duplicate stack[0] - stack contains {r1, r2, r1}
01D300    ; duplicate stack[1] - stack contains {r1, r2, r1, r2}
42D       ; math -             - stack contains {r1, r2, r1-r2}
301       ; print from stack to output
2         ; pop                - stack contains {r1, r2}

12010D3012; print newline

00D300    ; duplicate stack[0] - stack contains {r1, r2, r1}
01D300    ; duplicate stack[1] - stack contains {r1, r2, r1, r2}
43D       ; math *             - stack contains {r1, r2, r1*r2}
301       ; print from stack to output
2         ;                    - stack contains {r1, r2}

12010D3012; print newline

00D300    ; duplicate stack[0] - stack contains {r1, r2, r1}
01D300    ; duplicate stack[1] - stack contains {r1, r2, r1, r2}
44D       ; math /             - stack contains {r1, r2, r1/r2}
301       ; print from stack to output

Sources:

https://stackoverflow.com/a/473309/6850771 - d (capitalized)
https://stackoverflow.com/q/15405966/6850771 - 0 through 9

Try it online! You'll need to disable the output cache if it's not automatically disabled.

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


text:
Alphabetic Fannkuch
Fannkuch is a classic benchmark program. The name comes from the German "Pfannkuchen"- pancakes- for the algorithm's resemblance to flipping stacks of pancakes. A Fannkuch sequence of numbers is formed as follows:

Take a permutation of {1.....n}, for example: {4,2,1,5,3}. Take the
  first element, here 4, and reverse the order of the first 4 elements:
  {5,1,2,4,3}. Repeat this until the first element is a 1, so flipping
  won't change anything more: {3,4,2,1,5}, {2,4,3,1,5}, {4,2,3,1,5},
  {1,3,2,4,5}

You are to write a program or function which calculates a Fannkuch-like sequence for strings of alphabetic characters. Instead of using numbers to indicate how many elements of the list should be flipped each time, the position of a letter in the alphabet should be used. For example, a leading c would indicate that you should reverse the order of the first 3 elements, while a leading a indicates that the sequence is complete.
Input
Input will be provided as a string via stdin or as a function argument. The string will contain between 1 and 26 distinct lowercase letters. Strings will not contain letters whose equivalent index would cause the Fannkuch algorithm to flip more elements than exist.
Output
Programs or functions should return or print to stdout the sequence of terms produced by applying the Fannkuch algorithm until a leading a is encountered, including the initial string. For example, if the input is bca, you might print:
bca
cba
abc

Printed results can use any reasonable separator- commas, newlines, etc. Any choice of whitespace is acceptable.
As another example, if your input is eabdc you might return:
("eabdc"
 "cdbae"
 "bdcae"
 "dbcae"
 "acbde")

Rules and Scoring
This is code-golf- the shortest program wins. Standard Loopholes are disallowed.

Pyth, 16 bytes
.u+_<NJhxGhN>NJz

Demonstration.
The "repeat until it stops changing" feature of Pyth's reduce functions is really handy here. This is used with .u, the cumulative reduce function, to output all results. The body of the reduce is as naive as can be, but I couldn't find anything better.

T-SQL, 213 bytes
Of course being SQL it's really large, but it was interesting to do.
Created as an inline table function using a recursive CTE query.
CREATE FUNCTION F(@ CHAR(26))RETURNS TABLE RETURN WITH R AS(SELECT @ S UNION ALL SELECT CAST(STUFF(S,1,ASCII(LEFT(S,1))-96,REVERSE(LEFT(S,ASCII(LEFT(S,1))-96)))AS CHAR(26))FROM R WHERE LEFT(S,1)<>'a')SELECT*FROM R

Expanded
CREATE FUNCTION F(@ CHAR(26))
RETURNS TABLE
RETURN WITH R AS(
    SELECT @ S            -- Initial string as an anchor for the recursion
    UNION ALL
    SELECT CAST(
        STUFF(                                    -- Stuff into
            S,                                    -- string S
            1,                                    -- from position 1
            ASCII(LEFT(S,1))-96,                  -- to index value of first char
            REVERSE(LEFT(S,ASCII(LEFT(S,1))-96))  -- the reverse of the index first chars
            )
        AS CHAR(26))
    FROM R
    WHERE LEFT(S,1)<>'a'  -- recurse until first char is a
)SELECT*FROM R

Used as follows
SELECT * FROM F('eabdc')
S
--------------------------
eabdc
cdbae
bdcae
dbcae
acbde

(5 row(s) affected)

CJam, 22 bytes
This is an anonymous function which takes a string on stack and returns a list of string on the stack.
{_,{_0='`-/(W%\+s_}*]}

Try it online here

Python 2, 59 bytes
def p(l):
 print l;o=ord(l[0])-97
 if o:p(l[o::-1]+l[o+1:])

I guess this is a rather straightforward answer.  Uses recursion and Python's slice syntax.  Call as: p('eabdc').

SAS, 131 bytes
sub a(s$);outargs s;put s;do while(b ne 1);b=rank(char(s,1))-96;substr(s,1,b)=reverse(substr(s,1,b));if b>1 then put s;end;endsub;

An FCMP call routine.  Nongolfed below (with an extra check I highly recommend as SAS crashes if an FCMP routine enters an infinite loop).

options cmplib=work.funcs;
proc fcmp outlib=work.funcs.funcs;
  sub a(s$);
    outargs s;
    put s=;
    do while (b ne 1 and z<1e5);
        b=rank(char(s,1))-96;
        substr(s,1,b) = reverse(substr(s,1,b));
        if b>1 then put s=;
        z+1;
    end;
  endsub;
quit;

Nice work. We don't get much proc fcmp around here.

Haskell, 78 bytes
f l@(h:_)|h=='a'=[l]|1<2=l:f(reverse(take d l)++drop d l)where d=fromEnum h-96

Usage: f "eabdc" -> ["eabdc","cdbae","bdcae","dbcae","acbde"].

consider using splitAt -- you can get it down to 71 bytes!

@MtnViewMark well i seem to have the exact same algorithm, down to 68 bytes

K5, 21 bytes
{(|v#x),(v:*x-96)_x}\

Saved 5 bytes thanks to @JohnE and another byte by rearranging an expression.
For the first time on earth, I think K has beaten CJam!
27-byte version
(~97=*){(|v#x),(v:-96+*x)_x}\

You can make this quite a bit shorter if you use the fixed-point form of "scan".

@JohnE Thanks! I didn't realize that, when the first letter is an a, the string won't change.

Haskell, 68
f l@(x:_)|x<'b'=[l]|(x,y)<-splitAt(fromEnum x-96)l=l:f(reverse x++y)

Any more complicated tactic I thought of took more bytes.


text:
A code golf challenge, m'kay

Mr. Mackey is a South Park character well-known for adding "m'kay" in everything he says.
Write a program or function that transforms a string of text into something Mr. Mackey would say.
M'kay placement

m'kay has a random 50% chance of being added after the punctuations ,, ., ? and !. If that is the case, it will be followed by the exact same punctuation mark that preceeds it and preceeded by a space.
For example, in the sentence Test, test., there are two places where m'kay can be added: after the comma, and after the period, with a 50% chance at each place. Possible results would be Test, m'kay, test. or Test, test. M'kay. or Test, m'kay, test. M'kay..
There must always be at least one m'kay added. Moreover, it cannot always be at the same place and each valid place where m'kay could be added must occur with equal probability. That is, you can't add m'kay always at the end of the string if because of randomness you never added any m'kay. If there is only one m'kay, it must have the same probability of appearing in each valid position, even though its presence is enforced.
If m'kay is after ?, . or !, the m must be uppercased.
The number of m in m'kay must be uniformely picked between 1 and 3. That is, m'kay, mm'kay and mmm'kay are all possible choices, each with probability 0.33... If it must be uppercased (see above rule), all m must be uppercased.

Inputs, outputs

Inputs are ASCII strings containing characters from ASCII Dec 32 (Space) to ASCII Dec 126 (Tilde ~). There are no linebreaks in the input. You may assumed that any input will contain at least one of , . ? !.
You may assume that there are no m'kay or any of its variants in the input.
Inputs may be taken from STDIN, function arguments, command line, or anything similar.
Output may be via STDOUT, a function return, or something similar.

Test cases

Input: Test.

Possible output: Test. M'kay.

Input: Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Possible output: Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. MMM'kay. It's 100% free, mm'kay, no registration required.

Input: Drugs are bad, so, if you do drugs, you're bad, because drugs are bad. They can hurt your body, cause drugs are bad.

Possible output: Drugs are bad, m'kay, so, if you do drugs, you're bad, m'kay, because drugs are bad. They can hurt your body, m'kay, cause drugs are bad. M'kay.

Input: Do you understand? Really? Good!

Possible output: Do you understand? MM'kay? Really? Good! MMM'kay!
Scoring
This is code-golf, so the shortest code in bytes wins, m'kay?

+1, M'kay, but we need a Cartman challenge!

@steveverrill not sure the language in a Cartman challenge would be acceptable here sadly :P

I want to see an answer in Ook! MM'kay! But you'll probably want to use this algorithm for a pseudo-random number generator.

@Fatalize: It's all Kyle's mom's fault.

"M'kay has a random 50% chance of being added after the punctuations ,, ., ? and !" seems to be incompatible with "There must always be at least one m'kay added". Please clarify that

Does this "The number of m in m'kay must be uniformely picked between 1 and 3...    Mean that all M'kay's in a sentence should have the same number of M's?  Because your example outputs for "Programming puzzles...." and "Do you understand...." do not appear to follow this rule.  Please clarify what you mean.

Is a capitalized M'kay valid at the start of the string?

@Winny No, it's not valid.

@LuisMendo I don't see how it can be clearer. There's a 50% chance for each m'kay but at least one must be enforced regardless of the 50% chance.

@CBRF23 No, it, the number of m is independant between each m'kay.

In the first test case, shouldn't the program always produce the same output, given that at least one m'kay is required and they can only appear after punctuation? ie, *"Only possible output: Test. M'kay."

@AdamDavis The m'kay will indeed always be there but the number of M's can vary from one to three

@Fatalize Mmm'kay!

Can the input include m'kay, and if yes, would returning the input as the output (i.e. it includes at least one m'kay but did not add any) pass? I saw at least one answer that checked for the presence of m'kay to determine whether it had randomly added at least one, but that approach would fail if the input started with at least one m'kay.

@KRyan It's ok to assume that there are no m'kay in the input.

@Fatalize OK, then that should probably be in the question.

A way of demonstrating the incompatibility mentioned by @LuisMendo would be to consider a string with only one punctuation mark.

CJam, 65 52 49 bytes
l{_{_",.?!"#:IW>)mr{SI'M'm?3mr)*"'kay"3$}&}%_@=}g

Try it online in the CJam interpreter.
How it works
l            e# Read a line from STDIN.
{            e# Do:
  _          e#   Duplicate the line.
  {          e#   For each of its characters:
    _",.?!"# e#     Find its index in that string.
    :IW>     e#     Save the index in I and check if it's greater than -1.
    )        e#     Add 1 to the resulting Boolean.
     mr      e#     Pseudo-randomly select a non-negative integer below that sum.
             e#     If I == -1 the result will always be 0.
    {        e#     If the result is 1:
      S      e#       Push a space.
      I'M'm? e#       Select 'm' if I == 0 (comma) and 'M' otherwise.
      3mr)   e#       Pseudo-randomly select an integer in [1 2 3].
      *      e#       Repeat the M that many times.
      "'kay" e#       Push that string. MMM'kay.
      3$     e#       Copy the proper punctuation.
    }&       e#
  }%         e#
  _          e#   Copy the resulting array.
  @=         e#   Compare it to the copy from the beginning.
}g           e# Repeat the loop while the arrays are equal.
             e# This makes sure that there's at least one m'kay. M'kay.

APL (66)
{∊⍉⍵⍪⍉⍪(¯1+⌈?2×⍵∊',.!?')/¨{' ',⍵,⍨'''kay',⍨'mM'[1+⍵≠',']/⍨?3}¨⍵}⍣≢

Result of 10 runs:
      ↑ ({∊⍉⍵⍪⍉⍪(¯1+⌈?2×⍵∊',.!?')/¨{' ',⍵,⍨'''kay',⍨'mM'[1+⍵≠',']/⍨?3}¨⍵}⍣≢)¨ 10/⊂'Test, test. Test! Test?'
Test, m'kay, test. Test! Test?
Test, test. M'kay. Test! MMM'kay! Test? M'kay?
Test, mm'kay, test. Test! MM'kay! Test? MM'kay?
Test, mmm'kay, test. Test! Test? M'kay?
Test, mm'kay, test. Test! Test? M'kay?
Test, test. MM'kay. Test! Test? MMM'kay?
Test, test. MMM'kay. Test! MMM'kay! Test? M'kay?
Test, test. Test! MM'kay! Test?
Test, mm'kay, test. M'kay. Test! Test?
Test, test. MM'kay. Test! MM'kay! Test?

Explanation:

{...}⍣≢: apply the function to the input until the value changes

Generate a M'kay for each character:
{...}¨⍵: for each character in the input:

'mM'[1+⍵≠',']/⍨?3: generate 1 to 3 ms or Ms depending on whether the character was a comma or not.
'''kay',⍨: append the string 'kay.
⍵,⍨: append the character
' ',: prepend a space.

(¯1+⌈?2×⍵∊',.!?')/¨: for each M'kay', if its corresponding character is one of .,!?, select it with 50% chance, otherwise select it with 0% chance.
⍉⍵⍪⍉⍪: match each selection with its character,
∊: list all the simple elements (characters) in order.

Here's a link to try it online.

Ok, how does this enforce that there is always one added?

@JerryJeremiah: ⍣≢ applies the function repeatedly until the input does not match the output. So if one is added, the output is changed and it stops and returns the output, and if one is not added, the output remains unchanged and it runs again until one is added.

I missed that somehow.  That's very clever.

How is this code 66 bytes? Do you consider an ∊ to take 1 byte? M'kay?

@DmitryGrigoryev: if you use a traditional APL encoding, it does indeed only take 1 byte.

K5, 99 90 bytes
{f::0;{x;~f}{,/{f::f|r:(*1?2)&#&",.?!"=x;x,("";" ",((1+1?3)#"Mm"@x=","),"'kay",x)@r}'x}/x}

Well, someone needed to kick-start this!
Saved 9 bytes by using a less fancy method of uppercasing the M.
Explanation
{                                                                                }  Define a function
 f::0;                                                                                Set `f` (used to determine when to stop) to 0.
      {x;~f}{                                                                         }/x   While `f` is 0 (no "m'kay"s have been inserted), loop over the string argument
               {                                                                   }'x      For each character in the string
                       (*1?2)&#&",.?!"=x                                                    If we are at a punctuation character, generate a random number between 0 and 1
                     r:                                                                     and assign it to `r`
                f::f|                                                                       If the number is one, an "m'kay" will be inserted, so the outer while loop should exit after this
                                                            "Mm"@x=","                      If the punctuation is a comma, then use a lowecase `m`, otherwise use `M`
                                                    (1+1?3)#                                Repeat the `m` between 1 and 3 times
                                               " ",(                  ),"'kay",x            Join the "m'kay" string to the punctuation and prepend a space
                                         x,("";                                 )@r         If the random number is 1, append the "m'kay" string, to the current string
             ,/                                                                             Join the resulting string

99-byte version
{f::0;{x;~f}{,/{f::f|r:(*1?2)&#&",.?!"=x;x,("";" ",((1+1?3)#`c$(-32*~","=x)+"m"),"'kay",x)@r}'x}/x}

Julia, mm'kay, 115 114 bytes
f(s)=(R=replace(s,r"[,.?!]",r->r*(" "*(r==","?"m":"M")^rand(1:3)*"'kay"*r)^rand(0:1));ismatch(r"m'kay"i,R)?R:f(R))

This creates a recursive function that accepts a string and returns a string.
Ungolfed + explanation:
function f(s)
    # Replace occurrences of punctuation using random repeats
    R = replace(s, r"[,.?!]", r -> r*(" " * (r == "," ? "m" : "M")^rand(1:3) * "'kay" * r)^rand(0:1))

    # Check whether anything was replaced
    if ismatch(r"m'kay"i, R)
        # If so, return the replaced string
        R
    else
        # Otherwise recurse
        f(R)
    end
end

I dislike South Park, but the thrill of the golf was too enticing to pass this up. Thanks to KRyan for simplifying a regex, saving 1 byte.

JavaScript ES6, 79 86 108 bytes
Turns out making the M repeat takes a lot of bytes.
(s,z=Math.random)=>s.replace(/([!?.,])/g,l=>z(t=t+1)>=.5||t?` ${(l==','?'m':'M').repeat(0|z()*3+1)}'kay`+l:l)

Old version (doesn't repeat)(86 bytes)
(s,t=1)=>s.replace(/([!?.,])/g,l=>Math.random()>=.5||--t?` ${l==','?'m':'M'}'kay`+l:l)

Older version (doesn't repeat, doesn't require at least one m'kay)(79 bytes):
s=>s.replace(/([!?.,])/g,l=>~~(Math.random()*2)?l+` ${l==','?'m':'M'}'kay`+l:l)

Oldest version:
s=>(r=t=>t.replace(/([!?.])/,"$1 M'kay$1").replace(/,/,", m'kay,"),r(s),[for(i of s)~~(Math.random()*2)?r(i):i].join``)

Latest version has a ReferenceError: t is not defined

Only the oldest version actually works on the Test. input.

@Neil that shouldn't be happening, works just fine for me. Can you add the code you're using in the console

I wrap your submission in parentheses and then suffix ("Test.") to it.

Pyth, 51 50 49
Saved 1 byte thanks to @Maltysen.
 fnzJsm?&O2}dK",.!?"s[d\ *hO3?xKd\M\m"'kay"d)dz0J

Try it online.
Explanation & more golfing coming soon.

C, 170 bytes
First crack at it:
n;main(r,v,p)char**v,*p;{for(srand(time(0)),p=v[1];r=rand(),*p;p++)if(strchr(".,?!",putchar(*p))&&r%2||(!*(p+1)&&!n))n=printf(" %.*s'kay%c",r/2%3+1,*p%4?"MMM":"mmm",*p);}

Ungolfed:
n;
main(r,v,p)
char**v,*p;
{
    for(srand(time(0)), p=v[1]; r=rand(), *p; p++) /* loop through string */
        if(strchr(".,?!",putchar(*p)) /* print the char, check if punctuation */
            && r % 2 /* should we say it? */
            || (!*(p+1) && !n)) /* If this is the end of the string and we haven't M'kay'd, then do it now */
            n=printf(" %.*s'kay%c", r/2%3+1, *p%4 ? "MMM" : "mmm", *p); /* say it! */
}

Scala,  191 bytes
var(r,s,a,o)=(util.Random,readLine,1>2,"")
while(!a){o=""
for(c<-s)o+=(if(",.?!".contains(c)&&r.nextBoolean){a=2>1
s"$c ${(if(c==46)"M"else"m")*(1+r.nextInt(3))}'kay$c"}else s"$c")}
print(o)

Mathematica, 202 bytes
i=0;r=Random;x=r[];
h=" "<>If[#==",","m","M"]~Table~{Ceiling[3r[]]}<>"'kay"<>#&;
(ee/.a:>(If[e~Count~a@__==i&&#==Floor[x*i],h@#2,""]&))@
StringReplace[#,x:","|"."|"?"|"!":>x~~RandomChoice@{i++~a~x,h@x}]&

Line breaks added for readability. Evaluates to an anonymous function taking the string as an argument. ( is shorthand for \[Function].)
Ungolfed:
h[x_]:=" " <> Table[
    If[x==",", "m", "M"],
    { Ceiling[3 Random[]] }
] <> "'kay" <> x;

h takes a punctuation char and makes it " m'kay,", " mm'kay,", etc. randomly and capitalized appropriately.
f[s_] := (i = 0;
   StringReplace[s,
    x : "," | "." | "?" | "!" :>
     x ~~ RandomChoice[{a[i++, x], h[x]}]]);

f takes a string and looks for any punctuation character x; when it finds it, it tacks on with 50% probability the appropriate h[x], and 50% an expression like a[3, x]. It also updates i to the total number of punctuation replaced (with both cases). So f["X, x."] might evaluate to
"X," ~~ h[","] ~~ " x." ~~ a[1, "."]           ...which might expand to
"X, mmm'kay, x." ~~ a[1, "."]                  , and i would equal 2

Finally, g will deal with the a's.
g[expr_] := (r = Random[];
  expr /. a -> (If[Count[expr, a[__]] == i && # == Floor[r*i], h[#2], ""] &))

Count will count how many a's we put in there; if it equals i, the total number of punctuation, then we didn't add any m'kays. In this case, we will have expressions like a[0, _] ... a[i-1, _], and we define a so that it'll return an m'kay for exactly one of 0..i-1.

C++ 290
My solution
void M(string x){
srand(rand());
string p(",.?!");
char c=0,m='m',n='M';
int r=0;
size_t z=0;
for(size_t i=0;i<x.size();i++)
{
c=x[i];cout<<c;
z=p.find(c);
r=rand()%2;
if(z!=string::npos&&r)
{
cout<<' ';
c=(z?n:m);
r=rand()%3+1;
while(r--){cout<<c;}
cout<<"\'kay";
}
}
}

Explanation
variable z determines which punctuation mark and z=0 indicates to use 'm' rather than 'M'.
Test
int main()
{
int x=5;
while(x--){
string S("Do you understand? Really? Good! Yes, I do.");
M(S);
cout<<endl;
}
return 0;
}

string::npos => -1 or ~0. Choosing ~0 lets you use - instead of !=; so that conditional becomes if(z-~0&&r), saving 11 bytes.

Perl, 93 89 88 bytes
$_=$0=<>;s/[.?!]|(,)/$&.($".($1?"m":M)x(1+rand 3)."'kay$&")[rand 2]/ge while$0eq$_;print

Can definitely be golfed some more!
4 bytes cut off thanks to Dom Hastings

Python, 173 168 156
from random import randint as R
    m,k,s,C="mM","'kay",input(),0
    while C<1:
        S=""
        for c in s:r=R(0,c in",.!?");C+=r;S+=c+(' '+m[c!=","]*R(1,3)+k+c)*r
    print(S)

Ungolfed:
from random import randint
m, kay = "mM", "'kay"
string = input()
count = 0
while count < 1: #at least one occurrence
    newString= ""
    for char in s:
        rm  = randint(1,3) #number of "m"
        rmk = randint(0, char in ",.!?") #occurrence of "m'kay"
        count += rmk
        newString += char + (' ' + m[c != ","] * rm + kay + char) * rmk
print(newString)

Your indentation seems to be pretty messed up :/

I know, tabs got automatically converted to spaces.

><>, 150 bytes
i:0(?v
r0&v >
?v~>:0(?v::o1[:::",.?!"{=${=+${=+r=+]
>x~^    >&:0)?;&"."14.
v>&1+&1[:","=&"yak'"&84**"M"+
 >  >84*v
>x::^>22 .
 >: ^]
ol0=?^  >

13 wasted bytes, but I've gotten a little bored trying to rearrange it. Also, randomisation in a Funge is hard to golf -.-

JavaScript ES6, 121 bytes
(s,r=Math.random,f=t=>t==s?f(s.replace(/[!?.,]/g,m=>r()<.5?m:m+" "+(m==","?"mmm":"MMM").slice(r()*3)+"'kay"+m)):t)=>f(s)

Crashes if the given string contains no suitable punctuation.

Lua, 162 160 bytes
r=math.random;s,m=io.read()repeat m=s:gsub("([,.?!])",function(p)return p..(r()>.5 and" "..(p==","and"m"or"M"):rep(r(1)).."'kay"..p or"")end)until s~=m;print(m)

Did you ever hear the tragedy of Darth Plagueis The Wise? MM'kay? I thought not. MMM'kay. It’s not a story the Jedi would tell you. M'kay. It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, m'kay, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. MM'kay. The dark side of the Force is a pathway to many abilities some consider to be unnatural. MM'kay. He became so powerful… the only thing he was afraid of was losing his power, mmm'kay, which eventually, mm'kay, of course, m'kay, he did. M'kay. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. M'kay. Ironic. He could save others from death, but not himself.


text:
Create a working Stack
Your mission, if you choose to accept it, is to create a stack that can do basic math operations.
Explanation:
Your stack must be able to do basic arithmetic (+-*/) and must support normal base 10 numbers (0123456879); numbers will only be one character long.
Programming:
Input from stdin will be loaded as a program. After the program has finished running, the contents of the stack will be printed with no spaces in between after the program runs.
Each character in the program does a different thing to the stack:

A number will push itself
A math operation will take the top two numbers on the stack and push the output.

Example I/O:
Input:45+
Output:9
Input:235234
Output:235234
Input:566*+
Output:41
Input:243+-
Output:-5
Input:78+243+-
Output:15-5
Division is shown as a integer if it has .0:
Input:63/
Output:2
Repeating Decimals are cut off at 2 places:
Input:43/
Output:1.33
Rules:

You stack must have a length of least 128.
Your stack must be double/float based.
No eval-ing!

Scoring:
Your score is you byte count with a couple modifiers.

x0.9 if you include mod (%) and pow (^).
x0.8 if you parse numbers in base 36 (0-9A-Z).
x0.7 if you parse strings (each character of the string will be pushed as separate numbers)

"Hi" pushes 72 and 105, which will output 72105.

Duplicate?

Is there another stack question? Everything I found related to SE. @MartinBüttner

@AlexA. Yes, the input is the program.

@phase My comment was a link to another question which asks almost the same. The differences are the bonuses and that the other question doesn't read individual digits but entire (signed floating-point) numbers, which is why I didn't use my mod hammer to close it.

Ouch, I forgot I had [tag:code-golf] mod hammer.  Well if @MartinBüttner thinks its a dup too, then I think this is the right thing to do here.


text:
Write a D*mn Unambiguous Censor
Censors are a common tool used on the interwebs. But they often censor too much of the word, and thus make the cursing ambiguous to the reader. And sometimes they don't censor enough, so the words still remain offending. Your task is to fix that.
Your task
Write a program/function/whatever that takes two lists and a string. The first list will be the dictionary of all words in your language like: ["hello", "goodbye", "belgium", "offensive", "jumping", "hypercool"]. The next will be subset of the first list containing all of the offensive words in the language: ["belgium", "offensive"]. The words in these lists are guaranteed to contain only lowercase letters of the alphabet.
The string is the phrase you will have to censor. It will be made of words from the dictionary, separated by spaces: "Goodbye offensive belgium"
The return value will be that phrase censored. However, you have to censor in a certain way. Specifically, for each word in the offensive list, you have to censor as many letters as possible while remaining completely unambiguous in the main dictionary. So here it would be: Goodbye o******** b******.
Clarifications

Your code has to interpret the words case-insensitively, but return with the initial capitalization.
If there are multiple optimal answers, pick any of them.
If unambiguous censoring is impossible, censor a single letter that has the least number of other possible interpretations (If multiple are possible, again, its your choice).

Test Cases
["hello", "goodbye", "belgium", "offensive", "jumping", "hypercool"] ["belgium", "offensive"] "Goodbye offensive belgium" -> "Goodbye o******** b******"
["word"] ["word"] "word" -> "****"
["hot", "hat", "bat", "had"] ["hat"] "hat" -> "*at" or "h*t" or "ha*"
https://gist.github.com/deekayen/4148741 ["quart"] "I am a quart" -> "I am a q**r*"

This is code-golf so shortest d*mn code in bytes wins!
P.S. Anyone caught the reference with belgium? ;P

In your explanation you say ["hello", "goodbye", "belgium", "offensive"] ["belgium", "offensive"] "Goodbye offensive belgium" -> "Goodbye o******** b******" but the test cases say ["hello", "goodbye", "belgium", "offensive"] ["belgium", "offensive"] "Goodbye offensive belgium" -> "Goodbye offensive b******"  The test case is wrong, correct?

@JerryJeremiah fixed.

@DLosc you are right, fixing.

I'd thank you to limit remarks like "B*lgium" to something artistic.

"If unambiguous censoring is impossible, censor a single letter that causes the least collisions." What are collisions?

@Maltysen Yes, that makes sense.

There's still a problem in the example. If I see *******, I still know it's Belgium, unambiguously, because it's the only 7 letter word that might get censored.

@orlp I guess my question isn't clear enough. The "reader" of these censored messages isn't aware of the presence of the censor lists. They just know the main dict.

For the third example wouldn't ha* be invalid because it three interpretations unlike the other two which have just two?

@Maltysen Oh, I see, sorry I misread the list :o

@Maltysen - only Zaphod himself would be brazen enough to use a word like b****** in plain text, even when explaining the issue.  I'm shocked.  You are definitely not a hoopy frood!

JavaScript ES7, 194 bytes
(d,c,s,g=(a,b)=>[...b].reduce((z,l,i)=>z+(a[i]==l?1:0),0))=>[for(s of s.split` `)~d.indexOf(s)?[...c[(x=[for(i of c)g(i,s)]).indexOf(Math.max(...x))]].map((l,i)=>l!=s[i]?`*`:l).join``:s].join` `

A very large function. I'm guessing a few bytes can be golfed off but not much unless I completely change the way it works.


text:
Display words using 7-segment display
My first ever Programming Puzzles & Code Golf is the Seven-Slash Display. Here is my first Challenge, also based on 7-segment display.
I often think about, besides numbers, what kind of letters I can display using a simple 7 segment display. Turns out a lot of letters can be displayed. In fact, all but the letters K, M, V, W, X can be displayed using a single 7-segment display. This is because you can display either lower case or the upper case of a letter. e.g.
"abcdef" can be displayed as
 _     _     _  _
!_!!_ !   _!!_ !_
! !!_!!_ !_!!_ !

Note that each character is a 3x3 matrix made up of ! and _.
Of course, the 7-segment display can be used to display numbers and symbols:
 _     _  _  _           _  _     _
  ! _ !_ !_ !      _!  !!_ !_!!  !_!!_!
  !    _!!_ !_!   !_!  ! _!!  !_ ! ! _!

Some letters can have both upper and lower case:
 _                 _
!   _ !_!!_   !   ! ! _ ! !
!_ !_ ! !! !  !  !!_!!_!!_!!_!

Here are the full set of characters:
 _     _  _     _  _  _  _  _                       _
! !  ! _! _!!_!!_ !_   !!_!!_!    _ !_     _     _  _!
!_!  !!_  _!  ! _!!_!  !!_! _!   !_ ! !  !!_!!_!   !

 _     _     _  _  _                 _  _  _     _           _
!_!!_ !   _!!_ !_ !  !_!  !  !!   _ ! !!_!!_! _ !_ !_ ! !!_! _!
! !!_!!_ !_!!_ !  !_!! !  !!_!!_ ! !!_!!    !!   _!!_ !_! _!!_

Pay attention that there are a white space( ), a dash(-) and a question mark(?). The letter I, O and Z are the same as numbers 1, 0 and 2 respectively.
In this challenge, you will write a program or a function to display a string using 7-segment display format above.
Rules

You can write a program or a function

This is code-golf, the shortest code in bytes wins

Your program or function should take input from STDIN or as a parameter. And outputs a string to STDOUT or as a string in 3 lines without leading space but terminated with newline. Handle upper/lower case of CHIOU properly.

You may optionally print trailing white spaces

You must follow the format above. Using underscore _ and exclamation mark ! to form your 7-segment display.

You must support white space( ), dash(-) and question mark (?)

If the string contain unsupported character (k, m, v, w, x), a single error character (3 horizon line, see example) is displayed. Besides the 5 unsupported characters, you can assume the input is made up of only supported character set.

I opted to not have a letter for lowercase L (l) due to confusions but if you are so inclined, you can display it like a 1 either to the right or left.

Examples
$./a.out Start
 _     _
!_ !_ !_! _ !_
 _!!_ ! !!  !_
$./a.out "7-seg dIsplay"
 _     _  _  _           _  _     _
  ! _ !_ !_ !      _!  !!_ !_!!  !_!!_!
  !    _!!_ !_!   !_!  ! _!!  !_ ! ! _!
$./a.out "0123456789 chiou-?"
 _     _  _     _  _  _  _  _                       _
! !  ! _! _!!_!!_ !_   !!_!!_!    _ !_     _     _  _!
!_!  !!_  _!  ! _!!_!  !!_! _!   !_ ! !  !!_!!_!   !
$./a.out "ABCDEFGHIJLNOPQRSTUZ"
 _     _     _  _  _                 _  _  _     _        _
!_!!_ !   _!!_ !_ !  !_!  !  !!   _ ! !!_!!_! _ !_ !_ ! ! _!
! !!_!!_ !_!!_ !  !_!! !  !!_!!_ ! !!_!!    !!   _!!_ !_!!_
$./a.out "abcdefghijlnopqrstuz"
 _           _  _  _                    _  _     _        _
!_!!_  _  _!!_ !_ !  !_      !!   _  _ !_!!_! _ !_ !_     _!
! !!_!!_ !_!!_ !  !_!! !  !!_!!_ ! !!_!!    !!   _!!_ !_!!_
$./a.out "Bad Form"
 _
 _
 _
$./a.out "Hello"
    _
!_!!_ !  !   _
! !!_ !_ !_ !_!
$./a.out "World"
 _
 _
 _

Yes, you can assume there is no unsupported symbols. My intention is to make sure strings containing k, m, v, w, x do not get displayed.

Related: http://codegolf.stackexchange.com/questions/9266/emulate-a-7-segment-display

I think you confused carriage return (CR, \r) with line feed (LF, \n). *nix uses LF and Windows uses CRLF. Only certain legacy systems use CR by itself. More information here: https://en.wikipedia.org/wiki/Newline

Your "8" character seems to have a bar "|" instead of an exclamation mark "!". Is it intended?

Oops! I goofed. I will fix that!

@Winny, you are right of course. I was too lazy to look it up when I wrote it.

Hey, I was thinking about 7 digit alphabets a lot and here are ideas for a full alphabet (the letters below the 'main' letters are just alternatives), not all the letters are that nice but I think some of them might do well. here the image

Glad to see someone with the same interest! I like the way you defined V. IMO, the most difficult alphabet is X. It is just not possible to display it without some sort of diagonal segment.

Why doesn't 'a' have a lowercase representation? All segments on, except the top-left segment...

Usable characters IMO: 0123456789" '-_=ACcdEFGHhIiJLnoPrStUu

CJam, 123 114 112 110 bytes
Qq_eu";=KMVWX":T&"@"@?" -chiou"Tereu{i"^A^W^G;^Þ¯     ^Þ^Û9³·^É¿»
^@
^P
^Ü^Ò½7¦^_¶´§=   ^O^V&5^U¯¼¹^T³6/"=i2b9Ue[3/"!_!"f.{S?}.+}/N*

The above uses caret notation, since the code contains unprintable characters. One of them is a null byte (^@), which means that this code can only be executed from the command line.
At the cost of only two more bytes (for a total of 112), we can fix this.
Qq_eu";=KMVWX":T&"@"@?" -chiou"Tereu{i"AWG{ÞïIÞÛyó÷Éÿû
@
P
ÜÒýwæ_öôç}IOVfuUïüùTóvo"=i448+2b1>3/"!_!"f.{S?}.+}/N*

This time, all characters are printable. Try it online in the CJam interpreter.
Example run
$ LANG=en_US
$ xxd -ps -r > 7seg.cjam <<< 51715f6575223b3d4b4d565758223a5426224022403f22202d6368696f752254657265757b69220117073b9eaf099e9b39b3b789bfbb0a000a100a9c92bd37a61fb6b4a73d090f16263515afbcb914b3362f223d6932623955655b332f22215f2122662e7b533f7d2e2b7d2f4e2a
$ wc -c 7seg.cjam
110 7seg.cjam
$ echo -n '0123456789 chiou-?' | cjam 7seg.cjam; echo
 _     _  _     _  _  _  _  _                       _
! !  ! _! _!!_!!_ !_   !!_!!_!    _ !_     _     _  _!
!_!  !!_  _!  ! _!!_!  !!_! _!   !_ ! !  !!_!!_!   !
$ echo -n 'ABCDEFGHIJLNOPQRSTUYZ' | cjam 7seg.cjam; echo
 _     _     _  _  _                 _  _  _     _           _
!_!!_ !   _!!_ !_ !  !_!  !  !!   _ ! !!_!!_! _ !_ !_ ! !!_! _!
! !!_!!_ !_!!_ !  !_!! !  !!_!!_ ! !!_!!    !!   _!!_ !_! _!!_
$ echo -n 'World' | cjam 7seg.cjam; echo
 _
 _
 _

Idea (printable version)
Each character can be shown on the 9-segment display
!_!
!_!
!_!

by replacing some of its characters characters with spaces.
We can turn a specific character into an integer by replacing each shown segment, in natural reading order, with a 1, each not shown segment with a 0 and considering the result binary digits.
The first and third segment are never shown, so this will produce integers in the ranges [0,64) and [128,192).
We can encode each of these integers as a single byte, but half of them will result in unprintable characters. Thus, we add 64 to each integer before casting to character, which makes sure the code points are in the ranges [64,128) and [192,256).
The only unprintable character in these two ranges is DEL (code point 127), which corresponds to the following, unsued display configuration:
!_!
!_!

We can reverse the above encoding by adding 448 == 512 - 64 to each code point, converting to base 2 and removing the first binary digit.
All that's left to to find an efficient way of associating these encoded segmenets with their corresponding ASCII characters.
If we map the characters of " -chiou" to the characters of ";=KMVWX" and convert the entire input to uppercase, we can simply store encoding for all characters between 0 (code point 48) and Z (code point 90), giving a range of 43.
Array indexing is modular in CJam, so if A is a string of length 43, A86=, A43= and A0= all yield the same results. The character with code point 86 is V, so we simply store the encoded segments of V - Z and 0 - U, in order.
In the actual code, we select the at sign as "bad form" character, replace the entire input with the string "@" if it contains a forbidden letter and reverse the steps from above.
Code (printable version)
Q            e# Push an empty array for posterior concatenation.
q            e# Read from STDIN.
_eu          e# Copy the input and convert is to uppercase.
";=KMVWX":T& e# Intersect the result with with T := ";=KMVWX".
"@"@?        e# Select "@" if truthy and the input if falsy.
" -chiou"Ter e# Perform transliteration.
eu           e# Convert everything to uppercase.
{            e# For each character in the modified input:
  i          e#   Push its code point.
  "…"=       e#   Select the corresponding character from the string.
  i448+      e#   Push that character's code point and add 448.
  2b1>       e#   Convert to base 2 and discard the first digit.
  3/         e#   Group into triplets of digits (rows).
  "!_!"      e#   Push that string.
  f.{        e#   For each group of digits:
    S?       e#     Select the corresponding char of "!_!" for 1 and " " for 0.
  }          e#
  .+         e#   Concatenate along the rows with the previous results.
}/           e#
N*           e# Join, separating by linefeeds.

Perl, 475 469 424 390 280 272 bytes
$_=<>;die" -
"x3if/[kmvwx]/i;y/chiou/kmvwx/;$_=lc;while(/(.)/g){$z=ord($1=~y/a-z0-9\-\? /{v\x17nWS7z(.F\x16rb?[yBuV> f&|O?(Omxuw)\x7f}@K\0/r);$i.=$z&1?' _ ':$"x3;$m.=($z&16?'!':$").($z&64?'_':$").($z&8?'!':$");$p.=substr("  !  _!_",$z&6,2).($z&32?'!':$")}print"$i
$m
$p
"

multi-line with comments:
$_=<>;   # accept input
die" -   # check for invalid chars
"x3if/[kmvwx]/i;
y/chiou/kmvwx/;$_=lc;   # substitute invalid chars, convert to lowercase
while(/(.)/g)   # loop over each character
    # lookup character from string using transliteration and convert to
    # number using ord() for bit checking:
    {$z=ord($1=~y/a-z0-9\-\? /{v\x17nWS7z(.F\x16rb?[yBuV> f&|O?(Omxuw)\x7f}@K\0/r);
    $i.=$z&1?' _ ':$"x3;    # first row
    $m.=($z&16?'!':$").($z&64?'_':$").($z&8?'!':$");   # second row
    $p.=substr("  !  _!_",$z&6,2).($z&32?'!':$")}    # third row
# print result:
print"$i
$m
$p
"

The bit patterns encoding the segments are stored in a string (escaping 3 unprintable chars using \x and using \0 for space) and are mapped to the input characters using the Perl transliteration operator.
For 5 of the 7 segments, a bitwise and is used along with the ternary operator to output a space or the segment character. For the bottom left two segments (encoded by 2 and 4 in the bitset), a substring lookup into an 8 character string is used to save 2 bytes.
Thanks to Dom Hastings for his Perl golfing tips.
Old version (using regexes to encode the patterns), 390 bytes:
$_=<>;if(/[kmvwx]/i){print" -\n"x3;exit}y/chiou/kmvwx/;$_=lc;while(/(.)/g){$z=$1;$i.=($z=~/[acefgopqsz\?0235-9]/?' _ ':'   ');$m.=($z=~/[abce-hlmopqstuy045689]/?'!':' ').($z=~/[abdefhkmnp-twyz\-\?2-689]/?'_':' ').($z=~/[adhijopquyz\?0-4789]/?'!':' ');$p.=($z=~/[a-hj-prtuwxz\?0268]/?'!':' ').($z=~/[b-egjklostuw-z0235689]/?'_':' ').($z=~/[abdg-jmnoqsu-y013-9]/?'!':' ')}print"$i\n$m\n$p\n"

multi-line with comments:
$_=<>;   # accept input
if(/[kmvwx]/i){print" -\n"x3;exit}   # check for invalid chars
y/chiou/kmvwx/;$_=lc;   # substitute invalid chars, convert to lowercase
while(/(.)/g)
{$z=$1;$i.=($z=~/[acefgopqsz\?0235-9]/?' _ ':'   '); # first row
$m.=($z=~/[abce-hlmopqstuy045689]/?'!':' ').
($z=~/[abdefhkmnp-twyz\-\?2-689]/?'_':' ').
($z=~/[adhijopquyz\?0-4789]/?'!':' '); # second row
$p.=($z=~/[a-hj-prtuwxz\?0268]/?'!':' ').
($z=~/[b-egjklostuw-z0235689]/?'_':' ').
($z=~/[abdg-jmnoqsu-y013-9]/?'!':' ')} # third row
print"$i\n$m\n$p\n" # print result

The string is read in and checked for invalid chars using a regex, exiting if any are found. Then the allowed lowercase chars are substituted for the invalid chars and the entire string is converted to lowercase.
The rows are generated one at a time, with 1 segment per letter on the first row and 3 on the other two. For each row, the string is processed one character at a time and the character is matched against a regex for each segment to check if a ! or _ should be displayed. Using a regex means that for characters where the segment is not set it takes zero bits per segment per character to encode whether to set it, and for those where it is it takes a little less than 8 bits on average because regex character ranges can be used. So it works out to around 3 or 4 bits per segment per character in the set, or around 21-24 bits per character.
It doesn't handle line-wrapping.

Hey @samgak, glad to see more Perl love! I noticed a few things that could help you shave off some bytes and wanted to share them! You can use some of Perl's magic variables to help reduce in this; ' ' can be replaced with $" and '   ' can be $"x3 which trims a few off, your \ns can be literal newlines to get rid of a few more. Your early exit can be shorted too, using die, so that if(/[kmvwx]/i){print" -\n"x3;exit} becomes die" - "x3if(/[kmvwx]/i). With a bit more fudging as well you can re-arrange the loop to avoid the brackets and you shouldn't need $z to save a few more!

I hope you aren't offended, but I had a look at reducing more, https://gist.github.com/dom111/e651b5de8c7e7fc9a6cf. Down to 323!

@DomHastings no offence taken at all, thanks for the great golfing tips! I've used as many of them as I could in my edited answer, which I've changed to use bitwise encoding instead of regexes for the segment patterns. Unfortunately $z is back, and I can't figure out how to get rid of it. Also, $_=lc<> doesn't work, because then the code can't discriminate between upper and lowercase CHIOU

Common Lisp, 488 416
(lambda(z)(dotimes(r 3)(map()(lambda(c)(do((i 0(+ 17 i))n)((or(and(> i 901)(setf n 146))(=(char-code c)(ldb(byte 8 9)(setf n(ldb(byte 17 i)#36RIL884OIVFXJY4DCQ0O8DPH8MOMR2DSLPP3O4ESYHS234A9HEQYSV8IBDBZI6Z3C3MCVR77OYD3QN5G6CX2UQWGL4UY5R9PKYI1JQ5Y6DC27MQQGUZSCGI8Q9JCYP9N1L4YYKRWM1ZNMSVTSB4792UUWV6Z3906VSP981WCCBMDNJ02)))))(loop for v from(* 3 r)for d across"!_!"do(format t"~:[ ~;~A~]"(logbitp v n)d)))))z)(terpri)))

Example
With "abcdefg'hijklnopqrstuz", prints:
 _           _  _  _  _           _           _  _     _        _
!_!!_  _  _!!_ !_ !   _ !_   !  ! _ !   _  _ !_!!_! _ !_ !_     _!
! !!_!!_ !_!!_ !  !_! _ ! !  !!_! _ !_ ! !!_!!    !!   _!!_ !_!!_

Remarks
Characters and their representations are encoded in this number in base 36:
IL884OIVFXJY4DCQ0O8DPH8MOMR2DSLPP3O4ESYHS234A9HEQYSV8IBDBZI6Z3C3MCVR77OYD3QN5G6CX2UQWGL4UY5R9PKYI1JQ5Y6DC27MQQGUZSCGI8Q9JCYP9N1L4YYKRWM1ZNMSVTSB4792UUWV6Z3906VSP981WCCBMDNJ02

The binary representation of this digit is divided in groups of 17 bits.
For example, the last group of 17 bits is 110000111101010, which is decomposed here in two parts:

110000, the char-code of character 0
111101010, an encoding of the drawing, best represented as follows:
010 (bits 0-2)         _
101 (bits 3-5)   =>   ! !
111 (bits 6-8)        !_!

Bits in first and last "column" are for ! characters, the ones in the middle column for the _ character. When necessary, both uppercase and downcase versions of a character are stored.

The function iterates three times over the input string, one for each line of output, searches for a matching character in the table (or defaults to 146, a.k.a. three bars),  and prints the representation at current row.

Thank you for participating in the challenge. I noticed that your 'K' is displayed as 'L' in your output. You may have misunderstood the requirement that unsupported character cannot be printed along with other valid character. Also, I see that you added the ' character, which is nice; however, it will be displayed outside of what a 7-segment display capable of. If you move the ! down by 1 line, it would be perfect.

I'll update the ' character and edit the question for K because in fact, I put the K in the wrong place in the input string ("...jlKn...") ;-) You can see the triple bars (error) just after the L. Thanks for noticing it.

JavaScript (ES6), 380 352 324 bytes
(Note: Code uses caret notation, as it contains some unprintable characters. To get original code, click here and select the raw data. And no, h is not a CJam program. ;)
d=s=>{a=' ',u=n=>r>>n&1?'!':a,v=n=>r>>n&1?'_':a,g='ABCDEFGHIJLNOPQRSTUYZabcdefghijlnopqrstuyz0123456789-? ÿ',h='{vUnWSuz(lTb}[;B7V|>O{vFnWSur lTbf[;B7Vd>O}(O/:7w)^??^BK^0^G',x=y=z='';for(i=0;i<s.length;x+=a+v(0)+a,y+=u(4)+v(1)+u(3),z+=u(6)+v(2)+u(5)){q=g.indexOf(s[i++]);if(q<0)return d`ÿ`;r=h.charCodeAt(q)}return x+`
${y}
`+z}

Called as d("7-seg display") or similar. Works in Firefox 40, but may not in other browsers. For some reason, the HTML/JS snippet does not save the non-printables, but you can copy-paste the raw data from over here.
Ungolfed:
(Note: g and h have been padded with spaces to match 8, -, ÿ and space with their corresponding Unicode values.)
d = function (s) {
  t = function (n) { return Math.floor(n) % 2; };
  g = 'ABCDEFGHIJLNOPQRSTUYZabcdefghijlnopqrstuyz012345679? 8      -      ÿ      space ';
  h = '{vUnWSuz(lTb}[;B7V|>O{vFnWSur lTbf[;B7Vd>O}(O/:7w)?K \u007f \u0002 \u0007 \u0000';
  x = y = z = '';
  for(var i = 0; i < s.length; i++) {
    q = g.indexOf(s.charAt(i));
    if (q < 0)          // if g does not contain the character
      return d('ÿ');    // ÿ is equivalent to the error character, '\u0007'
    r = h.charCodeAt(q);
    x += ' ' + (r % 2 === 1 ? '_' : ' ') + ' ';
    y += (t(r / 16) === 1 ? '!' : ' ') + (t(r / 2) === 1 ? '_' : ' ') + (t(r / 8) === 1 ? '!' : ' ');
    z += (t(r / 64) === 1 ? '!' : ' ') + (t(r / 4) === 1 ? '_' : ' ') + (t(r / 32) === 1 ? '!' : ' ');
  }
  return x + '\n' + y + '\n' + z;
}

Explanation:
I immediately noticed that the 7 segments, converted into 0/1 bits, would go well with the first 128 Unicode characters. The problem with this idea is that 1/4 of these characters are non-printable control characters. Using them in my code would make it look look incredibly messy (or incredibly intelligent; I haven't decided which one). To solve this while keeping the rest of the code simple, I came up with this idea:
With the exception of -, space, and error, none of the characters were missing both of the lower vertical segments. So to make sure that all those characters stayed between 0020 and 007f, I simply mapped the 64 and 32 bits to these segments, like so:
     1
    ---
16 |   | 8
  2 ---
64 |   | 32
    ---
     4

The other 5 segments' numbers aren't too important; they could be arranged in any other way and still have all the same characters "in-bounds".
As an example, here's the encoded version of A:
     1
    ---
16 |   | 8
  2 ---
64 |   | 32

Dec: 64 + 32 + 16 + 8 + 2 + 1 = 123
Hex: 40 + 20 + 10 + 8 + 2 + 1 = 7B = u+007B = {

I then stuffed the encoded version of each 7-seg character in h. However, 8 resulted in 007f (the delete control code; constant no matter how the segments are arranged), space resulted in 0000 (the null code; also constant), - resulted in 0002, and error resulted in 0007. I copy-pasted the raw bytes into the correct position for 8, -, and error; space was easily achieved with \0.
After all this encoding, all I had to do was use it to decode the string and output it in a 7-seg readable format. I used a for loop and three variables (x, y, and z, each corresponding to an output line) to go through each character in the string and add its 7-seg equivalent to the output. I chose ÿ for the error character because AFAIK, it's not on any keyboard, and it's the last character in the u+0000-u+00ff range. Perhaps I could have been witty and chosen Ξ (Greek letter xi) instead.... ;)
Edit 1: Saved a bunch of space by creating mini-functions to determine whether !, _, or  is needed.
Edit 2: Saved a bunch more space using the tricks I've learned since I last visited this post.
As usual, suggestions are greatly appreciated!


text:
Marching Squares Lookup
Marching Squares is an algorithm from computer graphics, which is used to recover 2D isocontours from a grid of samples (see also, its big brother Marching Cubes for 3D settings). The idea is to process each cell of the grid independently, and determine the contours passing through that cell based on the values at its corners.
The first step in this process is to determine which edges are connected by contours, based on whether the corners are above or below the value of the contour. For simplicity, we'll only consider contours along the value 0, such that we're interested in whether the corners are positive or negative. There are 24 = 16 cases to distinguish:

Image Source: Wikipedia
The identification of white and black doesn't really matter here, but for definiteness say that white is positive and black is negative. We will ignore cases where one of the corners is exactly 0.
The saddle points (cases 5 and 10) provide a little extra difficulty: it's not clear which diagonals should be used by only looking at the corners. This can be resolved by finding the average of the four corners (i.e. an approximation of the centre value), and choosing the diagonals such that the contours separate the centre from the corners with the opposite sign. If the average is exactly 0, either case can be chosen.
Normally, these 16 cases are simply stored in a lookup table. This is great for efficiency, but of course, we'd prefer the code to be short around here. So your task is to perform this lookup step and print an ASCII representation of the case in as little code as possible.
The Challenge
You're given the values of the four corners (non-zero integers) in a fixed order of your choice. You should then generate the correct layout of the contours, correctly resolving the saddle point cases.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Input may be taken in any convenient string or list format.
The 16 cases will be represented in ASCII art using one of the following 5x5 blocks:
o---o  o---o  o---o
|   |  |   |  | | |
|   |  |---|  | | |
|   |  |   |  | | |
o---o  o---o  o---o

o---o  o---o  o---o  o---o
|/  |  |  \|  |   |  |   |
|   |  |   |  |   |  |   |
|   |  |   |  |\  |  |  /|
o---o  o---o  o---o  o---o

o---o  o---o
|/  |  |  \|
|   |  |   |
|  /|  |\  |
o---o  o---o

You must not print any leading or trailing whitespace, but you may print a single optional newline.
This is code golf, so the shortest answer (in bytes) wins.
Test Cases
The test cases assume that input is given in order top-left, top-right, bottom-left, bottom-right. Test cases are presented in 9 groups, one corresponding to each of the 9 representations given above (in the same order, starting from the empty cell, ending with the two saddle points).
[1, 2, 1, 3]
[-9, -2, -2, -7]

[4, 5, -1, -2]
[-1, -2, 3, 4]

[7, -7, 7, -7]
[-5, 5, -5, 5]

[1, -6, -4, -1]
[-2, 3, 3, 4]

[-1, 6, -4, -1]
[2, -3, 3, 4]

[-1, -6, 4, -1]
[2, 3, -3, 4]

[-1, -6, -4, 1]
[2, 3, 3, -4]

[3, -8, -9, 2]
[-3, 8, 9, -2]

[8, -3, -2, 9]
[-8, 3, 2, -9]

Additionally, the following test cases may return either of the saddle points (your choice):
[1, -4, -2, 5]
[-1, 4, 2, -5]

Ruby, 201 180 176
This is an anonymous lambda function, to be called in the way shown in the ungolfed example.
This contains no variable s. In the ungolfed version a complex expression is assigned to s for clarity, before it is used. 4 bytes are saved in the golfed version by putting it inline. The only other difference between the versions is the whitespace and comments.
If it is acceptable to return the output as an array of five strings of five characters, instead of printing to stdout, one more byte can be saved.
->a{p=t=0
4.times{|i|t+=a[i]*=a[3];p+=a[i]>>9&1<<i}
q=p==6&&t>0?19:'@AC@P*10'[p].ord
puts c='o---o',(0..2).map{|i|b=p*i==3?'|---|':'|   |';b[q%4]='|/|\|/'[q%4+(i&2)];q/=4;b},c}

I'm happy with the parsing of the array, but I think there may be shorter ways to form the output.
All four elements of the input array are multiplied by the last element. This guarantees that the last element is positive, and reduces the number of cases from 16 down to 8. The elements are rightshifted 9 places, so that all positive numbers become 0 and all negative numbers become -1 (at least in the range of input given in the test cases.) They are then ANDed by 1<<array index to give a 3-bit binary number indicating the pattern (actually 4-bit, but as the last element is always positive, the 4th bit is always zero.)
This number from 0..7 is then fed to a (sigh) lookup table to determine which characters of each row are non-whitespace. It is at this stage that the two different displays for the saddle case are handled, with an alternative to the number in the lookup table being used if the total is positive (the question says to consider the "average", but as we are only interested in the sign, it doesn't matter if we consider the total instead.)
The way the display of output works is hopefully clear from the comments in the code.
ungolfed in test program
f=->a{p=t=0
  4.times{|i|                      #for each number in the input
    t+=a[i]*=a[3];                   #multiply each number by a[3]; totalize the sum in t
    p+=a[i]>>9&1<<i                  #shift right to find if negative; AND with 1<<i to build index number for pattern
  }                                #q is a 3-digit base 4 number indicating which character of each line is non-whitespace (if any).
  q=p==6&&t>0?19:'@AC@P*10'[p].ord #It's encoded in the magic string, except for the case of saddles with a positive total, which is encoded by the number 19.
  s=(0..2).map{|i|                 #build an array of 3 strings, indexes 0..2
    b=p*i==3?'|---|':'|   |';        #IF p is 3 and we are on row 1, the string is |---| for the horizontal line case. ELSE it is |   |.
    b[q%4]='|/|\|/'[q%4+(i&2)];      #The numbers in q indicate which character is to be modified. The characters in the string indicate the character to replace with.
    q/=4;                            #If q%4=0, the initial | is replaced by | (no change.) i&2 shifts the string index appropriately for the last row.
    b                                #divide q by 4, and terminate the loop with the expression b so that this is the object loaded into array s.
  }
puts c='o---o',s,c}                #print the array s, capped with "o---o" above and below.

[[1, 2, 1, 3],
[-9, -2, -2, -7],

[4, 5, -1, -2],
[-1, -2, 3, 4],

[7, -7, 7, -7],
[-5, 5, -5, 5],

[1, -6, -4, -1],
[-2, 3, 3, 4],

[-1, 6, -4, -1],
[2, -3, 3, 4],

[-1, -6, 4, -1],
[2, 3, -3, 4],

[-1, -6, -4, 1],
[2, 3, 3, -4],

[3, -8, -9, 2],
[-3, 8, 9, -2],

[8, -3, -2, 9],
[-8, 3, 2, -9],

[1, -4, -2, 5],
[-1, 4, 2, -5]].each{|k|f.call(k)}