Hackerrank - Diwali Lights Solution
1 min read

Hackerrank - Diwali Lights Solution

Hackerrank - Diwali Lights Solution

On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If at least one bulb in the set is on at any given instant of time, how many different patterns of light can the serial light bulb set produce?

Note: Lighting two bulbs *-* is different from **-

Input Format
The first line contains the number of test cases T, T lines follow.
Each line contains an integer N, the number of bulbs in the serial light bulb set.

Output Format
Print the total number of patterns modulo 105

Constraints
1 <= T <= 1000
0< N < 104

Sample Input

2
1
2

Sample Output

1
3

Explanation

Case 1: 1 bulb can be lit in only 1 way.
Case 2: 2 bulbs can be lit in -*, *-, ** i.e. 3 ways.

Solution in Python

def lights(n):
    return (2**n-1)%10**5

for _ in range(int(input())):
    print(lights(int(input())))

Enjoying these posts? Subscribe for more


Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.

×