# Task
 You have set an alarm for some of the week days.
 
 Days of the week are encoded in binary representation like this:
```
0000001 - Sunday
0000010 - Monday
0000100 - Tuesday
0001000 - Wednesday
0010000 - Thursday
0100000 - Friday 
1000000 - Saturday```
For example, if your alarm is set only for Sunday and Friday, the representation will be `0100001`. 

 Given the current day of the week, your task is to find the day of the week when alarm will ring next time.

# Example

 For `currentDay = 4, availableWeekDays = 42`, the result should be `6`.
 
 ```
currentDay = 4 means the current Day is Wednesday
availableWeekDays = 42 convert to binary is "0101010"
So the next day is 6 (Friday)
```

# Input/Output


 - `[input]` integer `currentDay`
 
 The weekdays range from 1 to 7, 1 is Sunday and 7 is Saturday


 - `[input]` integer `availableWeekDays`
 
 An integer. Days of the week are encoded in its binary representation.


 - `[output]` an integer

 The next day available.

Difficulty: introductory

Starter code:

def next_day_of_week(current_day, available_week_days):
	

Solutions:
def next_day_of_week(current_day, available_week_days):
    x = 2 ** current_day
    while not x & available_week_days:
        x = max(1, (x * 2) % 2 ** 7)
    return x.bit_length()

def next_day_of_week(c, a):
    return next((weekday - 1) % 7 + 1 for weekday in range(c+1, c+8) if (1 << ((weekday-1) % 7)) & a)

def next_day_of_week(current_day, available_week_days):
    b = f"{available_week_days:07b}"[::-1]
    return b.find("1", current_day) + 1 or b.index("1") + 1

def next_day_of_week(a, b):
    return (f"{b:7b}"[::-1] * 2).index("1", a) % 7 + 1

def next_day_of_week(current_day, available_week_days):
  #coding and coding..
  d = {1:1, 2:2, 3:4, 4:8, 5:16, 6:32, 7:64}
  
  while True:
      if current_day == 7:
         current_day = 0
      current_day += 1
      
      if available_week_days & d[current_day]:
            return current_day


def next_day_of_week(current_day, available_week_days):
    return (f"{available_week_days:07b}"[::-1]*2).index('1',current_day)%7+1

next_day_of_week=lambda n,b:next(i%7+1for i in range(n,n+8)if 1<<i%7&b)

def next_day_of_week(day,week):
    days=[d for d,v in enumerate(bin(week)[2:][::-1],1) if int(v)]
    return next((d for d in days if d>day),days[0]) 

def next_day_of_week(d, a):
    t = a & ~((1 << d) - 1) or a
    return (t & -t).bit_length()

from math import log

def next_day_of_week(current_day, available_week_days):
    code = bin(available_week_days)[2:].rjust(7, "0")[::-1]
    for i in range(current_day, 7):
        if code[i] == "1":
            return i + 1
    for i in range(current_day):
        if code[i] == "1":
            return i + 1