Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Voice TV Control by mozurin
class VoiceCommand:
def __init__(self, channels):
self.channels = channels
self.cur = 0
def _tune(self, cur):
self.cur = cur % len(self.channels)
return self.channels[self.cur]
first_channel = lambda s: s._tune(0)
last_channel = lambda s: s._tune(-1)
turn_channel = lambda s, i: s._tune(i - 1)
next_channel = lambda s: s._tune(s.cur + 1)
previous_channel = lambda s: s._tune(s.cur - 1)
current_channel = lambda s: s._tune(s.cur)
def is_exist(self, cond):
try:
return (
'Yes' if cond in self.channels or self.channels[cond]
else 'No'
)
except:
return 'No'
July 17, 2018
Comments: