Rectange inclusion X42222


Statement
 

pdf   zip

thehtml

Write a program that reads a sequence of rectangle pairs, and for each pair, states whether one rectangle fits inside the other. A rectangle R1 fits inside another R2 if the width of R1 is smaller or equal than the witdh of R2, and the same happens with its height. A rectangle R1 also may fit inside another R2 after rotating R1 90 degrees (i.e. exchanging its width and height)

Input

The input is a sequence of pairs of rectangles. Each rectangle in a pair is given as two integer numbers w,h corresponding to its width and height.

Output

The output is, for each pair of rectangles, whether the first rectangle fits inside the second, the second inside the first, or no fitting is possible. Follow the format of the examples.

Public test cases
  • Input

    2 8  7 1   
    5 2  3 6
    4 5  5 3
    2 9  6 1
    3 7  6 2
    5 3  9 1
    3 8  8 3
    1 5  6 4
    7 1  6 2 
    

    Output

    second inside first
    first inside second
    second inside first
    second inside first
    second inside first
    no fitting
    first inside second
    first inside second
    no fitting
    
  • Information
    Author
    Lluís Padró
    Language
    English
    Official solutions
    Python
    User solutions