Beta

Exploring the Trachtenberg System: Detailed Multiplication by Two

Description:

Exploring the Trachtenberg System: Multiplication by Two

Introduction:

Imagine young John, a middle school student, eager to impress his math teacher. He decides to learn the unconventional multiplication method known as the Trachtenberg System. This system, crafted by Jakow Trachtenberg while he was a prisoner in a concentration camp, was his mental escape and a way to retain sanity amidst chaos. To keep his mind occupied, Trachtenberg devised this innovative method to multiply long numbers by single digits using a set of simple rules. John starts with multiplying by 2, as multiplying by 1 is trivial, but he needs to ensure he's applying the procedure correctly.

Task:

Your task is to help John by creating a function that takes any integer and breaks down the multiplication process according to the Trachtenberg System. The function should return an array where each digit of the multiplied number corresponds to a string describing the step-by-step calculation process. Exemplary array which your function should return. An array of tuples, each containing a digit and a string describing the multiplication step, including carryovers for the number 9870 should look that way:

[(0, "0"), (7, "1/4"), (8, "1/7"), (9, "1/9"), (0, "1")]

The Trachtenberg System for Multiplication by Two:

General rules:

  1. Prefix each number with a 0 (e.g., 3461 becomes 03461).
  • Next two are not required for this particular kata:
  1. "Neighbor" refers to the digit on the right of a given digit. If there is no neighbor, assume it to be 0.
  2. The "half" of a digit is its floor-divided value by 2 e.g., half of 9 is 4.

Multiplication by 2

  1. Consider the number 9870. In accordance with note 2, we write it as 09870.
  2. Write down the digits of the number vertically, starting from the last digit and remembering the zero.
  3. Double each digit.
  4. If we get a number equal to or greater than 10 at any point, for example, 12, we keep 2, and carry over the 1 to the next lower digit.

Step-by-Step Example of Multiplying 9870 by 2:

  • 0 — 0 x 2 = 0
  • 7 — 7 x 2 = 1/4
  • 8 — 8 x 2 + 1 (carryover) = 1/7
  • 9 — 9 x 2 + 1 (carryover) = 1/9
  • 0 — 0 x 2 + 1 (carryover) = 1

If Jonh reads the result from the bottom up, he has the resoult of multiplication 9870 by 2, which is 19740.

This kata is just the beginning of exploring the Trachtenberg system, which includes unique techniques for multiplication by other numbers, squaring, and division. More complex katas will follow to delve deeper into this fascinating system. If you find this kata engaging and want to learn more, you might be interested in "The Trachtenberg Speed System of Basic Mathematics" which elaborates on these techniques in detail.

Mathematics
Algorithms
Number Theory
Arrays

Stats:

CreatedNov 11, 2023
PublishedNov 12, 2023
Warriors Trained9
Total Skips0
Total Code Submissions33
Total Times Completed5
Swift Completions5
Total Stars1
% of votes with a positive feedback rating0% of 2
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes2
Total Rank Assessments2
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • KuuuGR Avatar
Ad