# Lesson 2.Conditions: if, then, else

## Problem «Sign function» (Easy)

#### Statement

For the given integer X print`1`

if it's positive, `-1`

if it's negative, or `0`

if it's equal to zero. Try to use the cascade `if-elif-else`

for it.

## Problem «Minimum of three numbers» (Easy)

#### Statement

Given the three integers, print the least of them.## Problem «Leap year» (Easy)

#### Statement

Given the year number. You need to check if this year is a leap year. If it is, print`LEAP`

, otherwise print `COMMON`

. The rules in Gregorian calendar are as follows:

- a year is a leap year if its number is exactly divisible by 4 and is not exactly divisible by 100
- a year is always a leap year if its number is exactly divisible by 400

**Warning.** The words `LEAP`

and `COMMON`

should be printed all caps.

## Problem «Equal numbers» (Easy)

#### Statement

Given three integers. Determine how many of them are equal to each other. The program must print one of the numbers: 3 (if all are same), 2 (if two of them are equal to each other and the third is different) or 0 (if all numbers are different).## Problem «Rook move» (Medium)

#### Statement

Chess rook moves horizontally or vertically. Given two different cells of the chessboard, determine whether a rook can go from the first cell to the second in one move. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output `YES`

if a rook can go from the first cell to the second in one move, or `NO`

otherwise.

## Problem «Chess board» (Easy)

#### Statement

Given two cells of a chessboard. If they are painted in one color, print the word`YES`

, and if in a different color - `NO`

. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell.

## Problem «King move» (Medium)

#### Statement

Chess king moves horizontally, vertically or diagonally to any adjacent cell. Given two different cells of the chessboard, determine whether a king can go from the first cell to the second in one move. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output `YES`

if a king can go from the first cell to the second in one move, or `NO`

otherwise.

## Problem «Bishop move» (Hard)

#### Statement

Chess bishop moves diagonally to any number of cells. Given two different cells of the chessboard, determine whether a bishop can go from the first cell to the second in one move. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output `YES`

if a Bishop can go from the first cell to the second in one move, or `NO`

otherwise.

## Problem «Queen move» (Hard)

#### Statement

Chess queen moves horizontally, vertically or diagonally to any number of cells. Given two different cells of the chessboard, determine whether a queen can go from the first cell to the second in one move. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output `YES`

if a queen can go from the first cell to the second in one move, or `NO`

otherwise.

## Problem «Knight move» (Hard)

#### Statement

Chess knight moves like the letter L. It can move two cells horizontally and one cell vertically, or two cells vertically and one cells horizontally. Given two different cells of the chessboard, determine whether a knight can go from the first cell to the second in one move. The program receives the input of four numbers from 1 to 8, each specifying the column and row number, first two - for the first cell, and then the last two - for the second cell. The program should output `YES`

if a knight can go from the first cell to the second in one move, or `NO`

otherwise.

## Problem «Chocolate bar» (Medium)

#### Statement

Chocolate bar has the form of a rectangle divided into \(n \times m\) portions. Chocolate bar can be split into two rectangular parts by breaking it along a selected straight line on its pattern. Determine whether it is possible to split it so that one of the parts will have exactly k squares. The program reads three integers: n, m, and k. It should print `YES`

or `NO`

.