-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeeval.py
More file actions
138 lines (100 loc) · 2.63 KB
/
codeeval.py
File metadata and controls
138 lines (100 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import sys
# test_cases = open(sys.argv[1], 'r')
# def longest_common_substring(s1, s2):
# m = [[0] * (1 + len(s2)) for i in xrange(1 + len(s1))]
# longest, x_longest = 0, 0
# for x in xrange(1, 1 + len(s1)):
# for y in xrange(1, 1 + len(s2)):
# if s1[x - 1] == s2[y - 1]:
# m[x][y] = m[x - 1][y - 1] + 1
# if m[x][y] > longest:
# print m
# longest = m[x][y]
# x_longest = x
# else:
# m[x][y] = 0
# return s1[x_longest - longest: x_longest]
# for test in test_cases:
# if test != "\n":
# sub_strigs = test.rstrip().split(";")
# string_left = sub_strigs[0]
# string_right = sub_strigs[1]
# sub_string = [string_right[0]]
# for x,y in string_right[1:],enumerate(string_left):
# if x in string_left:
# for i in sub_string:
# if string_left.index(i) > string_left.index(string_left[y]):
# continue
# else:
# sub_string[:-1] = x
# test_cases.close()
# test_cases = open(sys.argv[1], 'r')
# for test in test_cases:
# problem = test.rstrip().split(";")
# word = problem[0]
# sub_strings = problem[1].split(",")
# #tuples_words = [[i,next(it)] for i in it]
# #tuples_words = [[x,y] for x, y in zip(*[iter(sub_strings)]*2)]
# tuples_words = zip(*[iter(sub_strings)]*2)
# for x,v in tuples_words:
# word = word.replace(x,v)
# print word
# test_cases.close()
# def left(lista):
# if lista:
# for x in lista[0]:
# print x,
# lista.remove(lista[0])
# def down(lista):
# if lista:
# for x in range(len(lista)):
# print lista[x].pop(),
# def right(lista):
# if lista:
# for x in range(len(lista[0])-1,-1,-1):
# print lista[len(lista)-1][x],
# lista.remove(lista[len(lista)-1])
# def up(lista):
# if lista:
# for x in range(len(lista)-1,-1,-1):
# if lista[x]: print lista[x].pop(0),
# test_cases = open(sys.argv[1], 'r')
# for test in test_cases:
# problem = test.rstrip().split(";")
# linhas = int(problem[0])
# colunas = int(problem[1])
# numeros = problem[2].split(" ")
# tuples_words = zip(*[iter(numeros)]*colunas)
# list_words = [list(x) for x in tuples_words]
# #print numeros
# #print list_words
# while list_words:
# left(list_words)
# down(list_words)
# right(list_words)
# up(list_words)
# pass
# print "\r"
# test_cases.close()
lista = []
def push(item):
lista.append(item)
def pop():
return lista.pop()
def lene():
return len(lista)
def clean():
lista[:] = []
def item(x):
return lista[x]
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
problem = test.rstrip().split(" ")
for x in problem:
push(x)
for x in xrange(lene()):
if x % 2 ==0:
print pop()
print lista
clean()
test_cases.close