i want code in python
Rahul is a maths genius so he came up with a game and as raj is Rahul's best friend so Rahul decided to play the game with raj. Rahul gives raj two numbers LL and RR and asks raj to find the count of numbers in the range from LL to RR (LL and RR inclusive) which are a digit palindromic. A number is a digit palindromic if its first digit is the same as its last digit.
As raj is not very good at maths so your task is to help Raj find out how many numbers are a digit palindromic in the range LL to RR.
For example if LL = 88 and RR = 2525 .The following numbers are a digit palindromic in the range of LL to RR: 8, 9, 11, and 22.
If LL = 12511251 and RR = 12661266. The digit palindromic numbers are 1251 and 1261.
Input format
The first line contains an integer denoting the number of test cases.
Each test case is described by a single line that contains two integers LL and RR.
Output format
For each test case output, an integer denoting how many a digit palindromic numbers are there in the given range.
Constraints
1≤T≤5∗1041≤T≤5∗104 1≤l≤r≤10181≤l≤r≤1018.
Time Limit
1 second
Example
Input
3 8 25 1251 1266 12 21
Output
4 2 0
Step by stepSolved in 2 steps with 2 images
- IN JS ONLY ASAP Create a function that outputs the result of a math expression in words. Examples wordedMath ("One plus one") → "Two" wordedMath ("zero Plus one") "One" wordedMath ("one minus one") ➡ "Zero"arrow_forwardPython only Rajesh loves lucky numbers. Everyone knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, the numbers 47,744, 4 are lucky and 5, 17,467 are not. Let Fa(x) equal the number of digits d in the decimal representation of the positive integer x. Chef is only interested in F4(x) and F7(x) functions. For a given positive integer N, he wants to know the total number of distinct pairs (L; R) such that F4(L) + F4(L + 1) + ... + F4(R) equals F7(L) + F7(L + 1) + ... + F7(R) and 1arrow_forwardIn picture thete is detailed. M8.arrow_forwardDescription Xiao Zhang is often distressed because there are too many things to arrange. Now he has n tasks at hand, and each task has a starting times, and an ending time e;. To complete a task, he must do it from the starting time to the ending time, and Xiao Zhang can only perform one task at the same time. Xiao Zhang wants to know how many tasks he can accomplish at most. Input The first line is an integer n (1sns300000), indicating the number of tasks Xiao Zhang has at hand. In the next n lines, each line contains two integers s₁, e¡ (1≤s;arrow_forwardLittle Frank loves mathematics. Every day, he solves some mathematical problems to improve his skill. A few days ago, he found a popular problem about turtles. The problem is as follows. Little Frank is given R rectangles, numbered 1 through R. The width and height of the i-th rectangle are Ni and M¡ unit respectively. There is a turtle located on the top-left corner of each rectangle. For each rectangle, count the number of ways the turtle can reach the bottom-right corner, if each turtle can only move right or down 1 unit at any time. The turtle is not allowed to move outside the rectangle, but, of course, the turtle can move on the boundary of the rectangle. In less than one second, this problem was solved for all rectangles. He felt that the problem was too easy. This morning, Little Frank wanted more challenges. Thus, for each rectangle į, he cut and removed a rectangle of A¡ x Bị unit from the top-right corner. See the following figure for detail. Bị Mi He could not solve this…arrow_forwardDescription A mathmatician Goldbach's conjecture: any even number(larger than 2) can divide into two prime number’s sum.But some even numbers can divide into many pairs of two prime numbers’ sum. Example:10 =3+7, 10=5+5, 10 can divide into two pairs of two prime number. Input Input consist a positive even number n(4<=n<=32766). Output Print the value of how many pairs are this even number can be divided into. Sample Input 1 1234 Sample Output 1 25arrow_forwardPart 3: Negative Binary Numbers This standard method of binary number representation doesn't account for negative numbers. We can't just throw a negative sign in front of a binary number though - everything in a computer must be represented by 1's and 0's. One way we can get around this is by using the very first digit of each binary number to represent the sign: 0 for positive and 1 for negative. This is called 1's complement representation. 00010110 -> 0 0010110 -> positive 22 10010110 -> 1 0010110 -> negative 22 Using 1's complement representation we can represent the numbers -127 through 127 in a single byte (note that we can only go half as high as an unsigned number because half of the possible representations for that byte are being used for the negative numbers). However, there is a flaw with 1's complement: the representation of the number 0. 00000000 -> 0 0000000 -> zero 10000000 -> 1 0000000 -> negative zero? Because of this, we…arrow_forwardIN JS ONLY ASAP Create a function that outputs the result of a math expression in words. Examples wordedMath ("One plus one") → "Two" wordedMath ("zero Plus one") "One" wordedMath ("one minus one") ➡ "Zero"arrow_forwardarrow_back_iosarrow_forward_iosRecommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education