# 30 days of code https://www.hackerrank.com

## Day 6

Given a string,S , of length N  that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail).

Note: is considered to be an even index.

Sample Input

2
Hacker
Rank


Sample Output

Hce akr
Rn ak

My code

# Enter your code here. Read input from STDIN. Print output to STDOUT
x=int(raw_input())

for i in range(x):
d=raw_input()
a='';b=''
for i in range(0,len(d),2):
a+=d[i]
print a,

for i in range(1,len(d),2):
b+=d[i]
print b,

print ''

t = int(raw_input())
for _ in range(t):
line = raw_input()
first = ""
second = ""

for i, c in enumerate(line):
if (i & 1) == 0:
first += c
else:
second += c
print first, second

## Day 8 Sample Input

3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry


Sample Output

sam=99912222
harry=12299933

# Enter your code here. Read input from STDIN. Print output to STDOUT
x=raw_input()
y={}
for i in range(int(x)):
k=raw_input()
y[k.split(' ')]=k.split(' ')[-1]

while True:
try:
c=raw_input()
except:
c=0
if c:
try:
print c+'='+y[c]
except:
else:
break

official

Python3
import sys

# Read input and assemble Phone Book
n = int(input())
phoneBook = {}
for i in range(n):
contact = input().split(' ')
phoneBook[contact] = contact

# Process Queries
for i in lines:
name = i.strip()
if name in phoneBook:
print(name + '=' + str( phoneBook[name] ))
else:
print('Not found')

## Day 12: Inheritance

class Person:
def __init__(self, firstName, lastName, idNumber):
self.firstName = firstName
self.lastName = lastName
self.idNumber = idNumber
def printPerson(self):
print "Name:", self.lastName + ",", self.firstName
print "ID:", self.idNumber

class Student(Person):
def __init__(self, firstName, lastName, idNum ,scores):
Person.__init__(self, firstName, lastName, idNum)
self.scores=scores

def calculate(self):
avg = sum(scores) / len(scores)
if (90 <= avg <= 100):
if (80 <= avg < 90):
if (70 <= avg < 80):
if (55 <= avg < 70):
if (40 <= avg <= 55):
if (avg < 40):

line = raw_input().split()
firstName = line
lastName = line
idNum = line
numScores = int(raw_input()) # not needed for Python
scores = map(int, raw_input().split())
s = Student(firstName, lastName, idNum, scores)
s.printPerson()
print "Grade:", s.calculate()

## Day 14: Scope

The absolute difference between two integers

class Difference:
def __init__(self, a):
self.__elements = a

def computeDifference(self):
self.maximumDifference = max([a-b for a in self.__elements for b in self.__elements])

# End of Difference class

_ = raw_input()
a = [int(e) for e in raw_input().split(' ')]

d = Difference(a)
d.computeDifference()

print d.maximumDifference

class Node:
def __init__(self,data):
self.data = data
self.next = None
class Solution:
while current:
print current.data,
current = current.next

else:
while True:
if(current.next == None):
current.next = Node(data)
break
current = current.next
mylist.display(head);