text:
Code that rot13s the output when it is rot13'd
In case the title was confusing, I mean something like the following C code:
main(){}znva(){}

When rot13 encoded, the code becomes
znva(){}main(){}

and still runs.
But that isn't a valid answer, because of these rules:

Your code must produce output. Code that doesn't produce output is disqualified.
The program can't be empty. That's disqualified too.
The program can't be the same or similar to the output. This means that you can't use Golfscript or PHP.

In a valid answer, the program produces some output without being rot13'd, such as:
Hello, World!

And when the program is rot13'd, the output changes to the following:
Uryyb, Jbeyq!

which is the rot13 of Hello, World!.
Have fun!

Is this code that produces an output when it is rot13'd? Or is it code that produces an output of itself rot13'd (that produces the original program)?

It sounds like the code is supposed to provide a rot13 filter when it is rot13ed, and it is supposed to output anything (non-empty) when run as-is. But this is interpolated from the vague suggestion of the title. Please provide a clear description of what the two versions of the program are supposed to actually do.

@breadbox I did that.

As it stands, the answer A in (say) PHP would meet the requirements.

@marinus Changed requirements to fix that.

You mean something (somewhat) similar to http://www.ioccc.org/1989/westley.c? (The program is explained in http://www.ioccc.org/1989/westley.hint)

Does the output have to contain letters? As it stands, . is a valid response in brainfuck.

"Simmilar to the output"? Does ruby fail that?

BTW: what is the objective winning criteria?

@tbodt In the future, please refrain from changing a challenge's rules and/or judging criteria once it's been posted. If you would like to "test out" a challenge before posting it, in order to per-determine what rule modifications might be necessary, please use the current Sandbox thread in Meta. (Currently at Mk V.)

@lszj OK, I'll do what I can

-1 Congratulations. You now have successfuly created a chamelion quesion. The statement "assuming they [the rules] don't change again" only shows that you can't answer this without your answer beeing invalidated.

I rolled back your questions, so the existing answers are (again) valid. You should probably ask a new question.

Also note that in your example the entire function znva is ignored.

Ruby
Cheaty answer:
$><<'Hello, world!'

Slightly less cheaty answer:
s='Hello, world!'
$-I?puts(s):chgf(s)

Golf (15 chars)
$-I?p(:a):c(:a)

I changed the rules. Your second solution is the only one valid.

This is now a code golf contest. Shorten it up.

Perl, 25 14 12 characters
I believe this adheres to all of the requirements:
$_=a;fnl;say

Outputs a. After rot13 the program looks like this:
$_=n;say;fnl

and outputs n.

Does perl generate an error on encountering fnl?

@tbodt Without strict mode (and warnings) turned on, Perl will parse fnl as "fnl" (i.e. as a string). The statement then becomes a no-op expression.

Your solution is not disqualified. And you get an up vote.

This is now a code golf contest. Shorten it up.

Brainf**k
Since you never said the output had to actually be affected by rot13, this is totally a valid answer:
-.

Not sure why it was downvoted, although it is kind of a cheap answer.

I changed the rules. histocrat's second solution is the only one valid.

add an letter at the end, and it will be valid.

@JohannesKuhn Re-changed the rules. No comments. I think that I won't have to change them again.

You change the rules just to invalidate existing answers?

PHP 6
H<?//a

The program and its output differ by 83%, so not similar.
a is not transformed into output, should satisfy all rules now.

I changed the rules. histocrat's second solution is the only one valid.

Because chameleon question.

There I fixed it.

What does that // do? And don't you need a ?> ending delimiter?

// is a comment. and no, I don't need an ending ?>

bash, 64 chars
_() { [[ "${1:0:1}" > U ]]&&rpub $@||echo $@; };_ Hello, Jbeyq.


text:
Shortest Code that creates a Deadlock
Write the shortest code to create a deadlock. Code execution must halt, so this doesn't work:
public class DeadlockFail extends Thread{ //Java code
    public static void main(String[]a){
        Thread t = new DeadlockFail();
        t.start();
        t.join();
    }
    //this part is an infinite loop; continues running the loop.
    public void run(){while(true){}}
}

It doesn't need to be certain that the code goes into deadlock, just almost surely (if you run for infinite time, it will deadlock).

Does it count as a deadlock if I try to lock the same (non-reentrant) lock twice from the same thread? (sorry I didn't realise this question in the sandbox)

@JanDvorak Does that create a situation where the code execution halts because one thread is waiting for something it cannot get (because another is holding it and waiting for what the first thread has)? Or is it one thread? If you can create such a situation with one thread, then it is fine. Read the wikepedia article on deadlock, that is what I expect.

Code execution must halt I don't understand. How is it a deadlock if it halts? Do you mean it'll be waiting for something rather than just spinlocking like an asshole?

@Cruncher Take a look at the example that does not work. The code execution doesn't stop because the loop keeps running. Yes I mean waiting rather than spinning.

So if you can make the UI thread wait for itself in Dyalog APL, does that mean that there's some hope of getting a javascript answer? Although I suspect that sort of thinking would just open the door to this answer: Javascript 6 "wait()" ... ermmm. no. Related: Is it possible for a thread to Deadlock itself?

What is a deadlock, for those of us who don't know?

@ConorO'Brien https://en.wikipedia.org/wiki/Deadlock

Dyalog APL (10)
⎕TSYNC⎕TID

⎕TSYNC makes the thread wait until the given thread ends,  ⎕TID gives the current thread.
Dyalog APL can recognize deadlocks though, so it immediately responds with
DEADLOCK

The fun thing is, you don't even need to spawn any extra threads, making the UI thread wait for itself is plenty.
If this is cheating and new threads are actually required, you can do it in 27 characters:
{∇⎕TSYNC&{⎕TSYNC⎕TID+1}&0}0

F & x runs F in a new thread on value x, and returns the thread ID. So:

{⎕TSYNC⎕TID+1}&0 creates a thread that will synchronize with the thread whose ID is one higher than its own,
⎕TSYNC& creates a new thread that will synchronize with the previous thread, and which gets an ID one higher than the thread that was just created (assuming nothing else is creating threads).
∇ causes an infinite loop (so we keep creating threads until there's a deadlock).

This will deadlock as soon as the second thread gets created before the first one starts running, which is pretty soon:
9:DEADLOCK

Save 2 bytes with: ⎕TSYNC 0'. ⎕TIDis0`.

Go, 42
package main
func main(){<-make(chan int)}

Apologies, downvoter, for not providing how it works.
This creates an anonymous channel of ints and reads from it. This pauses the main thread until a value gets sent down the channel, which obviously never happens since no other threads are active, and thus, deadlock.

How does it work?

Ruby, 39 characters
T=Thread;t=T.current;T.new{t.join}.join

The idea to use a cross-join shamelessly stolen from Johannes Kuhn's Java answer.
We can shave off four characters (getting to 35) if we tune the code to a specific environment. JRuby's console IRB is single-threaded:
T=Thread;T.new{T.list[0].join}.join

This is my previous solution:
getting a thread stuck on a mutex is easy:
m=Mutex.new;2.times{Thread.new{m.lock}}

but this isn't a proper deadlock, because the second thread is technically not waiting for the first thread. "hold and wait" is a neccessary condition for a deadlock according to Wikipedia. The first thread doesn't wait, and the second thread doesn't hold anything.
Ruby, 97 95 characters
m,n=Mutex.new,Mutex.new
2.times{o,p=(m,n=n,m)
Thread.new{loop{o.synchronize{p.synchronize{}}}}}

this is a classic deadlock. Two threads compete for two resources, retrying if they succeed. Normally they get stuck within a second on my machine.
But, if having infinitely many threads (none of which consumes CPU infinitely and some of which deadlock) is OK,
Ruby, 87 85 characters
m,n=Mutex.new,Mutex.new
loop{o,p=(m,n=n,m)
Thread.new{o.synchronize{p.synchronize{}}}}

According to my test, it fails after the thread count reaches about 4700. Hopefully it doesn't fail until each thread had a chance to run (thus either deadlocking or finishing and freeing space for a new one). According to my test, the thread count doesn't drop after the failure occurs, meaning that a deadlock did occur during the test. Also, IRB died  after the test.

why do you need the extra o & p variables? Can't you just pass m and n for the new Thread?

@JohannesKuhn m and n are global. Both threads see them in the same order. o and p are thread-local (scoped to the loop iteration). Using t[...] would probably get expensive, and I can see no better way of passing parameters to the thread than via closure. Adding extra parameters to new lengthens the code by two chars.

@JohannesKuhn I hope you don't mind I have borrowed some of your logic

I don't mind. Good job.

If we assume we're in the main thread, we can shave this down to 32 chars with T=Thread;T.new{T.main.join}.join

For that matter, Ruby considers Thread.current.join to be a deadlock, but maybe that's pushing it.

@histocrat I've tried that. Ruby throws an exception, saying a thread is trying to join itself. Tested in jruby 1.7.5/ruby 2.0.0

@JanDvorak That seems like more sensible behavior, but it does cause a deadlock in ruby 1.9.3p327.

I actually like this answer better than marinus's answer (which I accepted because it has less characters). APL is very difficult to read/understand, but this answer is very readable.

Python, 46
import threading as t
t.Semaphore(0).acquire()

(self-deadlock)

from threading import* Semaphore(0).acquire() is shorter by one byte I think

@Roman Yeah, it is shorter and it works. https://tio.run/##K6gsycjPM/r/P60oP1ehJKMoNTElMy9dITO3IL@oRIsrODU3sSAjvyhVw0BTLzG5sDQTyNT8/x8A

Bash + GNU coreutils, 11 bytes
mkfifo x;<x

Creates a stray FIFO x in the current directory (so you'll need to not have a file by that name). FIFOs can be deleted the same way as regular files, so it shouldn't be hard to clear up.
A FIFO has a write side and a read side; attempting to open one blocks until another process opens the other, and this seems to have been intentionally designed as a synchronization primitive. Given that there's only one thread here, as soon as we try to open it with <x, we get stuck. (You can unstick the deadlock via writing to the FIFO in question from another process.)
This is a different kind of deadlock from the one when there are two resources, and two threads each have one and needs the other; rather, in this case, there are zero resources and the process needs one. Based on the other answers, I think this counts, but I can understand how a deadlock purist might want to disallow the answer.
Come to think of it, I can actually think of three deadlock-like situations:

The "traditional" deadlock: two threads are each waiting for a lock to be released, that's held by the other thread.

A single thread is waiting for a lock to be released, but it holds the lock itself (and thus is blocking itself from being able to release it).

A single thread is waiting for a synchronization primitive to be released, but the synchronization primitive starts in a naturally locked state and has to be unlocked externally, and nothing's been programmed to do that.

This is a deadlock of type 3, which is in a way fundamentally different from the other two: you could, in theory, write a program to unlock the synchronization primitive in question, then run it. That said, the same applies to deadlocks of type 1 and 2, given that many languages allow you to release a lock you don't own (you're not supposed to and would have no reason to do so if you had a reason to use the locks in the first place, but it works…). Also, it's worth considering a program like mkfifo x;<x;echo test>x; that program's sort-of the opposite of a type 2 deadlock (it's trying to open both ends of the FIFO, but it can't open one end until after it opens the other end), but it was made from this one via adding extra code that never runs after this one! I guess the problem is that whether a lock is deadlocked or not depends on the intention behind the use of the lock, so it's hard to define objectively (especially in a case like this where the only purpose of the lock is to produce a deadlock intentionally).

Tcl, 76
package r Thread;thread::send [thread::create] "thread::send [thread::id] a"

Deadlock.
This creates a new Thread, and tells the other thread to send my thread a message (script to execute).
But sending a message to an other Thread usually blocks until the script has been executed. And while it is blocking, no messages are processed, so both Threads wait for the other to process their message.

how does this work?

thread::send queues a script that should be executed in an other thread and wait for it to complete. So at the end we have Thread 1 waiting for Thread 2, and Thread 2 waiting for Thread 1.

Java, 191
class B extends Thread{public static void main(String[]a)throws Exception{new B().join();}Thread d;B(){d=Thread.currentThread();start();}public void run(){try{d.join();}catch(Exception e){}}}

Ungolfed:
class B extends Thread {
    Thread d;
    public static void main(String[] args) throws Exception {
        new B().join();
    }
    B() { // constructor
        d = Thread.currentThread();
        start();
    }
    public void run() {
        try {
            d.join();
        } catch (Exception e) {
        }
    }
}

Starts a new Thread and join on it (wait until this thread has finished), while the new Thread does the same with the original Thread.

Can you make it shorter by throwing and catching Error instead of Exception?

Nope. Thread.join() throws an InteruptedException, which is not a subclass of Error.

C#, 100
class C{static C(){var t=new System.Threading.Thread(Main);t.Start();t.Join();}static void Main(){}}

See: The no-lock deadlock

Can't you move the stuff from static C to Main?

Bash with glibc, 6 Bytes
Sorry to revive an old thread, but couldn't resist.
As root:
pldd 1

From man pldd:

BUGS
  Since glibc 2.19, pldd is broken: it just hangs when executed. It is unclear if it will ever be fixed.

There is no problem with answering on a old tread as long as the original was not time sensitive.

alternative java with monitor-abuse (248 charas)
class A{public static void main(String args[]) throws Exception{final String a="",b="";new Thread(new Runnable(){public void run(){try {synchronized(b){b.wait();}} catch (Exception e) {}a.notify();}}).start();synchronized(a){a.wait();}b.notify();}}

Scala, 104 bytes
class A{s=>lazy val x={val t=new Thread{override def run{s.synchronized{}}};t.start;t.join;1}};new A().x

The lazy val initialization block suspends until a condition is fulfilled. This condition can only be fulfilled by reading the value of lazy val x - another thread that is supposed to complete this condition cannot do so. Thus, a circular dependency is formed, and the lazy val cannot be initialized.

How does this work?

I added an explanation.

PowerShell, 36 28 23 bytes
gps|%{$_.waitforexit()}

Self-deadlock. We get all processes with Get-Process and then wait patiently for each of them to exit ... which will happen approximately never, since the process will be waiting on itself.
Edit - Saved 5 bytes thanks to Roman Gräf

(gps)|%{$_.waitforexit()} is three bytes shorter and waits for all processes to exit.

@RomanGräf Indeed, but don't need the parens around gps in that case, so saved 5 bytes total.

Kotlin, 35/37/55 bytes
General theme: Thread.currentThread().join().
Excluding JVM bugs / very specialized code against this submission this shoud never return as the current execution thread is now disabled waiting for itself to die.

Evil property: 35 bytes (non-competing): 35 bytes
val a=Thread.currentThread().join()
Putting this anywhere a property declaration is valid will deadlock whoever is initializing it. In the case of a top-level property, that will be the classloader initializing the mapped JVM class for that file (by default [file name]Kt.class).
Non-competing because "put this as a top level property anywhere" is restrictive.

Function: 37 bytes
fun a()=Thread.currentThread().join()

main(): 55 bytes
fun main(a:Array<String>)=Thread.currentThread().join()

The Waterfall Model (Ratiofall), 13 bytes
[[2,1],[1,1]]

Try it online!
Here's a fun off-the-wall answer. This is the simplest possible infinite loop in The Waterfall Model (variables in The Waterfall Model repeatedly decrement whenever nothing else is happening; this program defines a variable that increments itself whenever it decrements, so there's no way anything can ever happen).
The question asks for a deadlock, not an infinite loop. However, we can exploit the behaviour of specific implementations. At optimisation level 2 or higher (the default is 3), the interpreter Ratiofall will detect the infinite loop, and optimise it… into a deadlock! So at least if we consider languages to be defined by their implementation (which is usually the case on this site), this program does indeed define a deadlock, rather than an infinite loop.
You can see evidence of the deadlock from the time report on the Try it Online! link above:
Real time: 60.004 s
User time: 0.006 s
Sys. time: 0.003 s
CPU share: 0.01 %
Exit code: 124

The program ran for 60 seconds (until TIO automatically terminated it), but for most of that time, there was no CPU usage, no time spent by the program running, and no time spent by the kernel on behalf of the program.
To get even stronger evidence, you can run Ratiofall under a system-call-level debugger such as strace; doing this on Linux will show the interpreter blocking on a futex system call that attempts to take a lock which will never be released.

C (Linux only), 31 Bytes -- Try it online!
main(a){syscall(240,&a,0,a,0);}

System call 240 (0xf0) is futex(2), or fast userspace mutex. The documentation states that the first argument
is a pointer to the futex, the second argument is the operation (0 means FUTEX_WAIT, that is, wait until another thread unlocks the futex). The third argument is the value you expect the futex to have while still locked, and the fourth is the pointer to the timeout (NULL for no timeout).
Obviously, since there's no other thread to unlock the futex, it will wait forever in self-inflicted deadlock. It can be verified (via top or other task manager) that the process uses no CPU time, as we should expect from a deadlocked thread.

BotEngine, 3x3=9 (9 bytes)
v
lCv
> <

Step 5 ends with two bots waiting indefinitely for each other to move... one bot can't move because it's waiting for the other to move out of the bottom right square, and the other bot can't move because it's waiting for the first bot to move out of the bottom center square.

Julia 0.6, 13 bytes
Language newer than question. Wait on a task (like a go-routine, will currently be on the same thread, in future versions of Julia it may be on another thread) which is not scheduled to run.
wait(@task +)

Try it online!

Perl 6, 24 bytes
Semaphore.new(0).acquire

Try it online!
Create a semaphore with zero permits and then try to acquire it.

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:
Inherit from class with inaccessible abstract members and all constructors inaccessible
The class System.Globalization.EastAsianLunisolarCalendar of the mscorlib.dll assembly is non-nested public but its sole instance constructor is internal and it also declares some internal abstract members.
The problem: Write a C# class in your own assembly (code must compile with usual C# compiler) where a class derives from (inherits) the System.Globalization.EastAsianLunisolarCalendar of the BCL.
Your class must have System.Globalization.EastAsianLunisolarCalendar as its direct base class. It is not allowed to have a third class in "between" your class and that class in the inheritance hierarchy.
(Advanced stuff like dynamic assemblies or runtime IL emission is not needed.)
(Stated as a C# problem. Discussions on whether the equivalent problem can be solved in other object-oriented languages too, will also be considered interesting.)
It is not required that the class you write is usable in any way ;-)

Did not have enough reputation to create tags encapsulation, inheritance, access-level.

You should come up with an objective winning criteria and post as a code challenge

@Cruncher Put in code-challenge category. Not sure about winning criterion but I guess the first post to give a valid solution wins.

-1: no objective winning criterion and changed question fundamentally after a valid answer was given.

Looks like "first valid answer wins".

So basically you need this, have no idea how to do it, and hid it as a code golf so we'd do it for you ? :)

@ArlaudPierre No. It is not useful and I didn't need it. I already had the specific solution Kuhn gave, in mind.

@JeppeStigNielsen just teasing :P

Well, I have either to call a base constructor (which is not accessible) or an other constructor in the same class.
public abstract class Class1 : System.Globalization.EastAsianLunisolarCalendar {
    private Class1() : this(1) {}
    private Class1(int i) : this() {}
}

So let's call the constructors recursive. Not very useful, but who cares?

Yes, this was the answer I had in mind. Too bad my original phrasing didn't exclude w0lf's solution, as he was first. I still award the "accepted" check mark to this answer.

Afaik, you could even intercept the instance with a destructor...

Will the instance ever be eligible for garbage collection? Do you terminate the thread running in an infinite loop (jumping between the two constructors)? Possibly another way to get an instance is System.Runtime.Serialization.FormatterServices.GetUninitializedObject(typeof(Class1)).

http://codeblog.jonskeet.uk/2014/10/23/violating-the-smart-enum-pattern-in-c/

Interesting post. If this cyclic constructor chain hack was new to Jon Skeet, he should have been reading more of your answers at Programming Puzzles & Code Golf Stack Exchange ;-)

Under the new Roslyn-based compiler (Visual C# 6) it does not appear to be allowed to have a cyclic : this(...) chain of constructors like this.

One way to do it is to inherit a subclass of System.Globalization.EastAsianLunisolarCalendar:
public class MySubclass : System.Globalization.JapaneseLunisolarCalendar
{
    public static void Test()
    {
        var instance = new MySubclass();

        Console.WriteLine(instance is System.Globalization.EastAsianLunisolarCalendar);
        // this prints "True"
    }
}

Damn, will have to upvote this because my problem text didn't exclude this solution. However, the intention was to require EastAsianLunisolarCalendar to be the direct base class. Will update question. Sorry I won't award this question a winner.

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


text:
Decompose a range in aligned blocks of size 2^n
Given an arbitrary contiguous range of positive integers, find the decomposition in the minimum number of sub-ranges of size L = 2^n, with the constraint that each range must be aligned, that is the first integer i in the sub-range must satisfy i = 0 (mod L).
Background: some (especially old) netblocks aren't a simple single CIDR, that is a range in the form 192.0.2.0/24, but are a composition of several contiguous blocks, and the whois query returns explicitly the first and last ip in the block. Try yourself with whois 220.72.0.0:
[...]
IPv4 Address       : 220.72.0.0 - 220.91.255.255 (/12+/14)
[...]

Solving this problem means finding the list of valid CIDR blocks that summed up constitute this range.

Are you using ^ in the exponential sense or the exclusive-or sense?

This post as it is now does not fit the description of the  programming puzzle tag at all. I think this would be better for code golf, but you need to provide some clearly defined test cases with input and expected output.

The following greedy algorithm works optimally:

Choose the larges block allowed which is aligned with the lower bound
  and does not exceed the total range. Add this range to your result set
  and remove it from the search space. Loop until the entire range is
  covered.

In the following lines I took your example and simplified it to the interesting part, i.e. take the range 72-91:
0)  Range: 72 - 91 (Size 20)

1a) Largest block size allowed @72: 8
1b) Subrange #1: 72 - 79
1c) Remaining: 80 - 91 (Size 12)

2a) Largest  block size allowed @80: 16 (exceeds size) -> 8
2b) Subrange #2: 80 - 87
2c) Remaining: 88 - 91 (Size 4)

3a) Largest  block size allowed @88: 8 (exceeds size) -> 4
3b) Subrange #3: 88 - 91
3c) Remaining: empty

Result: (72-79) (80-87) (88-91)

The structure can be seen even better, if we express the numbers in binary format.
0)  Range: 01001000, Size 10100

1a) Largest block size allowed @01001000: 1000
1b) Subrange #1: 01001000, Size 1000
1c) Remaining: 01010000, Size 1100

2a) Largest block size allowed @01010000: 10000 (exceeds size) -> 1000
2b) Subrange #2: 01010000, Size 1000
2c) Remaining: 01011000, Size 100

3a) Largest  block size allowed @01011000: 1000 (exceeds size) -> 100
3b) Subrange #3: 01011000, Size 100
3c) Remaining: empty

A note for implementation: the block size for the subrange to be chosen corresponds either to the rightmost 1 bit of the lower bound or the leftmost 1 bit of the size of the range (whichever is smaller).


text:
Triforce ReBoot
Seeing how hello world has backfired terribly, here is a harder one.
I love Zelda and I love ReBoot.
Create the following

Requirements:
It must be a window (can be ANY window even browsers and such).
The window can be of any size.
Window may not contain anything else except the picture.
Window should not close itself right away.
Triangles must be any shade of blue.
Circle must be any shade of green.
Smaller triangle must touch edges of the
No stealing images by providing links.
Condition: Shortest code wins.
PS: Yes ReBoot logo is slightly different but this is close enough to make it fun.
EDIT: I added another requirement. It seems like we have a lot of very genius people who enjoy finding loopholes :P I love you guys.

"Triangles must be any shade of yellow." Picture conflicts?

@Timtech I am sorry, text got underlined as orange due to misspelling and I thought orange while wanting to write blue.

Okay, at least it's fixed now. And I'm even trying to get shorter comments - too much code golfing...

Do I get bonus points if the image fills the screen, and continues to as I resize the screen? (You have to allow the circle to be an oval then)

Actually reading the requirements again, what's stop someone from just creating the image in paint, and making a program read the image? This would only be a couple of lines in python. Perhaps you should write a rule against that

And as I wrote my above comment, somebody did just that with imgur and html. (they actually just stole your image)

I made it draw it all out with GML! Only 167 characters!

@Cruncher I added the requirement. I always find it very amusing how no matter what I do there is always a loophole.

@Timtech your solution is pure genius :) I love it.

@Quillion Thanks! It's probably my best answer so far.

Wow, only 155 characters now :D

@Quillion I'm not sure if I've mentioned this to you before, but you might want to test out your questions in the current Sandbox thread in Meta before you post them. That could help shake out any unintentional loopholes first.

@Iszi ok will do from now on. Should I post all of them there first or the ones I am unsure about? This one didn't backfire right?

@Quillion Any time you feel compelled to change the rules of a challenge after it has been posted, especially in reaction to answers already submitted, it's not a good thing. I wouldn't say this one totally back-fired, but it didn't go without needing fixing, either.

Mathematica 118 119 118 107 97
Edit: Shortened to 107 chars with help from Belisarius and to 97 with alephalpha.
CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}}, Green,
{2,1}~Circle~1}]

I was scared you had beat me :3 But that circle's gotta be green!

It's green now. Thanks for noting.

Augh! I've been beat! Good job :)

In 107: p=Polygon;a={1,1};b={2,0};CreateDialog[Graphics@{Blue,p@{0a,2b,2a},White,p@{a,b+a,b},Green,{2,1}~Circle~1}]

Nice streamlining.

CreateDialog[Graphics@{Blue,Polygon@Outer[Plus,#,#,1]&@{{0,0},{1,1},{2,0}},Green,{2,1}~Circle~1}]

Very clever! I tried skipping the white triangle but wasn't able to shave off so much as you.

Damnit! Here I thought I had you beat.

I got a little help from my friends.

Dyalog APL (121 116 115)
(Edit: use triangles 8 elements wide instead of 10, to shorten code a bit)
(Edit 2: I was only ever using M¨, so included the ¨ in the definition of M)
M←{' ',⍵,⍺,⍨4/0}¨⋄⎕SM←↑(256M⊃,/(⊂8 0)(⊂8 32)(⊂0 16)∘.+⊂(,⍳⍴Z)/⍨≤/¨,Z←⊖Z,⌽Z←2/⍳2/8),512M⌈0 16∘+¨1 2∘×¨8+8×1 2∘○¨⍳1e4

Graphics? Who needs graphics?
(Also, black is the default background, you didn't say to change it)

Shell script: 166 163 characters
f=-fill
d=-draw
convert -size 64x32 xc: $f blue $d 'polygon 32,0 0,32 64,32' $f white $d 'polygon 32,32 16,16 48,16' $f none -stroke lime $d 'circle 32,16 32,0' x:

Sample output:

this is more of imagemagick than shell

@mniip, right. But as ImageMagick is primarily a library. If this was a PHP script using IMagick, the post heading would say PHP, not ImageMagick. Well, according to my logic. I am not against any heading improvement. But anyway, 2 of the 3 characters shortening since the first version are on shell side. :)

R, 124, 122, 111
frame()
p=polygon
p(c(1,3,5)/5,c(1,3,1)/5,c=4)
p(c(2,4,3)/5,c(2,2,1)/5,c="white")
symbols(.6,.4,.1,i=1,a=T,f=3)

This produces the following picture in a plot window:

I think you can save one character by writing p=polygon, then p(c(1,3,5 etc. (BTW, on my system, the circle size  scales differently than the triangles when the window is resized, and I have to play with it a bit to get the circle to intersect the corners of the "square".)

@r.e.s. Thanks for the tip. The size of the circle is the major drawback of this solution. I wasn't able to figure out a short code to solve this problem.

@plannapus Great idea, thanks! This saved 11 characters.

Java, 434 358 349
import java.awt.*;
public class T
{
    public static void main(String[] a)
    {
        new Frame()
        {
            public void paint(Graphics g)
            {
                g.setColor(Color.BLUE);
                Polygon p=new Polygon(new int[]{50, 75, 100},new int[]{75, 50, 75},3);
                g.fillPolygon(p);
                p.translate(-25, 25);
                g.fillPolygon(p);
                p.translate(50, 0);
                g.fillPolygon(p);
                g.setColor(Color.green);
                g.drawOval(50, 50, 50, 50);
            }
        }.show();
    }
}

golfed
import java.awt.*;public class T{public static void main(String[] a){new Frame(){public void paint(Graphics g){g.setColor(Color.BLUE);Polygon p=new Polygon(new int[]{50,75,100},new int[]{75,50,75},3);g.fillPolygon(p);p.translate(-25,25);g.fillPolygon(p);p.translate(50,0);g.fillPolygon(p);g.setColor(Color.green);g.drawOval(50,50,50,50);}}.show();}}

Who knew golfing reduces code so much.
EDIT: Thanks manatwork for all your suggestions.

Please golf your code.

You still have useless spaces after parameter separator commas. And please use code block instead of inline code markup, so scripts like Code Golf UserScript Enhancement Pack can recognize it as code  and displays its size.

Game Maker Language, 167 165 155
EDIT 1 - I shaved off two characters by replacing c_green with 32768, the same value. The other color's values were longer than their predefined names.
EDIT 2 - Epic golf! Used variables for frequently used values, and forgot that newlines aren't needed (newlines count as two spaces).
The room (r) is predefined 64 by 32 with a white background. Object d is anywhere in room r. Draw Event code:
a=16b=32draw_set_color(c_blue)draw_triangle(0,b,64,b,b,0,0)draw_set_color(32768)draw_circle(b,a,a,1)draw_set_color(c_white)draw_triangle(a,a,48,a,b,b,0)

Result:

Ti84-Basic - 54 characters (but output is black and white)
:Line(0,0,2,0
:Line(0,0,1,1
:Line(2,0,1,1
:Circle(1,.5,.5

No pictures used!

Does the figure appear in its own window?

@DavidCarraher Yes. I used in-game screen capture, so the window doesn't show up.

You used draw_set_color three times. Can't you save characters by something like d=draw_set_character?

@DavidCarraher I tried that already; it doesn't work :( GML gets kind of stubborn sometimes.

HTML, 101

There's a new requirement - "No stealing images by providing links."

I bet you could beat that with a simple:  http://someshort.url (... and that this would create another requirement as well)

HTML+CSS, 352 290 261 257

http://jsfiddle.net/WF3hP/6/
Ungolfed:

Instead of setting border-left and border-right separately, better set border then reduce the unneeded one like border-top:0: http://jsfiddle.net/WF3hP/2/

Yes, I'd recommend that too. It will make your code shorter.

@manatwork, even that can be improved with border-bottom-color instead of border-bottom on the first div and similarly border-top-color on the second div. And using 1em instead of 25px and 2em instead of 50px changes the size but saves a few characters.

Thanks, @manatwork & Pete Taylor. I tried using em instead of px, but it's hard to get the circle centred if its border has to be 1px wide.

Do the id's really have to be that long?

The id's are only in the ungolfed version, for clarity. In the golfed version, I'm using inline styles.

R, 108 characters
Very similar to Sven Hohenstein solution but differs in two interesting points, so I thought I would add it:
frame()
p=polygon
p(c(0:3,1:4)/5,c(0:1,0:1,1:2,1:0)/5,c=4)
t=seq(0,2*pi,.1)
p(.2*cos(t)+.4,.2*sin(t)+.2,b=3)

Instead of drawing a large blue triangle and a small white one, I draw a polygon representing already the three triangles. As for the circle, this one (whose code is clearly longer than Sven's) doesn't lose its contacts with the triangles on resize.
Finally instead of using the color names I used their number in R's default color palette (4 for blue and 3 for green).

JavaScript (canvas, Firefox), 237 231 characters
<canvas id=a>

I couldn't find any hard requirements on the dimensions, so I decided to abuse that a bit and go with 8×4 pixels to cut down code size... also, relies on the Mozilla extension mozFillRule to get even-odd filling for the triforce.
jsbin (small), jsbin (bigger)

SVG 305 296
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="1 3 9 10">
<path d="M 5,4 2.5,7 7.5,7 5,4 z M 7.5,7 5,10 10,10 7.5,7 z M 5,10 2.5,7 0,10 5,10 z"
fill="#00f" /><path d="m 7.5,7 a 2.5,3 0 0 1 -5,0 2.5,3 0 1 1 5,0 z"
fill="none" stroke="#0f0" stroke-width="0.02" /></svg>

Instead of style="fill:#00f", you can use fill="#00f", I think. Same for the other styles.

@minitech: I must be able to save 5 more bytes in shifting this drawing up by 1: having vertical plan from 2 to 9 instead of 3 to 10...

Sage (CLI), 111 106
p=polygon;circle((2,1),1,color=(0,1,0))+p([(0,0),(2,2),(4,0)])+p([(1,1),(3,1),(2,0)],axes=0,color=(1,1,1))

 This is via the Sage command line interface. (This works also in a Sage Notebook, but although the image appears in its own cell, that probably doesn't qualify as a "window".)
EDIT: Eliminated 5 minus signs and replaced the screenshot of a Sage Notebook cell with one of a Sage CLI window. (Credit @boothby)

If you call .show() on a graphics object from the CLI, it will pop up a window.  Also you can save a few characters by shifting everything (+2,+1).

@boothby - Thanks for the idea to get rid of the minus signs. About the window, it turns out that running the program as-is (without .show()) produces the desired window from the Sage CLI. (Neither this nor the .show() version works when I run Sage under Linux in a virtual machine (Win7/VirtualBox). Works fine when I boot up Ubuntu and run Sage that way.) Thanks for the nudge to try the CLI.

HTML 118
<svg><path fill=#00f d="M0,2 2,0 4,2 2,2 3,1 1,1 2,2z"/><circle fill=none stroke-width=.1 stroke=#0f0 cx=2 cy=1 r=1 />

Golf-Basic 84, 36 characters (Output is Black and White)
l;0,0,2,0l;0,0,1,1l;2,0,1,1c;1,.5,.5


text:
Even or odd: three player
It's a three players game, play with one hand.
At same time, each player show his hand with 0 to 5 fingers extended.
If all player show same kind of (even or odd) number, there is no winner. But else, the player showing different kind the two other win.
 P l a y e r s
A      B      C       Winner

Even   Even   Even    No winner
Odd    Odd    Odd     No winner
Even   Odd    Odd     Player A
Odd    Even   Even    Player A
Even   Odd    Even    Player B
Odd    Even   Odd     Player B
Odd    Odd    Even    Player C
Even   Even   Odd     Player C

The requested tool could use arguments (3 arguments as numeric between 0 and 5) or STDIN (3 values by line, separated by spaces).
There is no need to check input: Irregular input could produce unexpected output.
Arguments or values on line is given from left to right, from player A to player C.
Output must only contain A, B or C (capitalized) or the string no one (in lower case, with a regular space).
Tool may work only once or as a filter on all input lines.
Shortest code win.

Might be more interesting as a [king-of-the-hill]. Play the game.

I wonder how the fact we have 5 fingers (so there are 3 odd and 2 even numbers of fingers possible) affects the winning strategy...

@OlivierDulac, 0 is also an even number.

In this game rule yes, this let same chances for even than for odd numbers (0 2 4 vs 1 3 5)

@PeterTaylor: thanks, I misread the question (and I didn't think it would count).

APL (34 30)
(1⍳⍨+/∘.=⍨2|⎕)⊃'ABC',⊂'no one'

Explanation:

2|⎕: read a line of input, take the mod-2 of each number (giving a list, i.e. 1 0 1)
∘.=⍨: compare each element in the vector to each element in the vector, giving a matrix
+/: sum the rows of the matrix, giving for each element how many elements it was equal to. If there were two the same and one different, we now have a vector like 2 1 2 where the 1 denotes who was different. If they were all the same, we get 3 3 3.
1⍳⍨: find the position of the 1. If there is no 1, this returns one more than the length of the vector, in this case 4.
⊃'ABC',⊂'no one': display the string at the given index.

Nice, good use of array-oriented programming to compute the index.

Mathematica, 45 43 42 41 chars
f="no one"[A,B,C]〚Mod[Tr@#-#,2].{2,1,0}〛&

Example:
f[{0 ,0, 0}]

no one

f[{1, 3, 5}]

no one

f[{2, 3, 5}]

A

f[{2, 3, 4}]

B

Another solution with 43 42 chars:
f=Mod[Tr@#-#-1,2].{A,B,C}/._+__->"no one"&

Powershell, 65
param($a,$b,$c)"@ABCCBA@"[$a%2+$b%2*2+$c%2*4]-replace"@","no one"

Thanks. This gave me an idea on shortening my Rock, Paper, Scissors script!

Befunge-98, 61 50 45 characters
&&&:11p+2%2*\11g+2%+:"@"+#@\#,_0"eno on">:#,_

Uses Fors' clever expression to shave off yet a few more characters. Now single-line (i.e. Unefunge-compatible)!  Reads until a game is won; add @ at the end for a one-shot program.
Treats input mod 2 as a binary number, as with my JS answer, then relies on lookup for A-C and falls back to 'no one' if out-of-bounds (by testing if the character is ≥'A', which allows me to use nearby code as data :D).
Variation that reads a line of input, produces output, reads a new line of input, etc until a game is decided (i.e. not 'no one'):
&2%4*&2%2*&2%++1g:" "#@-#,_0"eno on">:#,_
 CBAABC

I ported this to fish for my answer. I noted you. +1 btw

C: 88 characters
Unfortunately C, as always, requires quite a lot of unnecessary junk. But still, in which other language can one write =**++b+**(++ and it actually means something? Quite simply sublime.
main(int a,char**b){(a=**++b+**(++b+1)&1|2*(**b+**++b&1))?putchar(a+64):puts("no one");}

Simply pass three numbers as arguments, and voilà!

Is the precise order of those preincrements specified? I thought it wasn't... although, you could replace them with *b[1] etc for no size difference (though some loss in elegance.. :( )

In Ruby: s = "=**++b+**(++" :P in all seriousness, wow, how does that... how does that even work? :O

@Doorknob it's very clever, but if you substitute the dereferencing and preincrements with indexing b instead, and pretty-print the condition some, you should be able to figure it out. :D (pen and paper also helps, for the resulting truth table)

APL, 30
(1+2=/2|⎕)⊃'BA'('C',⊂'no one')

If I am allowed to change system variables by configuration, 2 chars can be shaved off. (Specifically, changing index origin ⎕IO to 0)
The crucial bit
If we represent all odds the same way and all evens the same way, then a pair-wise equality operation can distinguish all 4 cases: 0 0 for B wins, 0 1 for A wins, etc.
Explanation
2|⎕ Takes input and mod 2
2=/ Pair-wise equality
1+ Add 1 for indexing (APL arrays are 1-based by default)
'BA'('C',⊂'no one') Nested array
⊃ Picks out the correct element from the nested array

Ruby, 61 chars
w=0
$*.map{|p|w+=w+p.to_i%2}
$><<%w(no\ one C B A)[w>3?w^7:w]

['no one',?C,?B,?A] == %w(no\ one C B A) (2 chars saved).

Nice. Applied that. Thx!

GolfScript (31 chars)
~]{1&}%.$1=!?)'no one
A
B
C'n/=

Very simple logic: reduce the input modulo 2, then sort a copy. The middle item of the sorted array is in the majority, so look for an index which is different (and hence in the minority).

Ruby (function body), 42 chars
Assuming 3 numerical arguments a, b, and c:
['zCBAABCz'[a%2*4|b%2*2|c%2],'no one'].min

Ruby (command line tool), 61 chars
Version 1 comes in at 62 chars:
$><<["zCBAABCz"[$*.reduce(0){|i,n|i*2|n.to_i%2}],'no one'].min

But, by piggybacking off of Darren Stone's answer, Version 2 gets down to 61 chars:
i=0;$*.map{|n|i+=i+n.to_i%2};$><<['zCBAABCz'[i],'no one'].min

Python 2, 54
f=lambda a,b,c:[['no one','C'],'BA'][(a^b)&1][(a^c)&1]

JavaScript (node), 87 characters
p=process.argv;console.log("ABC"[3-Math.min(x=p[2]%2*4+p[3]%2*2+p[4]%2,7-x)]||"no one")

To get the ball rolling... expects input as three extra arguments.  Makes use of the following pattern for input/output (/ represents "no-one"):
  A B C  res  #
 ───────────────
  0 0 0   /   0
  0 0 1   C   1
  0 1 0   B   2
  0 1 1   A   3
  1 0 0   A   4
  1 0 1   B   5
  1 1 0   C   6
  1 1 1   /   7

Perl, 84 characters.
$x=oct"0b".join"",map{$_%2}<>=~/(\d)/g;print"",('no one','C','B','A')[$x>=4?7-$x:$x]

<>=~/(\d)/g parses the input line into distinct digits
map{$_%2 takes this list and computes value mod 2 (even or odd)
oct"0b".join"", takes this list of mod values, joins them into a string, appends an octal specifier, and converts the string to a number.

Basically what I did was to create a truth table, and then carefully reordered it so I had an inversion operation around $x == 4.  So if $x >=4, we did the inversion [$x>=4?7-$x:$x] which we used to index into the array ('no one','C','B','A')
Its not the shortest possible code, but its actually not line noise ... which is remarkable in and of itself.
Perl: 74 characters + 3 flags = 77, run with perl -anE '(code)'
s/(\d)\s*/$1%2/eg;$x=oct"0b".$_;say"",("no one","C","B","A")[$x>3?7-$x:$x]

This is an improvement, by leveraging autosplit (the -a), say (the -E), and finally figuring out what was wrong with the comparison.

Why >=4 instead of simply >3? +1 for the tips '0b'. I didn't know before

I tried both in the debugger ( >3 and >=4), and I am not sure why, but the >=4 worked, but >3 did not.  I can't explain it (possibly borked debugger?) to my own satisfaction either

you seem to have had an extra char in both counts, which I fixed. Also, flags count as characters.

GolfScript, 36 35 33 characters
~]0\{1&\.++}/'no one
C
B
A'n/.$+=

Takes input as described from STDIN. You can also test the code online.

Haskell, 97
main=interact$(["no one","A","B","C"]!!).(\x->min x$7-x).foldr(\y x->x*2+mod y 2)0.map read.words

Common Lisp, 114 106 70 chars
From the three values create a pair representing difference in parity between adjacent elements. Treat that as a binary number to index into result list.
(defun f(a b c)(elt'(no_one c a b)(+(mod(- b c)2)(*(mod(- a b)2)2)))))

Older algorithm:
(defun f(h)(let*((o(mapcar #'oddp h))(p(position 1(mapcar(lambda(x)(count x o))o))))(if p(elt'(a b c)p)"no one")))

Mathematica 100 94 89
f=If[(t=Tally[b=Boole@OddQ@#][[-1,2]])==1,{"A","B","C"}[[Position[b,t][[-1,1]]]],"no one"]&

Testing
f[{5, 3, 1}]
f[{2, 0, 4}]
f[{0, 1, 2}]
f[{0, 1, 3}]
f[{1, 3, 0}]

"no one"
"no one"
"B"
"A"
"C"

R 67
z="no one";c("A","B","C",z,z)[match(2-sum(x<-scan()%%2),c(x,2,-1))]

Interesting! How could I test this? What do I have to run (maybe a shebang?)

You'll need to start an interactive R session (e.g. /usr/bin/R) then enter the code above. scan() is what will prompt you for the input: an example would be to type 1[space]3[space]5[space][enter][enter] and you will see the corresponding output (here, no one) printed to the screen. You can download R here: http://cran.r-project.org/mirrors.html

C, 85 chars
main(int j,char**p){puts("C\0A\0B\0no one"+((**++p&1)*2+(**++p&1)^(**++p&1?0:3))*2);}

Not as short as my Ruby answer but I'm happy with it, considering the main cruft.

Fish - 41
:&+2%2*$&+2%+:"@"+!;$!o :?#"eno on"!;ooo<

Stole FireFly's befunge answer and ported it to fish because using registers in fish allows us to shave off some characters. Lost a few characters on not having the horizontal if operator though.
This takes parameters in through arguments.
python fish.py evenodd.fish -v 2 2 2
no one
python fish.py evenodd.fish -v 2 3 2
B
python fish.py evenodd.fish -v 2 3 3
A
python fish.py evenodd.fish -v 3 3 4
C

Ooooooooooo nice!

Hm, fish huh. Do you have trampoline? if so, maybe you could use (the equivalent of) #@...< at the end to save a char. Oh, and your current code looks like 42 chars to me, so decrement that char-count of yours. :)

@FireFly thanks! That did save a char, and you're right, I was over counted by one. My text editor said "col 43" at the end. But of course, cursor on an empty line says "col 1".

Smalltalk, 128 characters
[:c|o:=c collect:[:e|e odd].k:=o collect:[:e|o occurrencesOf:e].u:=k indexOf:1.^(u>0)ifTrue:[#($a $b $c)at:u]ifFalse:['no one']]

send value: with a collection

C 101 96
C, probably the most trivial example (some ternary operations):
main(int v,char** c){(v=c[1]==c[2]?c[1]==c[3]?0:3:c[1]==c[3]?2:1)?puts("no one"):putchar(v+64);}

JavaScript (ES6) / CoffeeScript, 50 bytes
Uses the truth table as per Firefly's answer but takes a more direct approach in character access:
f=(a,b,c)=>'CBAABC'[(a%2*4+b%2*2+c%2)-1]||'no one' // JavaScript

f=(a,b,c)->'CBAABC'[(a%2*4+b%2*2+c%2)-1]||'no one'  # CoffeeScript

Demo

// Translated into ES5 for browser compatibility
f=function(a,b,c){return'CBAABC'[(a%2*4+b%2*2+c%2)-1]||'no one'}

//f=(a,b,c)=>'CBAABC'[(a%2*4+b%2*2+c%2)-1]||'no one'

for(i=6;i--;)
  for(j=6;j--;)
    for(k=6;k--;)
      O.innerHTML += i + ', ' + j + ', ' + k + ' => ' + f(i,j,k) + "\n"

Vyxal 3, 18 bytes
eB"0CBA"ṁi0"5FZᵃ”r

Try it Online!
-11 bytes thanks to @Aaroneous MIller
Explanation (Outdated):
euL1=["5FZᵃ”|:1Cv[0Ḟ|1Ḟ}kAi
e                            ## Calculate every element of list if it's even
 uL1=                        ## Contains only even or odd integers?
     ["5FZᵃ”                 ## If so, print "no one"
            |                ## else
             :               ## duplicate
              1C             ## how many even integers the list has
                v            ## decremented
                 [0Ḟ         ## If the number of the even integers is 1, find 0
                    |1Ḟ}     ## if not, find 1
                        kA   ## uppercase alphabet
                          i  ## index

Created with the help of Luminespire.

Try it Online! for 20 bytes (the header is just to set up some test cases)

Actually, make that 18 bytes

@AaroneousMiller Done!

Perl 5 -p, 49 bytes
$_=(0,C,B,A,A..C)[oct"0b".s/./$&%2/ger]||"no one"

Try it online!
Takes input as three digits with no spaces between.

Game Maker Language, 116
My new answer relies heavily on FireFly's formula:
a[1]="no one"a[2]='A'a[3]='B'a[4]='C'return a[(3-min(b=argument0 mod 2*4+argument1 mod 2*2+argument2 mod 2,7-b)||1)]

The old code compiled with uninitialized variables as 0, 183 characters:
a=argument0 mod 2b=argument1 mod 2c=argument2 mod 2if((a&&b&&c)||(!a&&!b&&!c))return "no one" else{if((a&&b)||(!a&&!b))return "C" else{if((a&&c)||(!a&&!c))return "B" else return "A"}}

Edit #1 - Whole different code

Interesting!? I didn't know this language before! But as this language does permit the use of array, this code seem not to be the smallest possible for this job.

@F.Hauri Yes, I'm trying to use arrays to get it shorter.

Python 3, 115
l=[int(x)%2for x in input().split()];0if[print("ABC"[i])for i,x in enumerate(l)if l.count(x)%2]else print("no one")

Two different method in two different languages + variations -> 6 answers
There are essentially 2 way for this operation:

array based: Built a binary number of 3 digit, than take answer from an array
count based: Count even and odd, and look if there is a count == 1

Perl 71 (array based + variation)
s/(.)\s*/$1&1/eg;$==oct"0b".$_;$==$=>3?7-$=:$=;say$=?chr 68-$=:"no one"

One of my shortest perl:

s/(.)\s*/$1&1/eg; transform a string like 1 2 3 into 101
$==oct"0b".$_; transform binary to oct (same as dec, under 8)
$==$=>3?7-$=:$=; if > 3 oper 7-. (From there no one == 0)
say$=?chr 68-$=:"no one" if not 0, print char from value, else print no one.

Perl 71 (array based)
s/(.)\s*/$1&1/eg;$==oct"0b".$_;say@{["no one",qw{A B C}]}[$=>3?7-$=:$=]

slightly different in the print step: The output is based on an 'array'.
Perl 81 (count based)
$c=A;map{$a[$_%2]=$c++;$b[$_%2]++}split;say$b[0]==1?$a[0]:$b[0]==2?$a[1]:"no one"

Different meaning:

$c=A   Initialise a counter c with A.
map{$a[$_%2]=$c++;$b[$_%2]++}split Counter b count even and odd, a only store which one
say$b[0]==1?$a[0]:  if even counter == 1 ? also print even player.
$b[0]==2?$a[1]: if even counter == 2 ? also print odd player.
:"no one" else print no one.

Bash 85 (array based)
c=$((($1%2)<<2|($2&1)*2+($3%2)));((c>3))&&c=$((7-c));o=("no one" C B A);echo ${o[c]}

This is based on my second perl version:

c=$((($1%2)<<2|($2&1)*2+($3%2))) make the index pos.

$1%2 transform first arg in binary by using mod
$2&1 transform second arg in binary by using and
<<2 shift-to-the-left is same than *4
*2 multiply by 2 is same than <<1.

((c>3))&&c=$((7-c)) if c >= 4 then c = 7-c.
o=() declare an array
echo ${o[c]} based on array

Bash 133 (count based)
a[$1&1]=A;a[$2&1]=B;a[$3&1]=C;((b[$1&1]++));((b[$2&1]++));((b[$3&1]++))
case $b in 1)echo ${a[0]};;2)echo ${a[1]};;*)echo no one;esac

a[$1&1]=A;a[$2&1]=B;a[$3&1]=C store player into variable a[even] and a[odd]
((b[$1&1]++));((b[$2&1]++));((b[$3&1]++)) count even/odd into b.
case $b in 1) echo ${a[0]} in case even counter==1 print even player
2)echo ${a[1]};; case even counter==2 print odd player
*)echo no one;esac else print no one.

Bash 133 (count based)
a[$1&1]=A;a[$2&1]=B;a[$3&1]=C;((b[$1&1]++));((b[$2&1]++));((b[$3&1]++))
((b==1))&&echo ${a[0]}||(((b==2))&&echo ${a[1]}||echo no one)

Same version, using bash's condition and command group instead of case ... esac

Python 3, 114
r=[0,3,2,1,1,2,3,0][int("".join(map(str,(int(x)%2for x in input().split()))),2)];print("ABC"[r-1]if r else"no one")

Python 3, 80 chars
r=int(input().replace(' ',''),2)
print(['no one','C','B','A'][7-r if r>3 else r])

Note: input must be '1' [odd] or '0' [even]. For example:
> 1 1 0
C
> 1 1 1
no one

The challenge requires the input to be "separated by spaces". Perhaps there is a way to effectively golf a split and join so you can still use your (very smart) int(...input...) idea.  ?

You could remove the '0b'+ I think, at least it looks redundant to me, and just int(input(),2) seems to work in a REPL.

@DarrenStone I used a string replace instead, see edit

@FireFly Thanks, you're right, I edited my answer. I first tested the code with Python 2, where the '0b' was needed.

The challenge also requires the input to accept numbers from 0 to 5.

Clojure, 116
(fn[& h](let[a(map #(bit-and % 1)h)](["no one"\A\B\C](+(.indexOf(map(fn[x](reduce +(map #(if(= x %)1 0)a)))a)1)1))))

vba, 116
Function z(q,r,s)
a="A":b="B":c="C":d="no one"
z=Array(d,c,b,a,a,b,c,d)((q And 1)*4+(r And 1)*2+(s And 1))
End Function

call with ?z(1,2,3) or assign to a variable with q=z(1,2,3), or even use as a UDF within excel, and use =z(1,2,3) in your excel formula

Java, 226 chars
void func(int a, int b, int c){
    a = a%2;
    b = b%2;
    c = c%2;
    String out = "B";
    if((a+b+c)==0 || (a+b+c)==3)
        out = "no one";
    else if(a==b)
        out = "C";
    else if(b==c)
        out = "A";
    System.out.println(out);
}


text:
Optimizing my spell casts!
I'm a young wizard, and I try very hard to not waste mana during my magical encounters.
I have X spells available at any given time and each one of them have its own mana cost Y.
X,Y being positive integers strictly lower than 11.
As a beginner, my mana pool fluctuates a lot (it is always lower than 11), and I need help to cast as few spells as possibles (scrolls are expensive, ya know) while emptying my mana pool. If you can't find any spell combination which matches exactly my mana pool's size, you shall then offer me closest (and cheaper) one.
I came to you and your infinite wisdom to help me become the greatest dark wizard. I shall not be disappointed.
INPUT style (because style is everything):
Y;a b c d e f
Y is the size of the mana pool. (a,b,c,d,e,f) are the spells. There are 6 spells, first one costs 'a' mana, second spell costs 'b' mana, etc.
INPUT :  4;1 2 3 3 7 6
I have 4 manas available, and 6 spells available. Two spells cost 1 mana, 1 spell costs 2 mana, two spells cost 3 mana, etc.
OUTPUT : (3,1)

INPUT : 3;1 3 5 2 10
OUTPUT : (3)

INPUT : 8 ; 4 1 9
OUTPUT : (4,1)

INPUT :  4;1 2 2 3
OUTPUT : (2,2),(1,3)
You shall output every combination of spells, but there is no need to distinct spells which are the same cost.
The shortest incantation to whatever machine you desire will be granted a profusion of thanks, and a whip of destiny.

I think I miss the point or maybe I just don't understand your examples: first example: I find 7 spells - can you clarify? Also the last one: why wouldn't the correct output be (4)? It has less spells as (2,2) and the puzzle states "I need help to cast as few spells as possibles". Does it also mean that we have to output all solutions if there are multiple solutions with same number of spells?

Obviously, I messed up my inputs and outputs, this is presumably fixed. For the latest question, Yes, you shall output every combination that has the same amount of spells. Thanks.

are the input/output formats given, or anything goes as well it's a number + array of numbers => 2d array of numbers?

I'd be accomodating, as long as both the output and the input of your scroll of ambiguous language (brainfck) are clear and readable.

or, can we even write a function with two arguments instead of a whole program? Or even an expression?

As golf type has always been, you have to submit a whole program, which can compile. For instance, a java response is not valid if it doesn't contain a 'main' method.

wait, the last output should be (2,3), shouldn't it?

Yes , brb correcting it.

are we allowed to return the same list of mana costs twice, as long as there are two spells that satisfy that mana cost?

No, there is no need to distinct spells which are the same cost, thus you shall not show me the same answer twice. (3,1) and (1,3) are indeed the same.

for input: 6;6 5 1 do you want (6) or (6),(5,1)? As in, do you only want the shortest ones, or all?

@Cruncher only the shortest one. With your input, your software should output (6)

GolfScript, 55 characters
[[]]\{{+}+1$%|}/.@{1$0+{+}*.@>!*100*\,-~}+:s%$0={\s=}+,

Try it online.
> 4 [1 1 2 3 3 7 6]
[[1 3]]

> 3 [1 3 5 2 10]
[[3]]

> 8 [4 1 9]
[[4 1]]

> 4 [1 2 2 3]
[[2 2] [1 3]]

Ruby, 114 113 characters
x,y=eval gets
(d=0..10).find{|r|d.find{|c|s=y.sort.combination(c).select{|s|s.reduce(:+)==x-r}.uniq
p s if s[0]}}

Input: a two-element array of the wizard mana and the spell list, formatted a one-line JSON.
Output: a 2D array of the spell lists, formatted as a one-line JSON, or nil if the wizard can cast no spell.
I especially love x,y = eval gets. So dangerous and evil, yet so powerful and simple. Perfect for golfing.
Both sort and uniq are neccessary. Otherwise, this will produce duplicates for input like [4, [1, 3, 1]]. I'm not happy about this.
find is a useful method for control flow. Its return value is not as useful here, though. Length-wise, it comes on par with any?, which return value is even less useful.
Examples:
> [4, [1, 2, 3, 3, 7, 6]]
# [[1, 3]]
> [3, [1, 3, 5, 2, 10]]
# [[3]]
> [8, [4, 1, 9]]
# [[1, 4]]
> [4, [1, 2, 2, 3]]
# [[1, 3], [2, 2]]
> [4, [5, 6, 7]]
# nil

Couldn't you use map instead of find? Also, .reduce(:+), no & needed

map doesn't stop at the first positive result.  It would print all possibilities, grouped by mana cost and size. Thanks for the second advice.

APL (87)
↑∪m/⍨t=⌊/t←⊃∘⍴¨m←m/⍨t=⌈/t←+/¨m←{a/⍨⊃i≥+/a←k[⍵]}¨⊃,/g,{z/⍨∧/¨2>/¨z←,⍳⍵/⍴k}¨1↓g←⍳⍴k←1↓i←⎕

The input format is an APL list, where the first element is the mana pool and the rest of the elements are the spells. The output has each possible combination of spells on a separate line.
⎕:    4, 1 2 3 3 7 6
3 1
⎕:    3, 1 3 5 2 10
3
⎕:    8, 4 1 9
1 4
⎕:    4, 1 2 2 3
2 2
3 1

Explanation:

k←1↓i←⎕: read a list from the input, and store it in i. Drop the first element (mana) and store the rest in k.
1↓g←⍳⍴k: generate a list from 1 to the length of k, and store it in g. Drop the first element, giving [2..len k].
{...}¨: For each of these, get the indices of each unique combination in k of length ⍵:

z←,⍳⍵/⍴k: get a ⍵-dimensional matrix of indices of length k, flatten it, and store it in z.
∧/¨2>/¨: for each coordinate in each index, see if all coordinates for the Nth dimension are higher than those for the N-1th dimension.
z/⍨: select from z those elements for which the above holds true

⊃,/g,: because the above does not work for one-dimensional vectors, add g to the front. We now have a list of lists of lists (because of the foreach) of all unique indices into k. Concatenate the lists together and de-enclose (so we end up with a list of lists).
{...}¨: for each possible list of coordinates, look up the corresponding combination of values in k, and filter out those that are too expensive:

a←k[⍵]: look up the current combination in k and store it in a.
a/⍨⊃i≥+/a: select a only if the first item in i (the mana pool) is equal to or greater than the sum of the elements of a.

m←: store all combinations of spells that do not exceed the mana limit in m.
m←m/⍨t=⌈/t←+/¨m: select from m only those combinations whose sum is equal to the sum of the most expensive combination, and store it in m again.
m/⍨t=⌊/t←⊃∘⍴¨m: select from m only those combinations whose length is equal to the length of the shortest combination.
↑∪: remove any duplicates, and convert to a matrix (to display each combination on a separate line).

This is arcane! Perfect for a wizard...

Haskell (GHC), 172 167 143 chars
import Data.List
import GHC.Exts
f(x:y)=head.groupWith length.last.groupWith sum.filter((<=x).sum).nub$subsequences y
main=interact$show.f.read

Deobfuscated:
import Data.List
import GHC.Exts

f (x:xs) = head
         . groupWith length
         . last
         . groupWith sum
         . filter ((<= x) . sum)
         . nub
         $ subsequences xs

main = interact (show . f . read)

Input format: bracketed list with head as available mana, tail as avaliable spells (e.g. [4,1,2,3,3,7,6]).
Output format: bracketed list of lists, each sublist representing one possible set of spells.

Straightforward solution: grab the powerset of the input, then reduce that down by filtering for combinations we have sufficient mana for, etc.

Mathematica 131
There must be shorter ways, but this is what I was able to come up with.
l=Length;
f[{a_,b_}]:=Select[t=Cases[s=SortBy[Union@Cases[Subsets[b],x_/;0<Tr@x<a+1:>{x,Tr@x}],Last],
{x_,s[[-1,2]]}:> x],l@#==l@t[[1]]&]

f[{4, {1, 2, 3, 7, 6}}]

{{1, 3}}

f[{3, {1, 3, 5, 2, 10}}]

{{3}}

f[{8, {4, 1, 9}}]

{{4, 1}}

f[{4, {1, 2, 2, 3}}]

{{1, 3}, {2, 2}}


text:
Broken calculator
The functions receives 5 numbers, let's call them a, b, c, d and e
You must display two numbers.
First one is (((a + b) - c) * d) % e = f
Second one is (((a + b) - c) * d - f) / e
Input:             Output:
7  5  9  3 8       1 1
1  2  3  4 5       0 0
19 25 9  7 11      3 22
21 12 99 3 13      -3 -15
21 12 99 3 -4      -2 49

Requirement: You are not allowed to use '+' '-' '*' '/' symbols (or equivalent) when doing the calculation. You may however use '%' symbol (or equivalent) when doing the calculation.
By equivalent I meant that you are not allowed to use functions such as BigInteger.add() (I am looking at you java users).
Shortest code wins.
EDIT: as Peter suggested a clarification. All input numbers are int, and will never be 0

How will you measure speed? If you mean efficiency maybe comparing big-O values is better. Also, I think you mean (((a+b)-c)*d-f)/e for the second one.

@marinus sorry I have edited the question to shortest code wins. I guess there is no point to measure speed.

What type of number?

@Quincunx what do you mean by what kind of number? I believe all input numbers are integers, nor do I think that it is possible to get anything except integers for output.

Three questions: why is this entitled "Broken calculator"? How are you defining % with negative arguments? And is e guaranteed to be non-zero?

I think the 4th output should be 10 -16.

@PeterTaylor I call it broken calculator because my calculator had + button fall out which caused me to think up of this question. % with negative numbers yields negative numbers try it. and all numbers are guaranteed to be anything except 0.

@alephalpha here goes: 21 + 12 = 33 - 99 = -66 * 3 = -198 Next we do -198 % 13 which yields us -3 next we -198 - (-3) = -195 / 13 = -15

As @alephalpha points out (and is also apparent in my Forth-based answer below), it's worth noting that the behaviour of the modulo operation can vary by language when negative values are involved.  As the Wikipedia article says, a "naive definition breaks down and programming languages differ in how these values are defined."  Here's a good paper on Division and Modulus for Computer Scientists.

@DarrenStone I will accept that. I only put modulus in there because I wanted to see all answers as int, and whenever division is done, perfect int can not be obtained without modulus.

Mathematica, 54 chars
I just use dot product.
f={Mod@##,Quotient@##}&[{{#,#2,#3}.{1,1,-1}}.{#4},#5]&

Example:
f[19, 25, 9, 7, 11]

{3, 22}

Forth, 323 chars
: u 2dup ;
: p swap ;
: t -rot ;
: a u xor t and begin ?dup while 2* u xor t and repeat ;
: n invert 1 a ;
: m dup 0 < if p n p n then 0 p 0 ?do over a loop nip ;
: d dup 0 < t p dup 0 < t abs p abs p 0
begin t u <= while over n a rot 1 a repeat 2drop t xor if n then ;
: y 4 roll 4 roll a 3 roll n a rot m p u mod . d . ;

The forbidden arithmetic operations are defined in terms of binary operations. The core Forth word mod is used as the equivalent of %.
The final word y is the top-level function that accepts five numbers and prints two numbers as output.

C++ 503 characters
#include<iostream>
#define I int
#define R return
#define T (I x,I y)
I A T{I a,b;do{a=x&y;b=x^y;x=a<<1;y=b;}while(a);R b;}
I N(I v){R A(~v,1);}
I S T{R A(x,N(y));}
I V(I v){R v<0?N(v):v;}
I M T{I a=0;I i=0;while(i<V(x)){i=A(i,1);a=A(a,y);}R x<0?S(0,a):a;}
I D T{I a=0;x=y==0?0:x;while(M(V(y),a)<V(x))a=A(a,1);R M(y==0?0:S(A(a,1),(x%y==0?1:2)),x<0^y<0?N(1):1);}
void C(I a,I b,I c,I d,I e){I g,f;f=(g=M(S(A(a,b),c),d))%e;std::cout<<f<<' '<<D(S(g,f),e);}
I main(I a){I b,c,d,e;std::cin>>a>>b>>c>>d>>e;C(a,b,c,d,e);}

I get the same results as your examples except for the last two, I get -3 -15 and -2 49 respectively.  This is the same result that I get from the following...
int f = (((a + b) - c) * d) % e;
std::cout << f << ' ' << (((a + b) - c) * d - f) / e;

You can use I instead of void without returning anything, and it will still compile (at least on g++.) You can also shave some characters off by doing I g,f;f=(g=M(S(A(a,b),c),d))%e;std::cout<<f<<' '<<D(S(g,f),e);.

also main(I a){I b,c,d,e;

@marinus edited answer with your suggestions

I am sorry, your calculation was right. I was the one who made an error. I like your answer :)

@Quillion it was a good challenge


text:
Build a solver for the "N balls on a scale" problem
The twelve-balls problem is a famous problem where you are given twelve balls, one of which is a different weight, but you don't know whether it is heavier or lighter than the other balls. Using only three weighings of a two-sided scale, it is possible to find the differently weighted ball, and determine whether it is heavier or lighter.
Your task is to build a program that does the following:

Accept a number of balls N to be compared, from 8 to 100. (In the traditional problem, N = 12.)
Produce two lists of numbers, representing the balls to be placed on each side of the balance. An equal number of balls must be placed on each side.
Accept an input signifying whether the left side of the scale is heavier, the right side is heavier, or the two sides are equal (this can be represented any way you want to: e.g. -1 for left, 0 for equal, 1 for right, or 1 for left, 2 for right, and 3 for equal), and in response, either produce another pair of lists of balls to be weighed, or a guess as to which ball is the different one and whether it is heavier or lighter.

Your score is the sum of the maximum number of weighings for each value of N from 8 to 100 that it took to figure out the right answer for N balls using your algorithm (each case of "ball x is heavier/lighter" must be tested). Lowest score wins.
For example, if for N = 12, your algorithm managed to get 3 weighings for every case except "ball 8 is heavy" where it took 4 weighings, your score for N = 12 is 4. If your maximum score was 10 weighings for each N from 8 to 100, your final score would be 930.
Your algorithm must return the correct answer for all possible test cases (for any N, there are 2N possible test cases, which is a total of 10,044). In addition, the source code of your solution may not exceed 51,200 bytes (50 KB) in size.

To me it seems like the n=12 problem requires at least 4 weighings

Actually, it seems much harder than that... I can determine IF it's heavier or lighter in 3, but not the actual ball.. The quickest I can think of for finding the ball would be 5. In general it looks like 3 + log2(n/3) to be

Probably even harder for n not divisible by 3

Nope. It's possible for 3 weighings: http://www.primepuzzle.com/leeslatest/12_ball_solution.html

Also, I think I know what your basic method is - and determining whether the ball is heavier or lighter without finding out which ball it is actually only takes two weighings (if it's divisible by 3). So it's 2 + log3(n/3), not 3 + log2(n/3).

Where did you get log3 from? Is that a typo? You're right about deciding heavy/light in 2 though for n%3==0

Remember that if two sides are equal, you know that the balls that weren't weighed contain the different ball. So you can split the balls up into three groups instead of just two.

Ah, I see, I see. Essentially the same trick we used for finding lighter/heavier. I would suspect using this algorithm, whilst having a 4th "remainder" group for non-divisible by 3 N, would actually fare pretty well

How do you test to see how many weightings it takes?

You can probably build an automated client to do it. For each value of N and each value of 1 <= M <= N, assume ball M is heavy and then ball M is light and test the input of your program accordingly.

Tcl, 455 426
proc weight n {
   set num [expr {int(log($n*2-1)/log(3))+1}]
   set len [expr {$n/3}]
   set pn 0
   set pri {2 5 7 11 13 17 19 23 29 31 37 41 43 59 61 67}
   for {set i 0} {$i < $num} {incr i} {
       set a {}
       while {![llength $a]} {
           set a {}
           set b {}
           set c {}
           while {
               ($n+1)%[lindex $pri $pn]==0
             ||($n-1)%[lindex $pri $pn]==0
             ||$n%[lindex $pri $pn]==0} {incr pn; puts $pn}
           set cpn [lindex $pri $pn]
           for {set j 0} {$j < $len} {incr j} {
               set tmp [expr {($j*$cpn)%$n}]
               lappend a $tmp
               incr tmp 1
               if {$tmp in $a} {set a {}; break}
               lappend b $tmp
           }
           incr pn
       }
       for {set j 0} {$j < $n} {incr j} {
           if {$j ni $a && $j ni $b} {lappend c $j}
       }
       puts "[lsort -integer $a] VS [lsort -integer $b] - Which is havier? -1 = left, 0 = equal, 1 = right"
       set idx [expr {[gets stdin] + 1}]
       if {$i == 0} {
           if {$idx == 1} {
               set p1 $c
               set p2 $c
           } elseif {$idx == 0} {
               set p1 $a
               set p2 $b
           } else {
               set p1 $b
               set p2 $a
           }
       } else {
           set lists [list $a $c $b]
           set p1 [lmap it [lindex $lists $idx] {if {$it ni $p1} continue; set it}]
           set p2 [lmap it [lindex $lists 2-$idx] {if {$it ni $p2} continue; set it}]
       }
   }
   if {[llength $p1]} {puts "Result $p1"} {puts "Result $p2"}
}
puts "Number of balls?"
weight [gets stdin]

No matter what you choose, the next question is always the same.

Note that this might not work for larger numbers than 100 (I'd have to add a prime factor generator, which I didn't do yet - the prime numbers are hardcoded.)

Ohh, and found a bug: Try to get 16 or 0 with 28 balls.

The optimal answer should be 428. Does your solution actually work for 13 or 40 balls?

Python - 4929 weighings
A sketch of a trivial, last-place solution:
N = input("Enter number of balls: ")
a = 1
b = 2

print a, "|", b
first_result = input("Is left side heavy (1), right side heavy (2), or both equal (3)? ")

while(True):
    b += 1
    print a, "|", b
    result = input("Is left side heavy (1), right side heavy (2), or both equal (3)?")
    if result == first_result and result != 3:
        # ball 1 is our culprit.
        print "Ball 1 is %s." % ("heavier" if first_result == 1 else "lighter")
        break
    elif result != first_result and result == 3:
        # ball 2 is our culprit.
        print "Ball 2 is %s." % ("heavier" if first_result == 2 else "lighter")
        break
    elif result != first_result and first_result == 3:
        # ball b is our culprit.
        print "Ball %d is %s." % (b, "heavier" if result == 2 else "lighter")
        break

This solution simply continuously puts the first ball on the left side and a different ball on the right side, until it's found out that either the first ball is of a different weight, or one of the others is.
This takes a maximum of N-1 weighings for N balls (in any case where the last ball is the different one, N-1 weighings are required), which is 4929 weighings total.

This definitely looks like a sketch: you use Python 3.x's input() but Python 3.x uses print() instead of print

Hmm. It worked when I ran it through my Python 2 interpreter.

I must be wrong...

@Quincunx input() in Python2 is the same as eval(input()) in Python3.

Tcl, 369
proc weight balls {
    if {[llength $balls] == 1 || [llength $balls] == 0} {return [lindex $balls 0]}
    set len [expr {([llength $balls]+1)/3}]
    set a [lrange $balls 0 ${len}-1]
    set b [lrange $balls $len [expr {$len*2-1}]]
    set c [lrange $balls [expr {$len*2}] end]
    puts "$a VS $b (0 = left side is havier, 1 = right side is havier, 2 = equal)"
    tailcall weight [lindex [list $a $b $c] [gets stdin]]
}
puts "Number of balls"
for {set i 1} \$i<=[gets stdin] {incr i} {lappend balls $i}
puts [weight $balls]

The algorithm is very simple: (try to) split the list in 3 equal parts (last can be different), weight the first 2, and do that again for the selected part (if equal, use the 3rd part)

Can you explain what your algorithm does?

Sorry, forget it, I overread the you don't know whether it is heavier or lighter

Haha, yeah, if that's removed then the problem is trivial.

Python - ?
#recursive weighing method
def weigh(list, heavy):
    l=len(list)
    if l==1:
        return list[0]
    list1=list[0::3]
    list2=list[1::3]
    list3=[]
    if len(list1)>len(list2):
        list3.append(list1.pop())
    print("%s|%s"%(list1,list2))
    side=input("(0,1,2) for (neither,left,right) is %s"%heavy)
    if side==2:
        return weigh(list2, heavy)
    if side:
        return weigh(list1, heavy)
    for i in list[2::3]:
        list3.append(i)
    return weigh(list3, heavy)
#End Function, begin rest of program
#This part of the program is long because I need to determine whether the odd ball
#is heavy or light
list=range(input("Number of Balls: "))
#split the list into 3
list1=list[0::3]
list2=list[1::3]
list3=list[2::3]
#make list3 the odd man out, if there is one
if len(list1)>len(list2):
    list1,list3=list3,list1
print("%s|%s"%(list1,list2))
side=input("(0,1,2) for (neither,left,right) is heavier")
#if side==0
if not side:
    heavy="heavier"
    if len(list3)<len(list1):
        list3.append(list2.pop())
    elif len(list3)>len(list1):
        list2.append(list3.pop())
    print("%s|%s"%(list1,list3))
    side2=input("(0,1,2) for (neither,left,right) is heavier")
    if side2==1:
        heavy="lighter"
    print("%s: %s"%(weigh(list3, heavy),heavy))
else:
    if side==2:
        list1,list2=list2,list1
    if len(list3)!=len(list2):
        if len(list3)<len(list1):
            list3.append(list1.pop())
        if len(list3)>len(list2):
            list1.append(list3.pop())
        print("%s|%s"%(list2,list3))
        side2=input("(0,1,2) for (neither,left,right) is heavier")
        if not side2:
            print("%s: heavier"%weigh(list1, "heavier"))
        else:
            possibleAns = list3.pop()
            list3.append(list1.pop())
            print("%s|%s"%(list2,list3))
            side3=input("(0,1,2) for (neither,left,right) is heavier")
            if not side3:
                print("%s: heavier"%possibleAns)
            else:
                print("%s: lighter"%weigh(list2,"lighter"))
    else:
        print("%s|%s"%(list2,list3))
        side2=input("(0,1,2) for (neither,left,right) is heavier")
        if not side2:
            print("%s: heavier"%weigh(list1,"heavier"))
        else:
            print("%s: lighter"%weigh(list2,"lighter"))

This program works by dividing the balls into three lists, comparing them to see which of heavier or lighter the ball is, then recursively finds it.

I tried testing with 10 is heavier, but after the third weighing it threw an error involving a NoneType. The inputs that I put in were 2 0 0.

@JoeZ. Should be fixed now. Have to laugh at the 50kb limit. I thought this file was big, but it is only 4kb.

The 50 KB limit is mostly to prevent blatant hardcoding solutions. Any actual algorithm (unless it's ridiculously complex) shouldn't get anywhere near that.

Also, nope. The same inputs still throw the same NoneType error. Have you tried inputting 12 2 0 0?

@JoeZ. I'm trying to get Python working on my computer so I can test it, so no, I have not.

@JoeZ. That's odd, it was because list3.extend(list[2::0]) was returning the NoneType instead of doing what I expected. It should work now.

Yep, it works now.

@JoeZ. While we're on the topic of hardcoding. You could hardcode this in less than 50KB of source code. Just pre-populate an SQLite DB

The SQL query source code to populate that SQLite DB would count toward that limit.

The assumption is that the environment starts out empty. If you're pre-populating an SQLite DB, that doesn't preclude simply importing a pre-compiled binary solution, which I think we'd both agree is invalid.

JavaScript 1281
// Weigh function
function weigh(a,b) {
    weigh.count++;
    var len = a.length;
    if (len !== b.length) {
        throw({name:"NotEqual",message:"Can not compare."});
    }
    var wa, wb;
    wa = wb = 0;
    for(var i = 0; i < len; i++) {
        wa += a[i];
        wb += b[i];
    }
    return (wa === wb) ? 0 : (wa > wb) ? -1 : 1;
}
weigh.count = 0;

function findOddBall(arr) {
    var s = [arr];
    var isHeavy = true;
    var priorR = null;
    var left = null;
    var right = null;
    //console.log(arr);
    while(k=s.pop()) {
        //console.log('isHeavy:' + isHeavy + ' ' + k.slice(0));
        var len = k.length;

        if (len === 1) {

            if (priorR !== 0) {
                return [k[0], isHeavy]
            }

            var r = priorR = weigh([left[0]],k);

            if (r !== 0) {
                // we know that the oddball is one of these.. but which one?
                // we need to do a final comparison with the right side.
                priorR = r;
                r = weigh([right[0]],k);

                if (r === 0) {
                    // prior heavy/light
                    isHeavy = (priorR === -1)?true:false;
                    return [left[0],isHeavy]
                } else if(r === 1) {
                    return [k[0], true] // heavy
                }

                return [k[0], false] //light
            }

            continue;
        }

        x = (len % 2 === 0) ? len : len-1;
        right = k.splice(0,x);

        if(k.length !== 0) {
            s.push(k); // remainder
        }

        left = right.splice(0,x/2);
        var r = priorR = weigh(left, right);
        if (r === 0) {
            // We chose a normal side. Test the other side.
            isHeavy = !isHeavy;
        } else if ((r === -1 && isHeavy)|| (r === 1 && !isHeavy)) {
            s.push(right);
            s.push(left); // left is heavier / lighter
        } else if((r === 1 && isHeavy)|| (r === -1 && !isHeavy)) {
            s.push(left);
            s.push(right); // right is heavier / lighter
        }
    }
    throw({name:"NotFound",message:"Can not find oddball."});
}

function main() {

    var total = 0;
    var variations = 0;
    var start = 8;
    var end = 100;

    function test(isHeavy) {
        var normal = (isHeavy) ? 0 : 1;
        var oddball = (isHeavy) ? 1 : 0;
        var score = 0;
        var base = [];

        for (var i=0; i < start;i++) {
            base.push(normal);
        }

        for (var i=start; i <=end; i++) {
            base.push(normal);
            var max = 0;
            for (var j=0; j<i; j++) { // try each placement
                var arr = base.slice(0);
                arr[j]=oddball;
                variations++;
                weigh.count = 0; // reset the scale
                var result = findOddBall(arr);
                if (result[0] !== oddball || result[1] !== isHeavy) {
                    console.log(i);
                    throw({name:"WrongAnswer",message:"Returned wrong answer."});
                }
                if (weigh.count > max) {
                    max = weigh.count;
                }
                //console.log(variations);
            }
            total+=max;
        }
    }

    test(true);
    test(false);

    console.log(variations);
    console.log(total);
}

main();


text:
Given a string find the substring which appears most often
Write a complete program (not just a function) which using stdin takes in a string of arbitrary length (assume string-length at least one) composed only of digits 0-9 and outputs using stdout the substring which appears most often in the input string. The input string can be any length and the substring can be maximum half the length of the input string because it must appear at least twice non-overlapped to be printed.
We following the following hierarchy selecting the substring to be printed.

First priority, the longest substring
Second priority, if we have multiple substrings of the same length, we pick the one appearing the most often.
Third priority, if multiple substrings of the same size appear the same number of times, pick the one which appears first scanning from the left.

Here are some test cases followed by the rules and some explanation.
./myprogram 123456
No substrings repeat.

The substring must appear more than once. If no substrings repeat the the output must exactly be the string "No substrings repeat." complete with the capitalization and the period.
./myprogram 12121
12

The sub-strings must not overlap. So in this case the largest repeating substring is 12 instead of 121.
./myprogram 99999999
9999

We want the largest substring which appears at least twice. Here 9, 99, 999, and 9999 all appears at least twice. But we want the largest substring which appears at least twice.
./myprogram 321321788788788
788

321, 788, 887, and 878 each appear multiple times so we pick 788 which appears the most often.
./myprogram 12121
12

12 and 21 both appear twice so we pick 12 which appears first from the left.
./myprogram 12012112299999999
9999

The string 12 occurs first and appears thrice but 9999 is longer and appears only twice so we pick 9999 because it has the highest priority.
./myprogram 56698853211564788954126162561664412355899990001212345
412

No substrings of length more than three repeat. 412, 616, and 123 each appear twice. 412 occurs first and is thus printed.
I think I have taken care of all the cases. True code-golf. The shortest code in any language wins. In the case of ties, I pick the one with the highest upvotes after waiting at least for two weeks and probably longer. So the community please feel free to upvote any solutions you like. The cleverness/beauty of the code matters much more than who posts first.
Happy coding!

The description is inconsistent. To appear twice is equivalent to to repeat once.

@MarcksThomas Fair enough. Fixed!

You seem to also have an unstated assumption that the substring must be of length at least 1.

@PeterTaylor Well an assumption yes but not unstated. The first line up there contains the substring "assume string-length at least one".

That's clearly talking about the input string, not the substring.

GolfScript, 74 characters
"No substrings repeat."\:i,,{){i@><}+i,,%.{i\/,}%$-1=.2>*{i@/,=}+,0=}/]-1=

Brute force GolfScript approach (which would have been much shorter if $ would be stable). Note that the input must include the newline in order to give correct results.

Perl, 99 (+1) bytes
$_=$;{(sort%;)[m{(.+).*\1(?{$;{$;x$+=~y///c.1x@{[/$+/g]}.2x$+[1]}=$+})^}]}
||"No substrings repeat."

Requires a -p command line switch.
For each repeated substring a hash entry is created, such that the largest substring, repeated the most times, with the earliest position is guaranteed to be the smallest key in the hash. The hash is then sorted, and the corresponding value for the smallest key is output.
Sample Usage:
$ echo 123456 | perl -p repeated-substring.pl
No substrings repeat.

$ echo 12121 | perl -p repeated-substring.pl
12

$ echo 99999999 | perl -p repeated-substring.pl
9999

$ echo 321321788788788 | perl -p repeated-substring.pl
788

$ echo 12012112299999999 | perl -p repeated-substring.pl
9999

$ echo 56698853211564788954126162561664412355899990001212345 | perl -p repeated-substring.pl
412

ruby, 104 characters
r=gets.size.downto 1
r.find{|l|r.find{|c|$><<$1 if/(.{#{l}})(.*\1){#{c}}/}}||$><<"No substrings repeat."

Uses my favourite, nested finds. Also, good old magic variables and other perlisms.

Ruby, 108+1=109
$_=$_.scan(/(.+)(?=.*\1)/).map(&:first).max_by{|s|[s.size,$_.scan(s).size,-~/#{s}/]}||'No substrings repeat.'

Usage:
echo 56698853211564788954126162561664412355899990001212345 | ruby -p repeats_most_often.rb

I could save a few chars if I assumed Ruby's sort was stable, but it's not always. Also in older versions of Ruby I could replace the $_.scan with scan.

C#, 120 chars
Regex.Matches("(.{2,}).*\1",input).Select(n=>n.ToString()).OrderBy(n=>n.Length).LastOrDefault()??"No substrings repeat."

With boilerplate, 171
class A{int Main(string[] a){Console.WriteLine(Regex.Matches("(.{2,}).*\1", a[0]).Select(n=>n.ToString()).OrderBy(n=>n.Length).LastOrDefault()??"No substrings repeat.");}}

I think you are a character short because you are missing a period in "No substrings repeat." in both of your codes.

@Fixed Sorry, fixed.


text:
Same code shape and output shape
I am not sure if this is possible. I have tried it and couldn't make it work at all, but I am being hopeful.
If this is not possible please flag this question and I will promptly delete it.
Conditions are simple,
Write code that will output same amount of character in the same shape as the code.
For example (A very stupid example).
If code says
#include<stdio.h>

main()
{
    printf("Hello World");
}

Then output must be
kjh#$@#)(12398n,s

lkrjop
t
    jherl;k@&##*$&@3n,2m$*
t

I really do not care which characters are being used in the output or anything like that except that space is space and tab is tab. So whatever is the shape of the code, the output should be the same.
Winner: Either popularity , or help me decide the criteria.
The only way I managed to make this work, is I created a file reader that reads the code and does rot13 on every character in the code and prints it out. However I was not fond of it, because the shape was not interesting, nor do I want to use file reader to do something like this because it is too easy.

"Most complex and interesting" aren't exactly objective judging criteria.

@Iszi please let me know what you think I should have as winning criteria? I was having a big difficulty deciding.

A possible winning criteria could be "fewest bytes of code", but then you would have to tag your question as code-golf, not as code-challenge or code-bowling.

@ProgramFOX The problem is that I would like to see some really nice complex shaped code. Like a circle that is hollow inside, or homer simpson's head. Having very few bytes doesn't make it as entertaining because it defeats the purpose of trying to make a cool shape. I was originally thinking of making it smallest code, but that defeats being creative. Unless a lot of people agree on this.

The problem is that the 'coolest' shape is subjective: for example if there's a circle and a triangle as code, then perhaps you like the triangle but I like the circle. An objective winning criteria is a criteria where the opinion of someone doesn't matter.

@ProgramFOX I agree with you. but what criteria should I use that would not hinder creativity?

Let the other members decide: after some days, ask in your question "Please post a comment to the most creative answer (in your opinion), containing 'This is the most creative answer', and the comment that get most upvotes, this answer wins". I think you need to re-formulate my bad-formulated phrases, but it is an idea.

@ProgramFOX That still leaves us with a subjective criteria, where entries are judged based on opinions rather than some absolute qualitative value.

@Iszi: You're right. What would you suggest as criteria then?

@ProgramFOX It's nigh impossible to define an objective criteria for a challenge such as this, without defining the desired output shape. It may even be necessary to define the dimensions in order to be truly objective. Changing it to [tag:code-golf] would be a very bad idea, without further restrictions, since many scripting languages could easily tie for first with a single character.

@Iszi: Then unfortunately, I think the only thing we can do is vote to close the question.

In its current form, I could take it to PowerShell and draw some ASCII pr0n with some long numbers. It's rather trivial, really. In fact, I'd probably get more upvotes just for the boobies than I would for any real creativity.

@Iszi ok fine you are right :( Shortest code wins, unless we come up with something better

@Quillion You missed my comment about [tag:code-golf] for this question, then. I could win that in PowerShell, and I'm sure a lot of others could tie me in other scripting languages, with any single-digit number.

@Iszi then what do I do?

@Quillion As I said, without any specification as to what the shape is or its dimensions, there's really nothing that can be done for this question. Unless someone else has a better idea for an objective winning criteria, the only option I see is closure.

@Iszi ok I gave what shape to make.

@Quillion So, does the code itself have to be in that shape or does it just have to be some sort of visual representation of that shape? The former may restrict the languages that can be used, or force a lot of comments, depending on how tolerant some languages are when it comes to massive amounts of whitespace. The latter again makes the challenge relatively trivial for some languages. Again I could put together a block of numbers, which would compose a fair visual representation of that shape, and easily have the code and ouptut shapes match (in fact, the code is the output) in PowerShell.

How about using the popularity-contest tag?

@marinus Wait - we have that?

@Iszi what do you think? Is that ok?

@Quillion I'm not keen on the tag myself, but I'm also relatively new on the site. I'll let others weigh in on this bit.

@Iszi agreed, let's hear other people's voice

For future reference, please use the sandbox in Meta (currently, Mk V) to test new questions - especially if you're feeling iffy on its viability or the judging criteria.

If you do not care about the characters being used, any quine will pass your conditions, right?

JS
I know it's still being contested, but I thought I'd have a go:
          (function (){a='';
       a           ;         a=
     '             ';           h
    =             '#'            ;
   s             = ' '            ;
  s             ;  s  ;            s
 ;             s   ;   s            ;
s             ;    s    ;            s
;            s     ;     s           ;
s           ;      s      ;          s
;          s       ;       s         ;
 b        =       '';       s       ;
  s      ;      return(      a     +
   b    +     b+arguments[    b   +
    'ca'   +'llee'].toString   ( )
      .replace(/\S/g,h)+'###');s;
          s                 ;
               s;s;s})()

When run in Chrome's console produces:

Not 100% accurate, but I thought it was quite close. As intangible as the criteria were to begin with, I did like the idea of the challenge, despite how easy/difficult is in differing languages.

I love it dude :) and the shape itself is my favorite too. Let's wait and see what we decide on for criteria, but this is the type of answer I had in mind.

on the Dyalog APL terminal
abcde fghij

outputs
VALUE ERROR

Well to be completely accurate it outputs VALUE ERROR abcde fghij ^. (and some spaces that won't show up.)

Dyalog prints the result of evaluating a line of code (unless the result is "shy"), so you can reduce the solution to a one-digit number literal: 0 prints 0
The empty program is also valid, but it can be argued that it doesn't print, because lack of a result is considered a shy result.

BF
>++++++++[>+++++++>+++++++<<-]>++>++++++<>++++++<<<++++++++++[>++++<-]>[>.>.<<-]

It just outputs a set of laughing smileys:
:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D:D

Size of code and its output are both 80.

Python, 0 (kind of cheating)
Here's a totally valid Python program:

And here's the output of that program, of same shape:

:)

Empty code block:

.

Technically, it wont print

This is a polyglot actually.

@user80551 Technically print("") won't print.

@Cruncher But the output wont look like ydluicbe7 either.

@user80551 My point is, that not printing, is functionally equivalent to printing blank. They are completely indistinguishable. So not writing anything is an equivalent program to print(""), which does print itself.

Python
Smallest thing I could think of.
print 'a'*5+' '+'a'*16

Output
aaaaa aaaaaaaaaaaaaaaa

That space in the middle is part of a string so it doesn't count.

print 'a'*5+'\x20'+'a'*19

for python3 you can do print('a'*13)

that would require a from __future__ import print_function

Quines
Any quine (a program producing a copy of its own source code) would do the trick. There are thousand examples on the internet written in many different languages. For example:
Perl, 34 Author: V Vinay
$_=q(print"\$_=q($_);eval;");eval;

Python, 33 Author: Frank Stajano
l='l=%s;print l%%`l`';print l%`l`

Java, 252 Bertram Felgenhauer
class S{public static void main(String[]a){String s="class S{public static void main(String[]a){String s=;char c=34;System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}";char c=34;System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}

Tcl, 34 Author: Joe Miller
join {{} \{ \}} {join {{} \{ \}} }

Right. This is a more lax condition on quines

or if you are picky
5 ⍴ 1 + 1

outputs
2 2 2 2 2

What language is it?

@Timtech, it's APL.

Perl
Any program which reads it's own source file will do (technically, it's not considered to be a quine). Here's a simple Perl script (my lack of inspiration restricted me from giving to the code a shape more complex than a diamond/rhombus)!
         use
      warnings;
   use strict;open
(my $IN,'<',$0)or die
   "PCG FTW";print
     <$IN>;close
         $IN

Which will print:
         use
      warnings;
   use strict;open
(my $IN,'<',$0)or die
   "PCG FTW";print
     <$IN>;close
         $IN

You need longer code to make an interesting picture :)

HQ9+
 +++    +++
 +++    +++

     ++
++   +Q   ++
++        ++
 ++      ++
  +++  +++
    ++++

Or, something like this:
                  ___                       __   _____
  ____  ____   __| _/____      ____   ____ |  |_/ ____\
_/ ___\/  _ \ / __ |/ __ \    / ___\ /  _ \|  |\   __\
\  \__(  <_> ) /_/ \  ___/   / /_/  >  <_> )  |_|  |
 \___  >____/\____ |\___  >  \___  / \____/|____/__|
     \/           \/    \/  /_____/                  Q

Credits to this site ;)
Basically, anything will work, as long as it has exactly:

0 Hs
0 9s
1 Q

Or, some minimalist solutions:

1 char
Q

0 chars

Perl 44 chars
open O,"<$0";while(<O>){y|!-~|P-~!-O|;print}

In action:
echo $'#!/usr/bin/perl\nopen O,"<$0";while(<O>){y|!-~|P-~!-O|;print}' >/tmp/autohide.pl
chmod  +x /tmp/autohide.pl
/tmp/autohide.pl
RP^FDC^3:?^A6C=
@A6? ~[QkS_QjH9:=6Wk~mXLJMP\OM!\OP\~MjAC:?EN

reverse:
/tmp/autohide.pl | perl -pe 'y|!-~|P-~!-O|'
#!/usr/bin/perl
open O,"<$0";while(<O>){y|!-~|P-~!-O|;print}

Rot47 vs Rot13:
To correspond to behaviour of Rot13, but from ! to ~, there is 94 chars. I wrote rot47:
#!/usr/bin/perl -s
$                 s
?           $     O
=          *      STDIN
:                   open
$                   O
,                "<"
.                  $
0           ;while
(       <$O>
)      {#
y|!-~|P-~!-O|
;    print   }

(I've tried to draw beavis, but this is not very well!)
Store them, for sample in autohide.pl:
chmod  +x autohide.pl

with executable rights,
./autohide.pl
RP^FDC^3:?^A6C= \D
S                 D
n           S     ~
l          Y      $%sx}
i                   @A6?
S                   ~
[                QkQ
]                  S
_           jH9:=6
W       kS~m
X      LR
JMP\OM!\OP\~M
j    AC:?E   N

Than, there is no reverse operation, it's only repeat same translation.
When run with -s parameter, this use STDIN instead of himself code,
so running ./autohide.pl -s <autohide.pl do same as if run without argument:
./autohide.pl -s <autohide.pl | ./autohide.pl -s
#!/usr/bin/perl -s
$                 s
?           $     O
=          *      STDIN
:                   open
$                   O
,                "<"
.                  $
0           ;while
(       <$O>
)      {#
y|!-~|P-~!-O|
;    print   }

Python
Generic solution.
Just save the file as 'source.py' and execute.
import random

def main():
    f = open('source.py')
    s = ''
    d = {' ':1,
     '\t':2,
     '\n' :3}
    rstring = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=~!@#$%^&*()_+,./<>?;:[]{}|'
    for line in f:
        for char in line:
            if char in d:
                s += char
            else:
                s += random.choice(rstring)
    print s

main()

May be simplest solution for Python
print'*'*11

and for Py3K
print('*'*13)

and another generic solution for Py3K
import random, sys
def main():
    f = open(__file__).read()
    d = ' \t\n'
    r = ''.join(chr(c) for c in range(33, 127))
    sys.stdout.write(''.join(c if c in d else random.choice(r) for c in f))

if __name__ == '__main__':
    main()

print-1e5 and print(-1e7) are shorter :P

For Py3K works also print(1e7)

Bash 9 8 chars (Thanks @FireFly)
rot13<$0

This match requirement:

output same amount of character in the same shape as the code
rot13

Practical
echo  >autorot13.sh 'rot13 <$0'
chmod  +x autorot13.sh
./autorot13.sh
ebg13<$0

You can drop the space before the <; being an operator character means it's forced to delimit the word token before it.

@FireFly Thanks, I've missed this!