-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
713 additions
and
337 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/DataStructure/.idea | ||
/DataStructure | ||
/.idea |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python | ||
|
||
t = int(raw_input()) | ||
|
||
nums = [] | ||
|
||
for i in range(0, t): | ||
orgs = raw_input().split(' ') | ||
if orgs[0] == "insert": | ||
nums.insert(int(orgs[1]), int(orgs[2])) | ||
elif orgs[0] == "append": | ||
nums.append(int(orgs[1])) | ||
elif orgs[0] == "remove": | ||
nums.remove(int(orgs[1])) | ||
elif orgs[0] == "pop": | ||
nums.pop() | ||
elif orgs[0] == "index": | ||
print nums.index(int(orgs[1])) | ||
elif orgs[0] == "count": | ||
print nums.count(int(orgs[1])) | ||
elif orgs[0] == "sort": | ||
nums.sort() | ||
elif orgs[0] == "reverse": | ||
nums.reverse() | ||
elif orgs[0] == "print": | ||
print nums |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/python | ||
|
||
from __builtin__ import hash | ||
|
||
n = int(raw_input()) | ||
nums = map(int, raw_input().split(" ")) | ||
|
||
tuples = tuple(nums) | ||
|
||
print hash(tuples) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/python | ||
|
||
m = int(raw_input()) | ||
one = set(map(int, raw_input().split())) | ||
n = int(raw_input()) | ||
two = set(map(int, raw_input().split())) | ||
|
||
result = one.symmetric_difference(two) | ||
|
||
for i in sorted(result): | ||
print i |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/python | ||
|
||
x, y, z, n = (int(input()) for i in range(4)) | ||
|
||
print [[a, b, c] for a in range(0, x + 1) for b in range(0, y + 1) for c in range(0, z + 1) if a + b + c != n] |
16 changes: 16 additions & 0 deletions
16
Python/Data Types/5-find-second-maximum-number-in-a-list.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/python | ||
|
||
n = int(raw_input()) | ||
|
||
nums = map(int, raw_input().split()) | ||
|
||
print max(filter(lambda x: x != max(nums), nums)) | ||
|
||
# just solution two. | ||
# big, sbig = -6000, -6000 | ||
# for i in lis: | ||
# if (i > big): | ||
# big, sbig = i, big | ||
# elif (i < big and i > sbig): | ||
# sbig = i | ||
# print (sbig) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python | ||
|
||
a = [[raw_input(), float(raw_input())] for _ in range(int(raw_input()))] | ||
s = sorted(set(x[1] for x in a)) | ||
|
||
for name in sorted(x[0] for x in a if x[1] == s[1]): | ||
print name | ||
|
||
# stupied | ||
# n = int(raw_input()) | ||
|
||
# stus = [] | ||
|
||
# for _ in range(n): | ||
# name = raw_input() | ||
# grade = float(raw_input()) | ||
# stus.append([name, grade]) | ||
|
||
# stus.sort(lambda x, y: cmp(x[1], y[1])) | ||
# print stus | ||
# min = stus[0][1] | ||
# stus = filter(lambda x: x[1] != min, stus) | ||
# print stus | ||
# min = stus[0][1] | ||
|
||
# results = filter(lambda x: x[1] == min, stus) | ||
# print stus | ||
# results.sort(lambda x, y: cmp(x[0], y[0])) | ||
# print stus | ||
|
||
# for s in results: | ||
# print s[0] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python | ||
|
||
print("Hello World!") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/python | ||
|
||
firstname = raw_input() | ||
lastname = raw_input() | ||
|
||
print "Hello %s %s! You just delved into python." % (firstname, lastname) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/python | ||
|
||
a = int(raw_input()) | ||
b = int(raw_input()) | ||
|
||
temp = a | ||
a = b | ||
b = temp | ||
|
||
num = (a, b) | ||
|
||
print num[0] | ||
print num[1] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/python | ||
|
||
t = int(raw_input()) | ||
|
||
stus = {} | ||
|
||
for i in range(0, t): | ||
name, math, physic, chemistry = raw_input().split(" ") | ||
stus[name] = (float(math) + float(physic) + float(chemistry)) / 3 | ||
|
||
name = raw_input() | ||
if name in stus: | ||
print("%.2f" % stus[name]) | ||
else: | ||
print "No" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/python | ||
|
||
# n = int(raw_input()) | ||
|
||
# print ''.join(map(str, range(1, n + 1))) | ||
# print ''.join(str(x+1) for x in range(input())) | ||
|
||
from __future__ import print_function | ||
|
||
N = int(input()) | ||
print(*range(1, N + 1), sep='', end='\n', file=sys.stdout) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/python | ||
|
||
input = raw_input() | ||
|
||
print(input) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/python | ||
|
||
one = int(raw_input()) | ||
two = int(raw_input()) | ||
|
||
print(one + two) | ||
print(one - two) | ||
print(one * two) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/python | ||
|
||
from __future__ import division | ||
|
||
one = int(raw_input()) | ||
two = int(raw_input()) | ||
|
||
print(one // two) | ||
print(one / two) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/python | ||
|
||
from __future__ import division | ||
|
||
# a = int(raw_input()) | ||
# b = int(raw_input()) | ||
a, b = int(raw_input(), raw_input()) | ||
|
||
print(a // b) | ||
print(a % b) | ||
print(divmod(a, b)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/python | ||
|
||
a = int(raw_input()) | ||
b = int(raw_input()) | ||
m = int(raw_input()) | ||
|
||
print(a ** b) | ||
print(pow(a, b, m)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/python | ||
|
||
a = int(raw_input()) | ||
b = int(raw_input()) | ||
m = int(raw_input()) | ||
|
||
print(a ** b) | ||
print(pow(a, b, m)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/python | ||
|
||
a = int(raw_input()) | ||
b = int(raw_input()) | ||
c = int(raw_input()) | ||
d = int(raw_input()) | ||
|
||
print(a**b + c**d) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/python | ||
|
||
a = int(raw_input()) | ||
|
||
for i in range(0, a): | ||
print i ** 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/python | ||
|
||
from __future__ import print_function | ||
|
||
s = raw_input() | ||
|
||
for a in s: | ||
if a.isalpha(): | ||
if a.islower(): | ||
print(a.upper(), end="") | ||
else: | ||
print(a.lower(), end="") | ||
else: | ||
print(a, end="") | ||
|
||
# wtf!!!! | ||
# import string | ||
# print string.swapcase(raw_input()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/python | ||
|
||
n = int(raw_input()) | ||
|
||
width = len(bin(n)) - 2 | ||
|
||
for i in range(1, n + 1): | ||
print "{0:{width}d} {0:{width}o} {0:{width}X} {0:{width}b}".format(i,width = width) | ||
|
||
# from __future__ import print_function | ||
# for i in range(1, n + 1): | ||
# print("%s %s %s %s" % (str(i).rjust(width, " "), str(oct(i))[1:].rjust(width, " "), hex(i)[2:].rjust(width, " ").upper(), bin(i)[2:].rjust(width, " "))) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/python | ||
|
||
# n = int(raw_input()) | ||
# for i in range(n): | ||
# s = "-".join(chr(ord('a')+n-j-1) for j in range(i+1)) | ||
# print((s+s[::-1][1:]).center(n*4-3, '-')) | ||
|
||
# for i in range(n-1): | ||
# s = "-".join(chr(ord('a')+n-j-1) for j in range(n-i-1)) | ||
# print((s+s[::-1][1:]).center(n*4-3, '-')) | ||
|
||
a = ord('a') | ||
n = int(raw_input()) | ||
width = 4 * n - 3 | ||
|
||
str = [] | ||
|
||
for i in range(1, n): | ||
left = '' | ||
for j in range(i - 1): | ||
left = left + chr(a + n - 1 - j) + '-' | ||
right = left; | ||
left = left + chr(a + n - i) + left[::-1] | ||
str.append(left) | ||
|
||
center = '' | ||
for i in range(n - 1): | ||
center = center + chr(a + n - 1 - i) + '-' | ||
center = center + 'a' + center[::-1] | ||
|
||
for s in str: | ||
print s.center(width, '-') | ||
print center.center(width, '-') | ||
|
||
for s in reversed(str): | ||
print s.center(width, '-') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python | ||
|
||
print ' '.join(word.capitalize() for word in raw_input().split(' ')) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#!/usr/bin/python |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/python | ||
|
||
print "-".join(raw_input().split()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/local/python | ||
|
||
s = raw_input() | ||
args = raw_input().split() | ||
pos = int(args[0]) | ||
char = args[1] | ||
|
||
print s[:pos] + char + s[pos + 1:] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python | ||
|
||
string = raw_input() | ||
findme = raw_input() | ||
count = 0 | ||
start = 0 | ||
|
||
while 1: | ||
temp = string.find(findme, start) | ||
if (temp != -1): | ||
count = count + 1 | ||
start = temp + 1 | ||
else: | ||
break | ||
|
||
print count | ||
|
||
# A = raw_input() | ||
# x = raw_input() | ||
|
||
# count = 0 | ||
# for i in range(len(A)-len(x)): | ||
|
||
# if A[i:i+len(x)] == x: | ||
# count += 1 | ||
# print count |
Oops, something went wrong.