Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Get lines like that:
- x < 42
- x > 0.2
- x < 0.4
- x > 0.3
- And print final interval:
- 0.3 < x < 0.4
- """
- import sys
- def main() -> None:
- lower = float(-2**32)
- upper = float(2**32)
- for line in sys.stdin:
- line = line.rstrip()
- variable, operator, value_str = line.split()
- assert variable == 'x'
- value = float(value_str)
- if operator == '<':
- upper = min(upper, value)
- else:
- assert operator == '>'
- lower = max(lower, value)
- print(f'{lower} < x < {upper}')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement