text:
Shortest code to check if a number is in a range in JavaScript
This is how I checkout to see if a number is in a range (in between two other numbers):
var a = 10,
    b = 30,
    x = 15,
    y = 35;

x < Math.max(a,b) && x > Math.min(a,b) // -> true
y < Math.max(a,b) && y > Math.min(a,b) // -> false

I have to do this math in my code a lot and I'm looking for shorter equivalent code.
This is a shorter version I came up with. But I am sure it can get much shorter:
a < x && x < b
true
a < y && y < b
false

But downside is I have to repeat x or y

a<x&x<b will return 1 or 0, and is 7 characters shorter.

For code-golf purposes beary605's solution is best, but if you're using the code a lot you'd be better off declaring a function like within(a,b) or inrange(a,b) somewhere in your code and using that. It's instantly obvious what it does and therefore easier to maintain in the future.

beary605, your solution won't work because it will always return 0 when b<a even if x is in between a and b (for example when a=20; b=10; x=15)

@Yellos  a is supposed to be the minimum while b is max. Your example shows the minimum higher than the maximum!

13 chars, checks both variants a<b and b<a
(x-a)*(x-b)<0

In C may be used expression (may be also in JavaScript). 11 chars, No multiplications (fast)
(x-a^x-b)<0

a<x==x<b

JavaScript, 8 chars.

0<0==0<1 ->
false

I like Yellos answer. And 0>=0==0<1 returns true

@Mohsen the OP's request was a number in between two limiting numbers, not including them. Therefore, 0<0==0<1 should return false, because in that case, 0 is the lower limit, but also the number that should be in between the range. And they are equal.

JavaScript,  7 bytes
a<n&n<b

Golfed: a<n<b

@A̲̲ That doesn't work in Javascript


text:
Golf the Subset-Sum Problem
Task
Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0.

Test Case
Input:  8 −7 5 −3 −2
Output: -3 -2 5

Winning Criterion
This is code-golf, so the shortest code in bytes wins!

Do we have to worry about uniqueness if the input contains non-unique numbers?  In other words, how many results do I have to print for the input 3 3 -3 -3?

@Keith.  By convention, sets consist of distinct elements that appear at most once.  Multisets can have elements that appear more than once. http://en.wikipedia.org/wiki/Multiset

@DavidCarraher, OP mixes terminology by talking about subsets of lists.

@PeterTaylor Thanks. Good point.

GolfScript, 41 characters
~][[]]\{`{1$+$}+%}%;(;.&{{+}*!},{" "*}%n*

If you do not care about the specific output format you can shorten the code to 33 characters.
~][[]]\{`{1$+$}+%}%;(;.&{{+}*!},`

Example (see online):
> 8 -7 5 -3 -2 4
-3 -2 5
-7 -2 4 5
-7 -3 -2 4 8

Brachylog (2), 9 characters
{⊇.+0∧}ᵘb

Try it online!
{⊇.+0∧}ᵘb
 ⊇           subset
   +0        that sums to 0
  .  ∧       output the subset
{     }ᵘ     take all unique solutions
        b    except the first (which is the empty solution)

Python, 119 chars
def S(C,L):
 if L:S(C,L[1:]);S(C+[L[0]],L[1:])
 elif sum(map(int,C))==0and C:print' '.join(C)
S([],raw_input().split())

Enumerates all 2^n subsets recursively and checks each one.

Bravo!  I came within a character...

Python, 120
I'm a character worse than Keith's solution.  But... this is too close to not post.  One of my favorite features of code-golf is how dissimilar similar-length solutions can be.
l=raw_input().split()
print[c for c in[[int(j)for t,j in enumerate(l)if 2**t&i]for i in range(1,2**len(l))]if sum(c)==0]

Mathematica 62 57 38
Code
Input entered as integers in an array, x.
x

Grid@Select[Subsets@x[[1, 1]], Tr@# == 0 &]

Output

Explanation
x[[1, 1]] converts the input to a list of integers.
Subsets generates all subsets from the integers.
Select....Tr@# == 0 gives all those subsets that have a total equal to 0.
Grid formats the selected subsets as space-separated integers.

Python (128 137 136)
Damn you, itertools.permutations, for having such a long name!
Brute force solution. I'm surprised it's not the shortest: but I guess itertools ruins the solution.
Ungolfed:
import itertools
initial_set=map(int, input().split())
ans=[]
for length in range(1, len(x)+1):
    for subset in itertools.permutations(initial_set, length):
        if sum(subset)==0:
            ans+=str(sorted(subset))
print set(ans)

Golfed (ugly output):
from itertools import*
x=map(int,input().split())
print set(`sorted(j)`for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)

Golfed (pretty output) (183):
from itertools import*
x=map(int,input().split())
print `set(`sorted(j)`[1:-1]for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)`[5:-2].replace("'","\n").replace(",","")

import itertools as i: importing the itertools module and calling it i
x=map(int,input().split()): seperates the input by spaces, then turns the resulting lists' items into integers (2 3 -5 -> [2, 3, -5])
set(sorted(j)for a in range(1,len(x)+1)for j in i.permutations(x,a)if sum(j)==0):
Returns a list of all subsets in x, sorted, where the sum is 0, and then gets only the unique items
(set(...))
The graves (`) around sorted(j) is Python shorthand for repr(sorted(j)). The reason why this is here is because sets in Python cannot handle lists, so the next best thing is to use strings with a list as the text.

I'm confused about how you're getting integers instead of strings.  split() makes a list of strings, but then later you're calling sum on the subsets of that split.

@KeithRandall: facepalm I was in a rush, so I didn't test my code. Thank you for pointing that out.

You can probably save a character by doing from itertools import*

actually the graves is shorthand for repr()

@gnibbler: That would make a lot more sense when running `'hello'`. Thanks!

Did you test this?  I get a syntax error on print \set(`...`

SWI-Prolog 84
This version prints the list, instead of trying to find an appropriate binding for a term in a predicate.
s([],O):-O=[_|_],sum_list(O,0),print(O).
s([H|T],P):-s(T,[H|P]).
s([_|T],O):-s(T,O).

Input method
s([8,-7,5,-3,-2,4],[]).

For the record, this is the version that finds a binding to satisfy the predicate:
s(L,O):-s(L,0,O),O=[_|_].
s([],0,[]).
s([H|T],S,[H|P]):-R is H+S,s(T,R,P).
s([_|T],S,O):-s(T,S,O).

Input method
s([8,-7,5,-3,-2,4],O).

Previous revision contains an incomplete solution that didn't manage to remove empty set.

C# – 384 characters
OK, functional-style programming in C# is not that short, but I love it! (Using just a brute-force enumeration, nothing better.)
using System;using System.Linq;class C{static void Main(){var d=Console.ReadLine().Split(' ').Select(s=>Int32.Parse(s)).ToArray();foreach(var s in Enumerable.Range(1,(1<<d.Length)-1).Select(p=>Enumerable.Range(0,d.Length).Where(i=>(p&1<<i)!=0)).Where(p=>d.Where((x,i)=>p.Contains(i)).Sum()==0).Select(p=>String.Join(" ",p.Select(i=>d[i].ToString()).ToArray())))Console.WriteLine(s);}}

Formatted and commented for more readability:
using System;
using System.Linq;

class C
{
    static void Main()
    {
        // read the data from stdin, split by spaces, and convert to integers, nothing fancy
        var d = Console.ReadLine().Split(' ').Select(s => Int32.Parse(s)).ToArray();
        // loop through all solutions generated by the following LINQ expression
        foreach (var s in
            // first, generate all possible subsets; well, first just their numbers
            Enumerable.Range(1, (1 << d.Length) - 1)
            // convert the numbers to the real subsets of the indices in the original data (using the number as a bit mask)
            .Select(p => Enumerable.Range(0, d.Length).Where(i => (p & 1 << i) != 0))
            // and now filter those subsets only to those which sum to zero
            .Where(p => d.Where((x, i) => p.Contains(i)).Sum() == 0)
            // we have the list of solutions here! just convert them to space-delimited strings
            .Select(p => String.Join(" ", p.Select(i => d[i].ToString()).ToArray()))
        )
            // and print them!
            Console.WriteLine(s);
    }
}

Jelly, 6 bytes
ŒPḊSÐḟ

Try it online!
Just for completeness. Similar to Brachylog, Jelly also postdates the challenge, but by now, newer languages compete normally.
ŒP       Power set.
  Ḋ      Dequeue, remove the first element (empty set).
    Ðḟ   Filter out the subsets with truthy (nonzero)...
   S       sum.

input needs to be space delimited

05AB1E, 5 bytes
æ¦ʒO>

Try it online!

If input must be space delimited, prepending # to this answer is the only change required.

J, 57 53 51 49 characters
>a:-.~(#:@i.@(2&^)@#<@":@(#~0=+/)@#"1 _])".1!:1[1

Usage:
   >a:-.~(#:@i.@(2&^)@#<@":@(#~0=+/)@#"1 _])".1!:1[1
8 _7 5 _3 _2 4
5 _3 _2
_7 5 _2 4
8 _7 _3 _2 4

Rewriting the train as (<@":@(#~0=+/)@#"1 _~2#:@i.@^#) saves 4 characters.

Stax, 8 bytesCP437
â±3╒yΣ╓à

Run and debug online!
Explanation
Uses the unpacked version (9 bytes) to explain.
LS{|+!fmJ
L            Convert to list
 S           Powerset
  {   f      Filter with block
   |+!       Sum is zero
       mJ    Print each subset, joined by spaces

Given a list of space-delimited integers as input; you are -- however -- taking a list as input.

Will fix at the cost of one byte.

J, 34 bytes
(a:-.~](<@#~0=+/)@#~[:#:@i.2^#)@".

Try it online!
how
". converts the input to a list.  then:
a: -.~ ] (<@#~ (0 = +/))@#~ [: #:@i. 2 ^ #
                                  i.       NB. ints from 0 to...
                                     2 ^ # NB. 2 to the input len
                            [: #:@         NB. converted to binary masks
       ] (             ) #~                NB. filter the input using
                                           NB. using those masks, giving
                                           NB. us all subsets
         (             )@                  NB. and to each one...
         (  #~ (0 = +/))                   NB. return it if its sum is
                                           NB. 0, otherwise make it
                                           NB. the empty list.
         (<@           )                   NB. and box the result.
                                           NB. now we have our answers
                                           NB. and a bunch of empty
                                           NB. boxes, or aces (a:).
a: -.~                                     NB. remove the aces.

Perl 6, 51 bytes
*.words.combinations.skip.grep(!*.sum)>>.Bag.unique

Try it online!
Returns a list of unique Bags that sum to 0. A Bag is a weighted Set.
Explanation:
*.words                 # Split by whitespace
 .combinations          # Get the powerset
 .skip                  # Skip the empty list
 .grep(!*.sum)          # Select the ones that sum to 0
 >>.Bag                 # Map each to a weighted Set
 .unique                # And get the unique sets

Ruby, 110 bytes
a=gets.split.map &:to_i;b=[];(1...a.length).each{|c|a.permutation(c){|d|d.sum==0?b<<d:0}};p b.map(&:sort).uniq

Will add TIO link later.
Takes input from stdin as a list of numbers, e.g. 8 −7 5 −3 −2
How it works: It converts the input into an array of numbers. Gets all the permutations of the lengths from 1 to the array's length. It adds them to the output array if they sum to 0. It outputs the array without duplicates.
Output for the sample input: [[-3, -2, 5]]

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:
Removing unique elements from string
I came upon this question, because it seems to be very common use-case to find unique characters in string. But what if we want to get rid of them?
Input contains only lower case alphabets. Only letters from a to z are used. Input length may be from 1 to 1000 characters.
Example:
input: helloworld
output: llool
Objective: Shortest code wins
Language: Any of the top 20 of TIOBE languages

Perl, 28 24 characters (includes 1 for 'p' option)
s/./$&x(s!$&!$&!g>1)/eg

Usage:
> perl -pe 's/./$&x(s!$&!$&!g>1)/eg'
helloworld
llool

At first I thought I could do this with negative look-ahead and negative look-behind, but it turns out that negative look-behinds must have a fixed length. So I went for nested regexes instead. With thanks to mob for the $& tip.

+1.  I naively thought I could take this thing with my Ruby answer.

i tried this on chinese text and it did not do the trick. =(

@ixtmixilix - then run perl with the -CDS option

@ixtmixilix I don't know enough about unicode and Perl's support of it to suggest a way to make it work with chinese text I'm afraid. Luckily for me the question says only lower case a to z.

Replace all the $1 with $& and you can lose a couple pairs of parentheses.

(GolfScript, 15 13 characters)
:;{.;?);>?)},

GolfScript is not one of the top 20, but a codegolf without GolfScript... (run it yourself)
Previous Version:
(run script)
1/:;{;\-,;,(<},

:;? You're deliberately trying to confuse newbies, aren't you? ;)

@PeterTaylor You're right. I should have chosen a ) - it would make it a smiley then :). Unfortunately, I didn't find a way to even eliminate the digit 1. (Note for GolfScript newbies: you may replace any ; in the code with a x (or any other letter or digit - or any character not used in the script otherwise). In this special case ; is just a variable name - and has not the meaning "pop and discard". In GolfScript almost all tokens are variables anyways, and using predefined symbols is great way to make scripts even more unreadable for outsiders ;-).)

Another 13-char solution: :a{]a.@--,(},

J, 12 characters
Having entered a valid Perl answer, here's an invalid (language not in the TIOBE top 20) answer.
a=:#~1<+/@e.

Usage:
   a 'helloworld'
llool

Declares a verb a which outputs only non unique items.

GolfScript (14 chars)
:x{{=}+x\,,(},

Online demo
Might not qualify to win, but it's useful to have a yardstick.

Ruby 46 40 36
gets.chars{|c|$><<c if$_.count(c)>1}

You may save 4 chars if you inline s and use $_ for the second appearance (the space before is then dispensable).

@Howard:  Nice catch.  Thanks.  I have about zero experience with Ruby.

Japt, 6 5 bytes
ÆèX É

-1 byte thanks to @Oliver
Try it online!

Welcome to Japt! There is actually a shortcut for o@: Æ

@Oliver Another shortcut that I missed, cool, thanks :)

@Oliver, the better question is how the feck did I miss it?! :\

Mathematica 72 63
Ok, Mathematica isn't among the top 20 languages, but I decided to join the party anyway.
x is the input string.
"" <> Select[y = Characters@x, ! MemberQ[Cases[Tally@y, {a_, 1} :> a], #] &]

Python 2.7 (52 51), Python 3 (52)
I didn't expect it to be so short.
2.7: a=raw_input();print filter(lambda x:a.count(x)>1,a)
3.0: a=input();print''.join(i for i in a if a.count(x)>1)
raw_input(): store input as a string (input() = eval(raw_input()))
(Python 3.0: input() has been turned into raw_input())
filter(lambda x:a.count(x)>1,a):
Filter through all characters within a if they are found in a more than once (a.count(x)>1).

If you use python 3 instead, you can use input() rather than raw_input(). Although you have to add one character for a closing bracket, since print is a function in python 3.

@Strigoides: I have added a Python 3 code snippet to my answer.

Python 3's filter returns an iterator... You'll need to do ''.join(...)

@JBernardo: :( Dang. Thanks for notifying me. As you can see, I don't use 3.0.

Perl 44
$l=$_;print join"",grep{$l=~/$_.*$_/}split""

Execution:
perl -lane '$l=$_;print join"",grep{$l=~/$_.*$_/}split""' <<< helloworld
llool

K, 18
{x@&x in&~1=#:'=x}

You can save a byte using  1<# instead of ~1=#

sed and coreutils (128)
Granted this is not part of the TIOBE list, but it's fun (-:
<<<$s sed 's/./&\n/g'|head -c -1|sort|uniq -c|sed -n 's/^ *1 (.*)/\1/p'|tr -d '\n'|sed 's:^:s/[:; s:$:]//g\n:'|sed -f - <(<<<$s)

De-golfed version:
s=helloworld
<<< $s sed 's/./&\n/g'        \
| head -c -1                  \
| sort                        \
| uniq -c                     \
| sed -n 's/^ *1 (.*)/\1/p'   \
| tr -d '\n'                  \
| sed 's:^:s/[:; s:$:]//g\n:' \
| sed -f - <(<<< $s)

Explanation
The first sed converts input into one character per line. The second sed finds characters that only occur once. Third sed writes a sed script that deletes unique characters. The last sed executes the generated script.

Brachylog (v2), 8 bytes
⊇.oḅlⁿ1∧

Try it online!
Function submission. Technically noncompeting because the question has a limitation on what langauges are allowed to compete (however, several other answers have already ignored the restriction).
Explanation
⊇.oḅlⁿ1∧
⊇         Find {the longest possible} subset of the input
  o       {for which after} sorting it,
   ḅ        and dividing the sorted input into blocks of identical elements,
    lⁿ1     the length of a resulting block is never 1
 .     ∧  Output the subset in question.

Why do you CW all your solutions?

@Shaggy: a) because I'm fine with other people editing them, b) to avoid gaining reputation if they're upvoted. In general I think the gamififcation of Stack Exchange is a huge detriment to the site – there's sometimes a negative correlation between the actions that you can take to improve rep and the actions you can take to actually improve the site. Additionally, being at a high reputation count sucks; the site keeps nagging you to do admin tasks, and everything you do is a blunt instrument (e.g. when you're at low rep you can suggest an edit, at high rep it just gets forced through).

Python (56)
Here's another (few chars longer) alternative in Python:
a=raw_input();print''.join(c for c in a if a.count(c)>1)

If you accept output as a list (e.g. ['l', 'l', 'o', 'o', 'l']), then we could boil it down to 49 characters:
a=raw_input();print[c for c in a if a.count(c)>1]

Hey, >1 is a good idea! May I incorporate that into my solution?

@beary605 Sure no problem at all - easy way to trim a character off :D

Perl (55)
@x=split//,<>;$s{$_}++for@x;for(@x){print if($s{$_}>1)}

Reads from stdin.

Ocaml, 139 133
Uses ExtLib's ExtString.String
open ExtString.String
let f s=let g c=fold_left(fun a d->a+Obj.magic(d=c))0 s in replace_chars(fun c->if g c=1 then""else of_char c)s

Non-golfed version
open ExtString.String
let f s =
  let g c =
    fold_left
      (fun a c' -> a + Obj.magic (c' = c))
      0
      s
  in replace_chars
  (fun c ->
    if g c = 1
    then ""
    else of_char c)
  s

The function g returns the number of occurences of c in the string s. The function f replaces all chars either by the empty string or the string containing the char depending on the number of occurences. Edit: I shortened the code by 6 characters by abusing the internal representation of bools :-)
Oh, and ocaml is 0 on the TIOBE index ;-)

f*** the TIOBE index.

I agree. Also, thanks for the upvote. Now I can comment :-)

C# – 77 characters
Func<string,string>F=s=>new string(s.Where(c=>s.Count(d=>c==d)>1).ToArray());

If you accept the output as an array, it boils down to 65 characters:
Func<string,char[]>F=s=>s.Where(c=>s.Count(d=>c==d)>1).ToArray();

PHP - 70
while($x<strlen($s)){$c=$s[$x];echo substr_count($s,$c)>1?$c:'';$x++;}

with asumption $s = 'helloworld'.

Java 8, 90 bytes
s->{for(char c=96;++c<123;s=s.matches(".*"+c+".*"+c+".*")?s:s.replace(c+"",""));return s;}

Explanation:
Try it online.
s->{                         // Method with String as both parameter and return-type
  for(char c=96;++c<123;     //  Loop over the lowercase alphabet
    s=s.matches(".*"+c+".*"+c+".*")?
                             //   If the String contains the character more than once
       s                     //    Keep the String as is
      :                      //   Else (only contains it once):
       s.replace(c+"",""));  //    Remove this character from the String
  return s;}                 //  Return the modified String

PowerShell, 59 bytes
"$args"-replace"[^$($args|% t*y|group|?{$_.Count-1}|% n*)]"

Try it online!
Less golfed:
$repeatedСhars=$args|% toCharArray|group|?{$_.Count-1}|% name
"$args"-replace"[^$repeatedСhars]"

Note: $repeatedChars is an array. By default, a Powershell joins array elements by space char while convert the array to string. So, the regexp contains spaces (In this example, [^l o]). Spaces do not affect the result because the input string contains letters only.

APL (Dyalog Extended), 8 bytesSBCS
Anonymous tacit prefix function.
∊⊢⊆⍨1<⍧⍨

Try it online!
⍧⍨ count-in selfie (count occurrences of argument elements in the argument itself)
1< Boolean mask where one is less than that
⊢⊆⍨ partition the argument by that mask (beginning a new partition on 1s and removing on 0s)
∊ ϵnlist (flatten)

JavaScript, 45 bytes
s=>[...s].filter(c=>s.match(c+'.*'+c)).join``

R, 70 bytes
a=utf8ToInt(scan(,''));intToUtf8(a[!a%in%names(table(a)[table(a)<2])])

Try it online!
A poor attempt, even from a TIOBE top 20 language. I know something can be done about the second half, but at the moment, any golfs escape me.

JavaScript (Node.js), 82 bytes
p=>[...p].map((v,i,a)=>a.filter(f=>f==v).length).reduce((a,c,i)=>c>1?a+=p[i]:a,[])

Try it online!

You can use .join\`instead of.join("")`.

JavaScript, 34 bytes
Input as a string, output as a character array.
s=>[...s].filter(x=>s.split(x)[2])

Try It Online!

Nice. Here's an alternate 34-byter using map: https://tio.run/##BcExDoAgDADAvzgYOtjBHT9CTCSICqmUWKL8vt5l/3oJT6ptKrxHPayKXRwiyoq3r6bbRVAqpWY6uHkdxw4auAhTROLTHGa4IhF//NA@AGZOZdtAfw

@Oliver, not quite.

C++, 139 bytes
string s;cin>>s;string w{s}; auto l=remove_if(begin(s),end(s),[&w](auto&s){return count(begin(w),end(w),s)==1;});s.erase(l,end(s));cout<<s;

ungolfed:
#include <algorithm>
#include <string>
#include <iostream>

int main() {
  using namespace std;
  string s;
  cin >> s;
  const string w{s};
  auto l = remove_if(begin(s), end(s), [&w](auto& s) {
                                         return count(begin(w), end(w), s) == 1;
                                       });
  s.erase(l, end(s));
  cout << s;
  return 0;
}

PHP - 137
Code
implode('',array_intersect(str_split($text),array_flip(array_filter(array_count_values(str_split($text)),function($x){return $x>=2;}))));

Normal Code
$text   = 'helloworld';
$filter = array_filter(array_count_values(str_split($text)), function($x){return $x>=2;});
$output = implode('',array_intersect(str_split($text),array_flip($filter)));

echo $output;

PHP - 83 78
<?for($a=$argv[1];$i<strlen($a);$r[$a[$i++]]++)foreach($ras$k=>$c)if($c>1)echo$k

Improved version:
<?for($s=$argv[1];$x<strlen($s);$c=$s[$x++]) echo substr_count($s,$c)>1?$c:'';

Of course this needs notices to be turned off
Edit: Improvement inspired by @hengky mulyono
I am so bad at codegolf :)

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


text:
Implementing a Traffic Light Checker
A three-color traffic light must switch lights in the following order: red, green, yellow, red.
To indicate when crossing slowly without a stop is permitted, the yellow signal may be flashed. To indicate when crossing immediately after a full stop is permitted, the red signal may be flashed.
Either flash sequence may only be started after the red light is lit and must be followed with a red. All lights are initially off. All sequences must begin a red light. Lighting any light causes all other lights to turn off.  No color may be repeated: e.g., red, red is not allowed.
Task:
Write a program that checks a sequence of light codes and determines if that sequence follows or violates the traffic light rules.
Input
Read from STDIN a sequence of the follow codes:  R (red), Y (yellow), G (Green),  P (Pause - flash red),  C (Caution - flash yellow), and X (off). Each code must be separated with a space.  The entire sequence is submitted by an end-of-line (e.g., pressing the Enter key.)  A sequence must have no more than 15 codes in total.
Winning criteria:
Output
Write to STDOUT an evaluation of the sequence:
ACCEPT     >> The entire input sequence meets all rules.
REJECT     >> The input sequence violates any sequence constraint; for example G Y.
ERROR      >> The input is malformed – undefined code, too short, too long, etc.

EXAMPLES:

1 - Input: R G Y R C R G Y R                  Output: ACCEPT
2 - Input: G Y R G Y R                        Output: REJECT
3 - Input: R Y G P                            Output: REJECT
4 - Input: R G Y                              Output: ERROR
5 - Input: X 8 S                              Output: ERROR
6 - Input: R G Y R C R P R G Y R G Y R G Y R  Output: ERROR

You do not have to worry about the reasons listed below, they are only used a reference as to why the input strings have either been Accepted, Rejected or Erroneous.
Reasons:

Correct
Doesn’t start with R
Invalid sequence
Undefined code
Undefined Codes e.g. X is not part of the grammar
The input is malformed – undefined code, too short, too long, etc.

Can you please specify a winning criteria? And can you please indicate how the X symbol should be handled?

Are there any constraints on the final item in the sequence? How can a sequence be "too short"?

There are constraints on the final item of the sequence, it has to be a X(off) or R(Red). A sequence maybe to short however this falls under this situation may fall Undefined Category or Invalid sequence category.

Seems a bit trivial for code-challenge.

Why is 4 an error and not reject?  Short sequences seem possible, e.g. R C R... your stated reason 'undefined code' is wrong.  Also, X is part of your grammar, but not a part of your acceptable sequences... what?

The alleged "winning criteria" isn't. It's an acceptance criteria for working programs that does not distinguish one from another. It leave this post looking like you want someone to write a program for you.

^^ Neat line ardnew, but check yourself for cases
1: R G Y R P
2: R G Y C

This was one of the questions from the IEEE contest
To determine the next light in the sequence its simply (let c = color of light)
(c == 'R') ? ('G', 'P', 'C') : (c == 'G') ? ('Y') : ('R')

Those conditions follows from the question statement

If the light is RED, the next light can only be (GREEN, PAUSE, CAUTION)
If the light is GREEN, the next light can only be (YELLOW)
Else (light is (YELLOW, PAUSE, CAUTION)) the next light is RED

The first conditions follow from the fact that its always RED GREEN YELLOW
The flashing lights PAUSE and CAUTION require there be a RED immediately before and after

Perl, 83 chars
good grief, halfway through golfing this thing i realized its a code-challenge
$_=<>;chop;print/.{30}|[^RYGPCX ]|\S\S/?ERROR:s/^(R (C|P|G Y) )+R?$//?ACCEPT:REJECT


text:
Turing Machine Simulator
Write a Turing machine simulator.
For simplicity we can assume statuses as integer, symbols as char, blank symbol equals whitespace
5-tuple in the form of current state, input symbol, next state, output symbol, direction (left or right) the order is not mandatory but specify if you swap it
The machine must stop when an unknown state is reached, no other halt condition allowed.
The tape is infinite in both directions and you can always read an empty character.
Input: the initial tape, an initial state and a program. you are free to read the data from anywhere in the format you like
Output: the tape after the execution of the program
Required: an example program that run on top of your simulator
This is a code-colf so the shortest code win.
I'll post an implementation and some example programs in the next few hours.

On The Turing Completeness of PowerPoint (SIGBOVIK)

GolfScript, 92 characters
~:m;n\+{:^.n?)>1<]m{2<1$=},.{~2>~^n/~1>[@\+]n*1$%n/~\1$1<+[\1>.!{;" "}*]n*\%@}{;;^0}if}do n-

The Turing machine in GolfScript became much longer than intended. Still playing around with different representations of the tape.
First line of the input is the original state, second line the initial tape, followed by an array of transitions (with order current state, input symbol, next state, direction, output symbol).
Example (also available online)
> 0
> '101'
> [[0 '0' 0 1 '0']
>  [0 '1' 0 1 '1']
>  [0 ' ' 1 -1 ' ']
>  [1 '0' 2 1 '1']
>  [1 '1' 3 -1 '0']
>  [3 '0' 2 1 '1']
>  [3 ' ' 2 1 '1']
>  [3 '1' 3 -1 '0']]

110

you beat my sed implementation by one char, time to see if I can do better

GNU sed with -r - 133 117 111 93 chars
Yes, sed is turing complete. GNU sed and -r (extended regexps) is only to save a few characters, it is only a small change to work with POSIX sed.
:s
s/^(.*@)(.*)>(.)(.*#\1\3([^@]*@)(..))/\5\2\6>\4/
T
s/(..)l>|r>/>\1/
s/>@/@> /
s/>#/> #/
bs

Input format is
[initial state]@[non-empty tape with > marking head position]#[state]@[input symbol][next state]@[output symbol][direction l or r]#...

The delimiters @, # and head character > cannot be used as a symbol on the tape. State labels cannot contain @ > or #.
It will run all of the programs in the input, one per line
Examples:
Marco's anbn program

Input
0@>aaabbb#0@a1@ r#0@ 4@ r#1@a1@ar#1@b1@br#1@ 2@ l#2@b3@ l#2@a5@al#3@b3@bl#3@a3@al#3@ 0@ r#4@ 5@Tr

Output
5@    T>  #0@a1@ r#0@ 4@ r#1@a1@ar#1@b1@br#1@ 2@ l#2@b3@ l#2@a5@al#3@b3@bl#3@a3@al#3@ 0@ r#4@ 5@Tr

Marco's Hello! program

Input
0@> #0@ 1@Hr#1@ 2@er#2@ 3@lr#3@ 4@lr#4@ 5@or#5@ 6@!r

Output
6@Hello!> #0@ 1@Hr#1@ 2@er#2@ 3@lr#3@ 4@lr#4@ 5@or#5@ 6@!r

TIO

So I'm a bit late, but just thought I would leave this here...
Turing Machine Simulating a Turing Machine: 370 bytes?
Here I'm using the structure Turing used in his 1936 paper. I'm using one symbol = one byte, including m-configs and operations.
╔═══════════════╦═══════╦═══════════════════╦═══════════════╗
║    m-config    ║ Symbol ║     Operations      ║ Final m-config ║
╠═══════════════╬═══════╬═══════════════════╬═══════════════╣
║ currentCommand ║ Any    ║ L                   ║ currentCommand ║
║                ║ *      ║ MR                  ║ readCommand    ║
╠----------------╬--------╬---------------------╬----------------╣
║ nextCommand    ║ Any    ║ L                   ║ nextCommand    ║
║                ║ *      ║ E  R  R  R  P* R    ║ readCommand    ║
╠----------------╬--------╬---------------------╬----------------╣
║ readCommand    ║ P      ║ R                   ║ readCommandP   ║
║                ║ M      ║ R                   ║ readCommandM   ║
║                ║ G      ║ R                   ║ readCommandG   ║
║                ║ E      ║ R                   ║ MHPNone        ║
╠----------------╬--------╬---------------------╬----------------╣
║ readCommandP   ║ 0      ║                     ║ MHP0           ║
║                ║ 1      ║                     ║ MHP1           ║
║                ║ e      ║                     ║ MHPe           ║
║                ║ x      ║                     ║ MHPx           ║
║                ║ None   ║                     ║ MHPNone        ║
╠----------------╬--------╬---------------------╬----------------╣
║ readCommandM   ║ R      ║                     ║ MHMR           ║
║                ║ L      ║                     ║ MHML           ║
╠----------------╬--------╬---------------------╬----------------╣
║ readCommandG   ║ 1      ║                     ║ G2<1           ║
║                ║ 2      ║                     ║ G2<2           ║
║                ║ 3      ║                     ║ G2<3           ║
║                ║ 4      ║                     ║ G2<4           ║
║                ║ 5      ║                     ║ G2<5           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G2<1           ║ int(1) ║ L  P@ R  R  R  P* R ║ GTS            ║
║                ║ <      ║                     ║ G21            ║
║                ║ *      ║ E  L                ║ G2<1           ║
║                ║ @      ║ E  L                ║ G2<1           ║
║                ║ Any    ║ L                   ║ G2<1           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G2<2           ║ int(2) ║ L  P@ R  R  R  P* R ║ GTS            ║
║                ║ <      ║                     ║ G22            ║
║                ║ *      ║ E  L                ║ G2<2           ║
║                ║ @      ║ E  L                ║ G2<2           ║
║                ║ Any    ║ L                   ║ G2<2           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G2<3           ║ int(3) ║ L  P@ R  R  R  P* R ║ GTS            ║
║                ║ <      ║                     ║ G23            ║
║                ║ *      ║ E  L                ║ G2<3           ║
║                ║ @      ║ E  L                ║ G2<3           ║
║                ║ Any    ║ L                   ║ G2<3           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G2<4           ║ int(4) ║ L  P@ R  R  R  P* R ║ GTS            ║
║                ║ <      ║                     ║ G24            ║
║                ║ *      ║ E  L                ║ G2<4           ║
║                ║ @      ║ E  L                ║ G2<4           ║
║                ║ Any    ║ L                   ║ G2<4           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G2<5           ║ int(5) ║ L  P@ R  R  R  P* R ║ GTS            ║
║                ║ <      ║                     ║ G25            ║
║                ║ *      ║ E  L                ║ G2<5           ║
║                ║ @      ║ E  L                ║ G2<5           ║
║                ║ Any    ║ L                   ║ G2<5           ║
╠----------------╬--------╬---------------------╬----------------╣
║ G21            ║ int(1) ║ L  P@ R             ║ GTS            ║
║                ║ Any    ║ R                   ║ G21            ║
╠----------------╬--------╬---------------------╬----------------╣
║ G22            ║ int(2) ║ L  P@ R             ║ GTS            ║
║                ║ Any    ║ R                   ║ G22            ║
╠----------------╬--------╬---------------------╬----------------╣
║ G23            ║ int(3) ║ L  P@ R             ║ GTS            ║
║                ║ Any    ║ R                   ║ G23            ║
╠----------------╬--------╬---------------------╬----------------╣
║ G24            ║ int(4) ║ L  P@ R             ║ GTS            ║
║                ║ Any    ║ R                   ║ G24            ║
╠----------------╬--------╬---------------------╬----------------╣
║ G25            ║ int(5) ║ L  P@ R             ║ GTS            ║
║                ║ Any    ║ R                   ║ G25            ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTS            ║ ^      ║ R                   ║ TS             ║
║                ║ Any    ║ R                   ║ GTS            ║
╠----------------╬--------╬---------------------╬----------------╣
║ TS             ║ 0      ║                     ║ RL0            ║
║                ║ 1      ║                     ║ RL1            ║
║                ║ e      ║                     ║ RLe            ║
║                ║ x      ║                     ║ RLx            ║
║                ║ None   ║                     ║ RLNone         ║
╠----------------╬--------╬---------------------╬----------------╣
║ RL0            ║ @      ║ R  R                ║ GTS0           ║
║                ║ Any    ║ L                   ║ RL0            ║
╠----------------╬--------╬---------------------╬----------------╣
║ RL1            ║ @      ║ R  R                ║ GTS1           ║
║                ║ Any    ║ L                   ║ RL1            ║
╠----------------╬--------╬---------------------╬----------------╣
║ RLe            ║ @      ║ R  R                ║ GTSe           ║
║                ║ Any    ║ L                   ║ RLe            ║
╠----------------╬--------╬---------------------╬----------------╣
║ RLx            ║ @      ║ R  R                ║ GTSx           ║
║                ║ Any    ║ L                   ║ RLx            ║
╠----------------╬--------╬---------------------╬----------------╣
║ RLNone         ║ @      ║ R  R                ║ GTSNone        ║
║                ║ Any    ║ L                   ║ RLNone         ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTS0           ║ 0      ║ R  P*  R            ║ readCommand    ║
║                ║ Any    ║ R                   ║ GTS0           ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTS1           ║ 1      ║ R  P*  R            ║ readCommand    ║
║                ║ Any    ║ R                   ║ GTS1           ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTSe           ║ e      ║ R  P*  R            ║ readCommand    ║
║                ║ Any    ║ R                   ║ GTSe           ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTSx           ║ x      ║ R  P*  R            ║ readCommand    ║
║                ║ Any    ║ R                   ║ GTSx           ║
╠----------------╬--------╬---------------------╬----------------╣
║ GTSNone        ║ _      ║ R  P*  R            ║ readCommand    ║
║                ║ Any    ║ R                   ║ GTSNone        ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHP0           ║ ^      ║ R                   ║ Print0         ║
║                ║ Any    ║ R                   ║ MHP0           ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHP1           ║ ^      ║ R                   ║ Print1         ║
║                ║ Any    ║ R                   ║ MHP1           ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHPe           ║ ^      ║ R                   ║ Printe         ║
║                ║ Any    ║ R                   ║ MHPe           ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHPx           ║ ^      ║ R                   ║ Printx         ║
║                ║ Any    ║ R                   ║ MHPx           ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHPNone        ║ ^      ║ R                   ║ PrintNone      ║
║                ║ Any    ║ R                   ║ MHPNone        ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHMR           ║ ^      ║ R  R                ║ MHR            ║
║                ║ Any    ║ R                   ║ MHMR           ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHML           ║ ^      ║ L                   ║ MHL            ║
║                ║ Any    ║ R                   ║ MHML           ║
╠----------------╬--------╬---------------------╬----------------╣
║ Print0         ║ ^      ║ R                   ║ Print0         ║
║                ║ None   ║ P0                  ║ nextCommand    ║
║                ║ Any    ║ E                   ║ Print0         ║
╠----------------╬--------╬---------------------╬----------------╣
║ Print1         ║ ^      ║ R                   ║ Print1         ║
║                ║ None   ║ P1                  ║ nextCommand    ║
║                ║ Any    ║ E                   ║ Print1         ║
╠----------------╬--------╬---------------------╬----------------╣
║ Printx         ║ ^      ║ R                   ║ Printx         ║
║                ║ None   ║ Px                  ║ nextCommand    ║
║                ║ Any    ║ E                   ║ Printx         ║
╠----------------╬--------╬---------------------╬----------------╣
║ Printe         ║ ^      ║ R                   ║ Printe         ║
║                ║ None   ║ Pe                  ║ nextCommand    ║
║                ║ Any    ║ E                   ║ Printe         ║
╠----------------╬--------╬---------------------╬----------------╣
║ PrintNone      ║ ^      ║ R                   ║ PrintNone      ║
║                ║ None   ║                     ║ nextCommand    ║
║                ║ Any    ║ E                   ║ PrintNone      ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHL            ║ ^      ║ R  R                ║ MHL            ║
║                ║ [      ║                     ║ SBL            ║
║                ║ Any    ║ L  P^ R  R  E       ║ nextCommand    ║
╠----------------╬--------╬---------------------╬----------------╣
║ MHR            ║ ^      ║ R  R                ║ MHR            ║
║                ║ ]      ║                     ║ SBR            ║
║                ║ None   ║ P^ L  L  E          ║ nextCommand    ║
╠----------------╬--------╬---------------------╬----------------╣
║ SBR            ║ ]      ║ E  R  R  P]         ║ currentCommand ║
╠----------------╬--------╬---------------------╬----------------╣
║ SBL            ║ ]      ║ R                   ║ SBLE           ║
║                ║ Any    ║ R                   ║ SBL            ║
╠----------------╬--------╬---------------------╬----------------╣
║ SBLE           ║ [      ║                     ║ currentCommand ║
║                ║ None   ║ L                   ║ SBLE           ║
║                ║ Any    ║ E  R  R  P] L       ║ SBLE           ║
╚═══════════════╩═══════╩═══════════════════╩═══════════════╝

Here is one of Turing's examples from the paper above for my machine:
['<', None, 1, '0', None, 'P', 'e', None, 'M', 'R', None, 'P', 'e', None, 'M', 'R', None, 'P', '0', None, 'M', 'R', None, 'M', 'R', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
                      '1', None, 'P', 'e', None, 'M', 'R', None, 'P', 'e', None, 'M', 'R', None, 'P', '0', None, 'M', 'R', None, 'M', 'R', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
                      'e', None, 'P', 'e', None, 'M', 'R', None, 'P', 'e', None, 'M', 'R', None, 'P', '0', None, 'M', 'R', None, 'M', 'R', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
                      'x', None, 'P', 'e', None, 'M', 'R', None, 'P', 'e', None, 'M', 'R', None, 'P', '0', None, 'M', 'R', None, 'M', 'R', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
                      '_', None, 'P', 'e', None, 'M', 'R', None, 'P', 'e', None, 'M', 'R', None, 'P', '0', None, 'M', 'R', None, 'M', 'R', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',

             None, 2, '1', None, 'M', 'R', None, 'P', 'x', None, 'M', 'L', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
                      '0', None, 'G', '3',

             None, 3, '0', None, 'M', 'R', None, 'M', 'R', None, 'G', '3',
                      '1', None, 'M', 'R', None, 'M', 'R', None, 'G', '3',
                      '_', None, 'P', '1', None, 'M', 'L', None, 'G', '4',

             None, 4, 'x', None, 'E', 'E', None, 'M', 'R', None, 'G', '3',
                      'e', None, 'M', 'R', None, 'G', '5',
                      '_', None, 'M', 'L', None, 'M', 'L', None, 'G', '4',

             None, 5, '0', None, 'M', 'R', None, 'M', 'R', None, 'G', '5',
                      '1', None, 'M', 'R', None, 'M', 'R', None, 'G', '5',
                      'e', None, 'M', 'R', None, 'M', 'R', None, 'G', '5',
                      'x', None, 'M', 'R', None, 'M', 'R', None, 'G', '5',
                      '_', None, 'P', '0', None, 'M', 'L', None, 'M', 'L', None, 'G', '2',
        None, '[', '^', None, ']', None]

Try it online!  (Uses Python 3 as an interpreter) --Edit: I just checked the TIO, and it doesn't seem to actually work right... Try it on your local machine and it should (hopefully) work. It does on mine.

No harm intended, just aligning the borders on the table.

@GregBacon No offence taken... perhaps there's some difference between how different computers render codeblocks, but your edit made the alignment much worse on my edit screen... I'm sure it looked fine when you suggested the edit; not sure what the problem is

Python, 101 189 152 142
a=dict(zip(range(len(b)),b))
r=eval(p)
i=s=0
while 1:
 c=a.get(i,' ')
 s,m,a[i]=r[s,c]
 if 0==m:exit([x[1]for x in sorted(a.items())])
 i=i+m

b and p are the inputs, b is the initial tape, p encodes the rules as (string representation of) a dict from (in-state, in-tape) tuple to (out-state, head move, out-tape) tuple. If move is 0 the program finishes, 1 is move to the right and -1 is move to the left.
b="aaba"

p="""{(0, 'a'): (1, 1, 'a'),
      (0, 'b'): (0, 1, 'b'),
      (1, 'a'): (1, 1, 'a'),
      (1, 'b'): (0, 1, 'b'),
      (1, ' '): (1, 0, 'Y'),
      (0, ' '): (0, 0, 'N')}"""

This sample program tests if the last letter of the string (before empty tape) is 'a', if so it writes 'Y' at the end of the string (first empty space).
Edit 1:
Changed the tape to be represented as a dict, as it seemed the shortest way to write an extensible data structure. The second to last line is mostly transforming it back into readable form for output.
Edit 2:
Thanks to Strigoides for a great deal of improvements.
Edit 3:
I had unnecessarily made it so 0 as output would leave the place as it is.
I removed this as we can always write the output the same as the input.

I don't think this is a valid solution because in your implementation the tape is limited. This way you need to know in advance the memory consumption of your program. And there are problems moving left. Hint: a tape can be made from two modified stack in wich you can always pop a blank symbol.

Ah, true. Sorry, didn't think this too far.

Uhm.. afaik the tape is infinite in both direction and you can always read an empty character. I will specify that in the answer.

You were correct (we had had more strict rules in our exercises). I fixed at least some of the flaws.

You can remove the space  in the first line, r=0;s=0 can become r=s=0 (and the semicolon at the end of that line is unnecessary), you can remove the function w, as it is unused, the brackets can be removed in (s,m,t)=r[s,c], the try/except block can be shortened using dict.get; c=a.get(i,' '), since m is either 0 or 1, you can use if m-1:, and you can shorten your map() call by converting it to a list comprehension.

Thanks! That get was extremely useful knowledge. I have no idea how that w-function was still left in the code, I thought I had removed it long ago. I'm not really that versed with python so your help with the syntax is appreciated too. Only thing is that m can also be -1 if we're moving left, I guess I should give an example of that too.

APL (110)
(It's not even that short...)
0(''⍞){×⍴X←0~⍨⍺∘{x y S T s m t←⍺,⍵⋄S T≡x,⊃⊃⌽y:s,⊂(⊃y){m:(¯1↓⍺)(⍵,⍨¯1↑⍺)⋄(⍺,⊃⍵)(1↓⍵)}t,1↓⊃⌽y⋄0}¨⍵:⍵∇⍨⊃X⋄,/⊃⌽⍺}⎕

It reads two lines from the keyboard: the first is the program and the second is the initial tape.
The format is
(in-state in-tape out-state movement out-tape)

and they should all be on the same line. 'Movement' is 0 to move right and 1 to move left.
Example program (line breaks inserted for clarity, they should be all on one line.)
(0 ' ' 1 0 '1')
(0 '1' 0 0 '1')
(1 '1' 1 0 '1')
(1 ' ' 2 1 ' ')
(2 '1' 3 1 ' ')

The program adds two unary numbers together, for example:
in:  1111 111
out: 1111111

Example 2 (adapted from the binary increment program from Marco Martinelli's entry):
(0 '0' 0 0 '0')
(0 '1' 0 0 '1')
(0 ' ' 1 1 ' ')
(1 '0' 2 0 '1')
(1 '1' 3 1 '0')
(3 '0' 2 0 '1')
(3 ' ' 2 0 '1')
(3 '1' 3 1 '0')

How can i try it? I'm using linux and tried with aplus but it doesn't work (undefined token :( ). Which interpreter / compiler should I try?

I'm using Dyalog APL. I'm not aware of using any Dyalog-specific functions but A+ is not completely the same thing. There's a free version of Dyalog but it's only for Windows. (It might run under Wine but it does use its own input method so you can type APL.) If you get Dyalog running, just enter/paste the APL code (on one line), then the Turing machine program (on a second line), then the initial tape (on the third line).

Postscript (205) (156) (150) (135)
<<
>>begin
/${stopped}def([){add dup{load}${exit}if}def
0 A{1 index{load}${pop( )}if
get{exec}${exit}if}loop
3{-1[pop}loop{1[print}loop

This is probably cheating, but the transition table contains code to perform the transitions. And since the tape is represented by a mapping from integers to integers, I've represented states as a mapping from names to dictionaries so the tape and the program coexist in the same anonymous dictionary.
Extra savings by making all state names executable, so they auto-load.
Ungolfed with embedded "Hello" program. An extra 52 chars buys a loop to read the tape from stdin. Run with gsnd -q tm.ps.
%!
<<
    /A<<( ){dup(H)def 1 add B}>>
    /B<<( ){dup(e)def 1 add C}>>
    /C<<( ){dup(l)def 1 add D}>>
    /D<<( ){dup(l)def 1 add E}>>
    /E<<( ){dup(o)def 1 add F}>>
>>begin %ds: int-keys=tape name-keys=prog
0 A %pos state
{ %loop
    1 index{load}stopped{pop( )}if  %pos state tape(pos)
    get    {exec}stopped{exit  }if  %new-pos new-state
} loop
% Loop from tape position 0 to left until left tape end is found
0{                                  %pos
  -1 add                            %new-pos
  dup{load}stopped{exit}if          %new-pos tape(new-pos)
  pop                               %new-pos tape(new-pos)
}loop
% Move to the right and print all chars until right end is hit
{                                   %pos
  1 add                             %new-pos
  dup{load}stopped{exit}if          %new-pos tape(new-pos)
  print                             %new-pos tape(new-pos)
}loop

So the table-format is
/in-state<<in-tape{dup out-tape def movement add out-state}
           in-tape2{dup out-tape2 def movement2 add out-state2}>>

where in-state is a name, in-tape and out-tape are chars (ie. integers, or expressions which yield integers), movement is -1 for left or 1 for right, and out-state is an executable name. Multiple in-tape transition for the same state must be combined as above.

Another problem is there's no provision for discovering what part of the tape is interesting. That's gonna cost quite a bit to do a currentdict{search-for-min-and-max}forall juggle-params-for-for. :(

Tried my own, but was way beyond your conciseness. But I suggested some improvements to your code.

BTW, what about the initial tape? I removed the commented out line from the un-golfed code because it didn't seem to do the job. ("0 not" returns -1, therefore no iteration of the loop)

Excellent improvements! ... About the initial tape code, I think I mistyped it from my notebook. S.B. 0 1 0 not{(%stdin)(r)file read not{exit}if def}for. I'm not sure why I thought I could get away with omitting that from the golfed version. :P

Oh, wait, -1! Then 0 not should be 16#7fffffff. Sorry. Aha! that's why it was commented! It came straight out of the notebook, didn't get tested, and I trimmed all comments without looking when I golfed it up. Don't tell the Python guy! :P

C (not golfed yet)
I suppose I can't win with this, still it was fun getting it to work. This is even more true now that it really does work. :)
Except it's only infinite in one direction. I suppose it needs a negative tape, too. Sigh....
Negative wasn't so bad. We interleave the two sides as evens and odds. Complication is now it needs to display the tape in sequential order, as the file itself is now jumbled. This is a legitimate alteration to make, I think. Turing himself simplified this way.
#include<stdio.h>
int main(int c, char**v){
    int min=0,max=0;
    int pos=0,qi;sscanf(v[1],"%d",&qi);
    FILE*tab=fopen(v[2],"r");
    FILE*tape=fopen(v[3],"r+");
    setbuf(tape,NULL);
    do {
        min = pos<min? pos: min;
        max = pos>max? pos: max;
        fseek(tape,(long)(abs(pos)*2)-(pos<0),SEEK_SET);
        int c = fgetc(tape), qt=qi-1,qr;
        fseek(tape,(long)(abs(pos)*2)-(pos<0),SEEK_SET);
        char x = c==EOF?' ':c, xt=x-1,xr,d[2];
        if (x == '\n') x = ' ';
printf("%d '%c' %d (%d)\n", qi, x, pos, (int)ftell(tape));
        while((qt!=qi)||(xt!=x)){
            fscanf(tab, "%d '%c' %d '%c' %1[LRN]", &qt, &xt, &qr, &xr, d);
            if (feof(tab)){
                goto HALT;
            }
printf("%d '%c' %d '%c' %s\n", qt, xt, qr, xr, d);
        }
        qi=qr;
        rewind(tab);
        fputc(xr,tape);
        pos+=*d=='L'?-1:*d=='R'?1:0;
    } while(1);
HALT:
printf("[%d .. %d]:\n", min, max);
    for (pos = min; pos <= max; pos++){
        fseek(tape,(long)(abs(pos)*2)-(pos<0),SEEK_SET);
        //printf("%d ",pos);
        putchar(fgetc(tape));
        //puts("");
    }
    return qi;
}

And here's the test-run:
522(1)04:33 AM:~ 0> cat bab.tm
0 'a' 0 'b' R
0 'b' 0 'a' R
523(1)04:33 AM:~ 0> echo aaaaa > blank; make tm ; tm 0 bab.tm blank; echo; cat blank
make: `tm' is up to date.
0 'a' 0 (0)
0 'a' 0 'b' R
0 'a' 1 (2)
0 'a' 0 'b' R
0 'a' 2 (4)
0 'a' 0 'b' R
0 ' ' 3 (6)
0 'a' 0 'b' R
0 'b' 0 'a' R
[0 .. 3]:
bbbÿ
babab

The program outputs the tape in sequential order, but the file represents the negative and positive sides interleaved.

There are problems with your implementation. Try this program that swap a and b 0 'a' 0 'b' R; 0 'b' 0 'a' R with input aaa the output is bab instead of bbb. And there are problems moving left.

Thanks for the attention! Update fixes both, I think (hope).

uhm.. still getting bab

yeah, but this time it's correct! 'aaa' corresponds to positions [0,-1,1] on the tape. But the output that should show this clearly needs work.

Groovy 234 228 154 153 149 139 124
n=[:];i=0;t={it.each{n[i++]=it};i=0};e={p,s->a=p[s,n[i]?:' '];if(a){n[i]=a[1];i+=a[2];e(p,a[0])}else n.sort()*.value.join()}

Formatted for readability
n=[:];
i=0;
t={it.each{n[i++]=it};i=0};
e={p,s->
    a=p[s,n[i]?:' '];
    if(a){
        n[i]=a[1];
        i+=a[2];
        e(p,a[0])
    }else n.sort()*.value.join()
}

t is the function that set the tape
e is the function that evaluate the program
Example 1 - Print "Hello!" on the tape :)
t('')
e([[0,' ']:[1,'H',1],
   [1,' ']:[2,'e',1],
   [2,' ']:[3,'l',1],
   [3,' ']:[4,'l',1],
   [4,' ']:[5,'o',1],
   [5,' ']:[6,'!',1]],0)

Example 2 - Leave a T on the tape if the initial string is in the form of anbn, stop otherwise.
t('aaabbb')
e([[0,'a']:[1,' ',1],
   [0,' ']:[4,' ',1],
   [1,'a']:[1,'a',1],
   [1,'b']:[1,'b',1],
   [1,' ']:[2,' ',-1],
   [2,'b']:[3,' ',-1],
   [2,'a']:[5,'a',-1],
   [3,'b']:[3,'b',-1],
   [3,'a']:[3,'a',-1],
   [3,' ']:[0,' ',1],
   [4,' ']:[5,'T',1]],0)

Example 3 - Increment of a binary number
t('101')
e([[0,'0']:[0,'0',1],
   [0,'1']:[0,'1',1],
   [0,' ']:[1,' ',-1],
   [1,'0']:[2,'1',1],
   [1,'1']:[3,'0',-1],
   [3,'0']:[2,'1',1],
   [3,' ']:[2,'1',1],
   [3,'1']:[3,'0',-1]],0)

in the examples 1 means move to the right and -1 means move to the left


text:
Program my microwave oven
I'm very lazy so I try to always program my microwave with the fewest possible button presses.  My microwave has the following buttons:

A "minute plus" button which may only be pressed first and implies "start".  It may be pressed multiple times for multiple minutes, but it will not add a minute to a manually entered time.  Output +
A set of 0-9 buttons.  Time entry is MMSS (i.e. "130" means 1 minute 30 seconds).  Seconds may range from 0..99.  So "130" and "90" are equivalent entries.  Obviously each minute is 60 seconds even if the seconds part of the entry exceeds 59.  Output 0..9
A "start" button which must be pressed to start the microwave if the time is entered manually.  Output S

My food packages specify time in MM:SS and so the program must accept that input.
Examples

1:00 is + (remember "minute plus" implies start)
1:01 is 61S (seconds can exceed 59, but "minute plus" does not work in conjunction with digits -- I think this is a design flaw in my microwave)
9:00 is 900S (shorter than +++++++++)

will the answers be verified with your dinner?

also which takes precedence: 400S or ++++ ?

@ardnew: I guess tiebreak should be minimum finger movement, thus ++++ wins.  :)

finger movement? so is 888S shorter than 928S, but 900S shorter than 860S ? i'm gonna need precise geometry of your buttons and each of their positions.

Could your second example of 61S also be 1S+?

The result for 10:39 is 999S? It is shorter then 1039S. Or breaks the microwave with this entry?

If I had to microwave my "Pedant's Meal for One" for 1:59, I would press ++ (wait for 1:59) and then press "cancel" one second before the end. Three button presses, assuming you have a "cancel" button and consider standing staring at the timer to be a cheap process. Maybe you could consider this option for subsequent meals! (Or for a subsequent challenge)

APL
APL has a bad reputation that it's unreadable, which is totally not the case if it's not golfed.
The rules:

Whole minutes <= 4 get +, ++, +++, and ++++
960-999 is preferred above 1000-1039. 9960-9999 is preferred above 10000-10039, etc.
If the time can be rewritten such that the seconds are 66, 77, 88, or 99 then this is done. (This never gives a worse solution and usually gives a better one, i.e. 888 instead of 928.)

∇ Microwave;time;secs;mins;fmt;⎕ML

 ⎕ML←3

 ⎕←'Enter the time (m+:ss)'
 time←⍞
 mins secs←⍎¨(time≠':')⊂time

⍝ 'minute plus' can only be used on whole minutes ≤ 4
 :If (secs=0)∧(mins≤4)
     ⎕←mins⍴'+'
     :Return
 :EndIf
⍝ If possible, save a keypress by using seconds > 60
⍝ if mins is a power of ten
 :If (mins>0)
     :If ((⌈10⍟mins)=(⌊10⍟mins))∧(secs<40)
         ⎕←('BI2'⎕FMT mins-1),(⎕FMT secs+60),'S'
         :Return
     :EndIf
 :EndIf
⍝ For the 'finger movement' requirement we want as many
⍝ of the keypresses as possible to be of the same key.
⍝ So 888S i.p.v. 928S.
 :If secs∊66 77 88 99-60
     ⎕←('BI2'⎕FMT mins-1),(⎕FMT secs+60),'S'
     :Return
 :EndIf
⍝ Otherwise, just output mmssS, there was no better alternative.
 :If mins>0
    ⍝ output seconds with leading zero
     ⎕←('BI2'⎕FMT mins),('G⊂99⊃'⎕FMT secs),'S'
 :Else
    ⍝ only output seconds, not with leading zero
     ⎕←('BI2'⎕FMT secs),'S'
 :EndIf
∇

I didn't specify a winning criteria, so I will retroactively choose the one that teaches me the most about APL.

@BenJackson Challenges require an objective winning criterion. See the description of the [code-challenge] tag you used.

JavaScript
var x = /(\d+):(\d\d)/.exec('<time here>');
x[1] === '0' ? +x[2] + 'S' :
x[1] < 4 && x[2] === '00' ? (
    x[1] === '1' ? '+' :
    x[1] === '2' ? '++' : '+++') :
x[2] < 40 ?
    (x[1] - 1 ? x[1] - 1 : '') + '' + (6 + +x[2][0]) + x[2][1] + 'S' :
x[1] + x[2] + 'S'

Perl
meets the requirements, but it isn't how I would enter the buttons (e.g. "860S" vs "900S") handles exactly 60 seconds as a special case
use strict;
use warnings;

sub cook
{
  my ($mins, $secs) = @_;

  my $plus = $secs =~ /00/ ? $mins : undef;

  my $secs_total = $mins * 60 + $secs;
  my $mins_total = 0;

  while ($secs_total > 99)
  {
    ++$mins_total;
    $secs_total -= 60;
  }

  $plus = "+" x $plus if defined $plus;

  my $nums = "";
  my $even = ($mins_total > 0 and $secs_total == 60);

  $secs_total *= not $even;
  $mins_total += $even;

  if ($mins_total > 0)
  {
    $nums = sprintf "%s%02dS", $mins_total, $secs_total;
  }
  else
  {
    $nums = sprintf "%2dS", $secs_total;
  }

  return ($nums, $plus)
    [defined $plus and length $plus < length $nums];
}

die "usage:$/\tperl $0 <MINUTES>:<SECONDS>$/"
  unless @ARGV > 0 and shift =~ /([0-9]{1,2}):([0-9]{1,2})/;

print cook($1, $2), $/;

Output
andrew@gidget:~$ perl mic.pl 9:00
900S
andrew@gidget:~$ perl mic.pl 1:00
+
andrew@gidget:~$ perl mic.pl 1:01
61S
andrew@gidget:~$ perl mic.pl 1:30
90S
andrew@gidget:~$ perl mic.pl 0:07
 7S
andrew@gidget:~$ perl mic.pl 4:00
400S

ruby
#Build a string for the microwave
def build_result(minutes, seconds)
  duration = minutes * 60 + seconds
  if duration < 99
    result = "%iS" % [ duration]    #shortcut '90S' instead '130S'
  else
    result = "%i%02iS" % [ minutes, seconds]
  end
  result
end

#Call microwave optimizer
def microwave( input )
  minutes  = input.split(/:/).first.to_i
  seconds = input.split(/:/).last.to_i

  #build result
  result = build_result(minutes, seconds)
  #try a shorter result, make 999S out of '10:39':
  if seconds < 40 and minutes > 0
    result2 = build_result(minutes - 1, seconds + 60)   #try a
    result = ( result.size <= result2.size ? result : result2 )
  end

  #Check if a version with only '+' is shorter
  if seconds == 0 and minutes <= result.size
    result = '+' * minutes
  end
  result
end

#Test if called with an argument
if ARGV.empty?
  require 'test/unit'   #Exceute a test
  class MicrowaveTest < Test::Unit::TestCase
    def test_007
      assert_equal('7S', microwave('0:07'))
    end
    def test_100
      assert_equal('+', microwave('1:00'))
    end
    def test_101
      assert_equal('61S', microwave('1:01'))
    end
    def test_130
      assert_equal('90S', microwave('1:30'))
    end
    def test_400
      #~ assert_equal('400S', microwave('4:00'))
      assert_equal('++++', microwave('4:00'))
    end
    def test_500
      assert_equal('500S', microwave('5:00'))
    end
    def test_900
      assert_equal('900S', microwave('9:00'))
    end
    def test_1000
      #~ assert_equal('1000S', microwave('10:00'))
      assert_equal('960S', microwave('10:00'))
    end
    def test_1015
      #~ assert_equal('1015S', microwave('10:15'))
      assert_equal('975S', microwave('10:15'))
    end
    def test_1039
      #~ assert_equal('1039S', microwave('10:39'))
      assert_equal('999S', microwave('10:39'))
    end
  end
else  #started via shell, evaluate input
  puts microwave(ARGV.first)
end

Remarks:

Start it with ruby program-my-microwave-oven.rb and a unit test is evaluated.
Start it with ruby program-my-microwave-oven.rb 10:00 and it writes 960S

Some remarks on the rules (and my interpretation):

The shortest for 10:00 is 960S (9 minutes and 60 seconds -> 10 minutes).
The shortest for 10:39 is 999S (9 minutes and 99 seconds -> 10 minutes and 39 seconds).
for 4:00 it prefers ++++ (less finger movements)


text:
Ode-cay Olf-gay
Write a program which accepts a sentence into stdin, and writes that sentence to stdout in pig latin.
Here are some test cases which your program should handle:
Input:
    Read your script
Output:
    ead-Ray our-yay ipt-scray

Hyphenation is mandatory. Note that multiple consonants at the start of the word must all be moved to the end. Capitalization of the output does not matter; Ead-ray or ead-ray are also valid translations of Read
Input:
    An utterance is allowed an opening vowel
Output:
    An-way utterance-way is-way allowed-way an-way opening-way owel-vay

Words starting with vowels have -way appended in their pig latin form (don't forget to handle capital opening vowels)
Input:
    sky
    -skyay

Words consisting entirely of consonants should have a hyphen prepended, and ay appended
Punctuation is undefined; I don't care if leading or trailing punctuation ends up inside the pig latin word.
This is code golf; the shortest program by character count wins. I've written a solution myself which handles all these cases which I shall post as a response.

And what if there is a language that has a built-in piglatinify function? The Odegolfpay language springs to mind. You should add a clause that penalises the use of libraries like that.

@MrLister I think it's better to not add a bunch of little restrictions to the puzzle unless it's actually a problem. Besides, an answer in such a language really isn't very interesting and I doubt it would get many upvotes.

@PeterOlson O-Kay.

-151 point bonus if an input of caribou lou gives aribou-kay, ou-lay, terrible day, you pay the liquor store teller with no hair or toupe

Perl (53)
s/(.*?)([aeiou].*)/$1||=w;print"$2-$1ay "/iefor split

Python, 89
import re
print re.sub('-a','-wa',re.sub('(?i)([^aeiou ]*)(\w*)',r'\2-\1ay',raw_input()))

Perl, 41 excluding switches
A simple modification of Timwi's answer. Runs with perl -p. Does not meet the spec for 'sky', but the original doesn't either.
s/(\S*?)([aeiou]\S*)/"$2-".($1||w).ay/ige

Perl (60)
Use perl -n. The -n switch is counted (as two characters).
s/(.*?)([aeiou].*)/print"$2-$1"."w"x!$1."ay "/iefor split

Python - 122 85 characters
import re
print re.sub("-a","-wa",re.sub("([^aeiou ]*)(\w*)",r"\2-\1ay",raw_input()))

122 -> 85: Improved use of regexes; running regex on whole sentence rather than individual words, and doing all the processing with regexes rather than a conditional expression. This ended up making it pretty similar to grc's answer

I would switch to Python 3 and shave off 2 characters :)

Cojure - 376 characters
Obviously not winning this one, but figured I'd take a shot at it.
Minified:
(defn n [a b] (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))
(defn t [a] (let [vowels ["a" "e" "i" "o" "u"] x "ay"] (if (> (.indexOf vowels (string/lower-case (first a))) -1) (str a "-way") (if (n vowels a) (str a x) (str (reduce str (rest a)) "-" (first a) x)))))
(defn ay-ya [a] (reduce str (map #(str (t %) " ") (string/split a #" "))))

Actual:
(defn no-vowel [a b]
    (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))

(defn transform [text]
  (let [vowels ["a" "e" "i" "o" "u"]]
    (if (> (.indexOf vowels (string/lower-case (first text))) -1)
        (str text "-way")
        (if (no-vowel vowels text)
          (str text "ay")
          (str (reduce str (rest text)) "-" (first text) "ay")))))

(defn ay-ya [text]
    (reduce str
        (map #(str (transform %) " ")
             (clojure.string/split text #" "))))

Perl 6,  78  66 bytes
put get.words.map: {samecase S:i/(.*?)(<[aeiou]>.*)|(.*)/$1-{~$0||'w'}ay/, $_}
put get.words.map: {~S:i/(.*?)(<[aeiou]>.*)|(.*)/$1-{~$0||'w'}ay/}

( You would use the samecase one if you cared about capitalization )
$ perl6 -e 'put get.words.map: {~S:i/(.*?)(<[aeiou]>.*)|(.*)/$1-{~$0||"w"}ay/}'
Read your script
ead-Ray our-yay ipt-scray

$ perl6 -e 'put get.words.map: {~S:i/(.*?)(<[aeiou]>.*)|(.*)/$1-{~$0||"w"}ay/}'
An utterance is allowed an opening vowel
An-way utterance-way is-way allowed-way an-way opening-way owel-vay

$ perl6 -e 'put get.words.map: {~S:i/(.*?)(<[aeiou]>.*)|(.*)/$1-{~$0||"w"}ay/}'
sky
-skyay

auto +1 for Perl 6!

K, 95
" "/:{$[&/~x in v:v,_v:"AEIOU";"-",x,"ay";("-"/:|_[;x]0,*&t),$[*t:x in v;"way";"ay"]]}'" "\:0:0

Clojure - 113 chars
(clojure.string/replace(read-line)#"([^aeiouAEIOU ]*)(\w*)"(fn[[a c r]](if(=""a)""(str r"-"(if(=""c)\w c)"ay"))))

Ruby 1.9, 68
puts ARGV.map{|w|w[/^([^aeiou]+)(.*)/i]?$2+"-"+$1+"ay":w+"-way"}*" "

I counted 68 characters ...

C, 134 bytes
char w[99],*p;c;main(l){for(;c^10;c=getchar())scanf("%s",w),p=strpbrk(w,"aeiouAEIOU"),l=p-w,printf("%s-%.*say ",p?p:"",l+!l,l?w:"w");}

Lexurgy, 116 bytes
p:
([]+)$1 *=>$1 \-way/$ {a,e,i,o,u} _
({b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z}+)$1 ([]*)$2 => $2 \- $1 ay/$ _

+52 bytes if you want case-insensitive support.


text:
The Strange Unsorting Machine for Nefarious Purposes
Good Evening Golfers!
Your challenge is to completely unsort a series of numbers.
Input
Exactly 100 integers will be fed to your program. Your program may accept the input either as a file, or via stdin. Each integer will be separated by a newline character.
Those 100 integers will range from the minimal to the maximal values of a signed integer in your chosen language.
There will be no duplicate values. The values may be ordered, unordered or partially ordered - your program should be able to handle each case.
Output
The output must be each of the 100 integers, completely unsorted, each separated by a newline character. The output may be via stdout, or to a file.
Completely Unsorted means that no value is adjacent to any value which it would be adjacent to if the list were completely sorted in an ordered sequence.
Score
1 point per character, and lowest score wins. There is a bonus of -100 for any solution using no built in or library sorting functions. There is a bonus of -20 for any solutions using no built in random number functions.
I have tried to define this question as completely as possible. If you have any questions, please ask. If you have any comments on how I could do better next time, please let me know.
Fore!

There are exactly 100 integers input, and there are no duplicate values (see under "Input")

Right you are, didn't spot that.

It's not a duplicate as such, but it's not very different to http://codegolf.stackexchange.com/questions/6487/code-golf-mix-the-nuts-so-that-none-of-the-same-kind-are-touching

So many clever responses! I'll select shortest answer on Oct 31 at 8:10-Zulu

GolfScript (score 27 - 120 = -93)
~].,{{.2$<{\}*}*]}*.(;+2%n*

Note: that $ is referencing an element on the stack. There is sorting, but it's done with an manually coded bubble sort.
Thanks to Howard, for -90 => -92; and Ilmari, who inspired -92 => -93.

Credit for such a concise answer, but (forgive me, as I don't speak or understand GolfScript) - wouldn't the ^ disqualify it from the -100 bonus?

@lochok, the built-in sort function is $ - that's why I mentioned that the $ in the program aren't sorts (it's context-dependent). The majority of the program (28 of the 42 characters) defines the function ^; the first version, using the built-in sort, was only 14 characters.

Ahh - right. Thanks for the clarification!

You can save two chars with the following output loop: 2/{~p}%n*.

2/zip~+n* and .);\+2%n* also do the trick for the same number of chars as @Howard's version. Alas, I haven't managed to find anything shorter yet.

Python -26
(94-120): New, crude approach. Keep popping lowest elements into new list to get the elements sorted, then iterate:
t=l=[]
i=N=100
exec't=t+[input()];'*N+'l+=[t.pop(t.index(min(t)))];'*N+'print l[i%N];i+=3;'*N

Python -13
(107-120): First approach:
Removes four lowest elements at a time, then print these four in another order:
exec'l=[]'+'+[input()]'*100
while l:
 a,b,c,d=eval('l.pop(l.index(min(l))),'*4)
 for e in[b,d,a,c]:print e

t=l=[] and exec't+=[input()];'*100 would save you a few chars

also, you can use one exec statement for more than one loop.

@quasimodo I tried something like that, but with t=l=[] t and l point to the same object and it doesn't work. Skipping parentheses on exec is nice though.

You could use t=t+[input()];, this creates a new object each time. And you can even do the print loop in the exec statement: ';i+=1;print l[i*3%100]'*100.

You're right again. Thanks! Also added some other golfing like removing the %3 and avoiding repeation of 100.

One last tip: initialize i as 100 and use it instead of N :)

Clever :) However, I don't gain anything on removing N completely, as I then have to write i%100 and the total count will end up the same as now anyways. Unless you have another idea.

C: 11 (131 - 120)
The programm reads from stdin and does a simple insert sort, after that it prints the nth together with th n+50th number, like many of the other solutions.
main(){int*i,a[101],*j=a;while(scanf("%d",a)>0)for(i=++j;i-->a;)i[1]=*i>=*a?*i:*(i=a);while(a<(i=j-50))printf("%d\n%d\n",*i,*j--);}

J, -63 (57-120) characters
Since everyone else is going down the self-written sort route...
,50(}.,.{.)($:@([-.m),~m=.]#~]=<./)^:(0<#),".[;._2[1!:1[3

Doesn't use any random number function, nor any built-in sort.
Uses a simple recursive selection sort to sort the input.

Mathematica -56 44 4    (95-120) = -25
Edit:
This version relies on neither built-in functions for sorting lists, nor randomization functions.
Riffle[RotateLeft[#[[All, 2]], 2], #[[All, 1]]] &
[Partition[l //. {x___, a_, b_, y___} /; b < a :> {x, b, a, y}, 2]]

Is Sort not a built-in sort function?

You are correct!  I missed the constraint about sort.

I made a hand-rolled Sort.

Ruby 1.9, -59
(61-120)
Recursion! This one does in fact, unlike my previous Ruby attempts, unsort the list regardless of their original order.
p *(f=->l{l[1]&&f[l-m=l.minmax]+m||[]})[$<.map &:to_i].rotate

Previous attempts
Cute one-liner, now using builtin sort to work properly:
$<.map(&:to_i).sort.each_slice(4){|a,b,c,d|p b,d,a,c}

First one -- Didn't necessarily unsort the last 4 values:
l=$<.map &:to_i
48.times{l-=p *l.minmax}
a,b,c,d=l
p b,d,a,c

Your -72 solution assumes the list starts out sorted, which is not the case.

Oops. Seems I didn't re-read the question thoroughly when I revisited this one. Will try to come up with something else.

@histocrat that should do it.

Python 2: 90 char
n=100
s=sorted(int(raw_input())for i in range(n))
for i in range(n):print s[(4*i+4*i/n)%n]

lazy attempt but just for starters

Python 27 (147 - 100 - 20)
R=range
def S(L):
 for i in R(len(L)-1):
    if L[i]>L[i+1]:L[i:i+2]=[L[i+1],L[i]];S(L)
a=map(input,['']*100);S(a)
for i in R(100):print a[i/2+i%2*50]

Note: the spaces before if L[i]>... should be a tab but apparently show up as spaces in a code block.

With R=range you could save 5 characters.

a=map(input,['']*100)

Python 48 = (148 - 100)
from random import*
x=[input()for i in range(100)]
while any(abs(x[i]-x[i+1])>1 for i in range(99)):n=randint(1,99);x=x[n:]+x[:n]
for j in x:print j

Haven't tested this because it isn't guaranteed (or likely) to run in any reasonable amount of time, but should work in theory given infinite time.

x=map(input,['']*100)

And I don't think you even need the extra []s, just any single character string.

Perl 5: 95 - 120 = -25 chars
Counting the following command line:
perl -ne '$n=$_;splice@n,(grep{$n[$_]>$n}0..@n),0,$n}{print for map{@n[$_,$#n/2+$_+1]}0..$#n/2'

Ruby: -50 (70 chars - 120)
I did the same as many other answers: iteratively remove the max and min from the input list and append them to the output.  However, I realized that if the 2 numbers on either side of the median are themselves consecutive, the output will be incorrect (because those 2 consecutive numbers will appear together at the end of the output).  To fix this, I rotate the "unsorted" list right by 1 element:
n=$*.map &:to_i;u=[];50.times{u+=n.minmax;n-=u.last 2};p *u.rotate(-1)

Or, to work with arbitrarily many inputs (using only 4 more characters):
n=$*.map &:to_i;u=[];(u+=n.minmax;n-=u.last 2)while n.any?;p *u.rotate(-1)

Note: Some fewer-char Ruby answers have already been posted, but those solutions did not address the median issue (and/or assumed a sorted input list).

J 37 - 100 = -63
({~?~@#)^:(+./@(1=|)@(2&(-/\))@/:)^:_

Uses no sort (though does use rank up)
Uses random numbers.
Explanation:
({~?~@#)             NB. Randomizes the array
^: foobar ^:_        NB. as long as
foo =: +./@(1 = |)   NB. as any 1 == absolute value of
bar =: (2&(-/\))@/:  NB. differences between adjacent ranks
foobar =: foo@bar

Brachylog, 22 bytes - 120 = -98
ṇịᵐpX¬{p≤₁s₂.&s₂p}∧Xẉᵐ

Try it online!
The TIO link only has an input of eight integers, rather than one hundred, because this is so dreadfully slow that it can't handle any more in 60 seconds. The reason for this is that, among other things, rather than implement some simple but normal sorting algorithm for the mandatory bonus, I for the sake of brevity used what amounts to a deterministic bogosort: p≤₁ backtracks through every permutation of the input until it finds one which is non-decreasing. Although a larger reason would probably be that it employs a similar degree of brute force to find the output, and that it recomputes the sorted version every time... I attempted to test it on an actual input of size 100, but I'm not sure just how many days it will take.
An overall better version:
Brachylog, 14 bytes - 20 = -6
p.¬{os₂.&s₂p}∧

Try it online!
This ignores the antiquated I/O requirements for brevity, and neglects to take the -100 bonus so it can possibly be tested without a supercomputer (although as of writing this, I've had it running on only 20 items for several minutes and it still hasn't given me anything).
 .                The output is
p                 a permutation of
                  the input
  ¬{        }∧    such that it cannot be proven that
         s₂       a pair of adjacent values in
        &         the output
       .   p      is a permutation of
     s₂           a pair of adjacent values in
    o             the output sorted.

Although this isn't exactly a practical answer, it could be of use for validating the output from other programs, since most of it is just describing the constraint placed on the output.

Forth (gforth), 79 - 120 = -21 bytes
: f 100 0 do dup i 2 mod 4 * 2 - i + i 99 = i 0 = - 3 * + cells + @ . cr loop ;

Try it online!
Ignore antiquated input requirements and takes input as an address in memory where the numbers are stored.
Explanation
Loops through all numbers from 0 to 99.
For each number (n):

If n is 0:

output the value at array address + 1

Else If n is 99:

output the value at array address + 98

Else If n is odd:

output the value at array address + (n + 2)

Else (n is even):

output the value at array address + (n - 2)

Output a newline

Code Explanation
: f               \ start new word definition
  100 0 do        \ loop from 0 to 99
    dup           \ duplicate the array address
    i             \ place the loop index on the stack
    2 mod 4 * 2 - \ convert to 2 if it's odd and -2 if it's even
    i +           \ add the result to the the loop index
    i 99 =        \ if i = 99 place -1 on top of the stack, else place a 0
    i 0 =         \ i i = 0 place -1 on top of the stack, else place 0
    - 3 *         \ subtract previous two results from each other and multiply by 3
\ the above line is used to avoid writing if/then by instead using math to get 98 and 1
    +             \ add result to existing result from above
    cells         \ multiply by the size of a single integer in memory
    +             \ add to the array's starting address
    @ . cr        \ get the value at the calculated address, print it, then print a newline
  loop            \ end the loop
;                 \ end the word definition


text:
Find The Least Common Characters
Given a string, find the 10 least common alpha-numeric characters within that string.
Output should be formatted with numbers left-padded with spaces so they look like this:
e:      1
t:     16
c:     42
b:    400
z:  50000
a: 100000

Use this to test your program: here
Output for test case:
j:  2
x:  3
q:  9
k: 32
v: 67
c: 73
w: 79
f: 93
b: 94
p: 96

Shortest code wins. You can submit a program or a function.

Do you want a function or a whole program?

@marinus: A program or a function, whichever is shorter for you.

I presume from your output to the test case that uppercase and lowercase letters are treated as the same?

@Gareth: Yes, they should be treated the same.

K, 60
{(-:|/#:'f)$f:10#$(!x)[i]!r i:<r:. x:#:'=_x@&x in,/.Q`a`A`n}

Mathematica, 102 93:
v2:
  Grid[SortBy[
             Tally@StringCases[ToLowerCase@#,x_?LetterQ:>x<>":"],
              Last@# &],
      Alignment->Right]&@s

v1:
TableForm[
         SortBy[Tally@StringCases[ToLowerCase@#, x_?LetterQ :> x <> ":"],
                #[[2]] &],
         TableAlignments -> Right] &

You beat me to it (and had more streamlined code).

@DavidCarraher But MMa is SO verbose! :(

I detect a hint of irony in your comment.

Bash, 72
Assuming no single-letter-named files in the current directory; input from stdin:
grep -io [a-z]|sort -f|uniq -ci|sort|head|sed -E 's/(.*)([a-z])/\2:\1/'

Works on Linux, but for some reason, my mac's grep seems to ignore the -i when used with -o (bug or undocumented gotcha?), but the following (78) works:
tr A-Z a-z|grep -o [a-z]|sort|uniq -c|sort|head|sed -E 's/(.*)([a-z])/\2:\1/'

If the output were allowed to be reversed, the sed part could be dropped to save 30 characters in each of the previous solutions.

APL (Dyalog Unicode), 45 36 bytes
10↑⌷⍨∘⊂∘⍋∘⌽⍨{⍺':',≢⍵}⌸∊⎕(∊⊆⊣)⍥⎕C⎕D,⎕A

Try it online!
A full program which accepts a string as input. tio link uses polyfills for ⍥ and ⎕C.
Shortened and tested with help from Bubbler.
-12 bytes from Adám.
Doesn't work on tio due to some problem with ⎕C.(Now works, thanks to Adám's help)
Explanation
10↑⌷⍨∘⊂∘⍋∘⌽⍨{⍺':',≢⍵}⌸∊⎕(∊⊆⊣)⍥⎕C⎕D,⎕A
                             ⍥⎕C      lowercase the following:
                                ⎕D,⎕A string of the alphabet and digits
                       ⎕              and the input
                        (∊⊆⊣)         filter out nonalphanumerics
                      ∊               flatten the string
            {⍺':',≢⍵}⌸                create a frequency table for each letter key
   ⌷⍨∘⊂∘⍋∘⌽⍨                          sort the table based on the last row
10↑                                   take the first 10 elements

Gofled a bit: {10↑⌷⍨∘⊂∘⍋∘⌽⍨{⍺':',≢⍵}⌸∊⍵(∊⊆⊣)⍥⎕C⎕D,⎕A} which you can make run on TIO by replacing ⍥ and ⎕C with polyfills: Ö←{(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵} ⋄ ∆C←819⌶. Also, since this only uses the argument once, you can save another 2 bytes by converting to a tradfn.

@Adám Another interesting use for the ∊⊆⊣ idiom. I'll get it running.

Listed here.

Java 452 444 433 430
import java.util.*;
interface L{
static void main(String[]a){
Map<Character,Integer>m=new HashMap<>();
for(char c:a[0].toLowerCase().toCharArray())if(96<c&&c<123) m.merge(c,1,(j,i)->j+i);
int l=String.valueOf(m.values().stream().reduce(0,Integer::max)).length();
m.entrySet().stream().sorted((e,f)->e.getValue()-f.getValue())
.forEachOrdered(e->System.out.println(e.getKey()+"-"+String.format("%"+l+"s",e.getValue())));
}}

My first contribution. I know Java will never win this kind of challenges but until now it is at least the shortest java response :)
First argument is used as input. If it contains spaces, it has to be quoted(")
Explained:
// there is not a lot you get for free, so import you will
import java.util.*;
interface L{
static void main(String[]a) {                 // java main entry point
    Map<Character,Integer> m=new HashMap<>(); // key=character, value=number of occurances in input text
    for(char c:                               // for each character in
        a[0]                                  // take first argument from command line
        .toLowerCase()                        // convert all characters to lowercase
        .toCharArray())                       // convert to array so we can loop over it

      if(96<c&&c<123)                      // accept only a-z
        m.merge(c, 1, (j,i)->j+i);            // fill map, increase corresponding value

    int l=String.valueOf(                     // l: to store length of counter
            m.values().stream()               // loop over counter values
              .reduce(0,Integer::max))        // find max value
            .length();                        // count number of digits of max value

    m.entrySet().stream()                     // loop over the counter map
    .sorted((e,f)->e.getValue()-f.getValue()) // sort the map by value ascending
    .forEachOrdered(                          // loop over the ordered result
        e->System.out.println(                // print for every entry
            e.getKey()                        // - the key
            +"-"
            +String.format("%"+l+"s",         // - format using l
                 e.getValue())));             //   the value
}}

452 -> 444 : removed spaces
444 -> 433 : class-> interface, public
433 -> 430: 96<c&c<123 (thanks @ceilingcat)

Nice first post, welcome to the site! I don't know Java, but is there a way some of that indentation could be removed to save some bytes?

I'm senior developer and it kind a hurts to write unreadable code :). But as this challenge is more about the number of bytes, I removed unnecessary spaces. Thanks

We also have a Tips for golfing in Java page if you're interested in reading (or contributing!) some.

Python, 206 199 195 characters
import sys
t=sys.stdin.read().lower()
f={}
for c in t:
 if c.isalnum():f[c]=f.get(c,0)+1
s=lambda x:x[1]
h=sorted(f.items(),key=s)[:10]
for n in h:print n[0]+': '+`n[1]`.rjust(len(`max(h,s)[1]`))

Undoubtedly there is a lot of room for improvement, but here's my first attempt. Produces identical output for the test case provided.
206 -> 199: Removed unnecessary newline and keyword argument
199 -> 195: iteritems()

Javascript, 271 characters
I'm not sure whether this breaks the rules of not (it doesn't justify the numbers in the output, but here's my solution anyway:
c=[];t=128;while(t--)c[t]=[0,t];i=prompt().toLowerCase();for(n=0;n<i.length;x=i.charCodeAt(n++),c[x][0]+=x>96&&x<123);for(n=i=0,c=c.sort(function(a,b){return(a[0]-b[0])});n<10;i++)if(c[i][0]>0){console.log(String.fromCharCode(c[i][1])+": "+("  "+c[i][0]).slice(-2));n++}

I'm pretty sure it can be simplified (I won't win with this character count :P), but now I can't find anything.
Okay, so I completely forgot that the padding was actually a requirement :O
Corrected that and fixed a bug. (250 -> 271)

Python, 144
import os
s=os.read(0,10000).lower()
n=s.count
a=sorted(filter(str.isalnum,set(s)),key=n)[:10]
for c in a:print c+': %%%ii'%len(`n(a[-1])`)%n(c)

I just proposed an edit that saves you 14 characters by switching to the 'raw_input()' function.

@ESultanik The problem is that raw_input() terminates on newlines, so it would stop after the first line of input in the supplied test case.

@Strigoides: Good point; I missed that the input could have newlines.  My fault for not looking at the test cases.

print c+': %%%ii'%len(n(a[-1]))%n(c) saves 3 characters

Haskell (229)
import Char
import Data.List
z=filter
t=show
l=length
k x=[(l$z(==m)x,m)|m<-x]
s z=[b:':':take(1+(maximum$map(l.t.fst)z)-l(t a))(repeat ' ')++t a++"\n"|(a,b)<-z]
main=interact$concat.s.take 10.sort.nub.k.map toLower.z isAlphaNum

Perl, 86 chars
given string is in $_
s/[a-z]/$h{lc($&)}++/eig;printf"$_:%9d$/",$h{$_}for(sort{$h{$a}<=>$h{$b}}keys%h)[0..9]

JavaScript 1.8 (ES6) 186
F=s=>(
  s.toLowerCase(n={}).replace(/[a-z0-9]/g,c=>n[c]=-~n[c]),
  s=Object.keys(n).sort((a,b)=>n[a]-n[b]),
  s.slice(0,10).map(x=>x+': '+('      '+n[x]).slice(-(n[s[9]]+'').length))
  .join('\n')
)

Jelly, 22 bytes
Øa;ØD
ŒlċⱮ¢¢żPƇ0ị$Þḣ⁵G

Try it online!
Doesn't output with a : on each row, but given that isn't explicitly specified in the spec (compared to the left padding), I assumed this was OK. 26 bytes to require separating by :.
How it works
Øa;ØD - Helper link. Yield a constant value "abc...xyz012...789"
Øa    - Yield "abc...xyz"
   ØD - Yield "0123456789"
  ;   - Concatenate

ŒlċⱮ¢¢żPƇ0ị$Þḣ⁵G - Main link. Takes a string S on the left
Œl               - Convert S to lowercase
    ¢            - Yield "abc...789"
   Ɱ             - For each character:
  ċ              -   Count occurrences in S
     ¢           - Yield "abc...789"
      ż          - Zip with occurrences
        Ƈ        - Keep characters where:
       P         -   There is at least 1 occurrence in S
           $Þ    - Sort by:
         0ị      -   Number of occurrences
             ḣ⁵  - Take the first 10
               G - Convert into a grid format

since all the other answers do output with a : character, I think it's  a better idea to post the 26 byte version.

Japt v2.0a0 -R, 28 bytes
Yet another old challenge hindered by an unnecessarily cumbersome output format.
r\W v ü ñÊ®Î¬pZÊÃ¯A yù ®q":

Try it (Note: I'm passing the input in the header here so it can be enclosed in backticks, allowing for the inclusion of both single & double quotes. Doing so, however, makes no difference to the code or byte count.)
r\W v ü ñÊ®Î¬pZÊÃ¯A yù ®q":      :Implicit input of string
r                                :Remove
 \W                              :  /[^A-Z0-9]/gi
    v                            :Lowercase
      ü                          :Group & sort
        ñ                        :Sort by
         Ê                       :  Length
          ®                      :Map each Z
           Î                     :  First character
            ¬                    :  Split
             p                   :  Push
              ZÊ                 :    Length of Z
                Ã                :End map
                 ¯               :Slice to
                  A              :  10th element
                    y            :Transpose
                     ù           :Left pad each sub array with spaces to the length of the longest and implicitly transpose back
                       ®         :Map
                        q":      :  Join with ": "
                                 :Implicit output joined with newlines

link says Error: URI too long

Fixed that earlier, @Razetime - thanks.

authors: Дамян Станчев


text:
Determine the original sequence
Write a program that will determine the original sequence given five variations. The original sequence will be contain n unique elements in any order. A variation is made by making a copy of the original sequence and choosing a random item from the copy and inserting it at any random location in the sequence (this could be the same index it was originally at). Also, each item can only be chosen once so that the five variations will each operate on a different item.
Input
5          # number of items
1 2 3 4 5  # unknown
2 1 3 4 5  # 3,4,5 candidate
3 1 2 4 5  # 4,5 candidate
4 1 2 3 5  # 1,2 candidate
5 1 2 3 4  # 1,2,3 candidate
           # 1,2,3 + 3,4,5 = 1,2,3,4,5

Output
1 2 3 4 5

In case it's not clear what I meant, here is Python code to generate an example
from random import shuffle,randint

n = 5 # can be any number
a = range(1, n+1)
shuffle(a)
s = set()
#print str(a[0])+"".join(" "+str(x) for x in a[1:]) #debug (print orig sequence)
for run in xrange(5):
    c = list(a)
    i = randint(0, n-1)
    while c[i] in s:
        i = randint(0, n-1)
    t = c.pop(i)
    s.add(t)
    c.insert(randint(0, n-1), t)
    print str(c[0])+"".join(" "+str(x) for x in c[1:])

Keep in mind, the numbers aren't necessarily consecutive or all positive. The shortest wins.
Longer Example
Here's how the five variations are generated. Each is just one step away from the original.
6 3 4 5 7 1 2 # original

6 4 5 7 3 1 2 # 3 moved to index 3
3 6 4 5 7 1 2 # 6 moved to index 1
6 3 4 5 1 2 7 # 7 moved to index 6
6 3 4 7 1 5 2 # 5 moved to index 5
6 3 2 4 5 7 1 # 2 moved to index 2

Contiguous subsequences of the original will remain in each variation.
6 4 5 7 3 1 2
3 6 4 5 7 1 2
          x x # (1, 2) is a candidate

6 4 5 7 3 1 2
6 3 4 5 1 2 7
x             # (6) is a candidate but we can ignore it since one item
              # doesn't tell us much

6 4 5 7 3 1 2
6 3 4 7 1 5 2
x     x     x

6 4 5 7 3 1 2
6 3 2 4 5 7 1
x

3 6 4 5 7 1 2
6 3 4 5 1 2 7
    x x       # (4, 5)

3 6 4 5 7 1 2
6 3 4 7 1 5 2
    x

3 6 4 5 7 1 2
6 3 2 4 5 7 1

6 3 4 5 1 2 7
6 3 4 7 1 5 2
x x x         # (6, 3, 4)

6 3 4 5 1 2 7
6 3 2 4 5 7 1
x x           # (6, 3)

6 3 4 7 1 5 2
6 3 2 4 5 7 1
x x           # (6, 3)

Merging the candidates together we realize the sequence has
(6, 3, 4, 5) and (1, 2)

We can get the rest by realizing that by inserting an item, the sequence may be shifted by one in either direction, so repeat the above except using a unshifted sequence.
4 5 7 3 1 2
3 6 4 5 7 1 2

4 5 7 3 1 2
6 3 4 5 1 2 7
        x x   # (1, 2)

4 5 7 3 1 2
6 3 4 7 1 5 2
        x

4 5 7 3 1 2
6 3 2 4 5 7 1

6 4 5 7 1 2
6 3 4 5 1 2 7
x       x x   # (1, 2)

6 4 5 7 1 2
6 3 4 7 1 5 2
x     x x     # (7, 1) something new!

6 4 5 7 1 2
6 3 2 4 5 7 1
x

3 4 5 1 2 7
6 3 4 7 1 5 2

3 4 5 1 2 7
6 3 2 4 5 7 1
          x

3 4 7 1 5 2
6 3 2 4 5 7 1
        x

Merging those with our previous results give us
(6, 3, 4, 5) and (7, 1, 2)

Now do the same again except unshifting the other.
6 4 5 7 3 1 2
6 4 5 7 1 2
x x x x       # (6, 4, 5, 7)

6 4 5 7 3 1 2
3 4 5 1 2 7
  x x         # (4, 5)

6 4 5 7 3 1 2
3 4 7 1 5 2
  x

6 4 5 7 3 1 2
3 2 4 5 7 1

3 6 4 5 7 1 2
3 4 5 1 2 7
x

3 6 4 5 7 1 2
3 4 7 1 5 2
x

3 6 4 5 7 1 2
3 2 4 5 7 1
x   x x x x   # (4, 5, 7, 1)

6 3 4 5 1 2 7
3 4 7 1 5 2

6 3 4 5 1 2 7
3 2 4 5 7 1
    x x       # (4, 5)

6 3 4 7 1 5 2
3 2 4 5 7 1
    x

Merging those with our previous gives us
(6, 3, 4, 5, 7, 1, 2)

Each candidate gives the "general" order of the original sequence. For example (6, 4, 5, 7) just says "6 before 4 before 5 before 7" but doesn't say anything about numbers that max exist between say 6 and 4. However, we have (6, 3, 4, 5) which lets us know a 3 exists between 6 and 4 so when we merge the two candidates, we end up with (6, 3, 4, 5, 7).
Additional example
Input
6 1 7 2 5 3 4
1 7 2 5 6 3 4
1 7 5 6 3 4 2
1 7 2 6 5 3 4
7 2 5 6 1 3 4

Output
1 7 2 5 6 3 4

Doing it similar to the above, we get candidates
(3, 4)
(5, 3, 4)
(1, 7)
(1, 7, 2)
(5, 6)
(1, 7, 2, 5)
(6, 3, 4)
(7, 2, 5, 6)
(7, 2)

Some are obviously self-contained, so simplifying we get
(5, 3, 4)
(1, 7, 2, 5)
(6, 3, 4)
(7, 2, 5, 6)

Then one is an obvious extension of the other, so we get
(1, 7, 2, 5, 6)
(5, 3, 4)
(6, 3, 4)

The first lets us know 5 goes before 6 and the other two say (3, 4) go after both 5 and 6, so we get
(1, 7, 2, 5, 6, 3, 4)

If you noticed, each of the items in a candidate can represent a vertex and an edge going from one item to another. Putting them all together will allow you to make a DAG.
This is just the way I do it, there may be other and better ways to do it.

I don't get it. You take out a number at a certain place an put it back in at another. But what do the 'candidates' mean?

The candidates are what I refer to as contiguous subsequences of the original sequence. You know that since at most one element is moved (to a different position or possibly the same), you can just find candidates and piece it together. That's what I tried to demonstrate in the example.

after the longer explanation i feel even more confused

D: oh my am I really that bad at explaining things

GolfScript, 44 characters
n/{~]}%:^0=.,{{{.3$?\2$?>}^%$2={\}*}*]}*" "*

The solution can be tested online.
The algorithm is based on the fact, that the order in which two items can be may be reversed mostly twice: once when the first item is moved and once when the second is. Thus, in at least 3 out of the five cases the original order is preserved.
n/          # Split the input into lines
{~]}%       # and evaluate each line.
:^          # We now have an array of arrays
            # which we save to variable ^
0=          # Take the first item of this list
.,{{        # We now sort this list of items using bubble-sort
            # The following lines calculate the comparator
    {       #   For each line in the input
      .3$?  #     Determine position of first item
      \2$?  #     Determine position of second item
      >     #     Is first before/after second?
    }^%     #   End for each
    $2=     #   Take the middle element of the list.
            #   (i.e. was first item most of the time
            #   positioned after the second)
    {\}*    #   Swap if it was the case.
}*]}*       # End of bubble-sort loops
" "*        # Format output

Novel idea, and it works for many cases, but in a few cases, it gives the incorrect sequence. Example (6 1 7 2 5 3 4), (1 7 2 5 6 3 4), (1 7 5 6 3 4 2), (1 7 2 6 5 3 4), and (7 2 5 6 1 3 4) where the original is (1 7 2 5 6 3 4). +1

@milest It does not show incorrect results; for your example see here.

You're correct, it does not, but it seems when I copied/pasted, it left a trailing newline which altered the results as in this

@milest Ah, you're correct. It sometimes doesn't work if you have trailing newlines. If you have proper input it works perfectly.

Great job using a solution I would never have thought of!