Problem 136612 · easy · Phase 01 Prerequisites & Setup

Middle of Three

conditionals · comparison

Write middle_of_three(a, b, c) that returns the value that would sit in the middle if the three numbers were sorted. If two or three values are equal, that repeated value is the middle one.

Do it with comparisons only: no lists and no sorted.

Examples

Input:  a = 3, b = 1, c = 2
Output: 2

Input:  a = 5, b = 5, c = 1
Output: 5

Input:  a = -1, b = -10, c = 4
Output: -1

Constraints

  • -10**9 <= a, b, c <= 10**9

Goals

  • Compare three values against each other
  • Reason about all orderings, including ties
Starting Python…