Skip to content

Commit 86f963c

Browse files
authored
Merge pull request #1 from geekcomputers/master
update
2 parents a19a798 + e4c75b2 commit 86f963c

32 files changed

+956
-232
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1+
.idea
22
*.pyc

Binary_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def binarySearch(arr, l, r, x):
1414
l = mid + 1 #l is initialised to the rightmost element of the middle so that the search could be started from there the next time
1515

1616
# If x is smaller, ignore right half
17-
else:
17+
elif x<arr[mid]:
1818
r = mid - 1 #r is initialised to the leftmost element of the middle so that the search goes till there only the next time
1919

2020
# If we reach here, then the element was not present
@@ -27,7 +27,7 @@ def binarySearch(arr, l, r, x):
2727
print("Enter the array with comma separated in which element will be searched")
2828
arr =[int(x) for x in input().split(',')] #the input array will of int type with each element seperated with a comma due to the split fucntion
2929
#map function returns a list of results after applying the given function to each item
30-
x = int(input("Enter the element you want to search in given array"))
30+
x = eval(input("Enter the element you want to search in given array"))
3131

3232
# Function call
3333
result = binarySearch(arr, 0, len(arr) - 1, x)

Colors/primary_colors.py

Lines changed: 141 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,173 @@
1-
def simpleColor(r, g, b):
2-
3-
4-
""" simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B """
5-
r = int(r)
6-
g = int(g)
7-
b = int(b)
8-
try:
9-
# ROJO --------------------------------------------------
10-
if r > g and r > b:
11-
12-
rg = diff(r, g) # distancia rojo a verde
13-
rb = diff(r, b) # distancia rojo a azul
14-
15-
if g < 65 and b < 65 and rg > 60: # azul y verde sin luz
16-
return "ROJO"
17-
18-
gb = diff(g, b) # distancia de verde a azul
19-
20-
if rg < rb: # Verde mayor que Azul
21-
if gb < rg: # Verde mas cerca de Azul
22-
if gb >= 30 and rg >= 80:
23-
return "NARANJA"
24-
elif gb <= 20 and rg >= 80:
25-
return "ROJO"
26-
elif gb <= 20 and b > 175:
27-
return "CREMA"
1+
def simpleColor(r,g,b):
2+
""" simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B """
3+
r=int(r)
4+
g=int(g)
5+
b=int(b)
6+
try:
7+
#ROJO --------------------------------------------------
8+
if r > g and r > b:
9+
10+
rg = diff(r,g) #distancia rojo a verde
11+
rb = diff(r,b) #distancia rojo a azul
12+
13+
if g < 65 and b < 65 and rg > 60: #azul y verde sin luz
14+
return "ROJO"
15+
16+
gb=diff(g,b) #distancia de verde a azul
17+
18+
if rg < rb: # Verde mayor que Azul
19+
if gb < rg: #Verde mas cerca de Azul
20+
if gb >=30 and rg >= 80:
21+
return "NARANJA"
22+
elif gb<=20 and rg >= 80:
23+
return "ROJO"
24+
elif gb<=20 and b > 175:
25+
return "CREMA"
2826

29-
else:
30-
return "CHOCOLATE"
31-
else: # Verde mas cerca de Rojo
32-
if rg > 60:
33-
return "NARANJA*"
34-
elif r > 125:
35-
return "AMARILLO"
36-
else:
37-
return "COCHOLATE"
38-
elif rg > rb: # Azul mayor que verde
39-
if bg < rb: # Verde mas cerca de Azul
40-
if gb < 60:
41-
if r > 150:
42-
return "ROJO 2"
4327
else:
44-
return "MARRON"
45-
elif g > 125:
46-
return "ROSADO"
47-
else:
48-
return "ROJO 3"
49-
else: # Verde mas cerca de Rojo
50-
if rb < 60:
51-
if r > 160:
52-
return "ROSADO*"
28+
return "CHOCOLATE"
29+
else: #Verde mas cerca de Rojo
30+
if rg > 60:
31+
return "NARANJA*"
32+
elif r > 125:
33+
return "AMARILLO"
34+
else:
35+
return "COCHOLATE"
36+
elif rg > rb: #Azul mayor que verde
37+
if bg < rb: #Verde mas cerca de Azul
38+
if gb < 60:
39+
if r >150:
40+
return "ROJO 2"
41+
else:
42+
return "MARRON"
43+
elif g > 125:
44+
return "ROSADO"
45+
else:
46+
return "ROJO 3"
47+
else: #Verde mas cerca de Rojo
48+
if rb < 60:
49+
if r > 160:
50+
return "ROSADO*"
51+
else:
52+
return "ROJO"
5353
else:
5454
return "ROJO"
55-
else:
56-
return "ROJO"
57-
58-
else: # g y b iguales
59-
if rg > 20:
60-
if r >= 100 and b < 60:
61-
return "ROJO"
62-
elif r >= 100:
63-
return "ROJO"
64-
else:
65-
return "MARRON"
6655

67-
else:
68-
return "GRIS"
69-
# VERDE ---------------------------------------------------
70-
elif g > r and g > b:
71-
gb = diff(g, b) # distancia verde a azul
72-
gr = diff(g, r) # distancia verde a rojo
56+
else: # g y b iguales
57+
if rg > 20:
58+
if r>=100 and b <60:
59+
return "ROJO"
60+
elif r >=100:
61+
return "ROJO"
62+
else:
63+
return "MARRON"
7364

74-
if r < 65 and b < 65 and gb > 60: # rojo y azul sin luz
75-
return "VERDE"
65+
else:
66+
return "GRIS"
67+
# VERDE ---------------------------------------------------
68+
elif g > r and g > b:
69+
gb = diff(g,b) #distancia verde a azul
70+
gr = diff(g,r) #distancia verde a rojo
7671

77-
rb = diff(r, b) # distancia de rojo a azul
72+
if r < 65 and b < 65 and gb > 60: #rojo y azul sin luz
73+
return "VERDE"
7874

79-
if r > b: # ROJO > AZUL
80-
if gr < gb: # Verde con Rojo
75+
rb=diff(r,b) #distancia de rojo a azul
8176

82-
if rb >= 150 and gr <= 20:
83-
return "AMARILLO"
84-
else:
77+
if r > b: #ROJO > AZUL
78+
if gr < gb: #Verde con Rojo
79+
80+
if rb>=150 and gr <=20:
81+
return "AMARILLO"
82+
else:
83+
return "VERDE"
84+
else: #...Verde
8585
return "VERDE"
86-
else: # ...Verde
87-
return "VERDE"
8886

89-
elif r < b: # AZUL > ROJO
90-
if gb < gr: # Verde con Azul
87+
elif r < b: #AZUL > ROJO
88+
if gb < gr: #Verde con Azul
9189

92-
if gb <= 20:
93-
return "TURQUESA"
94-
else:
90+
if gb<=20:
91+
return "TURQUESA"
92+
else:
93+
return "VERDE"
94+
else: #...Verde
9595
return "VERDE"
96-
else: # ...Verde
97-
return "VERDE"
9896

99-
else: # r y b iguales
100-
if gb > 10:
101-
return "VERDE"
102-
else:
103-
return "GRIS"
97+
else: #r y b iguales
98+
if gb > 10:
99+
return "VERDE"
100+
else:
101+
return "GRIS"
104102

105103

106-
# AZUL ------------------------------------------------------
107-
elif b > r and b > g:
108-
bg = diff(b, g) # distancia azul a verde
109-
br = diff(b, r) # distancia azul a rojo
104+
#AZUL ------------------------------------------------------
105+
elif b > r and b > g:
106+
bg = diff(b,g) #distancia azul a verde
107+
br = diff(b,r) #distancia azul a rojo
110108

111-
if r < 65 and g < 65 and bg > 60: # rojo y verde sin luz
112-
return "AZUL"
109+
if r < 65 and g < 65 and bg > 60: #rojo y verde sin luz
110+
return "AZUL"
113111

114-
rg = diff(r, g) # distancia de rojo a verde
112+
rg=diff(r,g) #distancia de rojo a verde
115113

116-
if g < r: # ROJO > VERDE
117-
if bg < rg: # Azul con Verde
118-
if bg <= 20:
119-
return "TURQUESA"
120-
else:
121-
return "CELESTE"
122-
else: # ...Azul
123-
if rg <= 20:
124-
if r >= 150:
125-
return "LILA"
114+
if g < r: # ROJO > VERDE
115+
if bg < rg: #Azul con Verde
116+
if bg<=20:
117+
return "TURQUESA"
126118
else:
127-
return "AZUL *************"
128-
else:
129-
return "AZUL"
130-
131-
elif g > r: # VERDE > ROJO
132-
if br < rg: # Azul con rojo
133-
if br <= 20:
134-
if r > 150 and g < 75:
135-
return "ROSADO FIUSHA"
136-
elif ir > 150:
137-
return "LILA"
119+
return "CELESTE"
120+
else: #...Azul
121+
if rg <= 20:
122+
if r >= 150:
123+
return "LILA"
124+
else:
125+
return "AZUL *************"
126+
else:
127+
return "AZUL"
128+
129+
elif g > r: # VERDE > ROJO
130+
if br < rg: #Azul con rojo
131+
if br <=20:
132+
if r > 150 and g < 75:
133+
return "ROSADO FIUSHA"
134+
elif ir > 150:
135+
return "LILA"
136+
else:
137+
return "MORADO"
138138
else:
139139
return "MORADO"
140-
else:
141-
return "MORADO"
142140

143141

144-
else: # ...Azul
145-
if rg <= 20:
146-
if bg <= 20:
147-
return "GRIS"
142+
else: #...Azul
143+
if rg <= 20:
144+
if bg <=20:
145+
return "GRIS"
146+
else:
147+
return "AZUL"
148+
else: #r y g iguales
149+
if bg > 20:
150+
if r>=100 and b <60:
151+
return "ROJO"
152+
elif r >=100:
153+
return "ROJO"
148154
else:
149-
return "AZUL"
150-
else: # r y g iguales
151-
if bg > 20:
152-
if r >= 100 and b < 60:
153-
return "ROJO"
154-
elif r >= 100:
155-
return "ROJO"
155+
return "MARRON"
156156
else:
157-
return "MARRON"
158-
else:
159-
return "GRIS"
157+
return "GRIS"
158+
160159

160+
# IGUALES---------------------------------------
161+
else:
162+
return "GRIS"
161163

162-
# IGUALES---------------------------------------
163-
else:
164-
return "GRIS"
164+
except:
165165

166-
except:
166+
return "Not Color"
167167

168-
return "Not Color"
169168

170-
# ---------------------------------------------------------------------------------------------------
169+
#---------------------------------------------------------------------------------------------------
171170
# Puedes probar asi: python primary_colors.py 120,0,0 , esto resultara en un ROJO como respuesta
172-
# --------------------------------------------------------------------------------------------------
173-
if __name__ == '__main__':
174-
print(simpleColor(sys.argv[1], sys.argv[2], sys.argv[3]))
171+
#--------------------------------------------------------------------------------------------------
172+
if __name__=='__main__':
173+
print(simpleColor(sys.argv[1],sys.argv[2],sys.argv[3]))

0 commit comments

Comments
 (0)