Menu
Coddy logo textTech

TV

Part of the Fundamentals section of Coddy's C journey — lesson 63 of 63.

challenge icon

Challenge

Easy

A TV is drawn using numbers like below:

    1 1 1 1 1 1 1 1 1
    1 2 2 2 2 2 2 2 1
    1 2 2 2 2 2 2 2 1
    1 2 2 2 2 2 2 2 1
    1 1 1 1 1 1 1 1 3

The ones represent the TV's border, the twos represent the actual screen. The three in the lower right corner are the power buttons.

 

You are given a sequence of numbers from input until a 3 is entered. Calculate the width and height of the TV and output it to the screen.

 

Input
1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 3

Output
5 9

Input
1 1 1
1 2 1
1 1 3

Output
3 3

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
};

All lessons in Fundamentals