Mathematica Q&A: Four Ways to Sum Integer Digit Blocks
Got questions about Mathematica? The Wolfram Blog has answers! We'll regularly answer selected questions from users around the web. You can submit your question directly to the Q&A Team using this form.
This week's question comes from Craig, a hobbyist:
For each six-digit number in a list, how can I check whether the sums of the first and last three digits are equal?
For example, the sums of the first and last three digits of the number 123,222 are equal because 1 + 2 + 3 == 2 + 2 + 2.
There are several different ways of solving this straightforward programming problem in Mathematica, and it's instructive to compare them. In this post you'll see four methods demonstrating various combinations of built-in Mathematica functions for working with lists and digits of integers.