Skip to content
the poor coder

Hackerrank - Diwali Lights Solution

Poor Man
Published
Updated
Reading time
1 min read

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

Text
2
1
2

Sample Output

Text
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#

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

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

Keep going

2020

Hackerrank - Bus Station Solution

There are groups of friends, and each group is numbered from 1 to . The th group contains people. They live near a bus stop, and only a single bus operates on this route. An empty bus arrives at the bus stop and all the…

2020

Hackerrank - K Candy Store Solution

Jim enters a candy shop which has N different types of candies, each candy is of the same price. Jim has enough money to buy K candies. In how many different ways can he purchase K candies if there are infinite candies…

2020

Hackerrank - Is Fibo Solution

You are given an integer, . Write a program to determine if is an element of the Fibonacci sequence. The first few elements of the Fibonacci sequence are . A Fibonacci sequence is one where every element is a sum of the…

ESC