# Calculate The Digit Sum

Your task is to get two numbers, and output the digit sum of them. We'll define digit sum as the following:

• take the decimal (base 10) digits of each of them, and pad with 0s the shortest number (e.g. [1,9], [0, 7])
• sum the digits as vectors (e.g. [1, 16])
• convert the number back from base 19, and output it (e.g. 1*19+16=35)

# Input

You can take the input as two numbers, as a list containing both of them or in any other reasonable format (like an array of digits). You can assume the shortest number is padded with zeros so it fits the length of the longer one

# Output

You can output the digit sum in any reasonable format.

# Test cases

1, 2 -> 3
5, 10 -> 24
42, 32 -> 137
15717, 51358 -> 826819
1000, 1 -> 6860


explanation of 5, 10: the digits of these are [0, 5] and [1, 0]. Their sum is [1, 5], which when converted from base 19 results in 24.

# Scoring

This is code golf, so the shortest answer wins, good luck!

# J, 6 bytes

19#.+/


Try it online!

• 19#. convert the following to base 19...
• +/ elementwise sum of the input digit lists.
• You can take a digit list as an input. – user92069 May 4 '20 at 11:17
• Thanks, not much content at this point though. – Jonah May 4 '20 at 11:20

# Jelly, 4 bytes

ḅ19S


A monadic Link accepting a list of lists of digits which yields an integer.

Try it online!

# Python, 30 bytes

lambda a,b:int(a,19)+int(b,19)


An unnamed function accepting two strings of (base ten) digit characters which returns an integer.

Try it online!

# Japt-mx, 6 3 bytes

Takes input as an array of digit arrays.

ì19


Try it

# 05AB1E, 4 bytes

-1 thanks to Command Master.

+19β


Try it online!

• 4 bytes – Command Master May 6 '20 at 13:41
• + vectorizes!? I was an idiot. – user92069 May 6 '20 at 13:43

# Python 2, 46 bytes

f=lambda a,b:a+b and a%10+b%10+19*f(a/10,b/10)


Try it online!

Recursive function that sums each digit pair and convert them to base 19.

# Wolfram Language (Mathematica), 24 bytes

Tr[#~FromDigits~19&/@#]&


Unnamed function taking as input a list that contains two lists of digits. The main point here is that converting to base 19 first and then adding means that padding on the left is unnecessary.

Try it online!

# Wolfram Language (Mathematica), 30 bytes

Total@PadLeft@#~FromDigits~19&


Try it online!

Takes input as list of digits as @my pronoun is monicareinstate suggested and saved 13 bytes (IntegerDigits)

-1 byte @LegionMammal978

• I think you can take two lists of digits as input. – the default. May 4 '20 at 13:41
• -1 byte: Total@PadLeft@IntegerDigits@#~FromDigits~19& – LegionMammal978 May 5 '20 at 2:33

echo $[19#$1+19#$2]  Try the test cases online! The input numbers are passed as two arguments. Output is on stdout. # C (gcc), 67 65 bytes Saved 2 bytes thanks to Mitchell Spector!!! s;m;f(a,b){for(s=m=1;a+b;a/=10,b/=10,m*=19)s+=(a%10+b%10)*m;s--;}  Try it online! • 65 bytes – Mitchell Spector May 5 '20 at 3:51 • @MitchellSpector Nice, homogeneous init with a tweak at the end to make it the return value - thanks! :-) – Noodle9 May 5 '20 at 9:34 # K (oK), 5 bytes Solution: 19/+/  Try it online! Explanation: Takes input as two lists of digits. Assumes the shorter number is padded with 0s. 19/+/ / the solution +/ / sum 19/ / decode from base 19  # Charcoal, 8 bytes ＩΣＥ²⍘Ｓ¹⁹  Try it online! Link is to verbose version of code. Takes input as two strings. Explanation:  ⍘Ｓ¹⁹ Convert the input from base 19 Ｅ² Repeated twice ＩΣ Summed and output in decimal  # dc, 47 bytes ?[0q]sZ[sydsxly+0=ZlxA~rlyA~4R+_3Rlfx19*+]dsfxp  Try it online! Or verify all the test cases online. Input is on stdin (the two numbers on one line, separated by a space). Output is on stdout. This program makes use of a nice facility in dc, where the single-character command ~ will compute both the quotient and the remainder in a division operation. # Java (JDK), 40 bytes a->b->a.valueOf(""+a,19)+a.valueOf(b,19)  Try it online! Takes input as a:Integer and b:String. # PHP, 75 bytes for($n=strlen($a=$argv);$n--;)$r+=($a[$i]+$argv[$i++])*19**$n;echo$r;


Try it online!

As often, getting arguments and dollars makes PHP the longest answer so far :D still i'm content with this

Takes input as strings already padded with zeroes

# JavaScript (Babel Node), 43 bytes

f=(a,b)=>a+b&&a%10+b%10+19*f(a/10|0,b/10|0)


Try it online!

• But (a,b)=>(p=parseInt)(a,19)+p(b,19) is only 33 bytes... – tsh May 7 '20 at 5:07

# Pyth, 76 5 bytes

Takes input as two lists of digits. Assumes the shorter number is padded with 0's.

siR19


Try it online!

siR19
R       (Right-) Map each digit array of the input to:
i 19     The digit array converted from base 19
s         Take the sum


# Ruby, 24 bytes

->a{a.sum{|x|x.to_i 19}}


Accepts an array of two strings.

Try it online!

# Brachylog, 6 bytes

~ḃ₁₉ᵐ+


Try it online!

Takes input as a digit list, but the testing header converts from single integers for convenience.

# Python 3, 77 72 bytes

lambda x,y:sum(n*19**x for x,n in enumerate([*map(sum,zip(x,y))][::-1]))


Try it online!

Not one of the shortest approaches, but it works.

-5 bytes thanks to @ovs

• You can use map for 72 bytes: enumerate([*map(sum,zip(x,y))][::-1]). – ovs May 4 '20 at 17:24