Seven-Segment Display

4.1

341 votes
Ad-Hoc, Basic Programming, Easy, Input/Output
Problem

You all must have seen a seven segment display.If not here it is:

Alice got a number written in seven segment format where each segment was creatted used a matchstick.

Example: If Alice gets a number 123 so basically Alice used 12 matchsticks for this number.

Alice is wondering what is the numerically largest value that she can generate by using at most the matchsticks that she currently possess.Help Alice out by telling her that number.

 

Input Format:

First line contains T (test cases).

Next T lines contain a Number N.

Output Format:

Print the largest possible number numerically that can be generated using at max that many number of matchsticks which was used to generate N.

Constraints:

\(1 \le T \le 100\)

\(1 \le length(N) \le 100\)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

If you have 1 as your number that means you have 2 match sticks.You can generate 1 using this.

If you have as your number that means you have match sticks.You can generate 111 using this.

Editor Image

?