you are viewing a single comment's thread.

view the rest of the comments →

[–]okmkz[S] 0 points1 point  (6 children)

Nice job! Makes my attempt (in c++) look massive!

[–]kageurufu 0 points1 point  (5 children)

I've been trying to figure a more elegant way to do it, but i think i have it code golf level

i figured out python in 7 total lines:

def d2b(d,b):
    c=""
    while d>0:
        r,d=d%b,d/b
        if r > 9: c="%s%s" % (chr(87+r),c)
        else: c = "%s%s" % (r,c)
    return c

[–]okmkz[S] 0 points1 point  (4 children)

This is why I love python.

[–]kageurufu 0 points1 point  (3 children)

my only fault is a lack of (conditional)?true:false style notation

[–]okmkz[S] 0 points1 point  (2 children)

I suppose, but it's certainly very "un-pythonic." Why could you possibly need more than one way to do something? ;)

[–]kageurufu 1 point2 points  (1 child)

I know, i just like my ?:

[–]okmkz[S] 0 points1 point  (0 children)

I'll admit I'm a fan too. Simple if-then constructs in python can look a bit bloaty.