Question: Problem Statement Given a string of integers, write a program to generate an output string as follows i ) From the input integers, filter the

Problem Statement
Given a string of integers, write a program to generate an output string as follows
i) From the input integers, filter the integers that are perfect squares. Ex: 1,4,9,16,25,36,49,64,81,100dots
ii) For each perfect square obtained from step 1, find its factorial. If the factorial of the number is trailing by zeros, three digits present before the trailing zeros should be appended to output string. If not trailing by zeros append last three digits to output string. If there is a preceding zero, it is ignored.
i. If the number is 2 then 22, it does not have any trailing zeros and there is only one digit in it, so append 2 to output.
ii. If the number is 5 then 5120, it has one trailing zero and before the trailing zero there are only two digits present so append 12 to output.
iii. If the number is 9 then 9362880, it has one trailing zero, before trailing zero there are five digits present, so consider three digits before trailing zero that is 288 and append to output.
iv. If the number is 12 then 12479001600, it has two trailing zeros, before trailing zeros there are seven digits present, so consider three digits before trailing zero that is 016 as 0 is preceded here, 0 is ignored and 16 is appended to output.
iii)lf there are no positive perfect squares in the input string print -1
Example:
Input String: 2,4,6,9,35,100
Perfect squares from input are: 4,9,100
Factorial of the perfect squares are:
4-24(Factorial is not trailing by zero. Hence, will be considered as it is in Output).
9-362880(Factorial is trailing by zero. Hence, last 3 digits before zero -288, will be considered)
100-
93326215443944152681699238856266700490715968264381621468592
(Factorial is trailing by zero. Hence, last 3 digits before zero-864, will be considered)
Hence, Output will be: 24,288,864.
Input Format: Input string contains all the numbers separated by comma.
Output Format: All the values in output string should be printed in the form of single string, where values should be separated by comma. And in case, there are no positive perfect squares then -1 should be printed.
Input Format: Input string contains all the numbers separated by comma.
Output Format: All the values in output string should be printed in the form of single string, where values should be separated by comma. And in case, there are no positive perfect squares then -1 should be printed.
\table[[Sample Input,Sample Output,Explanation],[2,4,6,9,81,25,100,144,24,288,48,984,864,616,NA],[2,3,5,6,7,8,-1,\table[[There are no perfect],[squares present in the],[input, so-1 will be],[printed]]],[,24,\table[[Considered only positive],[numbers in the input]]]]
Languages: Python 3
 Problem Statement Given a string of integers, write a program to

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 Databases Questions!