Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 deleted 22 characters in body
source | link

Python 3, 165158

import re
def te=input(e):
 b=[];p=0
 for s in re.split('\D+''\D',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]=(b[2]+p)%24;f='{:02d}:'*3;return f.format%02d'*3;print(*b[:f[1:-1]]%(b[2],b[1],b[0])[:-1])

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24base[2]=(base[2]+previous_carry)%24
    format_str = '{:02d}:'*3%02d'*3
    return format_str.format(*base[:format_str[1:-1]]%(base[2],base[1],base[0])[:-1]

Python 3, 165

import re
def t(e):
 b=[];p=0
 for s in re.split('\D+',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]=(b[2]+p)%24;f='{:02d}:'*3;return f.format(*b[::-1])[:-1]

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24
    format_str = '{:02d}:'*3
    return format_str.format(*base[::-1])[:-1]

Python 3, 158

import re
e=input()
b=[];p=0
for s in re.split('\D',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
b[2]=(b[2]+p)%24;f=':%02d'*3;print(f[1:]%(b[2],b[1],b[0]))

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]=(base[2]+previous_carry)%24
    format_str = ':%02d'*3
    return format_str[1:]%(base[2],base[1],base[0])
2 deleted 4 characters in body
source | link

Python 3, 169165

import re
def t(e):
 b=[];p=0
 for s in re.split('\D+',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]+=p;b[2]=b[2]%24;f='b[2]=(b[2]+p)%24;f='{:02d}:'*3;return f.format(*b[::-1])[:-1]

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24
    format_str = '{:02d}:'*3
    return format_str.format(*base[::-1])[:-1]

Python 3, 169

import re
def t(e):
 b=[];p=0
 for s in re.split('\D+',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]+=p;b[2]=b[2]%24;f='{:02d}:'*3;return f.format(*b[::-1])[:-1]

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24
    format_str = '{:02d}:'*3
    return format_str.format(*base[::-1])[:-1]

Python 3, 165

import re
def t(e):
 b=[];p=0
 for s in re.split('\D+',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]=(b[2]+p)%24;f='{:02d}:'*3;return f.format(*b[::-1])[:-1]

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24
    format_str = '{:02d}:'*3
    return format_str.format(*base[::-1])[:-1]
1
source | link

Python 3, 169

import re
def t(e):
 b=[];p=0
 for s in re.split('\D+',e)[:3][::-1]:c,a=divmod(int(s),60);b+=[a+p];p=c
 b[2]+=p;b[2]=b[2]%24;f='{:02d}:'*3;return f.format(*b[::-1])[:-1]

Ungolfed version:

import re
def timer(elapsed):
    base=[]
    previous_carry=0
    for section in re.split('\D+',elapsed)[:3][::-1]:
        carry,amount=divmod(int(section),60)
        base+=[amount+previous_carry]
        previous_carry=carry
    base[2]+=previous_carry
    base[2]=base[2]%24
    format_str = '{:02d}:'*3
    return format_str.format(*base[::-1])[:-1]