Interval

Report a typo

There is an integer as input. Output True if its value is within the interval (15,12](14,17)[19,+)(−15,12]∪(14,17)∪[19,+∞), otherwise print False (case sensitive).

Please note the different brackets, which are used to specify intervals. The problem uses semi-open and open intervals. You can read more about them in the Wikipedia.

The union sign means a union of intervals. A shortlist of intervals:

(a,b)(a,b) a<x<ba<x<b
(a,b](a,b] a<xba<x\le b
[a,b)[a,b) ax<ba \le x <b
[a,b][a,b] axba \le x \le b

Sample Input 1:

20

Sample Output 1:

True

Sample Input 2:

-20

Sample Output 2:

False
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic