Computer Science, asked by suvarnarajuk170, 1 year ago

Consider a problem using the following components: 1) Spelt numbers (we shall confine these to integers): 2) Spelt operators: • "" (Empty string: perform no operation) • Plus (Add the spelt numbers) • Minus (Subtract the second from the first spelt number) • Into (Multiply the spelt numbers) • By (Divide the first by the second spelt number) • Square root of (Take the square root of the spelt number) 3) Spelt operators applied on the spelt numbers 4) The numeral equivalent of the result of the operation Let's see how the problem works through the following examples: '"" Four = 4 "" Minus Nine = -9 "" Minus Eleven = -11 "" Minus Thirteen = -13 Note how the count, excluding spaces, of letters, describing a number equals the number itself! In case the number is negative, its absolute value equals the count. Here are a few more examples with other operators: Five Plus Six = 11 Two Plus Nine = 11 Two Plus Eleven = 13 Five Plus Eight = 13 Two Plus Eighteen = 16 Two Minus Eighteen = -16 One Into Ten = 10 Eleven By one = 11 Square root of One Thousand Eighty Nine = 33 Here's the challenge: Accept an operator ¢ and two natural numbers m and n. Search for a number (if ¢ is "" or Square root of) or two numbers (if ¢ is Plus, Minus or By) between m and n (including themselves) such that the absolute value of the result of ¢ applied on the number or numbers equals the number of letters, excluding spaces, in the spelt number(s) and operator. Report all possibilities in the form of equalities as above. Separate multiple possibilities by "and". The possibilities should be sorted in ascending order of the numerical results and, for the same results, by the alphabetical order of the equalities. If no possibility is detected, output NONE. For commutative operators such as Plus and Into, where the order of the operands does not matter for the result, output possibilities with the first operand numerically smaller than the second. For example, output “Five Plus Six = 11” instead of “Six Plus Five = 11”.

Constraints
1. |M*N| <= 99999

2. If operator is “” or ‘Square root of’ then

|N| - |M| <= 1000

Else

|N| - |M| <= 50

Answers

Answered by khairnarkailas
2
ururgrrhegeggefgystgwtsgdyyeghxdgyudyhftuturhfuu3
Similar questions