vending-machine-1

Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum.

For example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny.

Write a program that will print the name of a man who will drink the n-th can.

Note that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon.
Input

The input data consist of a single integer n (1 ≤ n ≤ 109).

It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers.
Output

Print the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially.

SAMPLE INPUT
500000000

SAMPLE OUTPUT
Howard

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import math
arr = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
inp = eval(input())
high = 5
while(inp>high):
	inp=inp-high
	high=high*2
high=high/5
print(arr[int(math.ceil(float(inp)/high))-1])


import math

N=float(input())
if N<=5:
	if N==1:
		print("Sheldon")
	if N==2:
		print("Leonard")
	if N==3:
		print("Penny")
	if N==4:
		print("Rajesh")
	if N==5:
		print("Howard")
else:
	p=int(math.floor(math.log(N/5+1,2)-1))
	N=N-5*(pow(2,p+1)-1)
	#print p
	if N==0:
		print("Howard")
	else:
		N=float(N/pow(2,p+1))
		#print N
		if N<=1:
			print("Sheldon")
		elif N<=2:
			print("Leonard")
		elif N<=3:
			print("Penny")
		elif N<=4:
			print("Rajesh")
		elif N<=5:
			print("Howard")


q=['Sheldon', 'Leonard', 'Penny', 'Rajesh','Howard']
x=int(input())
for i in range(x):
	val=q.pop(0)
	q.append(val)
	q.append(val)
print(q[0])