Our social:

TCS codevita Season 5 Round 1 Problem : House Numbers Answer ( Solution )

Problem : House Numbers

There are a number of buildings of different sizes (width) and with different number of floors. Each may have zero, one or more flats marked with a different character, say $. Identify these flats and print the address in form of building number, floor and flat number. 

Buildings are separated from each other by a space character. Floors start from 1 i.e. the lowest floor is the first floor. Also flat numbers are assigned from left to right. The $ character is the flat of interest for which we have to find the address. 

For example, 
 

The above is an example of a colony with 4 buildings. The first building has 5 floors with 4 flats on each floor. The flat marked by $ in the first building can be identified as 134 (building 1, floor 3 and flat 4). Similarly, the flat marked by $ in the second building can be identified as 223 (building 2, floor 2 and flat 3). 

A file containing a random colony will be given as an input to your program. You have to identify all flats marked by $ in the colony. Note that there is no limit to the number of buildings, floors or flats. 

Input Format: 

Text file path 

Output Format: 

Print Building number(B), floor number(F), Flat numbers(R) of all flats marked by $ in the following format:
<BFR> 

Constraints:
Print order for $-marked flats should be from top floors to bottom floors and left building to right building

Sample Input and Output

SNo. Input Contents Of Input File Output
1 /tmp/T1.txt

232
2 /tmp/T2.txt
>
152
142
341
221
223
111
213

If you had solution then help others by providing your code in comment box..!!