From c1a136202c08df82252fa65436d158619aa3c88e Mon Sep 17 00:00:00 2001 From: AaqibhafeezKhan Date: Thu, 12 Nov 2026 07:12:50 +0530 Subject: [PATCH 1/3] docs: add source link to practice122 keypad phone simulator Link to original Codewars problem: Multi-tap Keypad Text Entry on an Old Mobile Phone This helps learners find the original problem statement and understand the T9-style multi-tap keypad input mechanism. Co-Authored-By: Claude Haiku 4.5 --- solutions/python/practice122.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solutions/python/practice122.py b/solutions/python/practice122.py index f314b1f..0470a05 100644 --- a/solutions/python/practice122.py +++ b/solutions/python/practice122.py @@ -1,6 +1,6 @@ -# Problem: Keypad Phone Simulator -# Source: -# Note: Simulates phone keypad text input +# Problem: Keypad Phone Simulator (Multi-tap Keypad Text Entry) +# Source: https://www.codewars.com/kata/54a2e93b22d236498400134b +# Note: Simulates phone keypad text input (T9-style multi-tap) number_of_word = int(input()) res = [] From b01740518cbe4b2acf03b0a8dbddcf817a0c8529 Mon Sep 17 00:00:00 2001 From: AaqibhafeezKhan Date: Thu, 12 Nov 2026 07:16:28 +0530 Subject: [PATCH 2/3] feat: port alternating digit sum solution to javascript Port of python/practice101.py to JavaScript. Solves the problem of calculating alternating digit sums by reading digits left to right, alternating between addition and subtraction. Closes #219 Co-Authored-By: Claude Haiku 4.5 --- solutions/javascript/practice2.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 solutions/javascript/practice2.js diff --git a/solutions/javascript/practice2.js b/solutions/javascript/practice2.js new file mode 100644 index 0000000..4443095 --- /dev/null +++ b/solutions/javascript/practice2.js @@ -0,0 +1,29 @@ +// Problem: Calculate Alternating Digit Sum +// Source: https://leetcode.com/problems/alternating-digit-sum/ +// Ported from: python/practice101.py +// Read the digits from left to right, adding the first, subtracting the next, +// and continuing to alternate. For example, 521 becomes 5 - 2 + 1 = 4. +// Time: O(d), where d is the number of digits. + +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.question('Enter a positive integer: ', (input) => { + const n = input.trim(); + + let plus = true; + let res = 0; + + for (const digit of n) { + const num = parseInt(digit); + res += plus ? num : -num; + plus = !plus; + } + + console.log(`Sum: ${res}`); + rl.close(); +}); From e56d21043eb81dbf48b2a8ddfe555426022ed1be Mon Sep 17 00:00:00 2001 From: Aaqibhafeez Khan Date: Thu, 12 Nov 2026 07:30:39 +0530 Subject: [PATCH 3/3] fix: satisfy solution header validation --- solutions/javascript/practice2.js | 5 ++--- solutions/python/practice122.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/solutions/javascript/practice2.js b/solutions/javascript/practice2.js index 4443095..b7ffd36 100644 --- a/solutions/javascript/practice2.js +++ b/solutions/javascript/practice2.js @@ -1,8 +1,7 @@ // Problem: Calculate Alternating Digit Sum // Source: https://leetcode.com/problems/alternating-digit-sum/ +// Note: Add and subtract consecutive digits from left to right. // Ported from: python/practice101.py -// Read the digits from left to right, adding the first, subtracting the next, -// and continuing to alternate. For example, 521 becomes 5 - 2 + 1 = 4. // Time: O(d), where d is the number of digits. const readline = require('readline'); @@ -19,7 +18,7 @@ rl.question('Enter a positive integer: ', (input) => { let res = 0; for (const digit of n) { - const num = parseInt(digit); + const num = parseInt(digit, 10); res += plus ? num : -num; plus = !plus; } diff --git a/solutions/python/practice122.py b/solutions/python/practice122.py index 0470a05..f314b1f 100644 --- a/solutions/python/practice122.py +++ b/solutions/python/practice122.py @@ -1,6 +1,6 @@ -# Problem: Keypad Phone Simulator (Multi-tap Keypad Text Entry) -# Source: https://www.codewars.com/kata/54a2e93b22d236498400134b -# Note: Simulates phone keypad text input (T9-style multi-tap) +# Problem: Keypad Phone Simulator +# Source: +# Note: Simulates phone keypad text input number_of_word = int(input()) res = []