Python programming   It is given a non-negative number x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, with the goal that the number shaped by the red digits is detachable by A, and the number framed by the dark digits is distinct by B.  Somewhere around one digit should be shaded in every one of two tones. Consider, the include of digits shaded in red is r and the

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Python programming

 

It is given a non-negative number x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, with the goal that the number shaped by the red digits is detachable by A, and the number framed by the dark digits is distinct by B. 

Somewhere around one digit should be shaded in every one of two tones. Consider, the include of digits shaded in red is r and the include of digits hued in dark is b. Among all potential colorings of the given number x, you need to yield any to such an extent that the worth of |r−b| is the base conceivable. Note that the number x and the numbers shaped by digits of each tone, may contain driving zeros. 

instance of painting the number x=02165 of n=5 digits for A=3 and B=13. The red digits structure the number 015, which is detachable by 3, and the dark ones — 26, which is distinguishable by 13. Note that the outright worth of the distinction between the counts of red and dark digits is 1, it is difficult to accomplish a more modest worth. 

Info : The main line contains one number t (1≤t≤10) — the quantity of experiments. Then, at that point, t experiments follow. 

Each experiment comprises of two lines. The main line contains three numbers n, A, B (2≤n≤40, 1≤A,B≤40). The subsequent line contains a non-negative number x containing precisely n digits and presumably containing driving zeroes. 

Output: For each experiment, yield in a different line: - 1 if the ideal shading doesn't exist; a string s of n characters, every one of them is a letter 'R' or 'B'. On the off chance that the I-th digit of the number x is hued in red, then, at that point, the I-th character of the string s should be the letter 'R', in any case the letter 'B'

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY