# Lesson 3.Conditions: if, then, else

## Problem «Sign function»

#### 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 «Equal numbers»

#### Statement

Given three integers, determine how many of them are equal to each other. The program must print one of these numbers: 3 (if all are the 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»

#### 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 - same color»

#### 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»

#### 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 moves»

#### Statement

In chess, the bishop moves diagonally, any number of squares. Given two different squares of the chessboard, determine whether a bishop can go from the first to the second in one move. The program receives as input four numbers from 1 to 8, specifying the column and row numbers of the starting square and the column and row numbers of the ending square. The program should output `YES`

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

otherwise.

## Problem «Queen move»

#### 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»

#### 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»

#### 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`

.

## Problem «Leap year»

#### 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.