Skip to content

Latest commit

 

History

History
6 lines (4 loc) · 393 Bytes

File metadata and controls

6 lines (4 loc) · 393 Bytes

Write a function close_or_equal(a: int, b: int) -> bool that takes two integer inputs, a and b. The function should return True if the two numbers are exactly equal or if their absolute difference is 1 or less.

In other words, it should return True if a == b, a == b + 1, or a == b - 1; otherwise, it should return False.

For example:

  • close_or_equal(5, 6) → True