As a strict big brother, I do limit my young brother Vasya on time he spends on computer games. I define a prime-time as a time period till which Vasya have a permission to play computer games. I specify start hour and end hour as pair of integers.

I need a function which will take three numbers - a present moment (current hour), a start hour of allowed time period and an end hour of allowed time period. The function should give answer to a question (as a boolean): "Can Vasya play in specified time?"

If I say that prime-time is from 12 till 15 that means that at 12:00 it's OK to play computer but at 15:00 there should be no more games.

I will allow Vasya to play at least one hour a day.

Difficulty: introductory

Starter code:

def can_i_play(now_hour, start_hour, end_hour):
	

Solutions:
def can_i_play(now_hour, start_hour, end_hour):
      return 0<=(now_hour-start_hour)%24<(end_hour-start_hour)%24


def can_i_play(now_hour, start_hour, end_hour):
    if start_hour < end_hour:
        return start_hour <= now_hour < end_hour
    return start_hour <= now_hour or now_hour < end_hour


def can_i_play(now, start, end):
    if end < start:
        start %= 12
        end += 12
        now = 12 if now == 0 else now % 12
        
    return now >= start and now + 1 <= end

from datetime import time
def can_i_play(now_hour, start_hour, end_hour):
    return end_hour < start_hour <= now_hour or end_hour > now_hour and start_hour > end_hour or start_hour <= now_hour < end_hour


def can_i_play(now_hour, start_hour, end_hour):
    if end_hour < start_hour:
        end_hour += 24
    if now_hour < start_hour:
        now_hour += 24
    return True if now_hour >= start_hour and now_hour < end_hour else False


from operator import and_, or_
def can_i_play(now_hour, start_hour, end_hour):
    return (and_, or_)[end_hour < start_hour](start_hour <= now_hour, now_hour < end_hour)

def can_i_play(now_hour, start_hour, end_hour):
  if end_hour < start_hour: end_hour += 24
  return start_hour<= now_hour < end_hour or start_hour<= now_hour+24 < end_hour


def can_i_play(now,start,end):
    return now in set(list(range(start,25))+list(range(end)) if end<start else range(start,end))

def can_i_play(now_hour, start_hour, end_hour):
    end = end_hour+24 if start_hour > end_hour else end_hour
    now_hour = now_hour if now_hour >= start_hour else now_hour+24
    return start_hour <= now_hour < end

def can_i_play(now_hour, start_hour, end_hour):

    if start_hour<end_hour:
    
        return start_hour<=now_hour<end_hour
    
    else:
        
        return start_hour<=now_hour or now_hour<end_hour