TV
Lesson 29 of 32 in Coddy's Coding Problems course.
Challenge
HardA 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
With ones is represented the border of the TV, with twos the actual screen and the three in the lower right corner is the power button.
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 Coding Problems
1Course Introduction
Introduction