text:
It's election time!
It's time... to count the votes!
Today there are local elections in my entire country. Here, the number of seats for each party is decided using the D'Hondt method. Your goal is to implement a program or function that will decide how many seats each party gets, in the shortest amount of bytes.
For this method there are a fixed number of seats to distribute, and it's done like so:

Every party is assigned a variable number, which starts at the number of votes it got.
Then the first seat is given to the party who has the biggest value in their variable and then that value for that party becomes their total number of votes divided by 1+seats, rounded down, where seats is the number of seats it already has (so after getting the first, their votes are divided by 2, and by 3 after getting the second seat).
After that the parties votes are compared again. The process continues until all the seats have been assigned.

If the highest number is a tie between two or more parties, it is resolved randomly (It has to be random, it can't just be the first of the two in the list).
Input
You will receive a number N, which will indicate the number of seats available, and a list of the votes each party received, in whatever format you prefer. Example:
25
12984,7716,13009,4045,1741,1013

Output
You should output a list of the seats each party got. In the example above it would be something like
8,5,9,2,1,0

They should be in the same order as the parties in the input.
Examples
5
3,6,1

outputs: 2,3,0

135
1116259,498124,524707,471681,359705,275007,126435

outputs: 45,20,21,19,14,11,5

Bonus
-20% bonus if take the parties name as input and give them in the output, like for example:
25
cio:12984,pcc:7716,irc:13009,icb:4045,cub:1741,bb:1013

outputs

cio:8
pcc:5
irc:9
icb:2
cub:1
bb:0

I feel we already did something like this

I couldn't find anything alike in the search... But if you find anything I will change it or remove the question, no problem!

@rcrmn There is something wrong with your last example. Maybe you meant 153 total seats instead of 135.

@Tyilo Right! I wrote it wrong in my test program and copied the answers without double-checking. It's fixed now. Thank you!

@rcrmn You also might want to add all the possible outputs that a program should be able to produce from 5 2,3,1.

Does this method use integer of floating point division?

Integer arithmetic, or floating point rounding down, I updated it to clarify.

Regarding the output for the bonus: Do we have to display the parties in this particular order? Also, do we have to display parties with 0 seats?

Finally, can we assume that the parties' names contain only letters?

Thanks @Jakube , that was a problem with the program I used to calculate, which returned the output ordered in seats with labels. Dennis you can return it in any order, since the label works as an identifyer. You can assume it only has letters if it's easier for you.

Splendid, thanks. bb:0 has to be displayed though, yes?

Yes, all parties should be displayed.

Related: http://codegolf.stackexchange.com/questions/12466/preferential-voting

@Oxinabox How are they similar, apart from being voting systems?

They are similar as they are both voting systems, with a kind of (interesting) reallocation component. It may be the question that edc65 was thinking of. (Sorry, I accidentally typed possible duplicate, I mistyped.)

Oh okay, I was just surprised because I couldn't see where the duplication was. Thanks for the link though

CJam, 35.2 28.8 28.0 26.4
q2*~,m*mr{~)f/1=~}$<:(f{1$e=1\tp}

This full program is 33 bytes long and qualifies for the bonus.
Try it online in the CJam interpreter.
Example run
$ cjam seats <<< '[["cio"12984]["pcc"7716]["irc"13009]["icb"4045]["cub"1741]["bb"1013]]25'
["cio" 8]
["pcc" 5]
["irc" 9]
["icb" 2]
["cub" 1]
["bb" 0]

How it works
q2*~   e# Repeat the input from STDIN twice. Evaluate.
       e# STACK: Array seats Array seats
,      e# Range: seats -> [0 ... seats-1]
m*     e# Take the cartesian product of the array from the input and the range.
mr     e# Shuffle the array. This makes sure tie breakers are randomized.
{      e# Sort by the following key:
  ~    e#     Dump: [["party" votes] number] -> ["party" votes] number
  f/   e#     Divide each: ["party" votes] number -> ["party"/number votes/number]
  1=   e#     Select: ["party"/number votes/number] -> votes/number
  ~    e#     Bitwise NOT.
}$     e#
<      e# Keep only the elements that correspond to seats.
:(     e# Shift each array.
       e# RESULT: S := [[number] ["party" votes] [number] ["party" votes] ...]
f{     e# For each A := ["party" votes]:
       e#     Push S.
  1$   e#     Push a copy of A.
  e=   e#     Count the occurrences of A in S.
  1\t  e#     Replace the vote count with the number of occurrences.
  p    e#     Print.
}      e#

Pyth, 36 bytes - 20% = 28.8
J<_hCo/@eCQhNheN.S*UQUvzvz.e,b/JkhCQ

This qualifies for the bonus.
Try it online: Demonstration or Test harness
Explanation:
                                       implicit: z = 1st input (as string)
                                                 Q = 2nd input (evaluated)

                      vz               evaluate z (#seats)
                     U                 generate the list [0,1,...,seats-1]
                   UQ                  generate the list [0,1,...,len(Q)-1]
                  *                    Cartesian product of these lists
                .S                     shuffle (necessary for break ties randomly)
     o                                 order these tuples N by:
        eCQ                               list of votes
       @   hN                             take the N[0]th vote count
      /      heN                          and divide by N[1]+1
   hC                                  extract the party index of the tuples
  _                                    reverse the list
 <                      vz             take the first #seats elements
J                                      and store them in J

                          .e     hCQ   enumerated map over the names of the parties
                                       (k = index, b = name):
                            ,             generate the pair:
                             b/Jk            name, J.count(k)
                                       print implicitely

J is unnecessary. You can get rid of it and save 2 bytes.

Also, if you swap z and Q, and then save Cvz to K, you can save another byte.

@isaacg Nope, it is very important. Because of the shuffling the expression might yield different results in .e and it messes up the counting.

Actually, the second tip doesn't work either, sorry, because I missed the UQ.

I did it without the party names in 24 bytes, substantially based off of your program. Should I put it as a comment here, or as a separate answer?

@isaacg Post it as an answer.

Javascript, 210 bytes
v=(a,b,c,d,e,f,g)=>{d=Object.assign({},b),c={};for(g in b)c[g]=0;for(;a--;)e=0,f=Object.keys(d),f.forEach(a=>e=d[a]>e?d[a]:e),f=f.filter(a=>d[a]===e),f=f[~~(Math.random()*f.length)],d[f]=b[f]/-~++c[f];return c}

Notes:

Requires a modern browser/engine with support for ES6. Tested in Firefox.
Uses the very important /-~++ operator :)

Example usage:
v(25, {cio:12984,pcc:7716,irc:13009,icb:4045,cub:1741,bb:1013})

It's not necessary to declare all of your variables as arguments.

Yes, but I wanted to avoid polluting the global scope of possible

JS golf is all about polluting the gobal scope :)

I've golfed your method down to 168 bytes. Sorry for mangling the variable names. F=(N,X)=>{for(t=[o={}],[t[o[j]=0,j]=X[j]for(j in X)];N--;t[z=y[new Date%y.length]]=X[z]/-~++o[z])m=0,y=[(m=m<t[j]?t[j]:m,j)for(j in X)],y=y.filter(j=>t[j]==m);return o}

Pyth - 54 bytes
AGZQ=kZK*]0lZVGJhOfqeTh.MZZ.e(kb)Z XJK1 XZJ/@kJ+@KJ1;K

Input format (stdin):
[25,[12984,7716,13009,4045,1741,1013]]

Output format (stdout):
[8, 5, 9, 2, 1, 0]

Variables used:
G = total number of seats
K = array of seats currently assigned to each party
k = number of votes for each party
Z = k/(K+1)
J = which party should have the next seat

Use vz and Q instead of G and Z. This way you will save the assignment with A.

Perl, 110
#!perl -pa
$n=pop@F;@x=map
0,@F;/a/,$x[$'/$n]++for(sort{$b-$a}map{map{($'/$_|0).rand.a.$i++}//..$n}@F)[0..$n-1];$_="@x"

Input space separated with the seat count last.
Try me.


text:
The polyglot challenge!
A polyglot is a program which can be run by several different language's interpreters/compilers without failing.
For example, the stackoverflow 404 page contains a polyglot which runs in Python, Perl, Ruby, C, brainfuck and befunge, each time printing 404 to stdout.

Now, my challenge is to create a polyglot which, when run as a certain language, will print:

Just Another #{Name Of Language} Hacker,

So, if you say that your program can be run as both JavaScript and ><>, when run in a JavaScript environment it should print
Just Another JavaScript Hacker,

and when run by a ><> interpreter,
Just Another ><> Hacker,

In your answers, you should list the number of languages which accept it as a valid program and produce correct output, as well as a list of those languages.
The program which runs under the most languages wins!

@flawr it's an exact duplicate of the second dupe target though. If this was considered sufficiently different (which I don't think it is), I'd say the older challenge should be reopened.

source: Stack Exchange

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

sort: votes


text:
Take first letter of each word, leave spaces and punctuation
Shrink each word in a string of group of strings to single letters delineated by spaces or punctuation.
Example
I'm a little teapot,  short and stout. Here is my handle, here is my spout. When I get all steamed up - hear me shout!   Tip me over and pour me out.

becomes
I' a l t, s a s. H i m h, h i m s. W I g a s u - h m s! T m o a p m o.

Edit  -  if there are multiple spaces,  preserve only one space.  All punctuation should be preserved,  I missed the apostrophe.  Yes this is code  golf :-).

Can there be multiple spaces between the words? Do we have to preserve them?

Also, which characters exactly count as punctuation?

What's the winning criterion? Is this code-golf?

Least characters used for successful completion wins. Also I edited the post to make more sense.

What is the required behavior for numbers or other characters besides punctuation (+ etc.)

Should we also handle numbers? And should we care about leading/trailing spaces?

Will there ever be more than one punctuation within a word? Something like O'Leary-Clarence-DeVois would become O'--?

...and why 2 spaces after the ! too

Probably a typo,  sorry...

You can accept an answer whenever you like, but it's better to leave some time (days) before closing a challenge.

I would have asked the edit I suggested in a comment If i could have, but did not have enough rep at the time, I only just acquired it.

CJam, 13 bytes
r{(\'A,f&Sr}h

Works if I can consider only the common punctuation characters, and the output can have trailing spaces. (Thanks to Dennis.)
This question needs much more clarification...
CJam, 17 16 bytes
r{(\eu_elf&Sr}h&

Try it online.
Explanation
r          e# Read one word from input.
{          e# While it is not EOF:
    (\     e# Extract the first character.
    eu     e# Convert the rest to uppercase.
    _el    e# And lowercase.
    f&     e# Delete characters in the first string if not in the second string.
    S      e# Append a space.
    r      e# Read the next word.
}h
&          e# Discard the last space by intersecting with empty string.

Can you add a link to test it please? I'm on mobile.

@Cthanatos Added.

r pushes an empty string on EOF, so this works as well: r{(\eu_elf&Sr}h;

@Dennis I'm sure I have seen code like that many times, but still didn't remember... Thanks. But the ; makes no sense then.

If required, you could still get rid of it with &. Also, depending on what exactly counts as punctuation, '@, would be a shorter alternative to eu_el.

@Dennis Edited.

Pyth, 14 bytes
jdm+hd-rtd0Gcz

Try it online: Demonstration
Explanation:
                 implicit: z = input string
            cz   split z by spaces
  m              map each word d to:
    hd              first letter of d
   +                +
       rtd0         (lowercase of d[1:]
      -    G         but remove all chars of "abc...xyz")
jd               join resulting list by spaces and print

Is this duplicating hyphens?

@Cthanatos Should work now.

@grovesNL can you think of a sentence that one might  come  across in regular writing  ie a book,  news article where numbers within a sentence  might be an issue or  come up?

@Cthanatos: There are plenty of cases where numbers are used in books or news articles. "Over 200 respondents..." "The lot is 50 acres..." "It is capable of holding approximately 20 liters..."

Touché...  Good point.

Python 3.4, 94 92 82 77 bytes
print(*[w[0]+''.join(c[c.isalpha():]for c in w[1:])for w in input().split()])

I'm new to code golfing but I thought I'd give it a try! This one's not a winner, but it was fun.
This just splits the string, taking the first character of each word along with any punctuation in the rest of the word.
*edited with changes by FryAmTheEggman, DLosc

You can use python's starred argument passing to save some bytes, and inverting the condition seems to save 1 byte (although it still looks suspiciously golfable). Here's what I got: print(*[w[0]+''.join([c for c in w[1:]if 1-c.isalpha()])for w in input().split()])

@FryAmTheEggman Ah, thanks! I forgot about starred argument passing.

No need for the square braces around the inner comprehension--join can take a bare generator as an argument.  Also, here's a string-slicing way of doing the "if not isalpha" logic: c[c.isalpha():]for c in w.  Should get you down to 77 bytes.  :^)

@DLosc That string-slicing trick is clever, thanks! I'll have to remember that one.

Jelly, 14 bytes
Ḣ;ḟØB$
Ḳ¬ÐfÇ€K

Try it online!
Solution done with Mr. Xcoder and caird coinheringaahing in Jelly Hypertraining chat room.
Alternative 14 bytes: Try it online!

sed (39 chars)
Just a couple of regular expressions:
sed 's+\<\(.\)[A-Za-z]*+\1+g;s+  *+ +g'

We usually not count the interpreter's name and the additional syntax required by shell to pass the code or data correctly to the interpreter. Your actual Sed code has only 32 characters.

Javascript (ES6) 72 68 bytes

f=x=>x.split(/\s+/).map(x=>x.replace(/^(.)|[a-z]/gi,'$1')).join(' ')
<input id="input" value="I'm a little teapot,  short and stout. Here is my handle, here is my spout. When I get all steamed up - hear me shout!   Tip me over and pour me out. " />
<button onclick="output.innerHTML=f(input.value)">Run</button>

Commented:
f=x=>
    x.split(/\s+/). // split input string by 1 or more spaces
    map(x=> // map function to resulting array
        x.replace(/^(.)|[a-z]/gi, '$1') // capture group to get the first character
                                        // replace all other letters with empty string
    ).
    join(' ') // join array with single spaces

PowerShell, 56 bytes
%{($_-split' '|%{$_[0]+($_-replace'[a-z]','')})-join' '}

Lua - 126 characters
Lua isn't much of a code golfing language, but I gave it a shot:
a=''for b in string.gmatch( c, '%S+%s?' )do d=(b:match('%w')or''):sub(1,1)e=b:match('[^%s%w]')or''a=a..d..e..' 'end print( a )

This assumes that c is the string.
Here it is cleaned up for readability:
local string = [[I'm a little teapot,  short and stout. Here is my handle, here is my
spout. When I get all steamed up - hear me shout!   Tip me over and pour me out.]]

local final = ''
for word in string.gmatch( string, '%S+%s?' ) do
    local first = ( word:match( '%w' ) or '' ):sub( 1, 1 )
    local second = word:match( '[^%s%w]' ) or ''
    final = final .. first .. second .. ' '
end
print( final )

You can test it here (copy and paste it. For the first on you also have to do c = "I'm a little ....)
For some reason the online demo of Lua won't let you input variables using io.read...

C99 - 170 169 bytes
main(_,a)char**a;{for(char*b=a[1],*c=b,*e,*d;*c++=*b;){for(e=b;*++b&&*b-32;);for(*b=0,d=strpbrk(e,"!',-."),d&&d-e?*c++=*d:0;b[1]==32;++b);++b;*c++=32;*c=0;}puts(a[1]);}

Ungolfed:
main(int argc, char**a) {
    char*b=a[1],*c=b,*e,*d;
    while(*c++=*b){
        for(e=b;*++b&&*b-32;); //scan for first space or end of word
        *b=0; //mark end of word
        for(;b[1]==32;++b); //skip following spaces
        d=strpbrk(e,"!',-."); //find punctuation
        if(d&&d-e) //append punctuation if any, and it's not the word itself
            *c++=*d;
        *c++=32; //append space
        b++;
    }
    *c=0; //mark end of line
    puts(a[1]);
}

Usage:
gcc -std=c99 test.c -o test
./test "I'm a little teapot,  short and stout. Here is my handle, here is my spout. When I get all steamed up - hear me shout!   Tip me over and pour me out."

Output:
I' a l t, s a s. H i m h, h i m s. W I g a s u - h m s! T m o a p m o.

Java 8, 87 bytes
s->{for(String x:s.split(" +"))System.out.print(x.replaceAll("^(.)|[a-z]+","$1")+" ");}

Explanation:
Try it here.
s->{                                  // Method with String parameter and no return-type
  for(String x:s.split(" +"))         //  Split the input on one or multiple spaces
                                      //  And loop over the substrings
    System.out.print(                 //   Print:
      x.replaceAll("^(.)|[a-z]+","$1")//    Regex to get the first letter + all non-letters
      +" ");                          //    + a space delimiter
                                      //  End of loop (implicit / single-line body)
}                                     // End of method

Regex explanation:
x.replaceAll("^(.)|[a-z]+","$1")
x.replaceAll("           ","  ") # Replace the match of String1 with String2, in String `x`
             "           "       # Regex to match:
              ^(.)               #  The first character of String `x`
                  |[a-z]+        #  Or any one or multiple lowercase letters
                           "  "  # Replace with:
                            $1   #  The match of the capture group (the first character)

So it basically removes all lowercase letters of a String, except the very first one.

Perl 5, 34 bytes
33 bytes code + 1 for -p.
s!\S\K\S+| \K +!$&=~s/\w| //gr!ge

Try it online!

R, 46 45 bytes
cat(gsub("^\\w\\W*\\K\\w*","",scan(,""),T,T))

This reads a line from STDIN and prints to STDOUT. It uses a regular expression to remove all characters after the first letter followed by any amount of punctuation.
Ungolfed + explanation:
# Read a string from STDIN and convert it to a character vector,
# splitting at spaces

input <- scan(what = "")

# Replace stuff with nothing using a regex.
# ^ start position anchor
# \w single "word" character
# \W* any amount of non-word (i.e. punctuation) characters
# \K move the match position forward
# \w* any number of word characters

replaced <- gsub("^\\w\\W*\\K\\w*", "", input, ignore.case = TRUE, perl = TRUE)

# Print the vector elements to STDOUT, separated by a space

cat(replaced, sep = " ")

Example:
> cat(gsub("^\\w\\W*\\K\\w*","",scan(,""),T,T))
1: I'm a little teapot,  short and stout. Here is my handle, here is my spout. When I get all steamed up - hear me shout!   Tip me over and pour me out.

I' a l t, s a s. H i m h, h i m s. W I g a s u - h m s! T m o a p m o.

05AB1E, 13 bytes
#õKεćsDáмJ}ðý

Try it online!
Explanation:
#õKεćsDáмJ}ðý  Full program
#              Split on spaces
 õK            Remove empty strings from the list
   ε           For each...
    ć             push a[1:], a[0]
     s            Swap
      D           Duplicate
       á          Push only letters of a
        м         pop a,b => push a.remove(all elements of b)
         J        Join
          }    End for each
           ðý  Join with spaces

VBA (Excel), 141 133 Bytes
Using VBA Immediate Window, [A1] as Inputted Strings.

z=" "&[A1]:for a=2 to len(z):c=mid(z,a,1):[A2]=[A2]&IIF(mid(z,a-1,1)=" ",c,IIF(asc(lcase(c))>96 and asc(lcase(c))<123,"",c)):next:?[TRIM(A2)]

z=" "&[a1]:for a=2 to len(z):c=mid(z,a,1):e=asc(lcase(c)):[a2]=[a2]&iif(mid(z,a-1,1)=" ",c,IIF((e>96)*(e<123),"",c)):next:?[TRIM(A2)]

Perl 6, 15 bytes
s:g/(\w)\w+/$0/

Try it online!

Output doesn't match the example.

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


text:
Write a self replicating program that stops replicating after "printing" "Hello world!" with the filenames
Write a self replicating program, in the source code filename H.*, contianed in an empty folder then manually compile and run or just run the program if your chosen language is dynamic, and it should then just create a new source file, e.*, with the same exact source code, and automatically compile/run that new program, which makes the new source file l.*, etc. until the source file !.* is made, and that program should do essentially nothing once it is compiled/run. "Hello world!" has some repeated characters, so the second character should be created by a similar filename, just with a new <space> at the end. Programs that just make/compile source files from the single instance of the program are invalid, and yes, " " is a valid filename. It should appear to say "Hello World!" when viewed in the file explorer sorted by time created.

For example, if you were to attempt this challenge in python, than you would create the source file H.py, which complies and runs e.py, which then itself creates l.py, that file l .py, o.py, .py, w.py, o .py, r.py, l  .py and d.py which finally creates and runs !.py, which does not do anything once run.

"Self-replicating" implies that the program creates another file exactly identical to the original. Do the files all have to be identical, so that they have to read their own filename?

maybe re-write this as an ouroboros challenge? instead of the programs compiling the next one, just output the source, so H.py produces e.py... d.py produces H.py

@Doorknob yes, They would have to have the same content, and need to check their filename to see what to make the next one called.

Shouldn't the example end with !.py? Also, it states that e.* should create e.* again.

@LegionMammal978 Fixed.

There are 3 ls in Hello world!. What should the filename of the 3rd be?

@user23013 add another space.

filenames are H.*,  e.*, l.*, l .*, o.*,   .* ,  w.*, o .*, r.*, l  .*,  d.* and !.*

Will the directory initially be empty, apart from the code itself? If not, then will it have files with the same extension?

Added a condition, start with an empty folder containing only H.py

If we don't need an extension, can our files just be H, e, etc?

Python 2, 194
import os,sys
h,A='H|e|l|l |o| |w|o |r|l  |d|!'.split('|'),sys.argv[0]
d,a,F=dict(zip(h,h[1:])),A.split('.')[0],file
if a in d:o=d[a]+'.py';F(o,'w').write(F(A).read());os.popen('python "'+o+'"')

the code runs without an error, but doesn't appear to do anything?

oops, after re-reading the specs, it seems that I missed the fact that it had to run itself ... that's fixed

you have to name the script "H.py" by the way

It still seems to not be working, have you tried it yourself?

Yes I did !  I run under linux, so maybe running "python.exe" instead of "python" is the cause of the issue

Right now I am running from IDLE 2.7.8 on a Mac...

Managed to get it working with os.system('python H.py')

Confirmed after testing on a windows laptop, only runs when executed from the command line, or using os.system

Bash, 99 88 84
X=`grep -Po "(?<=#$0#)[^#]*" "$0"` #H#e#l#l #o# #W#o #r#l  #d#!
cp "$0" "$X"
sh "$X"

Explanation:

First we create a regex from the name of the file (the argument $0).  For example, here is the regex constructed when the first file executes ($0 is H):
 (?<=#H#)[^#]*

This searches for a sequence of non-# characters preceded by #H#.  That is, it finds the next filename in a sequence of #-separated filenames.  (I used # so that the separator before H would function as the string delimiter itself, with the bonus of not needing a closing delimiter.)

Then we search (grep) the currently-executing file "$0" with this regex.  We need the -P flag (or similar) to use the lookbehind construct, and -o to only return the new filename, not the whole line.

We store the result (using backticks `) of this whole evaluation in the variable X.

We copy (cp) the current file to the new file.

Finally we execute the new file with sh.

Example usage:
robert@unity:~/hwbash$ ls -lrt
total 4
-rw-r--r-- 1 robert robert 97 May 25 23:52 H
robert@unity:~/hwbash$ sh H
cp: cannot create regular file `': No such file or directory
sh: 0: Can't open
robert@unity:~/hwbash$ ls -lrt
total 48
-rw-r--r-- 1 robert robert 97 May 25 23:52 H
-rw-r--r-- 1 robert robert 97 May 25 23:52 e
-rw-r--r-- 1 robert robert 97 May 25 23:52 l
-rw-r--r-- 1 robert robert 97 May 25 23:52 l
-rw-r--r-- 1 robert robert 97 May 25 23:52 o
-rw-r--r-- 1 robert robert 97 May 25 23:52
-rw-r--r-- 1 robert robert 97 May 25 23:52 W
-rw-r--r-- 1 robert robert 97 May 25 23:52 o
-rw-r--r-- 1 robert robert 97 May 25 23:52 r
-rw-r--r-- 1 robert robert 97 May 25 23:52 l
-rw-r--r-- 1 robert robert 97 May 25 23:52 d
-rw-r--r-- 1 robert robert 97 May 25 23:52 !
robert@unity:~/hwbash$

Updates

I saved some bytes by using bash H instead of #!/bin/bash.  This also means that I don't have to copy the executable permission, so sorting by timestamps works now (but you need to add a sleep 1 or something to make it reliable).
Saved some more bytes by moving the string to a comment and changing the command from bash to sh.

I would appreciate any bash masters who could advise me on where I can trim off whitespace, if any...

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


text:
Fissile Numbers
I found this sequence while working on Evolution of OEIS, but never got around to posting it as an answer. After writing a reference implementation in Mathematica, I thought this is a fun exercise to do as a separate challenge though, so here we go.
Let's build a numeric fission reactor! Consider a positive integer N. As an example, we'll look at 24. To fission this number, we have to find the largest number of consecutive positive integers that sum to N. In this case, that's 7 + 8 + 9 = 24. So we've split 24 into three new numbers. But this wouldn't be much of a fission reactor without chain reactions. So let's recursively repeat the process for these components:
       24
       /|\
      / | \
     /  |  \
    7   8   9
   / \     /|\
  3   4   / | \
 / \     /  |  \
1   2   2   3   4
           / \
          1   2

Notice that we stop the process whenever the number cannot be decomposed into smaller consecutive integers. Also note that we could have written 9 as 4 + 5, but 2 + 3 + 4 has more components. The Fission number of N is now defined as the number of integers obtained in this process, including N itself. The above tree has 13 nodes, so F(24) = 13.
This sequence is OEIS entry A256504.
The first 40 terms, starting from N = 1, are
1, 1, 3, 1, 5, 6, 5, 1, 6, 7, 12, 10, 12, 11, 12, 1, 8, 16, 14, 17, 18, 18,
23, 13, 21, 18, 22, 23, 24, 19, 14, 1, 22, 20, 23, 24, 31, 27, 25, 26

The first 1000 terms can be found in this pastebin.
The Challenge
Given a positive integer N, determine its Fission number F(N). (So you don't need to cover the leading 0 listed on OEIS.)
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
This is code golf, so the shortest answer (in bytes) wins.
Bonus question: Can you find any interesting properties of this sequence?

I notice that the OEIS seems to have an error at n = 34: starting at n = 32, it (currently) lists 1, 22, 22, 23, 24, 31, rather than 1, 22, 20, 23, 24, 31.

@mathmandan Good catch, I'll probably propose a correction (along with the first diagram).

Related challenge: http://codegolf.stackexchange.com/questions/5703/in-how-many-ways-can-a-number-be-expressed-as-a-sum-of-consecutive-numbers (and same question on math.SE: http://math.stackexchange.com/questions/139842/in-how-many-ways-can-a-number-be-expressed-as-a-sum-of-consecutive-numbers)

@mathmandan FYI, I have corrected the sequence and the example now, and also added my reference implementation and the first 10k terms.

Looks good! Thanks for your work!

I have posted a related question on Math.SE

Generating the ASCII art tree diagram for a number would be another great code golf challenge. (Maybe ignore numbers which decompose into four or more for the sake of simplicity.)

Fission, 1328 989 887 797 bytes
This answer is a bit unreasonably long (I wish we had collapsible regions)... please don't forget to scroll past this and show the other answers some love!
Working on this code was what inspired this challenge. I wanted to add an answer in Fission to EOEIS, which led me to this sequence. However, actually learning Fission and implementing this took a few weeks working on it on and off. In the meantime, the sequence had really grown on me so I decided to post a separate challenge for it (plus, this wouldn't have been particularly far down the tree on EOEIS anyway).
So I present to you, the Monstrosity:
 R'0@+\
/  Y@</ /[@ Y]_L
[? % \  / \ J
   \$@  [Z/;[{+++++++++L
UR+++++++++>/;
9\   ;    7A9
SQS  {+L  /$     \/\/\/\/\/   5/ @  [~ &@[S\/ \  D /8/
~4X /A@[  %5                   /; &    K  } [S//~KSA /
  3    \  A$@S  S\/  \/\/\/   \/>\ /S]@A  /  \ { +X
W7           X  X    /> \      +\ A\ /   \ /6~@/ \/
        /   ~A\;     +;\      /@
    ZX [K    / {/  / @  @ }  \ X @
       \AS   </      \V /    }SZS S/
         X   ;;@\   /;X  /> \ ; X X
 ;       \@+  >/ }$S SZS\+;    //\V
           / \\  /\; X X @  @  \~K{
           \0X /     /~/V\V /   0W//
    \        Z      [K \  //\
W       /MJ $$\\ /\7\A  /;7/\/ /
       4}K~@\ &]    @\  3/\
 /     \{   }$A/1 2  }Y~K <\
[{/\  ;@\@  /   \@<+@^   1;}++@S68
@\ <\    2        ;   \    /
$  ;}++ +++++++L
%@A{/
M  \@+>/
~     @
SNR'0YK
  \  A!/

It expects that there is no trailing newline on the input, so you might want to call it like echo -n 120 | ./Fission oeis256504.fis.
The layout could probably still be more efficient, so I think there's still a lot of room for improvement here (for instance, this contains 911 581 461 374 spaces).
Before we get to the explanation, a note on testing this: the official interpreter doesn't entirely work as is. a) Mirror.cpp doesn't compile on many systems. If you run into that problem, just comment out the offending line - the affected component (a random mirror) is not used in this code. b) There are a couple of bugs that can lead to undefined behaviour (and likely will for a program this complex). You can apply this patch to fix them. Once you've done that, you should be able to compile the interpreter with
g++ -g --std=c++11 *.cpp -o Fission

Fun fact: This program uses almost every component Fission has to offer, except for # (random mirror), : (half mirror), - or | (plain mirror), and " (print mode).
What on Earth?
Warning: This will be quite long... I'm assuming you're genuinely interested in how Fission works and how one could program in it. Because if you're not, I'm not sure how I could possibly summarise this. (The next paragraph gives a general description of the language though.)
Fission is a two-dimensional programming language, where both data and control flow are represented by atoms moving through a grid. If you've seen or used Marbelous before, the concept should be vaguely familiar. Each atom has two integer properties: a non-negative mass and an arbitrary energy. If the mass ever becomes negative the atom is removed from the grid. In most cases you can treat the mass as the "value" of the atom and the energy as some sort of meta-property that is used by several components to determine the flow of the atoms (i.e. most sorts of switches depend on the sign of the energy). I will denoted atoms by (m,E), when necessary. At the beginning of the program, the grid starts with a bunch of (1,0) atoms from wherever you place on of the four components UDLR (where the letter indicates the direction the atom is moving in initially). The board is then populated with a whole bunch of components which change the mass and energy of atoms, change their directions or do other more sophisticated things. For a complete list see the esolangs page, but I'll introduce most of them in this explanation. Another important point (which the program makes use of several times) is that the grid is toroidal: an atom that hits any of the sides reappears on the opposite side, moving in the same direction.
I wrote the program in several smaller parts and assembled them at the end, so that's how I'll go through the explanation.
atoi
This component may seem rather uninteresting, but it's nice and simple and allows me to introduce a lot of the important concepts of Fission's arithmetic and control flow. Therefore, I will go through this part in quite meticulous detail, so I can reduce the other parts to introducing new Fission mechanics and pointing out higher-level components whose detailed control flow you should be able to follow yourself.
Fission can only read byte values from individual characters, not entire numbers. While that's acceptable practice around here, I figured while I was at it, I could do it right and parse actual integers on STDIN. Here is the atoi code:
     ;
 R'0@+\
/  Y@</ /[@ Y]_L
[? % \  / \ J
   \$@  [Z/;[{+++++++++L
UR+++++++++>/;
           O

Two of the most important components in Fission are fission and fusion reactors. Fission reactors are any of V^<> (the above code uses < and >). A fission reactor can store an atom (by sending it into the character's wedge), the default being (2,0). If an atom hits the character's apex, two new atoms will be sent off to the sides. Their mass is determined by dividing the incoming mass by the stored mass (i.e. halving by default) - the left-going atom gets this value, and the right-going atom gets the remainder of the mass (i.e. mass is conserved in the fission). Both outgoing atoms will have the incoming energy minus the stored energy. This means we can use fission reactors for arithmetic - both for subtraction and division. If a fission reactor is hit from the site, the atom is simply reflected diagonally and will then move in the direction of the character's apex.
Fusion reactors are any of YA{} (the above code uses Y and {). Their function is similar: they can store an atom (default (1,0)) and when hit from the apex two new atoms will be sent off to the sides. However, in this case the two atoms will be identical, always retaining the incoming energy, and multiplying the incoming mass by the stored mass. That is, by default, the fusion reactor simply duplicates any atom hitting its apex. When hit from the sides, fusion reactors are a bit more complicated: the atom is also stored (independently of the other memory) until an atom hits the opposite side. When that happens a new atom is released in the direction of the apex whose mass and energy are the sum of the two old atoms. If a new atom hits the same side before a matching atom reaches the opposite side, the old atom will simply be overwritten. Fusion reactors can be used to implement addition and multiplication.
Another simple component I want to get out of the way is [ and ] which simply set the atom's direction to right and left, respectively (regardless of incoming direction). The vertical equivalents are M (down) and W (up) but they're not used for the atoi code. UDLR also act as WM][ after releasing their initial atoms.
Anyway, let's look at the code up there. The program starts out with 5 atoms:

The R and L at the bottom simply get their mass increment (with +) to become (10,0) and then stored in a fission and a fusion reactor, respectively. We will use these reactors to parse the base-10 input.
The L in the top right corner gets its mass decremented (with _) to become (0,0) and is stored in the side of a fusion reactor Y. This is to keep track of the number we're reading - we'll gradually increase and multiply this as we read numbers.
The R in the top left corner gets its mass set to the character code of 0 (48) with '0, then mass and energy are swapped with @ and finally mass incremented once with + to give (1,48). It is then redirected with diagonal mirrors \ and / to be stored in a fission reactor. We'll use the 48 for subtraction to turn the ASCII input into the actual values of the digits. We also had to increase the mass to 1 to avoid division by 0.
Finally, the U in the bottom left corner is what actually sets everything in motion and is initially used only for control flow.

After being redirected to the right, the control atom hits ?. This is the input component. It reads a character and sets the atom's mass to the read ASCII value and the energy to 0. If we hit EOF instead, the energy will be set to 1.
The atom continues and then hits %. This is a mirror switch. For non-positive energy, this acts like a / mirror. But for positive energy it acts like a \ (and also decrements the energy by 1). So while we're reading the characters, the atom will be reflected upwards and we can process the character. But when we're done with the input, the atom will be reflected downwards and we can apply different logic to retrieve the result. FYI, the opposite component is &.
So we've got an atom moving up for now. What we want to do for each character is to read its digit value, add that to our running total and then multiply that running total by 10 to prepare for the next digit.
The character atom first hits a (default) fusion reactor Y. This splits the atom and we use the left-going copy as a control atom to loop back into the input component and read the next character. The right-going copy will be processed. Consider the case where we've read the character 3. Our atom will be (51,0). We swap mass and energy with @, such that we can make use of the subtraction of the next fission reactor. The reactor subtracts 48 off the energy (without changing the mass), so the it sends off two copies of (0,3) - the energy now corresponds to the digit we've read. The upgoing copy is simply discarded with ; (a component that just destroys all incoming atoms). We'll keep working with the downgoing copy. You'll need to follow its path through the / and \ mirrors a bit.
The @ just before the fusion reactor swaps mass and energy again, such that we'll add (3,0) to our running total in the Y. Note that the running total itself will therefore always have 0 energy.
Now J is a jump. What it does is jump any incoming atom forward by its energy. If it's 0, the atom just keeps moving straight on. If it's 1 it will skip one cell, if it's 2 it'll skip two cells and so on. The energy is spent in the jump, so the atom always ends up with energy 0. Since the running total does have zero energy, the jump is ignored for now and the atom is redirected into the fusion reactor { which multiplies its mass by 10. The downgoing copy is discarded with ; while the upgoing copy is fed back into the Y reactor as the new running total.
The above keeps repeating (in a funny pipelined way where new digits are being processed before the previous ones are done) until we hit EOF. Now the % will send the atom downwards. The idea is to turn this atom into (0,1) now before hitting the running total reactor so that a) the total is not affected (zero mass) and b) we get an energy of 1 to jump over the [. We can easily take care of the energy with $, which increments the energy.
The issue is that ? does not reset the mass when you're hitting EOF so the mass will still be that of the last character read, and the energy will be 0 (because % decremented the 1 back to 0). So we want to get rid of that mass. To do that we swap mass and energy with @ again.
I need to introduce one more component before finishing up this section: Z. This is essentially the same as % or &. The difference is that it lets positive-energy atoms pass straight through (while decrementing the energy) and deflects non-positive-energy atoms 90 degrees to the left. We can use this to eliminate an atom's energy by looping it through the Z over and over - as soon as the energy is gone, the atom will be deflected and leave the loop. That is this pattern:
/ \
[Z/

where the atom will move upwards once the energy is zero. I will use this pattern in one form or another several times in the other parts of the program.
So when the atom leaves this little loop, it will be (1,0) and swapped to (0,1) by the @ before hitting the fusion reactor to release the final result of the input. However, the running total will be off by a factor of 10, because we've tentatively multiplied it for another digit already.
So now with energy 1, this atom will skip the [ and jump into the /. This deflects it into a fission reactor which we've prepared to divide by 10 and fix our extraneous multiplication. Again, we discard one half with ; and keep the other as output (here represented with O which would simply print the corresponding character and destroy the atom - in the full program we keep using the atom instead).
itoa
           /     \
input ->  [{/\  ;@
          @\ <\
          $  ;}++ +++++++L
          %@A{/
          M  \@+>/
          ~     @
          SNR'0YK
            \  A!/

Of course, we also need to convert the result back to a string and print it. That's what this part is for. This assumes that the input doesn't arrive before tick 10 or so, but in the full program that's easily given. This bit can be found at the bottom of the full program.
This code introduce a new very powerful Fission component: the stack K. The stack is initially empty. When an atom with non-negative energy hits the stack, the atom is simply pushed onto the stack. When an atom with negative energy hits the stack, its mass and energy will be replaced by the atom on the top of the stack (which is thereby popped). If the stack is empty though, the direction of the atom is reversed and its energy becomes positive (i.e. is multiplied by -1).
Okay, back to the actual code. The idea of the itoa snippet is to repeatedly take the input modulo 10 to find the next digit while integer-dividing the input by 10 for next iteration. This will yield all the digits in reverse order (from least significant to most significant). To fix the order we push all the digits onto a stack and at the end pop them off one by one to print them.
The upper half of the code does the digit computation: the L with the pluses gives a 10 which we clone and feed into a fission and a fusion reactor so we can divide and multiply by 10. The loop essentially starts after the [ in the top left corner. The current value is split: one copy is divided by 10, then multiplied by 10 and stored in a fission reactor, which is then hit by the other copy at the apex. This computes i % 10 as i - ((i/10) * 10). Note also that the A splits the intermediate result after the division and before the multiplication, such that we can feed i / 10 into the next iteration.
The % aborts the loop once the iteration variable hits 0. Since this is more or less a do-while loop, this code would even work for printing 0 (without creating leading zeroes otherwise). Once we leave the loop we want to empty the stack and print the digits. S is the opposite of Z, so it's a switch which will deflect an incoming atom with non-positive energy 90 degrees to the right. So the atom actually moves over the edge from the S straight to the K to pop off a digit (note the ~ which ensures that the incoming atom has energy -1). That digit is incremented by 48 to get the ASCII code of the corresponding digit character. The A splits the digit to print one copy with ! and feed the other copy back into the Y reactor for the next digit. The copy that's printed is used as the next trigger for the stack (note that the mirrors also send it around the edge to hit the M from the left).
When the stack is empty, the K will reflect the atom and turn its energy into +1, such that it passes straight through the S. N prints a newline (just because it's neat :)). And then the atom goes thorugh the R'0 again to end up in the side of the Y. Since there are no further atoms around, this will never be released and the program terminates.
Computing the Fission Number: The Framework
Let's get to the actual meat of the program. The code is basically a port of my Mathematica reference implementation:
fission[n_] := If[
  (div =
    SelectFirst[
      Reverse@Divisors[2 n],
      (OddQ@# == IntegerQ[n/#]
       && n/# > (# - 1)/2) &
    ]
  ) == 1,
  1,
  1 + Total[fission /@ (Range@div + n/div - (div + 1)/2)]
]

where div is the number of integers in the maximal partition.
The main differences are that we can't deal with half-integer values in Fission so I'm doing a lot of things multiplied by two, and that there is no recursion in Fission. To work around this, I'm pushing all the integers in a partition in a queue to be processed later. For each number we process, we'll increment a counter by one and once the queue is empty, we'll release the counter and send it off to be printed. (A queue, Q, works exactly like K, just in FIFO order.)
Here is a framework for this concept:
                      +--- input goes in here
                      v

                     SQS ---> compute div from n          D /8/
                     ~4X               |                /~KSA /
                       3               +----------->    { +X
initial trigger ---> W                               6~@/ \/
                              4
                     W        ^                     /
                              |              3
                     ^     generate range    |
                     |     from n and div  <-+----- S6
                     |         -then-
                     +---- release new trigger

The most important new components are the digits. These are teleporters. All teleporters with the same digit belong together. When an atom hits any teleporter it will be immediately move the next teleporter in the same group, where next is determined in the usual left-to-right, top-to-bottom order. These are not necessary, but help with the layouting (and hence golfing a bit). There is also X which simply duplicates an atom, sending one copy straight ahead and the other backwards.
By now you might be able to sort out most of the framework yourself. The top left corner has the queue of values still to be processed and releases one n at a time. One copy of n is teleported to the bottom because we need it when computing the range, the other copy goes into the block at the top which computes div (this is by far the single largest section of the code). Once div has been computed, it is duplicated - one copy increments a counter in the top right corner, which is stored in K. The other copy is teleported to the bottom. If div was 1, we deflect it upwards immediately and use it as a trigger for the next iteration, without enqueuing any new values. Otherwise we use div and n in the section at the bottom to generate the new range (i.e. a stream of atoms with the corresponding masses which are subsequently put in the queue), and then release a new trigger after the range has been completed.
Once the queue is empty, the trigger will be reflected, passing straight through the S and reappearing in the top right corner, where it releases the counter (the final result) from A, which is then teleported to itoa via 8.
Computing the Fission Number: The Loop Body
So all that's left is the two sections to compute div and generate the range. Computing div is this part:
 ;
 {+L  /$     \/\/\/\/\/   5/ @  [~ &@[S\/ \
/A@[  %5                   /; &    K  } [S/
   \  A$@S  S\/  \/\/\/   \/>\ /S]@A  /  \
         X  X    /> \      +\ A\ /   \ /
    /   ~A\;     +;\      /@
ZX [K    / {/  / @  @ }  \ X @
   \AS   </      \V /    }SZS S/
     X   ;;@\   /;X  /> \ ; X X
     \@+  >/ }$S SZS\+;    //\V
       / \\  /\; X X @  @  \~K{
       \0X /     /~/V\V /   0W//
\        Z      [K \  //\
           \ /\7\A  /;7/\/

You've probably seen enough now to puzzle this out for yourself with some patience. The high-level breakdown is this: The first 12 columns or so generate a stream of divisors of 2n. The next 10 columns filter out those that don't satisfy OddQ@# == IntegerQ[n/#]. The next 8 columns filter out those that don't satisfy n/# > (# - 1)/2). Finally we push all valid divisors on a stack, and once we're done we empty the entire stack into a fusion reactor (overwriting all but the last/largest divisor) and then release the result, followed by eliminating its energy (which was non-zero from checking the inequality).
There are a lot of crazy paths in there that don't really do anything. Predominantly, the \/\/\/\/ madness at the top (the 5s are also part of it) and one path around the bottom (that goes through the 7s). I had to add these to deal with some nasty race conditions. Fission could use a delay component...
The code that generates the new range from n and div is this:
 /MJ $$\
4}K~@\ &]    @\  3/\
\{   }$A/1 2  }Y~K <\
 \@  /   \@<+@^   1;}++@
  2        ;   \    /

We first compute n/div - (div + 1)/2 (both terms floored, which yields the same result) and store for later. Then we generate a range from div down to 1 and add the stored value to each of them.
There are two new common patterns in both of these, that I should mention: One is SX or ZX hit from below (or rotated versions). This is a nice way to duplicate an atom if you want one copy to go straight ahead (since redirecting the outputs of a fusion reactor can sometimes be cumbersome). The S or Z rotates the atom into the X and then rotates the mirrored copy back into the original direction of propagation.
The other pattern is
[K
\A --> output

If we store any value in K we can repeatedly retrieve it by hitting K with negative energy from the top. The A duplicates the value we're interested in and sends what copy right back onto the stack for the next time we need it.
Well, that was quite a tome... but if you actually got through this, I hope you got the idea that Fission i͝s̢̘̗̗ ͢i̟nç̮̩r̸̭̬̱͔e̟̹̟̜͟d̙i̠͙͎̖͓̯b̘̠͎̭̰̼l̶̪̙̮̥̮y̠̠͎̺͜ ͚̬̮f̟͞u̱̦̰͍n͍ ̜̠̙t̸̳̩̝o ̫͉̙͠p̯̱̭͙̜͙͞ŕ̮͓̜o̢̙̣̭g̩̼̣̝r̤͍͔̘̟ͅa̪̜͇m̳̭͔̤̞ͅ ͕̺͉̫̀ͅi͜n̳̯̗̳͇̹.̫̞̲̞̜̳

Now with 100% fewer scrollbars. so you say .. and its still To be continued...

Still more readable than most code our junior devs pump out.

As the creator of Fission, even I haven't yet written a program that large! I'm impressed! Your explanation is spectacular and could definitely serve as a tutorial for the language.

Also, the last line of your answer kinda looks like a Fission program ;)

Pyth, 23 22 21 bytes
Lh&lJfqbsT.:tUb)syMeJ

This defines a recursive function y. Try it online: Demonstration
Explanation:
L                      define a function y(b): return ...
            tUb          the list [1, 2, ..., b-1]
          .:   )         generate all consecutive sub-sequences
     f                   filter for sub-sequences T, which satisfy:
      qbsT                   b == sum(T)
    J                    and store them in J

                         return
   lJ                        len(J)
  &                        and (if len(J) == 0 then 0 else ...)
                    eJ       last element of J (=longest sub-sequence)
                  yM         recursive calls for all these numbers
                 s           sum
 h                         incremented by one (counting the current node)

CJam, 42 41 bytes
ri]{_{:X,:)_few:+W%{1bX=}=}%{,(},e_}h]e_,

A simple Breadth first traversal and a stopping condition of empty next level.
How it works:
ri]                                       e# This represents the root of the fissile tree
   {                               }h     e# Now we run a do-while loop
    _{                    }%              e# Copy the nodes at the current level and map them
                                          e# via this code block to get next level nodes
      :X,:)                               e# Store the node value in X and get array [1..X]
           _few                           e# Copy the array and get continuous slices of
                                          e# length 1 through X from the array [1..X]
               :+W%                       e# Right now, we have an array of array with each
                                          e# array containing slice of same length. We join
                                          e# those arrays and reverse them to get slices of
                                          e# higher length in front of lower lengths
                   {1bX=}=                e# Choose the first slice whose sum is same as X
                                          e# The reversal above makes sure that we give
                                          e# preference to slice of higher length in case of
                                          e# multiple slices add up to X
                            {,(},         e# Filter out slices of length 1 which basically
                                          e# mean that the current node cannot be split up
                                 e_       e# Join all slices in a single array. This is our
                                          e# next level in the Fissile tree. If this is empty
                                          e# it means that all no further node can be
                                          e# decomposed. In an {}h do-while loop, this fact
                                          e# itself becomes the stopping condition for the
                                          e# loop
                                     ]e_, e# Wrap all levels in an array. Flatten the array
                                          e# and take its length

Try it online here

This can probably be golfed to around 35 bytes. I am trying to figure out how ..

Python 3, 112 bytes
def f(n,c=0):
 d=n-c;s=(n-d*~-d/2)/d
 return(s%1or s<1)and f(n,c+1)or+(d<2)or-~sum(f(int(s)+i)for i in range(d))

4 bytes saved thanks to @FryAmTheEggman.
Explanation coming later...
Bonus fact: Every power of 2 has a Fission number of 1. This is because the sum of an even length sequence is always the sum of the two middle numbers, which is odd, multiplied by half the length of the sequence, which is integer. The sum of an odd length sequence is the middle number multiplied by the sequence length, which is odd. So because a power of 2 doesn't have an odd divisor it can be only expressed as the sum of itself.

2+3+4+5=14 which is not odd.  Your argument for even length sequences should be changed to "the sum of an even length sequence is the sum of the two middle numbers, which is odd, multiplied by half the length".  The rest of your statement goes through unaffected.

@BrunoLeFloch Thanks! Corrected.

Shouldn't your title reflect the improvements? i.e. 117 113 112

@corsiKa I usually only do that for major improvements. There would be too many striked numbers otherwise.

Python 2, 111 102 97 bytes
Somewhat readable:
def f(n,c=0):a=n-c;b=n-a*~-a/2;return 1/a or-~sum(map(f,range(b/a,b/a+a)))if b>b%a<1else f(n,c+1)

Not-so-readable:
def f(n,a=0):b=n-a*~-a/2;return b>0and(f(n,a+1)or b%a<1and(1/a or-~sum(map(f,range(b/a,b/a+a)))))

Both 97 bytes.
b is the n minus the (a-1)th triangular number. If b % a == 0, then n is the sum of a consecutive numbers starting from b.

I used to consider Python a generally readable language until I joined PPCG.

I think you need to improve your definition of readable .. :P

Python 2 doesn't allow 1else. Only the 2nd solution works. It's not until Python 3 that else can immediately follow a number.

@mbomb007 To my knowledge it works fine from 2.7.8 onwards

Ok, I was using 2.7.2.

Python 2, 86
f=lambda n,R={1}:n-sum(R)and f(n,R^{[min(R),max(R)+1][n>sum(R)]})or-~sum(map(f,R-{n}))

Less golfed:
def f(n,R={1}):
    d=sum(R)-n
    if d==0:return (sum(map(f,R-{n}))
    if d<0:return f(n,R|{max(R)+1})
    if d>0:return f(n,R-{min(R)})

The idea is to test potential runs of consecutive integers that sum to n. The run is stored directly directly as a set R rather than via its endpoints.
We check how the sum of the current run compares to the desired sum n via their difference.

If the sum is too large, we cut the smallest element in the run.
If the sum is too small, we extend the run by making its max bigger by 1.
If the sum is correct, we recurse, mapping f onto the run, summing, and adding 1 for the current node. If the run is {n}, we've tried all non-trivial possible sums, stop the recursion by removing n first.

Thanks to Sp3000 for saving 3 chars.

Python 2, 85
I am very proud of this answer because it already takes tens of seconds for n=9, and 5-10 minutes for n=10. In code golf this is considered a desirable attribute of a program.
f=lambda n,a=1,d=1:a/n or[f(a)+f(n-a,1+1%d*a)+1/d,f(n,a+d/n,d%n+1)][2*n!=-~d*(2*a+d)]

There is also a short-circuiting version that does not take so long and uses the same amount of bytes:
f=lambda n,a=1,d=1:a/n or~d*(2*a+d)+n*2and f(n,a+d/n,d%n+1)or f(a)+f(n-a,1+1%d*a)+1/d

It may be faster, but at least it exceeds the default recursion limit once n goes a little above 40.
The idea is to do a brute force search for numbers a and d such that a + a+1 + ... + a+d == n, on values between 1 and n. The f(n,a+d/n,d%n+1) branch of the recursion loops through the (a, d) pairs. In the case that the equality is satisfied, I manage to avoid an expensive map(range(...)) call by splitting into just two branches regardless of how long the sequence is. The numbers a+1 through d are lumped into one call of f by setting the a parameter so that a different way to split up the sequence can't be used.

How does this work?

"I am very proud of this answer because it already takes tens of seconds for n=9, and 5-10 minutes for n=10. In code golf this is considered a desirable attribute of a program."
+1'd just for that.

Haskell, 76 69 bytes
f x=head$[1+sum(map f[y..z])|y<-[1..x-1],z<-[y..x],sum[y..z]==x]++[1]

Usage:
*Main> map f [1..40]
[1,1,3,1,5,6,5,1,6,7,12,10,12,11,12,1,8,16,14,17,18,18,23,13,21,18,22,23,24,19,14,1,22,20,23,24,31,27,25,26]

How it works:
[  [y..z] |y<-[1..x-1],z<-[y..x],sum[y..z]==x]

           make a list of lists with all consecutive integers (at least 2 elements)
           that sum up to x, sorted by lowest number, e.g. 9 -> [[2,3,4],[4,5]].

1+sum(map f[...])

           recursively calculate the Fission Number for each list

[...]++[1]

           always append the 1 to the list of Fission Numbers.

head

           take the first element, which is either the Fission Number of the
           longest list or if there's no list, the 1 appended in the step before.

Retina, 66 bytes
^|$
,
(`,(1+?)(?=(?<1>1\1)+\D)
$0;
+)`,(1*);1\1
,$1,1$1;
^,|1

.
1

Takes input and prints output in unary.
You can put each line in a single file or run the code as is with the -s flag. E.g.:
> echo -n 1111111|retina -s fission
11111

Explanation:

We keep a comma-delimited list of the numbers to be splitted.
For every number we take the smallest starting value which can crate a valid splitup and delimit it from the rest with a semicolon.
If there is a semicolon inside a number we change it to a comma and delimit the next properly sized (length of previous element + 1) part of the number.
We repeat step 2 and 3 until changes happen.
We get a comma for every leaf and a semicolon for every inner node plus an extra comma because we started with two comma. So we remove a comma and the numbers' parts (1's) and convert the rest to 1's.

The states of the string throughout the process with input 11111111111111 (unary 14):
,11111111111111,
,11;111111111111,
,11,1;11,1111,11;111;,
,11,1,11;,1111,11,1;11;;,
,11,1,11;,1111,11,1,11;;;,
,,;,,,,;;;,
11111111111

Many thanks for @MartinButtner for the help in chat!

CJam (43 bytes)
qi,{):X),_m*{{_)*2/}/-X=}=~\,>0\{~$+}/)}%W=

Online demo
I'm sure that I'm missing some tricks with the advanced loops, but this does neatly exploit the CJam property (which has previously annoyed me) that inside a % map the results remain on the stack, and can therefore be accessed using $ with a negative offset.

I'll have a closer look tomorrow, but for a start you don't need the , at the beginning. / and % and a few others implicitly turn numbers into ranges.

,_m* can be replaced with 2m*. The arithmetic progression formula can be replaced with ~,>:Y_,+:+ and ~\,>0\  becomes !Y. Finally, if you use {}# instead of {}=, you don't need the ) after X. Putting it all together: ri{):X2m*{~,>:Y_,+:+X=}#!Y{~$+}/)}%W=

Go, 133 bytes
func 算(n int)int{Σ:=1;for i:=0;i<n;i++{for j:=0;j<n;j++{if i*i+i-j*j-j==2*n{for k:=j+1;k<=i;k++{Σ+=算(k)};j,i=n,n}}};return Σ}

This is my first code golf, sorry if I made any mistakes.
This uses the idea that the fissile "composition" can also be seen as a difference between two sequences of ordered integers. For example take the fissile "composition" for the number 13. It is 6,7. But it can be seen as the sum of integers 1...7 minus the sum of integers 1...5
  A: 1 2 3 4 5 6 7  sum = 28
  B: 1 2 3 4 5      sum = 15
A-B:           6 7  sum = 13, which is also 28-15 = 13

Recall the formula from Gauss's school days,sum 1...n=(n^2+n)/2. So to find a composition of sequential integers for a given n, we could also say, we are searching for 'end points' p and q along the range 1...n so that (p^2+p)/2 - (q^2+q)/2 = n. In the above example, we would have been searching for 'end points' 5 and 7 because 7^2+7=56/2, 5^2+5=30/2, 56/2-30/2 = 28-15 = 13.
Now there are multiple possible ways to fissile-compose a number, as Martin noted 9 = 2 + 3 + 4 but also 4 + 5. But it seems obvious that the "lowest" starting sequence will also be the longest, because it takes more little-numbers to sum up to a big number than it does medium-sized numbers. (I have no proof unfortunately)
So to find the composition of 9, test every 'end point pair', p and q, iterating both p and q separately from 0 to 9, and test if p^p+p/2 - q^2+q/2 = 9. Or, more simply, multiply the equation by 2, to avoid the division issues of rounding and keep all math in integers. Then we are looking for p and q such that (p^p+p) - (q^q+q) = 9*2. The first match we find will be the Fissile composition endpoints because, as noted, the lowest group of numbers will also be the longest, and we are searching low-to-high (0 to 9). We break out of the loop as soon as we find a match.
Now the recursive function finds those 'fissile end points' p and q for the given n, then recalls-itself for each of the 'children' in the tree from p to q. For 9, it would find 1 and 4, (20-2=18) then it would re-call itself on 2, 3, and 4, summing the results. For numbers like 4 it simply never finds a match, and so returns '1'. This might be shortenable but this is like my third go program, and I am no recursion expert.
Thanks for reading.

Nice work! But why the Unicode function/variable names. That costs unnecessary bytes and surely you could have just use some normal letter?

Thanks for your kind comment. But I asked myself, why not count characters instead of bytes :)

Because those are the default rules around here. :) The reason we usually count bytes and not characters is because otherwise this happens, which is little fun for all parties involved. ;) (That said, any challenge author is free to specify counting by characters instead of bytes, but I specifically didn't.)

Husk, 24 bytes
LΣΣU¡(fo¬εṁm₁);;
ḟo=¹ΣQḣ

Try it online! or Verify first 40 values
Explanation
Function ₁: Get the longest slice of numbers
ḟo=¹ΣQḣ
      ḣ range 1..n
     Q  all subsequences
ḟo      get the first value which satisfies:
    Σ   sum
  =     equals
   ¹    argument?

Taking the first value works because Husk orders subsequences lexicographically, and the longest sequence will always be the one which is lexicographically smallest.
LΣΣU¡(fo¬εṁm₁);;
              ;; nest the input twice: 24 → [[24]]
                 (conversion to node)
    ¡            iterate infinitely, producing intermediate results
          ṁ      map each node list to
           m₁    it's elements converted to their fissions
          ṁ      and join them
     fo          filter using two functions
       ¬ε        is it not of length <1?
                 (this removes all nodes which cannot be broken down)
   U             cut at first non-unique element
 ΣΣ              join all the nested nodes into one list
L                length

Husk, 12 bytes
→ṁ₀-¹ḟo=¹ΣQḣ

Try it online!
Explanation
→ṁ₀-¹ḟo=¹ΣQḣ   Input is a number, say n=24.
           ḣ   Range from 1: [1,2,3,..,23]
          Q    All slices in increasing order of last element: [[1],[2],[1,2],[3],..,[1,2,..,24]]
     ḟ         Find first slice for which this is truthy:
      o        Composition of two functions:
         Σ      Sum
       =¹       equals n.
               Result is [7,8,9].
   -¹          Remove first occurrence of n (only relevant when the list is [n]).
 ṁ             Map and sum
  ₀            this function recursively: 12
→              Increment: 13

Man, I really got ½'d.

CJam, 40 35 33 bytes
ri{__,f-_few:+{1b1$=}=|{F}*}:F~],

Thanks to @Optimizer for suggesting few, which saved 2 bytes.
Try it online in the CJam interpreter.
How it works
ri      e# Read an integer from STDIN.
{       e# Define function F(X):
  _     e# Push X.
  _,    e# Push [0 ... X-1].
  f-    e# Subract each from X. Pushes Y := [X ... 1].
  _few  e# Push all overlapping slices of Y of length in Y.
  :+    e# Consolidate the slices of different lenghts in a single array.
  {     e# Find the first slice S such that...
    1b  e#   the sum of its elements...
    1$= e#   equals X.
  }=    e#   Since Y is in descending order, the first matching slice is also the longest.
  |     e# Set union with [X]. This adds X to the beginning of the S if S != [X].
  {F}*  e# Execute F for each element of S except the first (X).
}:F     e#
~       e# Execute F for the input.
],      e# Count the integers on the stack.

If you combine my first half with your second half, you get 34 : ri{_,:)_few:+W%{1b1$=}=|{F}*}:F~],

@Optimizer: Nice. That allows an additional improvement. Thanks!

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


text:
Is there a shorter way to get user input in python?
This is not a challenge. I'm wondering if it's at all possible to get user input into two separate variables in python (2 or 3) with less than 19 bytes. These are all the shortest I can get:
a,b=input(),input()
a=input();b=input() (newline replaced with semicolon for readability)
i=input;a,b=i(),i()

Is there any shorter way to do this?

The third one would probably be the best if you are taking in more than two inputs.

I was going to say command line arguments with a,b=sys.argv[1:2] or whatever but then you need an import sys (right?)

In python3 a,b=input().split() would be another 19 bytes solution, not an improvement though. Note that that means a and b are strings and the input is entered in one go seperated by a space.

Not sure if it helps, but in some languages you could use a vector to get two numbers, rather than 2 variables. For two arbitrary variables a more complicated container may be used.

a,b=input() in Py2

If prompting the user doesn't matter, this is slightly shorter than eval for 3 or more:
a,b,c=map(input,[1]*3)
a,b,c=map(input,'111')

It's also shorter even if prompting is not ok:
a,b,c=map(input,['']*3)

Sadly, xnor's idea doesn't save anything for 2 inputs as it is still longer (19 bytes). However if you have some string (or appropriate iterable) with the appropriate length already (because magic?) then it could be shorter.
xnor found an example of a magic string for 3 inputs in Python 2 only:
a,b,c=map(input,`.5`)

This also requires that the prompts not be important, though.
This trick actually helps to save bytes for large numbers of inputs by using 1eX notation (getting x+3 inputs):
 a,b,c,d,e,f=map(input,`1e3`)

Explanation:
Python's map function performs the function it is passed on each element of the iterable that is also passed to it, and returns the list (or map object) containing the results of these calls. For the first example, the map could be decomposed to:
[input(1), input(1), input(1)]

Doing map(input,'xxx') is equal-length for 3 vars, better for 2, and worse for 4+.

If, by some chance, you need to take exactly 22 inputs, map(input,`id`) is shorter :-). Similarly, map(input,`.1`) for 19 inputs.

Actually, a,b,c=map(input,`.5`) does save a char for 3 inputs, since .5 is represented as 0.5.

Yeah, that's good. Cool trick!

For 3 or more inputs, this is shorter:
a,b,c=eval("input(),"*3)

Note that unless the question specifies the input type or requires a complete program, you can take input as function arguments, cutting out the need for input(). Where this is not an option, the following may help in certain cases.

If you want single characters in the variables a and b, you can use
a,b=input()

Entering a 2 character string will then result in the first character being assigned to a and the second character being assigned to b. (Less than 2 or more than 2 characters in the string will give an error.)
If you require more than a single character per variable then this approach will not work. This could still be used to enter 2 single digit numbers as a string. If numbers beyond 9 are required then the full range of potential input characters could be interpreted as numbers.
Note that this also works for more than 2 variables:
a,b,c,d,e,f,g,h=input()

This works because in Python a string is a sequence of characters, and can be used anywhere a sequence is expected.

This may be much shorter for Python3 and inputs as integer
a,b,c=map(int,open(0))

For example expected input is:
23
45
56
The above golf code will assign respective integer values a=23, b=45, c=56


text:
Expand an encoded string
There's the classic run length encoding and decoding.
input   output
a3b2c5  aaabbccccc

And that's fairly straight forward and done before.
The challenge is to also account for a non-standard behavior when multiple characters precede the run length (a single digit from 0-9). Each character before the run length digit (the last digit before a non-digit or end of the string) has that value applied to it individually and printed out in order.
Some test input and output including some edge cases:
input   output
ab3c5   aaabbbccccc
a0b3    bbb
13b1    111b
a13b1   aaa111b
a123b1  aaa111222b
aa2a1b1 aaaaab

A character sequence ([a-zA-Z0-9]+) must be followed by its run length length ([0-9])
Only valid input needs to be considered (([a-zA-Z0-9]+[0-9])*)

yes, empty string is valid input.

Input is via standard input, output via standard output

This is code golf, number of bytes determines the winner.

@AlexA. Correct. There are some esolangs that I enjoy seeing from time to time that are otherwise penalized by byte count. (I am certainly open to suggestions as to why this may be a mistake to count that way)

@MichaelT Scoring by characters strongly encourages compresssing the source code into UTF32, which allows the encoding of up to 4 bytes per character, but is completely unreadable.

@isaacg fair 'nuff.  I'll edit to change to bytes. I'll ruminate on a way to express sclipting's style to be acceptable for future challenges.

Is our submission supposed to complete without error if the input is the empty string? The consensus on meta is that output to STDERR can be ignored, but since you explicitly mentioned it, I have to ask.

@Dennis an empty string as input should, should halt. It should not go into an infinite loop or print other text to standard output.

Pip, 22 + 1 = 23 bytes
Uses -r flag. Note that this requires you to either 1) enter an EOF after the input (Ctrl-D on Linux, Ctrl-Z on Windows) or 2) pipe the input in from somewhere else.
(^_@<v)X_@vMa@`\D*\d+`

Explanation:
                        a is first line of stdin (from -r flag) and v is -1 (implicit)
              `\D*\d+`  Pattern (regex) object that matches zero or more non-digits
                        followed by at least one digit
            a@          Find all non-overlapping matches in a, returning a list of strings
           M            To that list, map a lambda function:
  _@<v                    Argument sans last character (equivalent to Python a[:-1])
(^    )                   Split into a list of characters
        _@v               Last character of argument
       X                  Repeat each character of the list that many times
                          (String multiplication X, like most operators, works item-wise
                          on lists)
                        Auto-print (implicit)

The result of the map operation is actually a list of lists, but by default lists are simply concatenated together when printed, so no manual conversion to string is necessary.
Example, with input a13b1:
Var a gets        "a13b1"
After regex match  ["a13" "b1"]
After map          [["aaa" "111"] ["b"]]
Final output       aaa111b

Pip has basic regex support as of... 2 days ago. Great timing!

That one works (and so does master) with the -r flag. (The question specifies that input has to come from STDIN.)

@Dennis Oops, missed that.  Added flag to byte count.  I should've been able to use the special variable q instead of a with no extra flags, but there seems to be a bug and it's asking for the input twice.

Finally a golfing language with regex support!

@Dennis I see you shifting to pip now!

Perl/Bash 54 40+1 = 41 bytes
perl -pe's:(\D*\d*)(\d):"\$1=~s/./\$&x$2/egr":ege'

It's basically a regex within a regex. And a bit of magic.
Explanation
The outer regex /(\D*\d*)(\d)/g extracts each run-length encoded group. We capture the stuff to repeat in $1 and the number of repetitions in $2. Now we substitute each such group with the expansion of that group. For that, we evaluate the code "\$1=~s/./\$&x$2/egr" two times (as by the /ee flag on the outer substitution).
The first evaluation will only interpolate the number of repetitions into the string – the other variables are protected by a backslash. So assuming the input a14, we would now have the code $1=~s/./$&x4/egr, which will be evaluated again.
This will apply the substitution to the contents of $1 (the stuff to repeat a1). The substitution matches each character .. The $& variable holds the whole match, which we repeat x4 times. We do this /globally for each match and /return the substituted string rather than modifying the $1 variable (which is read-only). So the result of the inner substitution is aaaa1111.
The -p flag applies the substitution to each input line and prints out the result.

It is customary to score this as a Perl solution, where you just add 1 byte for the -p modifier. I count 45 bytes. In addition, you should be able to use \D instead of [a-z], which also eliminated the need for i.

CJam, 33 31 27 bytes
Ughh, lack of regular expressions makes this pretty long...
qN+{:XA,s&L\:L>{])~e*[}&X}%

How it works
We loop through all characters of the input string and in each iteration, keep track of the last encountered character (starting with an empty character for the first time). Then we check if the current character is non-numeric and the last character is numeric. If so, we repeat each previous character (which has not been repeated already), the number times.
(A bit outdated code expansion)
q{                       }%        e# Read the input (q) and loop through each character
  L                                e# Put variable L (initially empty character) on stack
   A,                              e# Put variable A (equals 10) and create an array 0..9
     s                             e# Convert the array to string "0123456789"
      &                            e# Do a set intersect b/w previous char and 0-9 string
                                   e# If numeric, it gives 1 char string, otherwise 0
       \:LA,s&                     e# Swap to bring current character on top. Store it in L
                                   e# and do the same set intersect with it
              >                    e# Means we are checking that current char is non-numeric
                                   e# and previous numeric
               {      }&           e# Run this block if above is true
                ])~                e# Wrap everything not already repeated in an array and
                                   e# take out the last character and convert it to integer.
                                   e# This is the run length of the preceding string
                   e*              e# Repeat each character in the string, run length times
                     [             e# Start a new array to help when next run length is found
                        L          e# Restore the current character back on stack to be used
                                   e# in next iteration
                           )~e*    e# The last string-run-length pair is not decoded..
                                   e# So we do that now

Try it online here

I do appreciate the demonstration of the problem that the bytes qualifier causes. Thank you. I'm thinking a bit on how to phrase the qualification such that languages where a single instruction is a multi-byte character don't get penalized for that style of language without allowing the UTF encoding that you showed to get in via loophole. P.S. I really like seeing the algorithmic breakdown that you provide.

rs, 43 71 chars
Well, this turned long quickly. Stupid numbers...
(\d)(\D)/\1 \2
+(\w)(\w+?)(\d)(?= |$)/\1\3 \2\3
(\w)(\d)/(\1)^^(\2)
 /

Try it here!
Original version (did not work with input like 123):
+(\D)(\D+)(\d)/\1\3\2\3
(\D)(\d)/(\1)^^(\2)

Explanation
The first line places spaces between runs containing numbers, e.g. turning a313 into a3 13.
The second line continuously expands the compressed encodings like aa5 to a5a5.
The third line converts every instance of a5 into aaaaa using the repetition operator.
The last line removes the spaces.

How does it handle a123b1 ?

@Optimizer Not well. I need to tweak it a bit...

@Optimizer Fixed.

Javascript (ES6), 86 83 bytes

alert(prompt().replace(/(.+?)(\d)(?!\d)/g,(a,b,c)=>b.replace(/./g,y=>y.repeat(c))))

Commented:
alert( // output final result
    prompt(). // take input
    replace(/(.+?)(\d)(?!\d)/g, // replace ungreedy capture group of any characters
                                // followed by a digit (captured)
                                // and not followed by a digit (negative lookahead)
        (a, b, c)=> // replace with a function
            b.replace(/./g, // replace all characters in b
                y=>y.repeat(c) // with that character repeated c times
            )
    )
)

Won't alert(prompt().replace(/(.+?)(\d)(?!\d)/g,(a,b,c)=>Array(c+1).join(b))) do the same? It is only 71 bytes long.

@IsmaelMiguel that would only work if there was a single character before the digit. The array comprehension handles repeating each character individually.

Try Array(6).join('12') and it will return '1212121212'.

This one works: alert(prompt().replace(/(.+?)(\d)(?!\d)/g,(a,b,c)=>Array(-~c).join(b))) (same 71 bytes long, tested on http://www.es6fiddle.net/ia7gocwg/)

@IsmaelMiguel the expected result is '111111222222'

Oh, now I get it! Sorry for wasting your time then.

I found a different (obvious) way to say 3 bytes though :D

That, indeed, is obvious. And a good solution. I would never remember of using it like that. I was thinking that ab2 would be abab and not aabb. But well, it really is a good solution.

CJam, 27 25 bytes
r_'A+1>.{64&1$>{])~f*o}&}

Try it online in the CJam interpreter.
How it works
r_                        e# Read a token from STDIN and push a copy.
  'A+                     e# Append the character A to the copy.
     1>                   e# Discard the first character of the copy.
       .{               } e# For each character C of the input string and the
                          e# corresponding character D of the copy:
         64&              e#   Take the bitwise and of D and 64. This pushes @
                          e#   if D is a letter and NUL if it is a digit.
            1$>           e#   Compare the result to a copy of C. This pushes 1
                          e#   if and only if D is a letter and C is a digit.
               {      }&  e#   If the result was 1, do the following:
                ]         e#     Wrap the stack in an array.
                 )~       e#     Pop and evaluate the last character.
                   f*     e#     Repeat each char in the array that many times.
                     o    e#     Print all characters.

Pyth, 33 32 28 bytes
ssmm*vedkPdPcz-hMJf<@zT\=UzJ

Try it online: Demonstration or Test harness
Explanation
I'll explain the code using the example input aa1a23b2. Hopefully this is a bit easier to follow than without.
                               implicit: z = input string = 'aa1a23b2'
                         Uz    the indices of z: [0, 1, 2, 4, 5, 6, 7]
                  f            filter for indices T, which satisfy:
                   <@zT\=        z[T] < "="
                               this gives us the list of indices [2, 4, 5, 7],
                               which correspond to digits in z.
                 J             assignment, J = [2, 4, 5, 7]
               hMJ             increment all element in J: [3, 5, 6, 8]
              -            J   and remove the elements of J:
                                 [3, 5, 6, 8] - [2, 4, 5, 7] = [3, 6, 8]
            cz                 split z at these indices: ['aa1', 'a23', 'b2', '']
           P                   remove last element: ['aa1', 'a23', 'b2']
  m                            map each string d to:
   m     Pd                      map each string k of d-without-last-char to:
     ved                           int(last element of d)
    *   k                          * k
                               this creates [['a', 'a'], ['aaa', '222'], ['bb']]
 s                             sum the lists: ['a', 'a', 'aaa', '222', 'bb']
s                              sum the strings: 'aaaaa222bb'

Ruby 73
gets.split(/(\d)(?!\d)/).each_slice(2){|s,i|s.chars.map{|c|$><<c*i.to_i}}

Tests: http://ideone.com/L1fssb

JavaScript 112

alert(prompt().replace(/.*?\d+/g,function(m){for(i=n=m.length-1,o="";i--;){j=m[n];while(j--)o=m[i]+o}return o}))

Python 2.7, 98 bytes
import re
print"".join(c*int(m[-1])for m in
re.findall(r".+?\d(?!\d)",raw_input())for c in m[:-1])

This just does a simple regex search for digits that aren't followed by a digit, and then does the string arithmetic on each group and joins them all back together.

You could save 2 bytes by switching from Python 2 to 3. raw_input becomes input but print needs parentheses.

True, but I prefer to golf in python 2.7.

Python 3, 148 144 136 135 Bytes
w,o,r,d=''.join,'',[],[]
for c in input()+' ':
 if'/'<c<':':d+=[c]
 elif d:o+=w(x*int(w(d))for x in r);r=[c];d=[]
 else:r+=[c]
print(o)

Thanks to Pietu1998 and mbomb007 for the suggestions.
Python 2, 161 151 147 139 138 Bytes
Maybe today's just been a long day at work, but I can't for the life of me figure out how to golf this..
w,o,r,d=''.join,'',[],[]
for c in raw_input()+' ':
 if'/'<c<':':d+=[c]
 elif d:o+=w(x*int(w(d))for x in r);r=[c];d=[]
 else:r+=[c]
print o

Changing to Python 3 saves a couple of bytes (raw_ out, parentheses to print). len(d)>0 can be replaced by d since an empty list is falsy and a non-empty list truthy. list(...) can go straight to the for. The square brackets in w([...]) are unnecessary since it's the only argument. You can remove the space in ) for. That's all the minor things I came up with so far.

@Pietu1998 Thanks for the help!

Without changing your approach too much, you can get rid of list() since strings are iterable.  You can use w=r=''.  If you're willing to change it a lot, see my solution. :)

if c.isdigit() can become if'/'<c<':', if I'm not mistaken.

@DLosc thanks, that seems to work.

Remove the space in if '/'.

Julia, 105 99 95 87 bytes
s->join([join([string(b)^(int(p[end])-48)for b=chop(p)])for p=matchall(r"\D*\d*\d",s)])

This creates an unnamed function that takes a string as input a returns a string. To call it, give it a name, e.g. f=s->....
Two array comprehensions are used here, one nested within the other. The outer comprehension acts on each match of the input string against the regular expression \D*\d*\d. The inner comprehension repeats each character of the match according to the trailing digit. The elements of the inner array are joined into a string, so the outer array is an array of strings. These are joined and returned.
In Julia, strings can be treated like character arrays. However, note that the Char and String types in Julia don't have the same methods defined; in particular, there is no method for repetition using ^ for characters. This uses a convoluted workaround:

Loop over the string omitting the last character, which is removed using chop().
Convert the current character to a string using string().
Convert the trailing digit, which is also a character, into an integer. However, note that, for example, int('4') does not return 4. Rather, it returns the codepoint, which in this case is 52. Thus we can subtract 48 to get back the actual integer.
Repeat string(b) according to int(p[end]) - 48.

Examples:
julia> f("ab3c5")
"aaabbbccccc"

julia> f("a0b3")
"bbb"

julia> f("13b1")
"111b"

Java 7, 175 bytes
String c(String s){String r="",a[];for(String x:s.split("(?<=(\\d)(?!\\d))")){a=x.split("");for(int i=0,j,l=a.length-1;i<l;i++)for(j=0;j++<new Short(a[l]);r+=a[i]);}return r;}

The challenge is harder than it looks, imo..
Ungolfed & test code:
Try it here.
class M{
  static String c(String s){
    String r = "",
           a[];
    for(String x : s.split("(?<=(\\d)(?!\\d))")){
      a = x.split("");
      for(int i = 0, j, l = a.length-1; i < l; i++){
        for(j = 0; j++ < new Short(a[l]); r += a[i]);
      }
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c("ab3c5"));
    System.out.println(c("a0b3"));
    System.out.println(c("13b1"));
    System.out.println(c("a13b1"));
    System.out.println(c("a123b1"));
    System.out.println(c("aa2a1b1"));
    System.out.println(c("123"));
  }
}

Output:
aaabbbccccc
bbb
111b
aaa111b
aaa111222b
aaaaab
111222


text:
Fix the Braces, etc
Your mission, should you choose to accept it, is to add the minimum number of parentheses, braces, and brackets to make a given string (containing only parentheses, braces, and brackets) have correct brace matching. Ties of symbols added must be broken by having the maximum distance between paired braces. You must return only one correct answer that matches these two rules; Further ties, should they exist, may be broken any way you see fit.
Examples:
input      output
                          // Empty String is a legal input
[          []             // Boring example
[()]       [()]           // Do nothing if there's nothing to be done
({{        ({{}})         // NOT (){}{} (0 + 0 + 0). Maximum distance is 4 + 2 + 0, ({{}})
[([{])]}   {[([{}])]}     // NOT [([])]{[([])]} or similar

You may write a program or function, receives the input via STDIN as a string argument to your function, which returns the output as a string or prints it to STDOUT (or closest alternative). You may optionally include a single trailing newline in the output.
You may assume the input string consists only of the following 6 characters (or lack thereof): [](){} (You do not need to support <>)
This is code-golf, shortest program wins. Standard loopholes are banned, of course.

Did you mean to repeat the title directly underneath the actual title, or repeat the tag directly above the actual tags? Just asking in case you copy pasted from Sandbox and forgot to remove them.

@Rainbolt The former no (sandbox), the latter yes

@AlexA. I can see how they're different in minor ways, but I think they're too similar to be considered separate questions.

Fair enough. It's certainly not cut-and-dry, and I won't pursue getting it closed if others decide not to.

I would consider it different enough. Voted to reopen.

Will there be adjacent top-level groups (such as {[()]}[()])?

@AlexL. there can be, if that is the shortest answer with maximum distance. Note that in most cases it won't be, because of the maximum distance rule, but not all cases. For example {[()]}[() would result in {[()]}[()].

Python 3, 211 207 198 bytes
After some work on this variation of this question (matching the brackets given exactly 1 unclosed opening bracket, with no possible unopened closing brackets), I realized that my answer to that could be adapted to this problem (which was linked as a possible duplicate).
f=lambda s:s[::-1].translate(" ] [)(} {"*14)
def m(a):
 *u,b="",
 for x in a:
  if x in"([{":u+=x
  elif u and x!=f(y:=u.pop()):b+=f(y);*u,_=u
  b+=x
 return b+f("".join(u))
M=lambda a:f(m(f(m(a))))

Edit -4 bytes: inspired by some golfs on my answer on the other post by @ovs
Edit -9 bytes: We have tied the old python2 answer here!! I knew there had to be some way to golf the closing of any trailing unclosed brackets onto the return statement, and after trying a lot of nonsense involving map() I realized that if I just .join(u) with the empty string, I can reverse it with f() at the same time as flipping the brackets
Try it online!
Explanation and ungolfed code:
This answer takes my answer to the other problem, which loops through a string and adds a missing closing bracket to properly match an unclosed opening bracket, adapts it slightly to ensure it works for multiple unclosed brackets, and then applies it to the string twice, flipping the string in-between.
f=lambda s:s[::-1].translate(" ] [)(} {"*14) ## lambda that flips a string, and reverses all the brackets in it
def m(a): ## function that takes a string and matches every unclosed opening bracket (ignores unopened closing brackets)
    u=[] ## list holding all currently unclosed brackets
    b="" ## string that the result is build in
    for x in a: ## loop through the input
        if x in"([{": ## if its an opening bracket
            u+=[x] ## add it to the unclosed list
        elif u and x!=f(y:=u.pop()): ## if there are unclosed brackets and this bracket doesnt close the last opened one
            b+=f(y); ## add the necessary closing bracket
            u.pop() ## pop the extra opening bracket that x closes
        b+=x ## no matter what, add this character to the result
    return b+f("".join(u)) ## join the remaining unclosed brackets into a single string, flip it with f(), and add it to the result
M=lambda a:f( ## Flip the final string back to the correct order
         m(f( ## Flip the string and apply m again to match the unopened closing brackets
         m(a)))) ## Apply the above function to the result to match all unclosed opening brackets

Haskell, 513
The function h.  Previous version did not give correct answers for "({{)[" and "({{)}}"
import Control.Monad

m '('=')'
m '['=']'
m '{'='}'
m ')'='('
m ']'='['
m '}'='{'

data B=B Char[B]|N[B]|Z B Char[B]
instance Eq B where(==)a b=q a==q b
instance Ord B where(<=)a b=q a<=q b

w(B o s)=o:(s>>=w)++[m o]
v(N k)=k>>=w
n(B _ k)=(sum$n<$>k)+1
q(N k)=sum$n<$>k

u(Z(Z g pc pk) c k)=Z g pc(pk++[B c k])
u(Z(N pk) c k)=N(pk++[B c k])
t(N k)=N k
t z=t$u z

f z c|elem c "([{"=[Z z c[]]
f z@(Z p o k) c|m c==o=[u z]|2>1=(u$Z(Z p o [])(m c)k):f(u z)c
f (N k)c=[Z(N[])(m c)k]

h s=v.minimum$t<$>foldM f(N [])s

Python 2 - 198
I was hoping to get some of the comprehensions down a bit more but don't have a lot of time right now to really test different ways of doing things.
s="()[]{}";f=s.find
def F(S):
 r=m=""
 for c in S:
    i=f(c)^1
    if i%2:m=c+m;r+=c
    else:
     for d in m:
        if d==s[i]:break
        r+=s[f(d)^1]
     else:r=s[i]+r+c
     m=m[1:]
 for c in m:r+=s[f(c)^1]
 return r

The OP did not include an example like {[([{}])]}{[ (with adjacent groups), but whether or not this functionality is required this outputs the correct {[([{}])]}{[]}

How is that 198 bytes?

@ZacharyT, tabs (\t) get formatted as 4 spaces on stack overflow but I am actually alternating tabs and spaces (you can do this for indentation levels in Python 2, not 3) so first level is [space] second is [tab] third is [tab][space] forth is [tab][tab]. Entering the code in with spaces gives me 227 from here https://mothereff.in/byte-counter, and I count 10 tabs so 227 - (3 * 10) = 197. Huh, I guess I actually over-counted by 1 way back when I posted this.

DANG! That's a really good trick. (Enter at end of line). You can combine the bottom for-loop and the return-statement to return r+[s[f(c)^1]for c in m]to save bytes.