may 2023 PIC
may 2023 PIC
1 of 2
Regulation: R22 Code No: 22TP103/05
SECTION-B
Answer all Two questions 2×20M=40M
5. Large corpus of text file is available. But the problem in that text file is that there are many
errors.’a’ is written as ‘@’,’b’ is written as ‘p’, ‘p’ is written as ‘o’,’@’ is written as ‘b’,’o’ is
written as ‘a’,’.’ is written as ‘#’,’#’ is written as ‘?’,’?’ is written as ‘.’. Implement the
following tasks:
a. Read the text and clean the text by correcting them.
b. Find number of sentences
c. Find total number of words.
d. Find the number of words having “@#abp” sequence in them.
e. Find largest word without any special characters.
f. Print the unique words that does not have any special characters.
g. Print all the words having only digits.
6.In the game called Towers of Hanoi, there are three towers labeled A, B, and C. The game starts
with n disks on tower A. For simplicity, suppose n is 5. The disks are numbered from 1 to 5,
and without loss of generality we may assume that the diameter of each disk is the same as its
number. That is, disk 1 has diameter 1 (in some unit of measure), disk 2 has diameter 2, and
disk 3 has diameter 3 and so on.
All five disks start on tower A in the order 1, 2, 3,4,5. The objective of the game is to move
all the disks on tower A to C. Only one disk may be moved at a time. Any of the towers A, B,
or C may be used for the intermediate placement of disks. After each move, the disks on each
of the towers must be in order. That is, at no time can a larger disk be placed on a smaller
disk.
a. Implement the above problem using recursive function.
b. Implement the above problem using non recursive function.
c. Design a function to compute total number of moves required to solve the problem.
d. Draw the pictorial representation for the complete solution.
2 of 2