Skip to main content
Commonmark migration
Source Link

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

#Input YouYou 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!

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!

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!

Tweeted twitter.com/StackCodeGolf/status/1257460043362025473
Became Hot Network Question
Source Link
Command Master
  • 10.7k
  • 1
  • 11
  • 73

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!