Question: CS 1 3 1 5 Computer Programming Assignment Two ( 2 0 2 4 - 2 5 Sem. A ) Deadline: 2 7 - Nov

CS1315 Computer Programming
Assignment Two (2024-25 Sem. A)
Deadline: 27-Nov-202413:00(Week 13 Wed) No Late submission will be accepted
Problem description
From time to time, in magazine / newspapers, there are arithmetic
puzzles like the one on the right hand side. The puzzle replaced digits (0..9)
with alphabets (e.g. X) and players need to work out a feasible solution.
(For instance, in the puzzle on the right, X=3, so that 123+11+2=136)
In this assignment, we are not going to solve the puzzle; but instead, we need to verify
a given solution and report whether it is correct or not. For simplicity, we only
consider addition of term(s). The detailed requirements are as follows:
1. First the program will read in a single-line solution:
The line contains 2..52 chars, packed with interlaced alphabets (A..Z) and the
corresponding digits (0..9) in any order. (e.g.A1B2D4C3X7).
All alphabets are unique and is always in uppercase.
The solution contains ALL alphabets used in the puzzle (and maybe more).
2. Then the program reads in the number base:
The program should support any base from 2(binary) to 10(decimal).
3. The program then reads in the total line (like the 1X6 in the example):
The total line contains 1..100 alphabet(s)/ digit(s).
The total may or may not be in the simplest form (e.g.001X6).
4. Then the program reads in the number of term(s) N (>=1) to add:
N can be 1, which means no addition is needed.
5. Then N line(s) follows, with one term per line:
Each line contains 1..100 alphabet(s)/ digit(s).
Each line may or may not be in the simplest form (e.g.000012X).
It is guaranteed that the sum of the N terms will not exceed 100 digits.
6. The program will then report the finding:
Error if the mapped solution/input lines contains illegal digit under the
given base. (e.g. In base2,123, or 1XX with a mapping of X=2)
Correct if the mapping in the solution line can solve the puzzle.
Wrong if the addition result is numerically different from the solution line.
12X
11
+2
1X6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!