Tous les défis
Moyen 0 résolus 0 % de réussite

Empty Two Coin Piles

Decide whether paired removals can empty two piles.

Each move removes two coins from one pile and one coin from the other. Either orientation is allowed. You may never remove more coins than remain. Determine whether both piles can end at zero.

Implement coin_piles(left, right).

Input

left: The number of coins in the left pile.

right: The number of coins in the right pile.

Output

Return true if the piles can both be emptied; otherwise return false.

Contraintes

0 ≤ left, right ≤ 1,000,000,000. Two empty piles are already a successful result.

Exemples

Exemple 1
Entrée :
left = 4
right = 2

Sortie attendue :
expected = True
Entrée :
long long left = 4;
long long right = 2;

Sortie attendue :
bool expected = true;
Entrée :
long left = 4;
long right = 2;

Sortie attendue :
bool expected = true;

Explication

Remove (2, 1) twice: (4, 2) → (2, 1) → (0, 0).

Exemple 2
Entrée :
left = 4
right = 1

Sortie attendue :
expected = False
Entrée :
long long left = 4;
long long right = 1;

Sortie attendue :
bool expected = false;
Entrée :
long left = 4;
long right = 1;

Sortie attendue :
bool expected = false;

Explication

The only possible first move leaves (2, 0), after which no move can empty the left pile.

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.