text:
Shortest Way of creating a basic Space Invaders Game in Python
Your challenge is to create a basic version of Space Invaders in Python
Rules

Program must be not written in Py3K
All levels must be randomly generated
There must be a HUD showing the players score

The winner would be the answer which uses the least amount of code
Some Questions
Q: How detailed do the aliens and other elements have to be?
A: The aliens should be Block ASCII
Q: Can the bunkers be simplified to rectangles?
A: Yes, as long as they are filled
Q: How many enemies/bunkers do there have to be?
A: Number of Enemy's are chosen by random. 4 bunkers
Q: Do we need to implement the "mystery ship" that goes across the top of the screen?
A: No
Q:Do the symbols/characters that make up the laser cannon and the aliens need to be different?
A: Yes
Q: Do they need different shapes?
A: Yes
Q: Does it matter how fast the bullets/lasers travel?
A: No

I think this question is missing some basic requirements: objective winning criterion and a clear specification of the task (read the faq). Please try to clarify your question.

@Howard Ive improve'd it a little bit.. What else is it missing?

-0.  These requirements are too broad for meaningful code golf.  What counts as Space Invaders?  What are the rules of the game?
Also, why limit this to Python?

@StevenRumbalski 1. The classic game 2. See:Wikipedia 3. Because it is a challenge :?

How simplified is the final version allowed to be? The answer to this question can ultimately decide the winner because certain simplifications can make it much easier to do in less code. How detailed do the aliens and other elements have to be? Can the bunkers be simplified to rectangles? How many enemies/bunkers do there have to be? Do we need to implement the "mystery ship" that goes across the top of the screen? Do the symbols/characters that make up the laser cannon and the aliens need to be different? Do they need different shapes?  Does it matter how fast the bullets/lasers travel?

1
a. The aliens should be Block ASCII b. Yes, If they are filled c. Number of Enemy's are chosen by random d. No e. Yes f.Yes g. No

@PhiNotPi Added you details to the q. Thanks

3060 3031 characters
OKAY, this was fun. But I very highly doubt that my code is short enough to compete, or if it's basic enough. I'm new to code golf but regardless, I had fun and that's what matters. I'm too used to object-oriented programming so a lot of my code is probably just too much objects...
Game runs solely in the console, and I shortened most of the code with the exec''''''.replace() method. Complete with input of your name, random enemy firing, walls, aliens are randomly generated, worth 50 points each. each time you fire you lose one point so that you lose points if you just hold space in one spot to beat the level. Enemy speed increases each level, capped at every 0.2 seconds. Prints the level number, and game over at the bottom, your name,lives, and score at the top left. you have 3 lives. Ungolfed version is ~9500 characters, but I'll leave that out of here for now
instructions: fire with space, move with a and d, exit with x
let me know what think, if I can improve on anything
edit: forgot that msvcrt is Windows-Only. perhaps I can make a unix version too...
exec'''import threading as t
import msvcrt,Queue,time,random,os
u=raw_input('name:')
r=range
@Z:
$~(S):S.w=78;S.h=30;S.X();S.l='';S.Q=[];S.q=[];S.m=''
$J(S,x,y,c):S.q.append([x,y,c])
$X(S):S.s=[[' '^y in r(78)]^x in r(30)]
$V(S):
?s='';S.X()
?^x,y,z in S.q:S.s[y][x]=z
?S.q=[]
?^x in S.s:
? ^y in x:s+=y
? s+='\\n'
?s+=S.m.center(S.w)
?if s!=S.l:os.system('cls');S.l=s;print s
@E(Exception):pass
@C:
$~(S,g,c,p):S.g=g;S.c=c;S.p=p;S.s=[]
$M(S,a,d):
?if (a<0 and S.p[d]==0) or (a>0 and S.p[d]==(S.g.z.h if d else S.g.z.w)-1):raise E()
?S.p[d]+=a
$X(S):S.s.remove(S)
@A(C):
$~(S,g):C.~(S,g,'A',[39,28])
$M(S,a,d=0):
?try:C.M(S,a,d)
?except E:pass
@Y(A):
$~(S,g,p):C.~(S,g,'Y',p);S.s=g.a
@B(C):
$~(S,g,p,n):C.~(S,g,'|'if n<0 else'*',[p[0],p[1]+n]);S.s=g.b;S.d=n;S.a=0 if n<0 else 1
$M(S):
?try:C.M(S,S.d,1)
?except E:S.X()
$b(S):S.g.z.J(S.p[0],S.p[1],'X');S.g.z.V();S.X()
$co(S):
?^w in S.g.w:
? if S.p==w.p:S.b();w.X()
?if S.a:
? if S.p==S.g.p.p:S.b();S.g.d()
?else:
? ^a in S.g.a:
??if S.p==a.p:S.b();S.g.P(50);a.X()
@W(C):
$~(S,g,p):C.~(S,g,'#',p);S.s=g.w
@I(t.Thread):
$~(S,g):t.Thread.~(S);S.f=1;S.c={'a':g._g4,'d':g._g3,'x':g._X,' ':g._fi};S.start()
$run(S):
?while S.f:
? c=msvcrt.getch()
? if c in S.c:S.c[c]()
$X(S):S.f=0
@G:
$~(S):S.z=Z();S.x=3.0;S.c=0;S.b=[];S.Q=Queue.Queue();S.I=I(S);S.g2=0;S.g1=0;S.do=0;S.f=1;S.v=0;S.l=3;S.ti=[];S.G(1);S.O()
$O(S):
?while S.f:
? time.sleep(0.02)
? if not S.a:S.G(1)
? S.ch();S.B();S.u()
$u(S):
?S.z.X();S.P(0)
?s=u+' '+`S.l`
?^i in r(len(s)):S.z.J(i,0,s[i])
?^i in S.a+S.b+[S.p]+S.w:S.z.J(i.p[0],i.p[1],i.c)
?S.z.V()
$ch(S):
?try:
? while not S.Q.empty():S.Q.get_nowait()();S.Q.task_done()
?except Queue.Empty:pass
$cl(S):
?try:
? while not S.Q.empty():S.Q.get_nowait();S.Q.task_done()
?except Queue.Empty:pass
$_g4(S):
?if not S.g2:S.g2=1;S.Q.put(S.g4)
$g4(S):S.p.M(-1);S.g2=0
$_g3(S):
?if not S.g1:S.g1=1;S.Q.put(S.g3)
$g3(S):S.p.M(1);S.g1=0
$_X(S):S.I.X();S.Q.put(S.X)
$X(S):S.f=0;S.I.X();S.st()
$_fi(S):
?if not S.do:S.do=1;S.Q.put(S.fi)
$fi(S):S.b.append(B(S,S.p.p[:],-1));S.do=0;S.P(-1)
$_af(S):S.Q.put(S.af)
$af(S):c=random.choice(S.a);S.b.append(B(S,c.p[:],1));S.nt(random.uniform(0.1,2),S._af)
$nt(S,n,f):x=t.Timer(n,f);S.ti.append(x);x.start()
$st(S):
?^i in S.ti:i.cancel()
$G(S,n=0):
?S.st();S.cl();S.p=A(S);S.a=[];S.w=[];S.b=[]
?^x in[[i,o]^i in r(30)^o in r(3,10)]:
? if random.randint(0,99)%4==0:S.a.append(Y(S,x))
?S._m();S._af();f=[]
?^x in [6,27,46,65]:f+=[[z,y]^z in r(x,x+6)^y in r(23,26)]
?^i in f:S.w.append(W(S,i))
?S.v+=n;S.z.m='Level %s'%S.v;S.u()
?if S.x>0.2:S.x=1.6 - S.v*0.1
?S.m1=0;S.m2=0;S.k=1;time.sleep(3)
$_m(S):S.Q.put(S.m)
$m(S):
?x=0
?if S.m2:S.m2=0;S.m1=0;S.k=-S.k;x=1
?^i in S.a:i.M(*(abs(S.k),1)if x else(S.k,0))
?if S.m1==47:S.m2=1
?else:S.m1+=1
?S.nt(S.x,S._m)
$B(S):
?^i in S.b:i.M();i.co()
$d(S):
?S.l-=1
?if S.l==0:S.z.m='Game Over!';S.X();return
?S.G(0)
$P(S,n):
?S.c+=n if S.c+n>0 else 0;x=`S.c`
?^n in r(len(x)):S.z.J(n,1,x[n])
G()'''.replace('@','class ').replace('?','  ').replace('$',' def ').replace('^','for ').replace('~','__init__')

what the screen looks like:
Blazer 3
488            |

      YY  Y         YY  Y Y Y     Y
      YY  Y   YY  Y  Y           Y
      Y   Y    Y      Y    YY
                           Y   Y  Y
       YY Y   Y   Y Y             Y
           Y  YY YX Y Y
       Y       Y |                 Y

                   |

         *

                    |

      ####           |     ######             ######             ######
      ######               ######             ######             ######
      ######               ######             ######             ######

                     A

                                   Level 1

edit: managed to remove something I accidentally left in I wasn't using anymore


text:
ASCII Tux (Linux Penguin)
I once hacked upstart on my Ubuntu box so that a colored, themeable ASCII Tux displayed on the screen with the boot messages scrolling beneath him. I'm curious to see what kind of ASCII art Linux Penguins you can come up with.

It must fit in a 80 x 25 terminal, without using the bottom line (thus 80 x 24)
Compact source code
Bonus: use color
Bonus: use variations on the standard Tux

Edit: As a clarification, by "compact source code" I meant smallest source code per number of lines of output. The answers so far have been good but it would be fun to get a diversity of penguins going.

Bonus points for the Windows flag. Penalty points for the Apple apple.

Instead of attempting to print a given penguin, I hacked together a program to reduce ASCII art to a minimum production string in Python. I could do some crazy hacks with metaprogramming the environment to define variables for re-used strings, but this is good enough for now. It's Sunday, what can I say.
ASCII compiler - 882 - Python

#!/usr/bin/env python

import sys, re

d = "".join(sys.stdin.readlines()) # get all text (WARNING... BIG INPUTS POSSIBLE)
d = re.sub(r' +[\r\n]','',d)       # strip trailing spaces
i,j,c,o,f=0,0,d[0],"""#!/usr/bin/python
# -*- coding: UTF-8 -*-
print \"""",False      # set up vars

while (i <= j) and (j < len(d)):   # while the head cursor (j) is in bounds
 if(d[j] == c): j+=1               # if we are in a repetition be gready
 else:
  if c == "\\": c = "\\\\"         # generate repr()s of special case strings
  elif c == "\n": c = "\\n"
  elif c == "\r": c = ""           # bump \n\r
  elif c == "\"": c = "\\\""

  if((j-i)-9 > 0):                 # if the sequence is long enough to justify a repetition
   if(o): o += "\"+"
   o += "\""+c+"\"*{0}+\"".format(j-i)

  else: o += (c*(j-i))             # else just print the sucker
  i = j
  c = d[j]
o += "\""                          # system assumes an open quote at all times, close it

print o

Usage: cat ./tux.txt | python ./encode.py
My Tux - 1009 chars with spaces

                    ..- - .
                   '        `.
                  '.- .  .--. .
                 |: _ | :  _ :|
                 |`(@)--`.(@) |
                 : .'     `-, :
                 :(_____.-'.' `
                 : `-.__.-'   :
                 `  _.    _.   .
                /  /  `_ '  \    .
               .  :          \\   \
              .  : _      __  .\   .
             .  /             : `.  \
            :  /      '        : `.  .
           '  `      :          : :  `.
         .`_ :       :          / '   |
         :' \ .      :           '__  :
      .--'   \`-._    .      .' :    `).
    ..|       \   )          :   '._.'  :
   ;           \-'.        ..:         /
   '.           \  - ....-   |        '
      -.         :   _____   |      .'
        ` -.    .'--       --`.   .'
            `--                --

Compiled Tux - 878 - Python

print " "*20+"..- - .\n"+" "*19+"'"+" "*8+"`.\n"+" "*18+"'.- .  .--. .\n"+" "*17+"|: _ | :  _ :|\n"+" "*17+"|`(@)--`.(@) |\n"+" "*17+": .'"+" "*5+"`-, :\n"+" "*17+":("+"_"*5+".-'.' `\n"+" "*17+": `-.__.-'   :\n"+" "*17+"`  _."+" "*4+"_.   .\n"+" "*16+"/  /  `_ '  \\"+" "*4+".\n"+" "*15+".  :"+" "*10+"\\\\   \\\n"+" "*14+".  : _"+" "*6+"__  .\\   .\n"+" "*13+".  /"+" "*13+": `.  \\\n"+" "*12+":  /"+" "*6+"'"+" "*8+": `.  .\n"+" "*11+"'  `"+" "*6+":"+" "*10+": :  `.\n"+" "*9+".`_ :"+" "*7+":"+" "*10+"/ '   |\n"+" "*9+":' \\ ."+" "*6+":"+" "*11+"'__  :\n"+" "*6+".--'   \\`-._"+" "*4+"."+" "*6+".' :"+" "*4+"`).\n"+" "*4+"..|"+" "*7+"\\   )"+" "*10+":   '._.'  :\n   ;"+" "*11+"\\-'."+" "*8+"..:"+" "*9+"/\n   '."+" "*11+"\\  - "+"."*4+"-   |"+" "*8+"'\n"+" "*6+"-."+" "*9+":   "+"_"*5+"   |"+" "*6+".'\n"+" "*8+"` -."+" "*4+".'--"+" "*7+"--`.   .'\n"+" "*12+"`--"+" "*16+""

Edit 1: Sadly, while this is efficient for large ASCII art files, as with many compression schemes its performance is lackluster to say the least when presented with very small inputs. The "standard" penguin featured thus far "compresses" to 100 chars of Python which while much better than Brainf*ck is still nothing to brag about considering that the penguin itself is a mere 75 chars by my count.
Edit 2: Also as with many compression schemes the incremental gain is minimal. When I tested my compiler against several ASCII files I seem to get a mere 9-10% improvement over the source.
Edit 3: Re: kolmogorov complexity. After some quality time thinking and attempting to golf the base penguin, I have come to the conclusion that the optimal representation is 87 characters long, adding 12 to the actual penguin.
print """    .--.
   |o_o |
   |:_/ |
  //   \ \
 (|     | )
/'|_   _/'\
\___)=(___/"""

The python string repetition syntax for one character, say "a"*5, consumes 4+log10(n) characters in the best case (non-special characters) and 5+log10(n) for characters such as the newline or tab which require the string "\n" not a quoted single char. Therefor to achieve a compression greater than 0%, a character repetition greater than 9 characters in length must exist. (assuming that the repetition is part of a substring which must be terminated with a quote and added to with + and restarted with the same symbols, thus adding 4 to the cost of a repetition) A trivial examination of the penguin above reveals that no such string exists, therefore no compression is possible using string repetition and the best one can do is leverage the tripple quoted string syntax to represent newlines in one char not two.
Edit 4: Fixed edit 3 to reflect the relatively high probability of repetitions internal to some superstring, requiring a repetition like "+'a'*15+" which is of length 6+len(repr(a))-2+log10(n), updated compiler. (the -2 is required because repr() double-quotes everything)
Edit 5: Grabbed the ASCII art collection HERE, and threw together the BASH script below. Pulled a 12% compression average over the entire collection.
#!/bin/bash
l=$(find ./art/ -type f)
len=$(find ./art/ -type f | wc -l)
s=0

for i in $l; do
    chars=$(cat $i | wc -c)
    out=$(cat $i | python ./encode.py | wc -c)
    c=$(calc "1-(($out-42)/$chars)" | sed s/'~'/''/g)
    s=$(calc "$s+$c")
    cat $i | python ./encode.py | python 2> /dev/null
    echo -e "$i, $c\t|$?"
done;
echo $(calc "$s/$len")

Edit 6: Added the UTF-8 specification header to all compiler output and removed those chars from the test script's count because they are spec-required.

Wow, you deserve like a 1000 bonus points.

Many script languages, 6 UTF-8 bytes
It doesn't print ASCII art, but...
""

The character in the quote is the unicode character penguin (U+1F427) (if you want to see the penguin above, download the Symbola font). It looks like this (but a lot smaller):

+1 You deserve the award for shortest overall answer. I love things that are represented in single characters, but I didn't know about this one.

Unicode art!!! We will soon be able to draw a complete zoo with only a short line of code!

Is there a unicode-character for "Hello World"?

@userunknown: With two!!! \uD83D\uDC4B\uD83C\uDF0F == http://www.fileformat.info/info/unicode/char/1f44b/index.htm + http://www.fileformat.info/info/unicode/char/1f30f/index.htm

But that's not Tux! ...Or what diet has he been put on?

-1: Not ASCII art

Haskell - 14 characters
main=putStr"."

The penguin this program displays is in the far distance.

Actually, that penguin is not only in the far background, but also looking away from us.

Looks very similar to the ass hole of a gnu from not that far away, if you ask me ...

Wow...Is it waving ? Can we do this in PHP for 1 byte ?

brainfuck, 311 chars (44.4 sc/ol)
(where "sc/ol" stands for "source characters per output line")
++++++++++[>++++++>++++>++++>+>+++>+++++++++>++++++++++++>+++++++++++
<<<<<<<<-]>>>>>++....<<++++++.-..+.>.>...>>++++.>+.<<+++++.>>.<<<.>>.
<<<.>...>>.<<<<<<--.>>>>>.<<<+.>>.>>.<<<.>..<<..>>...>---.<.>.<<.>.<<
<.>>>>>.<<.....>>.<<.<<<+.>>.<.<--.>>>>>.<+++.<...>.<<<.<.>>>>---.<<.
>>.+++...<<<<++.<+++.>-.>>>>...<<<.

Same tux as CMP:
    .--.
   |o_o |
   |:_/ |
  //   \ \
 (|     | )
/'|_   _/'\
\___)=(___/

I inserted CRs to get rid of the scrollbar, but I didn't count them.
It's most probably still not optimal. I leave the maths to someone else. It's all in the choice of initial numbers/characters (to save increments and decrements) and in which order to place them (to save pointer moves).

I was just trying to find a smaller tux but, without spending too much time, it seems to be the smallest tux-looking tux around. Look at the small ones here, for example: http://www.ascii-art.de/ascii/jkl/linux.txt Not so tuxy.

Brainfuck - 378
++++[>++++++++<-]>[>+>++>+++>++++<<<<<+>-]<[>+<-]++++++++++
>....>++++++++++++++.-..+.<<.
>...>>>>----.-------------.<-.>.<<<<.>>>>+++++++++++++.<<<<<.
>...>>>>.<<------.>.<<+.<.>>>>.<<<<<.
>..>..<...>>>---.<<<.>>>.<<<<.
>.>-------.>>>.<<<<.....>>>>.<<<<.>+.<<.
>>++++++.<+++++++.>>>>.<+++.<<<-------...>>>.<<.<+++++++.>>>---.<<<<.
>>>>.+++...<<------.>+++.<-.>>...<<+++++++.<<.

Prints this:
    .--.
   |o_o |
   |:_/ |
  //   \ \
 (|     | )
/'|_   _/'\
\___)=(___/

Hand coded from an image I found on wikipedia. Unfortunately I have no facility to provide color.

+1 Hand-coded—I like it! Looks good for being so small! Also extremely impressed by the esoteric language (tho mildly offended by its name).

Again, I'm impressed that you managed to write this within two hours.

I really got lucky here. Saw the question right when it popped up, and it is actually not that hard to set up an array of seed values and spit out the proper characters in order.

It prints this, with a 4 * 7 block of spaces to the left. Removing these, you save 28 dots, plus maybe some pointer moves. I'll post my bf version too.

Good point. It saved me just a bit more than 28 because I didn't have to reset the character to space on the final line.

Try:
#!/bin/bash
sudo apt-get install cowsay
echo | cowsay -f tux.cow "Welcome"

This returns the exact same ascii as in the first answer.

Well, it returns the same Penguin, with a dialog box saying "Welcome".

This was inspired by @trinithis's answer with the small penguin in the distance. Getting a little closer, it appears he has turned to the side:
Bash – 7 characters
echo \&

Brainfuck - 446 (441 if omit >>>>>. which prints \n)
++++++++[>++++++>>++++>>>-------->+>++++<<<<<<<<-]>-[->+>>++>++>
++++<<<<<]>>.....>+......>>>++.<<<<....<.>......>>--.>>.>...<<.<
<<.<.>>>.<<..<.>>>.<<.>>>.>.>...<<.<<<...>..<...>>>.>.>...<<.<<<
..<.>..>>.>>>..<<.>.<<<<...<.>.<.>>....>.<<.>>.>>.<<<<..<.>.<.>>
>.<....<<.>>>.<<.>>.>>.<<<<.<.>.<.>........>>.<<.>>.>>.>.<<.>>.<
<.>>........<<.>>.<<.>.<<<<<.>.>>.>.>>........<<.<<<<.>.>>.>>.<.
<<<..>>.<........<<.>..>>>.>.<<.<...<<.>......>>.<...<<.>>>>>.

This prints
     ______
    /      \
   | /\  /\ |
   |   __   |
   |  /  \  |
   / /____\ \
  / /\____/\ \
 / /        \ \
 | |        | |
/ \|        |/ \
|  \________/  |
\___/      \___/

Therefore, it's 37.1667 (36.75 if the code printing last \n is omitted) letters per line.

+1 First answer to use a different Tux. Did you do the ASCII art yourself, or get it from somewhere else? I'm amazed to get so many Brainfuck answers—guess it is really good for code golfing, if you are good enough to use it.

@Kazark Actually, BF is well known for how not good it is for golf. It gets used here often because it is very challenging to hand code, and thus shows off programming ability.

@Kazark I drew this ASCII art myself to minimize number of characters used. I used BrainFuck because it's challenging..

PHP, 1 byte
Tux in a distance
.

Thanks to original by Thomas Eding
Try it online!

What does this do in PHP?

It prints the character to STDOUT @Kazark

source: Stack Exchange

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

sort: votes


text:
Acrostic polyglot programming
The challenge is to write an acrostic piece of code.
When read normally (horizontally), the code should take an input string and remove all but the first character on each line. For example, the input:
float
or and
ord
 line
bool var
auto
real

Output:
foo bar

In addition to this, the code also must contain valid code when run vertically. Such that applying the horizontal code on itself yields a new piece of valid code in a different language.
Rules/Restrictions:

Each horizontal line must contain at least 2 non-whitespace characters
The vertical code cannot use newlines.
The vertical code must be in a different language from the horizontal language, preferably something entirely different
The code does not have to be a complete program (doesn't need main function, etc)

What the vertical code does is up to you, although the goal is to have it do something interesting. Having it do nothing is not interesting.
Easy Mode:

You may use the same language both horizontally and vertically
No restrictions on language choice

Hard mode:

No comments
Both codes should compile and run (main function, etc)
Horizontal code contains exactly 1 word per line

Wow, that looks hard.

I think the main reason this should remain closed - after a conversion to being a golf, is that the second piece of code can do "anything" which isn't very clear.

Brainfuck -> Ruby
e,
v[
a.
l>
"+
a[
=-<,----------
[>
i+
=<
0[-]
]>
*]
3,
e]
4[
;g
"4
+d
$)
<^
.%
b$
y@
ta
el
sD
.{
m[
a}
p]
{.
|d
bA
|:)
{y
?T
.K
,s
"+
pG
up
th
c}
 P
a$
[v
iF
]o
"d
,8
?t
,=
,h
"3
ay
[&
i*
]H
=s
gj
e9
t,
c<
"D
,d
?`
[q
,z
")
wT
hx
ie
lz
eW
 >
a$
[^
i!
];
>Y
0q
"#
,T
?X
]A
,b
"J
e$
n#
ds
"K
,$
?}
<?
,.
"e
iJ
-W
=k
1B
"&
,J
?g
>.
,>
"/
i@
+/
=s
1v
"E
,)
?.
+8
,v
"7
aS
[b
i$
]#
+5
=m
1w
"3
,*
?u
-f
,Z
"I
aW
[U
i%
]3
-v
=T
1E
":
}G
[;
b2
]@
};
*/
"+
;M
"B]

Horizontal is this little gem:
,[.>+[-<,----------[>+<[-]]>],]

And Vertical is this:
eval"a=[i=0]*3e4;"+$<.bytes.map{|b|{?.,"putc a[i]",?,,"a[i]=getc",?[,"while a[i]>0",?],"end",?<,"i-=1",?>,"i+=1",?+,"a[i]+=1",?-,"a[i]-=1"}[b]}*";"

Which is a brainfuck interpreter stolen from this question. It qualifies for all of the hard mode criteria except the no comments bit, which I don't think is really fair to apply to brainfuck, or pretty much nothing but BF->BF would be possible.
Horizontal program runs till EOF(0) is read. Assumes newline at end of file.

Befunge-93 (main program) -> C (vertical program)
 >~:25*-v
m^>>>>v,_@
a^^...~
i^^...:
n^^...2
(^^...5
i^^...*
,^^...-
j^^<<<_$v
)^<<<<<<<
{|
f|
o|
r|
(|
i|
=|
0|
;|
i|
<|
6|
4|
;|
i|
+|
+|
)|
{|
f|
o|
r|
(|
j|
=|
0|
;|
j|
<|
6|
4|
;|
j|
+|
+|
)|
p|
u|
t|
c|
h|
a|
r|
(|
i|
&|
j|
?|
3|
2|
:|
4|
6|
)|
;|
p|
u|
t|
c|
h|
a|
r|
(|
1|
0|
)|
;|
}|
}|

The main program is a Befunge-93 code which does the task and ends by reading a blank line.
The vertical program is in C which prints a Sierpinski triangle of depth 4 with '.' characters.
main(i,j){for(i=0;i<64;i++){for(j=0;j<64;j++)putchar(i&j?32:46);putchar(10);}}

I think I met all rules and restrictions and all items in hard mode. I'm not sure if I didn't use comments. Because comment definition in Befunge is not the same as other languages.
EDITED: added some pipe characters which are vertical condition command in befunge to meet first rule (2 non-whitespace characters in each line) as pointed out by @CMP

Each horizontal line must have 2 non-whitespace characters. Add Jibberish.

Perl -> HQ9+
Any verbose target language results in huge and unreadable code (IMHO), so in the interest of the reader I'll keep it short:
+print/(^.)/for<>

I guess that's an interesting program as HQ9+ programs go... ;)

@mellamokb a very insightful remark.  By increasing the accumulator (which undoubtedly is also an "interesting" HQ9+ program) instead of greeting the world, I can spare a character!  Thanks a lot!

@cemper93 I beg your pardon, but just exactly what rule is being abused here?

I think HQ9+ by its very nature is rule abuse. +1

Well, I guess strictly speaking you abuse the lack of a rule regarding the vertical code's length ;)

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


text:
Write a base X to base Y function
Create a function 'baseXtoY' which:
converts an integer or string n, which is a base x number (hexadecimal, binary, etc)
into a base y number, reliably, including numbers like 10e50 or higher, using the least bytes possible, and using the following constraints:

Provide built-in support for bases up to 64 using the following
sequence: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=/
Provide support for bases higher than 64 by allowing a different sequence to be used in the input
Provide support for multi-byte sequences eg ('aa','bb','cc'...) in cases rally high value bases are needed (could also support unicode instead)
You cannot have a base less than 2. Show an error
You cannot use any built-in functions that convert base to base for you
You need not worry about floating point

parameters should be:

n - any number, as a string
x - the base of n, integer
y - the base of the return value
s1 - the sequence the given number's base uses
s2 - the sequence the desired base uses
b - the bytesize of the digits in s1
return value should be a string

example inputs:
using '88888'
base 10 to 2: baseXtoY('88888',10,2) >>> '10101101100111000'
base 2 to 5: baseXtoY('10101101100111000',2,5) >>> '10321023'
base 5 to 32: baseXtoY('10321023',5,32) >>> '2mpo'
base 32 to 10, using a new sequence, s=the above 64bit sequence, a=the alphabet: baseXtoY('2mpo',32,10,s,a) >>> 'hhhhh'
base 5 to 10, input base uses more than 1 byte per digit: baseXtoY('bbaaddccbbaaccdd',5,10,('aa','bb','cc','dd','ee'),'0123456789',2)) > '88888'`
you do not have to inlude the character length of the testing or input code, just the
function(s).
edit: I've given up trying to shorten my Python code lower than the answers, so I'll just show what I have. 585 characters python 2.7
r=range
def b1(n,x,s):
 if n==0:return s[0]
 if x<=1:raise
 l=[];p=n;i=0
 while 1:
  y=x**i;l.append(y)
  if y>p:break
  else:i+=1
 l.reverse();f=[]
 for p in l:h=int(n//p);f.append(h);n-=h*p
 while f[0]==0:f.pop(0)
 q=''
 for p in r(len(f)):q+=s[f[p]]
 return q
def b2(n,x,s,b):
 n=list(str(n));l=[]
 while n:
  a=''
  for p in r(b):a+=n.pop(0)
  l.append(a)
 m=0;q=0
 while l:c=s.index(l.pop());q+=c*(x**m);m+=1
 return q
s=''.join(map(chr,r(48,58)+r(97,123)+r(65,91)))+'=/'
def baseXtoY(n,x=10,y=2,s1=s,s2=s,b=1):return n if x==y else b2(n,x,s1,b)if y==10 else b1(b2(n,x,s1,b),y,s2)

test cases:
32 10 5 >>> 112
112 5 2 >>> 100000
100000 2 10 >>> 32
88888 10 5 0123456789 ('aa', 'bb', 'cc', 'dd', 'ee') 1 >>> bbaaddccbbaaccdd
bbaaddccbbaaccdd 5 10 ('aa', 'bb', 'cc', 'dd', 'ee') 0123456789 2 >>> 88888

The defaulting makes no sense, and restricts several languages.

Can you elaborate more on what is meant by multi-byte sequences (aa, bb, ..)?

@Pubby: perhaps it could be optional?

@CMP: incase it was impossible for the desired output to be represented by single-byte digits

Also allowing string and int as first argument rules out several languages. May we change this to string-only?

@howard: acceptable. you could also write more than one function if you did desire both int and string compatability, but since this is for shortest code, that's not really needed

I don't understand the "more than one byte" bit. We're in the 21st century: ignoring Unicode and equating bytes with characters is prehistoric.

Can we assume that the bases will always be integers? For example, does the program have to be able to handle conversion from base 6 to base 3.14?

The second last test case has to be '...aaaccdd' instead of '...aaddcc'.

updated the challenge, multi-byte is no longer needed, bases should be integers

Please do not change the task after some people already have answered your question. It is fine to clarify some points or define some corner cases but not such a fundamental change as you did. E.g. the removal of multi-byte would mean a complete rewrite of my code since many things were done with this feature in mind (and I think this is also true for user unknown).

This is also true for user unknown, yes. If you have a new quizzle in mind, open a new one, and prepare it in the chat or in the sandbox- http://meta.codegolf.stackexchange.com/q/423/373 -meta-thread, to handle questions beforehand. Thank you. Clarify the meaning of questions, but don't change them. So long -1 from me.

ack.. I'm new to this. Ineed to be more acquainted with the rules. sorry guys. I'll re-update the qustion to fit the answers already given

So I revoke my downvote and turn it into an upvote.

I've added my own attempt.. I'm never going to beat 128 characters :P. I think it's been long enough to choose the winner

@Mego: This should not be a dupe. Also, regardless of quality, this question was here first (making the newer one a dupe of this one). Personally, I think these questions are dissimilar enough to be left alone.

@ZachGates There is no clear consensus on that post. This much more recent answer of mine has very strong support for closing old challenges as dupes of new ones.

GolfScript, 139 130 128 characters
~]{.,5<{[10,""*26,{[97+]}%""*.{32-}%"=/"+++]+}*}2*.,6<{1+}*~:B;.""?!{1/}*:T;.""?!{B/}*:S;:Y;:X;B/0\{S?\X*+}%;""\{.Y%T=@+\Y/.}do;

Most of the characters come from reading and converting parameters and adding the optional ones. The actual conversion is only few chars.
The example inputs are processed as expected:
'88888' 10 2                      # 10101101100111000
'10101101100111000' 2 5           # 10321023
'10321023' 5 32                   # 2mpo
'2mpo' 32 10                      # 88888
'88888' 10 5 '0123456789' ['aa' 'bb' 'cc' 'dd' 'ee'] 1
                                  # bbaaddccbbaaccdd
'bbaaddccbbaaccdd' 5 10 ['aa' 'bb' 'cc' 'dd' 'ee'] '0123456789' 2
                                  # 88888

Edit 1: some minor improvements, esp. coding the digits sequence.
Edit 2: this was an easy one: 0= can be replaced by ! two times in the conversion of the base parameters.

That's one of the longer GolfScript programs... :P

scala: 399 365 chars:
type S=String
type I=Int
def t(l:List[I],b:I):I=l match{
case x::y=>(x%b)+b*t(y,b)
case Nil=>0}
def f(d:I,b:I):List[I]=if(d==0)List()else f(d/b,b):::List(d%b)
val c=(('0'to'9')++('a'to'z')++('A'to'Z')++Seq('=','/')).map(""+_)
def baseXtoY(a:S,g:I,r:I,i:Seq[S]=c,o:Seq[S]=c,w:I=1):S={
f(t(a.sliding(w,w).toList.map(i.indexOf(_)).reverse,g),r).map(o(_)).mkString("")}

testing code:
baseXtoY ("88888", 10, 2) //"10101101100111000"
baseXtoY ("10101101100111000", 2, 5) // "10321023"
baseXtoY ("10321023", 5, 32) // "2mpo"
baseXtoY ("2mpo", 32, 10) // "88888"
baseXtoY ("88888", 10, 5,"0123456789".map ("" + _).toSeq, "aabbccddee".sliding (2, 2).toSeq, 1) // "bbaaddccbbaaccdd"
baseXtoY ("bbaaddccbbaaccdd", 5, 10, "aabbccddee".sliding (2,2).toSeq, "0123456789".map ("" + _).toSeq, 2) // "88888"

result:
scala> baseXtoY ("88888", 10, 2) //"10101101100111000"
res218: S = 10101101100111000

scala> baseXtoY ("10101101100111000", 2, 5) // "10321023"
res219: S = 10321023

scala> baseXtoY ("10321023", 5, 32) // "2mpo"
res220: S = 2mpo

scala> baseXtoY ("2mpo", 32, 10) // "88888"
res221: S = 88888

scala> baseXtoY ("88888", 10, 5,"0123456789".map ("" + _).toSeq, "aabbccddee".sliding (2, 2).toSeq, 1) // "bbaaddccbbaaccdd"
res222: S = bbaaddccbbaaccdd

scala> baseXtoY ("bbaaddccbbaaccdd", 5, 10, "aabbccddee".sliding (2,2).toSeq, "0123456789".map ("" + _).toSeq, 2) // "88888"
res223: S = 88888

and ungolfed:
def todez (li: List[Int], base: Int): Int = li match {
  case x :: xs => (x % base) + base * todez (xs, base)
  case Nil => 0}
def fromdez (dez: Int, base: Int): List[Int] =
  if (dez == 0) List () else fromdez (dez /base, base) ::: List (dez % base)
def fromTo (li: List[Int], in: Int, out: Int) = fromdez (todez (li.reverse, in), out)

val coding=(('0'to'9')++('a'to'z')++('A'to'Z')++Seq('=','/')).map(""+ _)

def baseXtoY (in: String, f: Int, t: Int, inCoding: Seq[String] = coding, outCoding: Seq[String] = coding, width: Int=1): String = {
  val is = in.sliding (width, width).toList
  val li = is.map (inCoding.indexOf (_))
  val tmp = fromTo (li, f, t)
  tmp.map(outCoding(_)).mkString ("")
}

Scheme type conversions take care of this. The numerical tower too:
(define (f n b) (number->string n b))

Floating points, exceptions... Everything is taken care of. Just put a number and a base and it gets converted to whichever base.

This line will only convert a string representation of a base [2, 16] number to a number type. Isn't it a bit far from spec?

I don't see 6 parameters.


text:
Write the shortest code to match a tail-repeating string where one character falls off the head in each repetition
In this code-golf, you will attempt to match a string that is tail-repeating with one character falling off the head on each iteration. The code needs to be able to accept a string, and return to the user whether the string meets the above criteria.
Examples:
"", "x", and "xx" -> False

EDIT: There is some speculation about whether this is theoretically correct. I will accept any implementation that returns the same value for the three above values as of now. However I do not have an official position on whether this is true or false. Hopefully someone can formalize this.
The above cases will always be false regardless of the circumstance because the string is too short to have the property of tail repetition with one character falling off the head. For example "xx"'s first "tail" would be "x" and there is nothing after the "xx", so it would be false. The character does not matter here, "x" is an example.
"abb" -> True

"abb" is the simplest string I can think of that should be true, because if you take what we will call the "tail" off of it, you get "bb", then knock one character off the head, and you get "b", which is the next character in the string.
"abcbcc" -> True

"abcbcc" is the next simplest string I can think of that should be true. So far in contemplating this problem, testing the truth from the beginning to the end of the string seems difficult, so I'll explain from the end up.
"c", "cb", "cba"

When you examine the string in reverse it seems easier to determine where the "first tail" ends. It ends at the first "c" in "abc", but this can only be inferred from examining the string in reverse, to the best of my knowledge so far.
Here is an example of a string that does not match:
"abcbca" -> False

If we try to apply the above reverse-proof method to it:
"a", "cb"

we realize at the second step when the first character in the second string is not "a", that this must be false.
Shortest code in characters to implement this logic in any programming language wins.
EDIT: If you find a solution other than the suggested one, it is still a valid entry (and very cool!)

Surely x should be accepted? The first string is x; the second is the empty string, so end iteration.

you may be right about this, I would be interested to see someone formalize it

Assume we have defined an alphabet. Let e denote the empty word, a denote a letter in the alphabet, and w denote a word over the alphabet. Define a function f from words of the alphabet to words of the alphabet recursively as f(e) = e and f(aw) = aw f(w). Define the language L over the alphabet as the set of words l for which there exists a word w such that l = f(w). The language you're asking us to accept is the words in L of length at least two, but that's an arbitrary additional constraint.

Brachylog, 8 bytes
aa₁ᶠc?ẹṀ

Try it online!
Takes input through the input variable and outputs through success or failure. I don't quite get why length-zero and length-one initial heads have to have the same output as the very straightforwardly illegal "xx", but fortunately ruling them out only takes two bytes.
    c       The concatenation of
   ᶠ        every
 a₁         suffix (in descending order of length) of
a           some adfix of the input
     ?      is the input,
      ẹṀ    which has multiple elements.

Instead of using a sane algorithm to walk backwards through the input and match each repetition, or determine the initial head from the length of the input then generate the rest and check for equality, this brute-forces the initial head from the set of all adfixes of the input (not just prefixes, because that would be a byte longer).

I doubt this will be beaten

Python
Used the fact that the length of a valid string will always be a Triangle Number.
t=raw_input()
x=int(len(t+t)**.5)
print t==''.join(t[i:x]for i in range(x))

A Ruby solution might be shorter, will post soon.

very insightful

I don't think you need the 0 on 0.5

You can also use int((2*len(t))**0.5) which save quite some chars.

Or int(len(t+t)**.5) which is even shorter.

But unfortunately you have to add another check: "" and "x" yield true in your implementation.

@Howard, i think the OP changed the specification. :D and thanks for that golfing optimization. :D

@Howard, On second thought, can you describe the line entirely, i didn't quite get your short version. I understand you did a sqrt(2t) but what about the + 1 and - 1

Howard's version works on the basis that int(sqrt(x * (x+1))) == x for positive integer x. So the line just needs to be x=int(len(t+t)**.5)

@PeterTaylor, Aah, makes sense now. Thanks.

You can save a few characters if you use Python 3.

GolfScript, 25 chars
.,,{1$<..,{(;.@\+\}*;}%?)

NB This requires the most recent version of Golfscript, which supports a string array ? indexof function.
This implements the interpretation whereby "" and "x" are not in the language, which IMO is a funny way to define it. It is a statement which takes one argument on the stack and leaves an integer which can be interpreted as a boolean in standard GolfScript fashion (i.e. 0 for false, anything else for true). To turn this into a full program prepend n- and postpend some suitable manipulation depending on what output you want (e.g. "true""false"if).

Going to have lo learn golfscript now :)

Ruby, 63 characters
t=->x{b="";x.size>1&&(b,x=$2+b,$1while x=~/(.*)(.)#{b}/;x=="")}

This method returns true iff the string fits the definition.
Usage:
p t["abcbbc"]  # -> false
p t["abcbcc"]  # -> true

Perl regex, 24 69
^.(.+)(?{$a=$+})((??{"\Q$a"})(?{$a=substr$a,1}))*(?(?{''eq$a})$|(*F))

Obviously not a genuine CS regular expression, but those modern recursive regexes can work wonders and the edited (but fixed) version is not that short at all.  I'm starting to wonder if actual Perl code, with the ability to reverse the starting string, wouldn't be shorter than that.

wonderful, I initially thought of this problem while practicing regex but could not grasp how to do it yet. I'm in the middle of reading mastering regex 3rd ed.

Ah, I was too fast with my upvote. Although it is a great approach also this regex fails on input like aaaaa.

@Howard fixed.  At a huge cost. :(

Haskell, 48 characters
import List
f x=any((==x).concat.tails)$inits x

Brute force. Note that this returns true for f "x" and f "".
Example usage in GHCi:
> f "abb"
True
> f "abcbcc"
True
> f "abcbca"
False

VBA, 113 characters
Adding my 2 VBA cents...
Function t(s)
k=Right(s,Len(s)-1)
t=Round(Len(k)/2)
If t>0 Then If Left(k,t)<>Right(k,t) Then t=t(k)
End Function

This returns a 1 or 0.
Usage is MsgBox t("abcbcc"), or to get a "True"/"False" outsput, use MsgBox CBool(t("abcbcc"))

You can get this down to 97 bytes as Function t(s)
k=Right(s,Len(s)-1)
t=Len(k)\2
If t*(Left(k,t)<>Right(k,t))Then t=t(k)
End Function

C, 191 bytes
That's the best I can golf this in C:
main(){char a[9],*b=a,p[9],c=0,i=strlen(gets(a)),j=0,k=0;p[0]='\0';while(i>=0){b[strlen(b=a+(i-=++j))-k]='\0';k=strlen(b);if(strcmp(p,b+1)&&c++)exit(puts("false"));strcpy(p,b);}puts("true");}

165 bytes

Pyth, 33 22 bytes
This is my second attempt on Pyth :)
qz_jk.__<z/t@+1*8lz2 2
                       print(
q                       is_equal(
 z                       input(),
  _                       reverse(
   jk                      concat(
     ._                     all_prefixes(
       _                     reverse(
        <z                    input()[:
          /t@h*8lz2 2          divide(decrement(root(increment(multiply(8,len(z))),2)),2)
                                ])))))

Previous attempt:
KJ<z/t@+1*8lz2 2;WnkJ=K+K=JtJ;qKz

Try it online!
How it works:
KJ<z/t@+1*8lz2 2;WnkJ=K+K=JtJ;qKz
                                    z=input()
KJ<z/t@+1*8lz2 2                    K=J=z[:(root(1+8*len(z),2)-1)/2]
  <z                                    z[:
       +1*8lz                                    1+8*len(z)
      @      2                              root(          ,2)
     t                                                        -1
                 WnKJ               while not_equal(k,J):
                     =K+K=JtJ        K=plus(K,J=tail(J))
                              qKz   equal(K,z)

Element, 40 characters
_)#3:s;m;$'[m~)#4:m;$'[(#2:'."]#s~=[1`]]

This is a language of my own creation. It is designed so that all operators are one character long and always perform the same function. This allows the programs to be much shorter than many other programming languages. In some challenges, however, I must program something for which there is no built-in function, causing the program to grow in size. Element has no built-in regex matching of any kind, so I think that I actually did pretty well on this challenge.
This is a complete program that will take one line of input as the string to test, and it will print a 1 for true and nothing for false.
As for why I am answering code golf questions in Element, it is partially to raise awareness, partially a publicity stunt, and partially an exercise to test the language.
A description of Element can be found here, and the (hopefully working) source of an interpreter for Element (written in Perl) can be found here.

Scala 113:
def t(s:String):Boolean={
val k=s.tail
val l=k.size
if(l<2)false else
if(k.take(l/2)==k.drop(l/2))true else
t(k)}

Takes rekursively the rest of the string, and tests whether first half equals second.
ungolfed:
def tailrepeating (s: String): Boolean = {
  val k=s.tail
  if (k.size < 2) false else
  if (k.take (k.size /2) == k.drop (k.size / 2)) true else
  tailrepeating (k) }

bash 111
#!/bin/bash
s=$1
l=${#s}
for i in $(seq 1 $((l-2)))
do
test "${s:i:$(((l-i)/2))}" = "${s:$(((l+i)/2))}"&&exit 0
done||false

111 chars without shebang.
Invocation:
./tailrepeated.sh foobalaa && echo "true" || echo "false"

C (gcc), 80 bytes
i,j,k,l;f(b,e)char*b;{for(i=j=k=e<2;e--;k|=l?i-=++j:b[e]-b[j+e])l=++i>j;b=!k*l;}

Try it online!
Rejects "x" and "". -1 if "x" can be accepted, and another -1 if "" is ok as well.

Here is my own un-golfed answer in C for testing.
#include <stdio.h>
#include <string.h>
#include <assert.h>

int tailrep(char *str, char *sub, int sublen, int len) {
    if (str == sub) {
        return 1;
    }

    int i;
    for (i = 0; i < sublen; i++) {
        char *a,  *b;
        a = str + len - sublen;
        b = sub + sublen - 1;

//        printf("%p->%c %p->%c\n", a - i, a[-i], b - i, b[-i]);
        if (a[-i] != b[-i]) {
            return 0;
        }
    }

    return tailrep(str, sub - sublen - 1, sublen + 1, len - sublen);
}

int istailrep(char *str) {
    int len = strlen(str);
    if (len < 3) {
        return 0;
    }
    return tailrep(str, str + len - 1, 1, len - 1);
}

int main() {
    // must be false
    assert(!istailrep(""));
    assert(!istailrep("a"));
    assert(!istailrep("aa"));
    assert(!istailrep("aab"));
    assert(!istailrep("abcbbc"));
    assert(!istailrep("abcdabcdabcd"));

    // must be true
    assert(istailrep("aaa"));
    assert(istailrep("abb"));
    assert(istailrep("abcbcc"));
    assert(istailrep("abcdbcdcdd"));
    assert(istailrep("abcdebcdecdedee"));
    printf("yay\n");
    return 0;
}

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


text:
Optimal short-hand roman numeral generator
Goal:
Write a function that takes a number as input and returns a short-hand roman numeral for that number as output.
Roman Numeral Symbols:
Symbol  Value
I       1
V       5
X       10
L       50
C       100
D       500
M       1,000

For an example of what I mean when I say "short-hand roman numerals", let's consider finding a roman numeral to represent 1983, because that is the year I was born.  One option is to do this the normal way (10 letters):
1983 = MCMLXXXIII = (1000 - 100 + 1000 + 50 + 30 + 3)
The other option is to do it the short-hand way (6 characters):
1983 = MXVIIM = (1000 - (10 + 10) + 1000 + 3)
Do you know what this means?!?!!??  If I was roman I could have saved 4 characters every single time I wrote my birth date!  Woot Woot!!
However, before I get ahead of myself in excitement, I have a question to write, so I should probably define the short-hand roman numeral rules so we are all on the same page:
Short-Hand Roman Numeral Rules:

Always consider symbols from left to right until there are no more characters to consider.
If there are no higher-valued symbols to the right of the current symbol:

Add the value of the current symbol to the running total of this roman numeral.

If there are higher-valued symbols to the right of the symbol you are considering:

Locate the rightmost highest-valued symbol to the right of the current symbol
Consider all the characters up to that symbol as one roman numeral
Calculate the value of that roman numeral using these steps
Subtract the value of that roman numeral from the running total of this roman numeral.
Move to the next symbol after the group you just considered

Each roman numeral must have at least 1 symbol in it.
That's it!  Anything following these rules will be accepted!

Examples:
IIIIV = (-(1+1+1+1)+5) = 1  //Don't ask me why you'd want to do this!

VVX = (-(5+5) + 10) = 0  //Who said you couldn't represent 0 with roman numerals?!!?

VVXM = (-(-(5+5) + 10) + 1000) = 1000  //Again...don't ask me why you'd want to do this!

MXIIXMI = (1000-(10-(1+1)+10)+1000+1) = 1983  //Ahhh...such a great year :)

Question Rules:

Make a function that takes a single number as input and returns a roman numeral for that number as output using the above rules.  Calculate the codeGolfScore of this function.
example input: 2011
example possible output: MMXI
another possible output: MMVVIVV     //(2000 + 10 - 4 + 5)

Using your function from rule 1, generate the roman numerals between -1000 (that's right, NEGATIVE one-thousand) and 3000.  Then sum up the character length of these roman numerals to get your totalCharacterCount.  Here's some pseudocode to clarify:
totalCharacterCount = 0;
for(currentNumber = -1000; currentNumber <= 3000; currentNumber++){
    totalCharacterCount += getRomanNumeral(currentNumber).length;
}
return totalCharacterCount;

finalScore = codeGolfScore +  totalCharacterCount
Lowest finalScore wins!

Note:  As the totalCharacter count will be in the ten-thousands+, the character-length algorithm should be top priority.  Code-golf scores are just the tie-breaker in case multiple users find the optimal algorithm or algorithms that are close to each other.
Good luck, and have fun at your MMXII celebrations tomorrow night!!!

Great task! However, could you give an example of how a negative roman shorthand looks like? Does DDDDM stand for -1000?

@pimvdb You got it!

A question regarding the special case zero: Is "" allowed for zero or do we have to use VVX or something equivalent?

@Howard:  Great question, I hadn't thought of that!  I've added roman numeral rule 4 for which clarifies that case.

"Locate the rightmost highest-valued symbol to the right of the current symbol" -- which wins, rightmost or highest-valued?  i.e., is IXV = -(-1 + 10) + 5 = -4 (rightmost wins), or IXV = -1 + 10 + 5 = 14 (highest-valued wins)?

@KeithRandall I think it must be latter. Otherwise it would have to read "rightmost higher-valued".

@KeithRandall:  Highest value wins, so IXV = 14, and IXVX =-14+10= -4.

Is IDC as well as DIC allowed for 599 (499+100 vs. 500+99)?

@userunknown: Yep, both are allowed.

C++, 345 characters of code, 25021 roman numeral digits = 25366
int N[]={1,5,10,50,100,500,1000};int V(int s,int L){if(!L)return 0;int K=0,B,m=s%7+1;for(int k=1,b=7;k<L;k++,b*=7){if(s/b%7>=m){K=k;B=b;m=s/b%7;}}return K?V(s/B,L-K)-V(s%B,K):N[s%7]+V(s/7,L-1);}char r[99];char*f(int n){for(int L=1,B=7,i,j;1;L++,B*=7){for(i=0;i<B;i++){if(V(i,L)==n){for(j=0;j<L;j++){r[j]="IVXLCDM"[i%7];i/=7;}r[L]=0;return r;}}}}

deobfuscated a bit, with a driver:
int N[]={1,5,10,50,100,500,1000};
int V(int s,int L){
  if(!L)return 0;
  int K=0,B,m=s%7+1;
  for (int k=1,b=7;k<L;k++,b*=7) {
    if(s/b%7>=m){K=k;B=b;m=s/b%7;}
  }
  return K ? V(s/B,L-K)-V(s%B,K) : N[s%7]+V(s/7,L-1);
}
char r[99];
char *f(int n){
  for(int L=1,B=7;1;L++,B*=7) {
    for(int i=0;i<B;i++) {
      if(V(i,L)==n){
        for(int j=0;j<L;j++) {
          r[j]="IVXLCDM"[i%7];i/=7;
        }
        r[L]=0;
        return r;
      }
    }
  }
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
  printf("%s\n", f(atoi(argv[1])));
}

V computes the numerical value of a given roman numeral string s of length L.  Strings are encoded base 7 (first digit is s%7, second digit is s/7%7, ...).  Each digit is encoded with I=0, V=1, ..., M=6.  f does a brute-force enumeration of possible roman numeral strings to find one that V evaluates to n.
The total number of roman numeral digits is optimal.  The longest roman numeral needed for [-1000,3000] is 11 digits (e.g. -827=CMDDMLXXIII), which takes about 5 minutes on my machine.

Wait a moment, that doesn't behave the way specified. Your program gives e.g. LMCLXXIII as the answer to -777. I'd read that as -50+1000-100+50+10+10+3 = 923 ≠ -777, only with "rightmost higher -valued" instead of "highest" does it give -777. But that was just what you asked for in the comments!

@leftaroundabout: of course you are right.  I'll fix it, but no time right now...

@leftaroundabout: ok, all fixed.

All right. It's not optimal now, though (e.g. gives VVVXI for -4 when IXVX is actually shorter, as I just noticed) – but that's perfectly legal.

@leftaroundabout: ok, fixed again.  Hopefully it is correct this time...

Haskell, 25637 (= 268 + 25369) 26045 (= 222+25823)
r 0="VVX"
r n=s(zip[1000,500,100,50,10,5]"MDCLXV")n ξ
ξ='ξ'
s[]q f
 |q<0=s[](5-q)f++"V"
 |q<1=""
 |r<-q-1='I':s[]r f
s ω@((v,a):l)q f
 |q>=v,f/=a=a:s ω(q-v)ξ
 |f==a,γ<-'I':a:s l(q-v+1)ξ,η γ<η(s l q ξ)=γ
 |f==ξ,γ<-s ω(v-q)a++[a],η γ<η(s l q ξ)=γ
 |True=s l q ξ
η=length

to be used as e.g.
GHCi> r 7
"VII"
GHCi> r 39
"XIL"
GHCi> r (-39)
"ICXLC"        --  "LLXILC" in my original version
GHCi> r 1983
"MXVIIM"
GHCi> r 259876
"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMCXXIVM"

You can evaluate the length sum with the straightforward
GHCi> sum . map(length.r) $ [-1000..3000]
25369

Which takes something in the order of a minute.

Ruby, 25987 (= 164 + 25823)
h=->i,d,v,k{i==0?'':i<v ?(a=h[v-i,x=d[1..-1],v/k,k^7]+d[0];i<0?a:(b=h[i,x,v/k,k^7];a.size<b.size ? a :b)):d[0]+h[i-v,d,v,k]}
r=->i{i==0?'DDM':h[i,'MDCLXVI',1000,2]}

You can call r directly to get the results. The sum over the specified range yields
> (-1000..3000).map{|i|r[i].size}.reduce &:+
25823

which is the optimal sum as with the other solutions.

C# 23537 (639 characters of code + 22898 characters of output)
class M
{
    public static string R(int n, int? s = new int?())
    {
        var r = "";
        var D = new Dictionary<int, string> {{ 1000, "M"}, { 900, "CM"},{ 800, "CCM"},{ 500, "D"}, { 400, "CD"},{ 300, "CCD"},{100, "C"}, {90, "XC"},{80, "XXC"},{50, "L"}, {40, "XL"}, {10, "X"}, {9, "IX"}, {8, "IIX"}, {5, "V"}, {4, "IV"},{1, "I"}};
        if (n == 0) return "VVX";
        if (n == -1) return "IIIIIIV";
        if (n < 0) return N(n * -1);

        foreach(int k in D.Keys)
        {
            if (s.HasValue && k > s) continue;

            while(k <= n)
            {
                n -= k;
                r += D[k];
            }
        }

        return r;
    }

    public static string N(int n)
    {
        var D = new Dictionary<int, string> {{1, "I"}, {5, "V"}, {10, "X"}, {50, "L"}, {100, "C"}, { 500, "D"}, {1000, "M"}};

        int i = D.Keys.First(v => v >= n), m = D.Keys.Where(v => v < i).Max();

        return R(n + i, m) + D[i];
    }
}

To Calculate:
Enumerable.Range(-1000, 3000).Sum(i => M.R(i).Length);

And what's your score?


text:
Print the amount of ones in a binary number without using bitwise operators
Description
Given a number, print the amount of 1s it has in binary representation.
Input
A number >= 0 in base 10 that won't exceed the highest number your language is able to handle.
Output
The amount of 1s in binary representation.
Winning condition
The shortest code wins.
Disallowed

Bitwise operators. Other operators, like addition and multiplication, are allowed.
Built-in base conversion functions.

Examples
Input:     Ouput:

56432      8

Input:     Output:

45781254   11

Input:     Output:

0          0

Are functions allowed? I want to make a Java solution, but writing full code is too tedious... :/

I guess I won't be using Wise for this challenge... :)

APL, 9 12 characters
+/2|⌊⎕÷2*⍳32

This assumes that the interpreter uses 32-bit integers, and that ⎕IO is set to 0 (meaning that monadic ⍳ begins with 0, rather than 1). I used the 32-bit version of Dyalog APL.
Explanation, from right to left:

⍳32 generates a vector of the first 32 integers (as explained before, because ⎕IO is 0, this vector begins with 0).
* is the power function. In this case, it generates 2 to the power of each element of the vector supplied as its right argument.
÷ is the divided-by function. It gives us ⎕ (evaluated user input) divided by each element of the vector to its right (each power of two).
⌊ floors each element of the argument to its right.
2| gives us the remainder of each element of to its right divided by 2.
/ reduces (folds) its right argument using the function to its left, +.

Not quite 9 characters anymore. :(
Old, rule-breaking version:

+/⎕⊤⍨32/2

Explanation, from right to left:

32/2: Replicate 2, 32 times.
⍨ commutes the dyadic function to its left, which in this case is ⊤ (i.e., X⊤⍨Y is equivalent to Y⊤X).
⊤ is the encode function. It encodes the integer to its right in the base given to its left. Note that, because of the commute operator, the right and left arguments are switched. The base is repeated for the number of digits required, hence 32/2.
⎕ is a niladic function that accepts user input and evaluates it.
+/ reduces (folds) its right argument using +. (We add up the 0's and 1's.)

Doesn't this break the Built-in base conversion functions contraint?

Whoops! Missed that one.

Gah! Thought I'd given myself a fighting chance with my J program! :-) Nice job.

@Gareth: I didn't realize until reading your explanation just now, but my answer is pretty much identical to yours! I guess that could be expected from APL and J. :)

Brainbool, 2
,.

The most reasonable interpretation, in my opinion (and what most of the answers use) of "highest number your language is able to handle" is "largest number your language natively supports". Brainbool is a brainfuck derivative that uses bits rather than bytes, and takes input and output in binary (0 and 1 characters) rather than character codes. The largest natively supported number is therefore 1, and the smallest is 0, which have Hamming weights 1 and 0 respectively.
Brainbool was created in 2010, according to Esolang.

I knew it must have existed, but it took me an hour of sorting through Brainfuck derivatives on Esolang to find Brainbool.

Wow, this post was before the loophole was created!

Brainfuck, 53 characters
This was missing an obligatory Brainfuck solution, so I made this one:
[[->+<[->->>>+<<]>[->>>>+<<]<<<]>>>>[-<<<<+>>>>]<<<<]

Takes number from cell 1 and puts the result into cell 6.
Unenrolled and commented version:
[  while n != 0
  [  div 2 loop
    -
    >+<  marker for if/else
    [->->>>+<<]  if n != 0 inc n/2
    >
    [->>>>+<<]  else inc m
    <<<
  ]
  >>>>  move n/2 back to n
  [-<<<<+>>>>]
  <<<<
]

J, 13 characters
(+ the number of digits in the number)
+/2|<.n%2^i.32

Usage: replace the n in the program with the number to be tested.
Examples:
+/2|<.56432%2^i.32
8
+/2|<.45781254%2^i.32
11
+/2|<.0%2^i.32
0

There's probably a way of rearranging this so the number can be placed at the beginning or end, but this is my first J entry and my head's hurting slightly now.
Explanation(mainly so that I understand it in the future)
i.32 - creates an array of the numbers 1 to 32
2^ - turns the list into the powers of two 1 to 4294967296
n% - divides the input number by each element in the list
<. - rounds all the divison results down to the next integer
2| - same as %2 in most languages - returns 0 if even and 1 if odd
+/ - totals the items in the list (which are now just 1s or 0s)

I'll be happy to upvote this once it reads from stdin (or whatever equivalent J has).

The best I could do I think (maybe, depending on figuring out how) is move the input to the end of the program. Standard input isn't mentioned in the question though?

I'm sorry for not specifying the way of input. It would be unfair to change the rules now, so I'll accept this one. I will mention it next time!

@pimvdb No problem, it wasn't a complaint. I think with J programs though all you can do is define a verb that operates on the input given it. Not sure how I'd rearrange this to do that though. Maybe JB or one of the other J experts could help me out with that...

...and having read some more I now see that I was completely wrong about standard input.

I declined on this one.  J's got a 2-char convert-to-base-two verb, and nobody would agree on whether that counts as a bitwise operation or not.  (J 4-char answer would then be: +/#.)

@J B Conversion functions are disallowed.

@Gareth You can use the !: verb. IIRC input from stdin was 2!:1 and output was 2!:2 or something similar.

Python 2.6, 41 characters
t,n=0,input()
while n:t+=n%2;n/=2
print t

note: My other answer uses lambda and recursion and this one uses a while loop.  I think they are different enough to warrant two answers.

Ruby, 38 characters
f=->u{u<1?0:u%2+f[u/2]}
p f[gets.to_i]

Another solution using ruby and the same recursive approach as Steven.

GolfScript, 17 16 characters
~{.2%\2/.}do]0-,

Edit: new version saves 1 character by using list operation instead of fold (original version was ~{.2%\2/.}do]{+}*, direct count version: ~0\{.2%@+\2/.}do;).

C, 45
f(n,c){for(c=0;n;n/=2)c+=n%2;printf("%d",c);}

Nothing really special here for golfing in C: implicit return type, implicit integer type for parameters.

Perl, 45 43 36 Characters
$n=<>;while($n){$_+=$n%2;$n/=2}print

Thanks to Howard for 45->43, and to User606723 for 43->36.

You might use $n=int($n/2) which 2 characters shorter.

Are we sure we need the int()? $n=<>;while($n){$_+=$n%2;$n/=2}print This will keep looping until $n/2 finally gets close enough to 0, but do we care? ;)

@user606723 I just tried that out and it seems to work perfectly, at least for every case up to 1000.

Python 2.6, 45 characters
b=lambda n:n and n%2+b(n/2)
print b(input())

Can be shortened by two characters by using def instead of a lambda.

@KonradRudolph: Actually, you lose the advantage once you include the return statement.

Oops, I forgot that. Stupid.

You don't need the print b(input()). It is acceptable to return the value and take "input" as arguments for functions.

Perl, 30 chars
$==<>;1while$_+=$=%2,$=/=2;say

Based on PhiNotPi's solution, with some extra golfing.  Run with perl -M5.010 to enable the Perl 5.10 say feature.

Does the $= special variable do anything special in your program, or is it just another ordinary variable?

@PhiNotPi: $= only takes integer values, so using it saves me an int.

Shouldn't the command-line arg be part of the char count?

@SohamChowdhury: Not per this meta thread.

C, 61 60 57 53 characters
void f(x){int i=0;for(;x;x/=2)i+=x%2;printf("%u",i);}

The function body only is 38 characters. Edit: removed bitwise operator Edit: put printf out of the loop as suggested in the comments Edit: switch to K&R declaration; also, this is no longer C99-specific

I see bitwise!!!

I'm sorry but the AND operator also counts as a bitwise operator.

@M.Joanis: duh, thanks for noticing. Fixed.

I think you could spare a few characters if you switched to K&R C.  If you're ok with that.

You could shorten this by four characters by moving the printf out of the loop.

@marinus: good catch; that's only 3 characters unfortunately since it requires to put the declaration of i out of the loop, too.

Why void ? Let f be implicitly int (5 chars). Also, f(x,i) defines i, and there's no problem calling f(5) (2 chars). EDIT - noticed GigaWatt's answer, which does exactly this.

Common Lisp, 12 chars
(assuming a 1 char variable name - i.e.: 11 + number length)
It's not a base conversion function, so it should work:
(logcount x)

Examples:
[1]> (logcount 0)
0
[2]> (logcount 1)
1
[3]> (logcount 1024)
1
[4]> (logcount 1023)
10
[5]> (logcount 1234567890123456789012345678901234567890)
68

(Using GNU CLISP.)

Hm well, not exactly what I had in mind to see as an answer :) I don't think I can accept this. It's basically just another case of this.

C, 66 characters
main(int n,char **a){printf("%u",__builtin_popcount(atoi(a[1])))};

Note: requires gcc or gcc-compatible compiler (e.g. ICC, clang).
For some CPUs __builtin_popcount compiles to a single instruction (e.g. POPCNT on x86).

Is it correct that __builtin_popcount actually just implements the counting of 1s itself? If so, although it's not strictly wrong according to the rules I honestly don't think this is a fair entry.

You should probably stipulate this in the question if you want to disallow entries that take advantage of built-in capabilities of a given language or compiler.

This is not legal C++ because in C++ you cannot omit the return type on main, nor use printf without prior include.

@celtschk: fair point - edited out the C++

dc – 26 chars
This is rather long, mostly due to the lack of loop constructs in dc.
0?[d2%rsi+li2/d0<x]dsxx+p

Keeps adding up the modulo 2 of the number and dividing the number by to until it reaches zero. Can handle arbitrarily long integers.
Example:
$ dc -e '0?[d2%rsi+li2/d0<x]dsxx+p' <<< 127
7
$ dc countones.dc <<< 1273434547453452352342346734573465732856238472384263456458235374653784538469120235
138

D (70 chars)
int f(string i){int k=to!int(i),r;while(k){if(k%2)r++;k/=2;}return r;}

JavaScript, 78 72 71 characters
I'll post my initial solution which I came up with before posting the question as well. There is already a much better JavaScript answer though :)
for(n=prompt(a=0),j=1;j<=n;j*=2)for(i=j;i<=n;i+=2*j)n<i+j&&a++;alert(a)

http://jsfiddle.net/Mk8zd/1/
The idea comes from certain "mind reading cards" which enable you to obtain the number someone else has in mind, by showing them cards and let them say on which cards their number is apparent.
It works because each number is a unique combination of 1s / 0s in binary. My solution checks on which "cards" the number is apparent so as to determine how many 1s it has. It's just not very efficient, though...
I found this document which outlines the mind reading technique.

Haskell (60 chars)
f n=sum[1|x<-[0..n],odd$n`div`2^x]
main=interact$show.f.read

PHP, 57
$i=$s=0;for(;$i<log($n,2);){$s+=$n/pow(2,$i++)%2;}echo$s;

This assumes that $n holds the value to be tested.
PHP, 55 (alternative solution)
function b($i){return$i|0?($i%2)+b($i/2):0;}echo b($n);

Again, this assumes that $n holds the value to be tested. This is an alternative because it uses the or-operator to floor the input.
Both solutions work and do not cause notices.

Ocaml, 45 characters
Based on @Leah Xue's solution. Three spaces could be removed and it's sligthly shorter (~3 characters) to use function instead of if-then-else.
let rec o=function 0->0|x->(x mod 2)+(o(x/2))

Mathematica 26
Count[n~IntegerDigits~2,1]

Java 7, 36 bytes
int b(Long a){return a.bitCount(a);}

Because of course this, of all things, is something that Java has a builtin for...

Doesn't this fit under "built-in base-conversion functions", which are banned?

@Flp.Tkc I'm not actually doing base-conversion. I have no idea how bitCount operates under the hood.

this seems like just using a bulitin to do the job, but ok...

@Flp.Tkc That's... exactly what it is? I'm even including all required libraries (there aren't any). This is demonstrating the strength of the language! related meta

386 opcode, 10 Bytes
2BC0                       SUB EAX,EAX
01C9                       ADD ECX,ECX
1400                       ADC AL,0
41                         INC ECX
E2F9                       LOOP $-5
C3                         RET

Thank Peter Cordes for 1B save and 1B rule save

You can just write a function that returns a value in AL, avoiding the out.  Also use 2-byte adc al, 0.  But good use of inc/loop as a 3-byte replacement for test ecx,ecx/jnz.  And BTW, you could include another version that does popcnt eax, ecx / ret, for CPUs with that feature.

Vyxal l, 49 bits1, 6.125 bytes
ʀEṗ'∑?=;f

Try it Online!
Brute force solution, so the online interpreter times out. May potentially be made shorter by porting others, but I thought this solution was fun
ʀ         # range 0..input+1
 E        # raise 2^n for each value in that range
  ṗ       # powerset
   '   ;  # filtered by
    ∑     # the sum
     ?=   # is equal to the input?
        f # flatten
          # after which the l flag takes the length of the top of the stack and implicitly outputs it

JavaScript, 49 47 45 42 bytes
for(n=prompt(o=0);n=n/2|0;o+=n%2);alert(o)

Demo: http://jsfiddle.net/hcYdx/4/
Edit 1: remove q and use ~~ for rounding, save 2 chars.
Edit 2: use |0 rounding operator instead of ~~ to save parentheses (2 chars).
Edit 3: simplify n>0 to n and combine with n=n/2|0 to make entire condition; now have wasted statement space :(

Isn't the |0 a bitwise operator?

Technically yes.  But i'm using it purely to round to the nearest int, so I'm not getting any bit-wise benefit :)

Smells like bending the rules to me... but I'm not the judge.

Input 1 gives output 0.

| is bitwise operator... it is disallowed. Time to do Math.round :-)

Scala, 86 characters
object O extends App{def f(i:Int):Int=if(i>0)i%2+f(i/2)else 0
print(f(args(0).toInt))}

Usage: scala O 56432

R, 53 characters
o=function(n){h=n%/%2;n%%2+if(h)o(h)else 0};o(scan())
Examples:
> o=function(n){h=n%/%2;n%%2+if(h)o(h)else 0};o(scan())
1: 56432
2:
Read 1 item
[1] 8
> o=function(n){h=n%/%2;n%%2+if(h)o(h)else 0};o(scan())
1: 45781254
2:
Read 1 item
[1] 11
> o=function(n){h=n%/%2;n%%2+if(h)o(h)else 0};o(scan())
1: 0
2:
Read 1 item
[1] 0

If inputting the number is not part of the character count, then it is 43 characters:
o=function(n){h=n%/%2;n%%2+if(h)o(h)else 0}
with test cases
> o(56432)
[1] 8
> o(45781254)
[1] 11
> o(0)
[1] 0

 OCaml, 52 characters
let rec o x=if x=0 then 0 else (x mod 2) + (o (x/2))

Scheme
I polished the rules a bit to add to the challenge. The function doesn't care about the base of the number because it uses its own binary scale. I was inspired by the way analog to numeric conversion works. I just use plain recursion for this:
(define (find-ones n)
  (define (nbits n)
    (let nbits ([i 2])
      (if (< i n) (nbits (* i 2)) i)))
  (let f ([half (/ (nbits n) 2)] [i 0] [n n])
    (cond [(< half 2) i]
      [(< n i) (f (/ half 2) i (/ n 2))]
      [else (f (/ half 2) (+ i 1) (/ n 2))])))

Isn't reading a number into binary or printing the number from binary a "builtin base conversion function", thus invalidating every answer above that prints an integer?  If you permit reading and printing an integer, like almost all the above answers do, then I'll make claims using a builtin popcount function :
Haskell, 50
There was a popCount routine added to the Data.Bits module for GHC v7.2.1/v7.4.1 this summer (see tickets concerning the primop and binding).
import Data.Bits
main=interact$show.popCount.read

I cannot beat the above Python and Perl scores using their GMPY or GMP::Mpz modules for GMP sadly, although GMP does offer a popcount function too.

JavaScript, 57 55 51 50 bytes
a=prompt(b=0);while(a){b+=a%2;a=(a-a%2)/2}alert(b)

Modulo is not bitwise operator ☺

| is a bitwise operator...

I can't golf it further...

I think you can replace the while with a for.

The problem is how? I just don't know ;)

for(a=prompt(b=0);a;){...}

for(a=prompt(b=0);a;a=(a-a%2)/2)b+=a%2;alert(b)

sed, 100 bytes
:
s/[13579]/&;/g
y/123456789/011223344/
s/;0/5/g
s/;1/6/g
s/;2/7/g
s/;3/8/g
s/;4/9/g
/[1-9]/b
s/0//g

Output is in unary; if you want it in decimal, pipe through wc -c or append the following converter (GNU sed -r):
# unary to decimal
:d
s/;;;;;/v/g
s/vv/x/g
s/x([0-9]|$)/x0\1/
s/;;/b/g
s/bb/4/
s/b;/3/
s/v;/6/
s/vb/7/
s/v3/8/
s/v4/9/
y/;bvx/125;/
td

This implements successive division by 2, accumulating carry-out as output.  It is able to handle fairly large inputs; for example I tested the all-ones 8192-bit input thus:
$ dc <<<'2 8192^1-p' | tr -d '\\\n' | ./4434.sed | wc -c
8192

and the mostly-zeros of similar length:
$ dc <<<'2 8192^p' | tr -d '\\\n' | ./4434.sed | wc -c
1

TI-Basic (TI-84 Plus CE), 30 bytes
Prompt X
0→S
While X
S+remainder(2,X→S
int(X/2→X
End
S

TI-Basic is a tokenized language, all tokens but remainder( are one-byte, remainder is two

Welcome to the site!

PHP, 36 bytes
while($n){$o+=$n%2;$n/=2*1;}echo $o;

Assumes $n is the number to be tested, shows a PHP Notice for $o, and doesn't exactly work when $n is 0 (outputs nothing).
PHP, 53 bytes
$n=$argv[1];$o=0;while($n){$o+=$n%2;$n/=2*1;}echo $o;

Accepts command-line input, doesn't show a PHP Notice, and outputs correctly for 0.

Welcome to the site! :)

Forth (gforth), 37 bytes
: f dup 0> if 2 /mod recurse + then ;

Try it online!
Usually recursion isn't worth it when golfing Forth because it requires the if, then, (possible else), and recurse words. In this case we can do without else and we save more in stack-manipulation than we lose from recursion
Explanation

If n is greater than 0, get quotient and remainder of dividing n by 2.
Call recursively on quotient
Add remainder to result

Code Explanation
: f         \ start new word definition
  dup       \ duplicate top stack value
  0> if     \ if top stack value is greater than 0
    2 /mod  \ get quotient and remainder of dividing by 2 (quotient on top of stack)
    recurse \ execute current word
    +       \ add remainder to result of recursion
  then      \ end if statement
;           \ end word definition

MathGolf, 12 bytes
æ_╫`¡▲ÞÄ½↑;î

Try it online!
This fails for input 0, due to a bug in MathGolf. I'll explain why. But I thought it was a fun solution to this problem that might not be obvious.
This method could be seen as disallowed, but I refer to wikipedia: "The bit shifts are sometimes considered bitwise operations, because they treat a value as a series of bits rather than as a numerical quantity" (emphasis mine). I have chosen to interpret this to mean that MathGolf's bitshifts are allowed, since they don't operate on a fixed number of bytes. Bit rotating in MathGolf wraps the current number of bits in the number, and rotates using the bit width of the number. Thus, if you do this enough times, any number with \$n\$ set bits will converge to \$2^n-1\$. If you then divide the result by 2 until you reach 0, the number of divisions will represent the number of ones in the original number.
The reason that this fails for 0 is that 0 is somehow turned into 1 when left-rotated. This is a bug in the implementation of the operator, rather than this program itself, and should be fixed in an upcoming update.
Explanation
æ    ▲         do-while true using 4 operators
 _             duplicate TOS
  ╫            left-rotate bits in int, list/str
   `           duplicate the top two items
    ¡          push a, b, push a != b
               This do-while loop repeats until the left-rotated
      Þ        not implemented yet
       Ä       start block of length 1
        ½      pop a : push(a//2 if int else a/2)
         ↑     while true without popping
          ;    discard TOS
           î   index of current loop (1-based)

awk,  65 bytes
__=$(_^=___=_<_){++_;do{___+=__%_}while(__=int(__/_))}$!NF=___ ""

Example:
echo "56432\n45781254\n0" |

mawk '__=$(_^=___=_<_){++_;do{___+=__%_}while(__=int(__/_))}$!NF=___ ""'

8
11
0

Thunno 2 L, 8 bytes
LOʠæS=;Ḟ

Port of emirps's Vyxal answer.
Explanation
LOʠæS=;Ḟ  # Implicit input
LO        # Push 2 ** [0..input)
  ʠ       # Powerset of this list
   æ  ;   # Filtered by:
    S=    #  Sum equals the input
       Ḟ  # Flatten this list of lists
          # L flag gets the length
          # Implicit output

Screenshot

Python (48 without spaces, 65 with)
x = int(raw_input())
s = 0
while x:
    if x%2:
        s+=1
    x/=2
print s

My first ever submission on CodeGolf. Wish I had thought of eliminating the if before I saw @Steve Rumbalski's answer

Op, 23 19 (discontinued language of my invention)
0N[1~!?@2%{1+}2/])I

Here's a commented version:
0 # push a 0 onto the stack
N # read an integer from STDIN onto the stack
[ # begin an infinite loop
    1 # push a 1 onto the stack
    ~ # pop the 1 off the stack, and duplicate the top 1 items (i.e. the read number)
    ! # pop a number, push 1 if 0 or 0 otherwise (NOT)
    ? # pop a number, if the number is nonzero...
    @ # ... then break out of the infinite loop. Basically, break out when N reaches 0.
    2 # push a 2 onto the stack
    % # pop number "a" off the stack, then number "b", and push b modulo a.
    { # rotate the stack left
    1 # push a 1 onto the stack
    + # pop a and b, and push a + b (increment)
    } # rotate the stack right
    2 # push a 2 onto the stack
    / # pop number "a" off the stack, then number "b", then push b / a (int)
] # repeat back to start of loop
) # shift the stack right, taking off the 0 and leaving only the result
I # output the result as a number to STDOUT

excel, 35
=LEN(A1)-LEN(SUBSTITUTE(A1,"1",""))

This solution only provides the number of non-zero symbols in an input, and does not provide for the conversion to base 2, meaning that for the input 511 this provides the output 1 rather than the output 9. You should compare your output to that of =LEN(SUBSTITUTE(DEC2BIN(A1),0,)) (which is disallowed because of the builtin function DEC2BIN)

GolfScript - 21
~{.2%{0):0;}*2/.}do;0

Python 2, 25 bytes
lambda n:n and n%2+f(n/2)

Try it online!

Pushy, 12 bytes
$&2%v2/;O_S#

Try it online!
While the input is bigger than 0, it has its least significant bit (using mod) pushed to the second stack, then it is halved (integer division). Once all bits have been placed on the second stack, it is summed and the result is printed.

SNOBOL4 (CSNOBOL4), 66 bytes
	X =INPUT
I	O =O + REMDR(X,2)
	X =GT(X) X / 2	:S(I)
	OUTPUT =O
END

Try it online!

JavaScript, 43 Bytes, assuming 1/2/2/2/...=0
for(a=prompt(b=0);a;a/=2)b+=a%2>=1;alert(b)

J, 32 Bytes
There's probably a more mathematical way to do this that doesn't require finding the binary representation, but I thought this was pretty good none the less:
+/@:((}:,(|~2:)@{:,<.@-:@{:)^:])

Explanation:
+/@:((}:,(|~2:)@{:,<.@-:@{:)^:])  | Full program
    (                          )  | Convert to binary list:
     (                     )^:]   | do n times:
      }:                            | Curtail the list
        ,(|~2:)@{:                  | Append the remainder mod 2 of the item dropped
                  ,<.@-:@{:       | Append the floor of half the item dropped
+/@:                                | Sum

A step by step example:
    (}:,(|~2:)@{:,<.@-:@{:) 7
1 3
^ ^
| |
| Floor 7/2
7 % 2

    (}:,(|~2:)@{:,<.@-:@{:) 1 3
1 1 1
^ ^ ^
| | |
| | Floor 3/2
| 3 % 2
The input curtailed

    ((}:,(|~2:^#)@{:,<.@-:@{:)^:]) 7
1 1 1 0 0 0 0 0

    +/@:((}:,(|~2:)@{:,<.@-:@{:)^:]) 7
3

Of course, you would only have to do this Ceil(log2 n) times, but thats a lot harder to calculate than just n.

Make sure you’re not using a built-in base converter, as that is forbidden in the challenge specifications.

brainfuck, 34 bytes
>+<[[>-]++[>]+[<]>-]>[-<[->+<]>>]<

Try it online!
At 53 bytes, I thought the existing brainfuck solution was way too long /s. Starting cell contains the number and ends on the number of binary digits in it. Doesn't work for numbers above 255 unless you use an interpreter with larger than 8 bit or infinite cells.
How It Works
>+<[[>-]++[>]+[<]>-] Converts the number to binary
>[-<[->+<]>>]<       Adds all the numbers in the binary together

><>, 20 bytes
0$:&0=?n&:2%:}-2,@+!

Try it online!

dc, 14 bytes
[2~rd0<M+]dsMx

Try it online!
Input is taken from the stack, output is left on the stack. This is the same general idea as the previous dc entry (repeatedly reduce mod 2 and add remainders), but optimizing by using non-tail recursion makes a huge difference (I'd have made this a comment on that entry, but the user hasn't been active for over a year).


text:
Convert from binary to negabinary
Given a binary integer inclusively between 0 and 1111111111111111 (i.e. a 16-bit unsigned integer) as input, output the same integer in negabinary.
The input can be in whatever format is most convenient for your language; for example, if it is easier for the program to handle input with 16 digits, like 0000000000000101, rather than simply 101, you can write the program to only accept input that way.
Sample I/O
> 1
1
> 10
110
> 1010
11110
> 110111001111000
11011001110001000
> 1001001
1011001

Here is a sample program I wrote that does base conversions, including negative and non-integer bases. You can use it to check your work.

Just to clarify a bit further, the input and output would have to be binary, right? I mean: character strings of 0s and 1s. Looks clear to me, but an answer makes me doubt lightly...

@M.Joanis The input is binary, the output is negabinary (which looks exactly the same as binary--a string of zeroes and ones--but the way the number is interpreted is different.)

The link appears to be down, which is a prime reason for why we require questions to be self-contained these days

APL, 21 characters
'01'[-(16/¯2)⊤-2⊥⍎¨⍞]

I used Dyalog APL for this, with ⎕IO set to 0, allowing us to index arrays starting at 0 rather than 1.
Explanation, from right to left:

⍞ gives us the user's input as a character vector.
⍎¨ applies the execute function (⍎) to each (¨) of the aforementioned characters, resulting in a vector of integer 1's and 0's.
2⊥ decodes the vector from base 2 into decimal.
- negates the resulting decimal integer.
(16/¯2)⊤ encodes the decimal integer into base ¯2 (negative 2). (16/¯2 replicates ¯2, 16 times, yielding 16 digits in our negabinary number.)
- negates each element of our newly encoded number (before this, it consists of -1's and 0's), so that we can use it to index our character vector.
'01'[ ... ] indexes the character array ('01') using the 0's and 1's of the negated negabinary vector. This is so we get a prettier output.

Example:
      '01'[-(16/¯2)⊤-2⊥⍎¨⍞]
10111010001
0001101011010001

Ruby, 32 31 characters
m=43690
'%b'%(gets.to_i(2)+m^m)

Uses the negabinary calculation shortcut.

The input isnt hard coded. The 0xAAAA isnt the input, its the mask thats gonna transform the input. 0xAAAA is equivalent to 1010101010101010, which is used in a XOR operation to convert binary into negabinary.. The input itself comes from the gets keyword, which fetches from STDIN.

changed 0xAAAA to 43690 (which is the same number in decimal) to decrease character count by 1. Makes it harder to understand wtf is happening though.

Ah, okay. I don't ruby good so I wasn't sure. Sorry about that.

GolfScript, 34 29 27 characters
n*~]2base{.2%\(-2/.}do;]-1%

A plain straigt-forward approach. It is quite interesting that the shortest version is the one which first converts to number and then back to base -2 (at least the shortest version I could find up to now). But the nice thing about this one is, that it contains almost 15% %.
Edit 1: For base 2 we can save one modulo operation and also join both loops.
Edit 2: I found an even shorter code to convert binary string to integer.

Haskell, 86 83  Bytes
import Data.Bits
import Data.Digits
c n|m<-0xAAAAAAAA=digits 2$xor(unDigits 2 n+m)m

Call using c and then an integer array for digits, e.g.
c [1,1]

PS: I'm new, did I submit this correctly?
EDIT: Saved some bytes thanks to Laikoni and also fixed some typos
EDIT2: Alternatively, c :: String -> String:
import Data.Bits
import Data.Digits
c n|m<-0xAAAAAAAA=concatMap show.digits 2$xor(unDigits 2(map(read.(:[]))n)+m)m

For 114 bytes (but you call it with a string: c "11")

Yes, you did! Welcome to the site! Hope you stick around!

Welcome to PPCG! You can drop the parentheses around undigits 2 n, because the function application binds stronger than the +m. You can also save some bytes by binding m in a guard: c n|m<-0xAAAAAAAA= ....

Python (2.x), 77 characters
(not as short as the other solutions due to the need to manually switch base...)
Should satisfy the requirements.
i=input();d=""
while i:i,r=i//-2,i%-2;i+=r<0;d+=`r+[0,2][r<0]`
print d[::-1]

Suggestions for further improvements are welcome!
Feed it with starting values like this:
0b1001001

JavaScript, 68 bytes
function(b){for(r='',n=parseInt(b,2);r=(n&1)+r,n>>=1;n=-n);return r}

Would be 52 bytes in ES6, but that post-dates the challenge:
b=>eval(`for(r='',n=0b${b};r=(n&1)+r,n>>=1;n=-n);r`)

Jelly, 4 bytes, language postdates challenge
Ḅb-2

Try it online!
Takes input, and produces output, as a list of digits.
Explanation
Ḅb-2
Ḅ     Convert binary to integer
 b-2  Convert integer to base -2

This is pretty much just a direct translation of the specification.

I missed that. I'll put a note in the header.

k, 17 bytes noncompeting
Some of the features used probably postdate the challenge.
1_|2!{_.5+x%-2}\2/

Input is a list of 1's and 0's, and output is also a list of 1's and 0's.

PHP, 69 Bytes
for($i=bindec($argn);$i;$i+=$i%2&$c,$i>>=1,$c^=1)$r=($i%2).$r;echo$r;

Online Version

ES8, 54B
b=>eval`for(r='',n=0b${b};r=(n&1)+r,n>>=1;n=-n);r`

Japt, 4 bytes
Input as a binary string, output as a negabinary digit array.
Íì2n

Try it
Or, taking input as a binary digit array:
ì2JÉ

Try it

05AB1E, 4 bytes
C2(в

Try it online!


text:
The group of sequential positive numbers with the highest sum?
Given the following list of numbers, find the group of
sequential positive numbers with the highest sum.
Example input:
12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1

Example output:
131

The most succinct code wins.
My approach via Perl is 87 chars (with input as command-line args):
print((sort { $b <=> $a } do { push @s, $_ > 0 ? pop(@s) + $_ : 0 for @ARGV; @s })[0]);

This lacks an objective winning criterion. Also, as the rules are, I could just print 179 and have a valid solution.

Wouldn't it give 131? 20+9+76+5+4=114 and 19+80+32=131

possible duplicate of Find largest sum of subsequence

not duplicate, since the other question is not restricted to positive ints.

@userunknown right idea, wrong words. The other problem uses an UNSIGNED INT generator, this uses standard INTs.

@rmckenzie: I guess you're wrong. See example: printf "1\n2\n-1\n4\n" | ./sum \\ \n 6. He shifts the values in the end. You may jump over negative values, if you gain more points with the value on the other side, than it costs, to pick the negative value, while here, it is an absolute barrier, which you can't cross.

Sorry @cemper93, what could I have said to make it more clear? I figured it was self-explanatory.

@M.Joanis yes, you're right, the example input line got pasted incorrectly, .... sorry about that.

@userunknown, you're right that it's not a perfect duplicate, but it's so close that it's not worth having as a separate challenge.

@Al Newkirk: You should specify which solution will be the winner.  If this shall be the solution with the least characters (standard code-golf), please add a code golf tag. Also, don't say "use the following input", but specify something like "the input will be on standard input, and use the following input to test your submission".

@userunknown I stand corrected.

@AlNewkirk: I copyedited your post a bit, and removed the second copy of the example input.  Could you please check that I didn't accidentally change the meaning of what you wrote.  Also, as cemper93 notes, you really should clarify the winning criterion and tag your post accordingly (as [tag:code-golf] or [tag:code-challenge] for example).

Why did you accept M42's solution which isn't the shortest?

Perl: 56 53 characters
Thanks to Ilmari Karonen
push@s,$_>0?$_+pop@s:0for@ARGV;say+(sort{$b-$a}@s)[0]

Can be golfed down to 53: push@s,$_>0?$_+pop@s:0for@ARGV;say+(sort{$b-$a}@s)[0]

@IlmariKaronen: Yes, nice use of $b-$a in sort.

APL, 35 characters
i←⎕⋄⌈/{{+/⍵/⍨∧\⍵>0}⍵↓i}¨0,(i≤0)/⍳⍴i

I used Dyalog APL for this. ⎕IO should be set to its default of 1.
Example (note that high-minus, ¯, must be used instead of regular minus):
      i←⎕⋄⌈/{{+/⍵/⍨∧\⍵>0}⍵↓i}¨0,(i≤0)/⍳⍴i
⎕:
      12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1
131

Explanation (roughly right-to-left for each expression):

First, we get (and evaluate) the input: i←⎕. (⋄ separates expressions in a single statement.)
(i≤0)/⍳⍴i is an idiom to get the list of the locations of elements of i that are ≤0.

i≤0 returns a vector of binary values, where each element is 1 if the corresponding element in i is ≤0, and 0 otherwise.
⍳⍴i returns a list of integers, from 1 to the shape (length) of i.
The replication function, /, replicates each value in its right argument n times, where n is the corresponding element in its left argument. Because we have a binary list, this just includes or excludes elements (replicating them 0 or 1 times).
We tack a 0 on the beginning, using the concatenation operator (,).

Now, using the example input, we have the vector 0 4 10 12 16. We use the each operator, ¨, to map a function (its left operand) to each element of this list.
The function is a direct function (basically, an anonymous function), and its definition is surrounded with curly braces. Its right argument is represented by the omega symbol, ⍵.
For each element of our vector:

The outermost function, {{ ... }⍵↓i}, returns the vector i, with ⍵ elements dropped (↓) from the beginning. This is then fed to...
The innermost function, {+/⍵/⍨∧\⍵>0}, in slightly less golfed form is {+/(∧\⍵>0)/⍵}.
(∧\⍵>0)/⍵ is similar to the aforementioned idiom. First we generate a list of elements in ⍵ that are above 0. Then, we use the scan operator, \, along with the bitwise-AND function, ∧, to return the list (⍵1 , ⍵1 ∧ ⍵2 , ⍵1 ∧ ⍵2 ∧ ⍵3 , ...). In other words, this list consists of 1's up until the first non-positive element, where it is then all 0's. We use replication as before.
We now use the reduction operator, (also) represented by /, along with the addition function, +, to fold all positive elements in the current list, up to (but not including) the first non-positive one.

Lastly, we fold again, this time with the maximum function, ⌈.

Here are snapshots showing the results of some stages:
      i≤0
0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1

      ⍳⍴i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

      0,(i≤0)/⍳⍴i
0 4 10 12 16

      {⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  4 ¯5 19 80 32 ¯1  19 80 32 ¯1

      {{(∧\⍵>0)}⍵↓i}¨0,(i≤0)/⍳⍴i
 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0  1 1 1 1 1 0 0 0 0 0 0 0  1 0 0 0 0 0  1 1 1 0

      {{(∧\⍵>0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35  20 9 76 5 4  4  19 80 32

      {{+/(∧\⍵>0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
49 114 4 131 0

Hopefully some of this makes a bit of sense!

How about ⌈/{{+/⍵/⍨∧\⍵>0}⍵↓i}¨0,(i≤0)/⍳⍴i←⎕ for a size reduction by two characters?

CJam, 16 byte
This answer is not eligible for the green checkmark, as CJam is much newer than this challenge (and this answer relies on even newer features). However, I thought this was a really neat approach (and hey, I'm beating APL by quite a margin!), so I wanted to post it anyway.
l~]0fe>0a%::+$W=

Test it here.
Explanation
l~]              "Read input, eval, wrap in array.";
   0fe>          "Map max(0,x) onto the list, turning all non-positive numbers into 0.";
       0a%       "Split the list on zeroes - i.e. split into positive subarrays.";
          ::+    "Map a fold of + onto the array - i.e. compute the sum of each subarray.";
             $W= "Sort and get the last element - i.e. the maximum.";

K is an APL variant. You have won by only 4 bytes.

@user23013 I know it is... Doesn't mean I haven't beaten one member of the APL family by a considerable margin ;) (also even those four bytes are 20% which isn't exactly close)

But that might be because I'm not bothered to post a longer answer in APL... Still 27% shorter, though.

Python 3, 93 80 79 71 chars
a=b=0
for i in map(int,input().split()):b+=i;b*=i>0;a=max(a,b)
print(a)

Thanks to D C for pointing out how to save 8(!) characters from this:
a=b=0
for i in map(int,input().split()):b+=i;a=[a,b][b>a];b=[0,b][i>0]
print(a)

Saved one character by indexing by true/false rather than if statements.
It is much less readable than the equivalent 80 char version:
a=b=0
for i in map(int,input().split()):
 b+=i
 if b>a:a=b
 if i<=0:b=0
print(a)

The 93 character version converted to int later in the game:
print(max(sum(map(int,s.split()[1:]))for s in('-1 '+input().replace(' 0','-1')).split('-')))

You can shave 8 characters off by replacing b+=i;a=[a,b][b>a];b=[0,b][i>0] with b+=i;b*=i>0;a=max(a,b).

@DC: Awesome improvement!  Thank you.  I especially like multiplying by the result of the conditional.

Python 3 (92)
Reads the list of numbers from stdin.
m,s=0,[]
for x in map(int,input().split()):
 if x<0:s+=[m];m=0
 else:m+=x
print(max([m]+s))

You are missing a few chars and throwing an error as a result, 1input() has to be be raw_input(). Also, 0 is not considered positive so instead of x<0, you could just have x. Otherwise this seems to have hit Kolmogorov for python.

@rmckenzie: raw_input was renamed input in Python 3.  The Python 2 meaning of input was dropped.

I knew I was missing something....

Perl, 45 chars
say+(sort{$b-$a}map$p=$_>0?$_+=$p:0,@ARGV)[0]

(Uses say, so needs to be run with perl 5.10+ and the -M5.010 (or -E) switch.)

APL, 22 20
⌈/∊(+\×{∧\0<⍵})¨,⍨\⎕

To test it online:
{⌈/∊(+\×{∧\0<⍵})¨,⍨\⍵}

Try it here.
Explanation
{                ,⍨\⍵}    ⍝ Get a list of reversed prefixes.
        {  0<⍵}           ⍝ Check if each item is >0.
        {∧\0<⍵}           ⍝ Check if each prefix is all >0.
     +\                   ⍝ Sum of each prefix.
    (+\×{∧\0<⍵})          ⍝ Sum * all>0 for each prefix.
{   (+\×{∧\0<⍵})¨,⍨\⍵}    ⍝ Apply that to each reversed prefixes (So the prefixes of
                          ⍝   reversed prefixes are reversed suffixes of prefixes of
                          ⍝   the original string).
{  ∊(+\×{∧\0<⍵})¨,⍨\⍵}    ⍝ Flatten the array.
{⌈/∊(+\×{∧\0<⍵})¨,⍨\⍵}    ⍝ Find the maximum.

Japt -hx, 9 6 bytes
-3 bytes from @Shaggy
ô<0 ñx

Try it online!

6 bytes. Apologies for all the comments; trying to do too many things at once!

@Shaggy Don't worry, this helps me get better. Thanks

Racket, 108 chars
Once golfed, it gives 133 chars with intermediary "f", or 108 if you use "g" directly.
(define f
  (λ (l)
    (g l 0 0)))

(define g
  (λ (l M c)
    (cond
      ((null? l) (max M c))
      ((> 0 (car l)) (g (cdr l) (max M c) 0))
      (else
       (g (cdr l) M (+ (car l) c))))))

(f '(12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1)) ;-> 131

Where "l" is the list of values, "M" is the maximum sum yet encountered, and "c" is the current sum.
Golfed:
(define f(λ(l)(g l 0 0)))(define g(λ(l M c)(cond((null? l)(max M c))((> 0(car l))(g(cdr l)(max M c)0))(else(g(cdr l)M(+(car l)c))))))

Scala: 102 chars
def s(x:Seq[Int],y:Int=0):Int={
if(x==Nil)y else
if(x(0)<0)math.max(y,s(x.tail))else
s(x.tail,y+x(0))}

val data = List (12, 2, 35, -1, 20, 9, 76, 5, 4, -3, 4, -5, 19, 80, 32, -1)
s(data)

ungolfed:
def sumup (xs: Seq[Int], sofar: Int=0): Int = {
  if (xs.isEmpty) sofar else
  if (xs.head < 0) sofar + sumup (xs.tail) else
  sumup (xs.tail, sofar + xs.head)
}
sumup (List (12, 2, 35, -1, 20, 9, 76, 5, 4, -3, 4, -5, 19, 80, 32, -1))

K, 20
{max@+/'1_'(&x<0)_x}

Finds the indices where x<0, cuts the list at those indices, drops the negative numbers, sums and finds the maximum.
k){max@+/'1_'(&x<0)_x}12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1
131

Equivalent in q:
{max sum each 1_'(where x<0)_x}

05AB1E, 8 bytes
Œʒß0›}Oà

Try it online.
Explanation:
Œ           # Get all sub-lists of the input-list
            #  i.e. [2,4,-5,7]
            #    → [[2],[2,4],[2,4,-5],[2,4,-5,7],[4],[4,-5],[4,-5,7],[-5],[-5,7],[7]]
 ʒ   }      # Filter this list of lists by:
  ß         #  Take the smallest value of the inner list
            #   i.e. [4,-5,7] → -5
   0›       #  Check if it's larger than 0
            #   i.e. -5>0 → 0 (falsey)
 O          # Take the sum of each remaining item
            #  i.e. [[2],[2,4],[4],[7]] → [2,6,4,7]
  à         # And take the maximum of the sums
            #  i.e. [2,6,4,7] → 7

Perl6 with MoarVM, 53 chars
@a[$_ <0??++$i-$i!!$i||++$i]+=$_ for lines;@a.max.say

PHP, 56 bytes
while(~$n=$argv[++$i])$n<0?$k++:$r[$k]+=$n;echo max($r);

Run with -nr.

Java 8, 72 62 bytes
l->{int c=0,m=0;for(int i:l){c=i>0?c+i:0;m=m<c?c:m;}return m;}

Try it online here.
Ungolfed:
l -> { // lambda taking a List as argument and returning an int
    int c = 0, m = 0; // two sums: c is the sum of the current run of positive integers; m is the maximum sum found so far
    for(int i : l) { // for each element in the list:
        c = i > 0 ? c + i : 0; // if the number is positive, extend the current run by adding it to the sum; otherwise reset the sum to zero
        m = m < c ? c : m; // if the maximum recorded so far is smaller than the current sum, record the current sum as the new maximum
    }
    return m; // return the maximum
}

C (gcc/tcc), 69 bytes
c,m;f(int*a,int*b){c=m=0;for(;a<b;++a){c=*a>0?c+*a:0;m=m<c?c:m;}a=m;}

Port of my Java answer. Try it online here.

66 bytes

Perl 5 +-pa -MList::Util+(max), 28 bytes
$_=max map/-/?$-=0:$-+=$_,@F

Try it online!