Last active
August 29, 2015 14:15
-
-
Save biplav/69f8c0c305b378be2b35 to your computer and use it in GitHub Desktop.
Zopper interview programming question on HackerEarth. Question 1 Description available at: http://censore.blogspot.in/2015/02/zappos-online-assesment-question-on.html while Question 2 description is available at http://censore.blogspot.in/2015/02/zopper-programming-assessment-problem-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_ROW=500 | |
MAX_COL=500 | |
def assign_walls(row,col): | |
w = raw_input() | |
inp = w.split(" ") | |
if inp[0] is 'C': | |
col.append(int(inp[1])) | |
else: | |
row.append(int(inp[1])) | |
def main(): | |
sections = [] | |
row = [] | |
col = [] | |
section_areas=[] | |
row_counter = 0 | |
col_counter = 0 | |
row_section = [(0,MAX_ROW)] | |
col_section = [(0,MAX_COL)] | |
no_of_walls = raw_input() | |
for i in range(int(no_of_walls)): | |
assign_walls(row,col) | |
row.sort() | |
col.sort() | |
#print row | |
#print col | |
for i in row: | |
if(i < row_section[row_counter][1]): | |
row_end = row_section[row_counter][1] | |
row_start = row_section[row_counter][0] | |
row_section[row_counter] = (row_start,i) | |
row_section.append((i,row_end)) | |
row_counter = row_counter+1 | |
for i in col: | |
if(i < col_section[col_counter][1]): | |
col_end = col_section[col_counter][1] | |
col_start = col_section[col_counter][0] | |
col_section[col_counter] = (col_start,i) | |
col_section.append((i,col_end)) | |
col_counter = col_counter+1 | |
#print row_section | |
#print col_section | |
for i in row_section: | |
row_length = i[1]-i[0] | |
#print row_length | |
for j in col_section: | |
col_length = j[1]-j[0] | |
#print col_length | |
area = row_length*col_length | |
#print area | |
section_areas.append(area) | |
return section_areas[len(section_areas)-1] | |
if __name__ == "__main__": | |
out = [] | |
t = raw_input() | |
for i in range(int(t)): | |
out.append(main()) | |
for x in out: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == "__main__": | |
n = raw_input() | |
list1 = raw_input() | |
n=raw_input() | |
list2 = raw_input() | |
n=raw_input() | |
list3 = raw_input() | |
list1 = [int(n) for n in list1.split(" ")] | |
list2 = [int(n) for n in list2.split(" ")] | |
list3 = [int(n) for n in list3.split(" ")] | |
bigList = [] | |
for n in list1: | |
for m in list2: | |
for o in list3: | |
bigList.append(n+m+o) | |
bigList = list(set(bigList)) | |
#print bigList | |
#bigList.sort() | |
smart_number = 0 | |
for n in bigList: | |
smart_number = smart_number+1 if (n % 10 == 5 or n % 10 == 8) else smart_number | |
print smart_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment