blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9094ba06bc997b249e492daf8c14a50ecf672904 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์ฝ์์_๊ฐ์์_๋ง์
/sangmandu.py | 232 | 3.671875 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/77884
์ฝ์์ ๊ฐ์์ ๋ง์
[ํ์ด]
'''
def solution(left, right):
return sum([-num if num ** 0.5 == int(num ** 0.5) else num for num in range(left, right+1)])
'''
''' |
442d1fc42cad61166067dc77c81d10150ea4cb59 | DKU-STUDY/Algorithm | /codility_training/lessons.lesson05.PrefixSum.GenomicRangeQuery/sangmandu.py | 608 | 3.640625 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(S, P, Q):
# write your code in Python 3.6
pass
ret = []
for i in range(len(P)):
temp = S[P[i]:Q[i] + 1]
if temp.find("A") != -1:
ret.append(1)
elif temp.... |
5e78b18eff2cf51656e1f812797a9676cc91f3f1 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์๋ฆฟ์_๋ํ๊ธฐ/sangmandu.py | 330 | 3.65625 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/12931
์๋ฆฟ์ ๋ํ๊ธฐ
[ํ์ด]
1. list(str) = str์ ํ๊ธ์์ฉ ๋์ด์ ๋ฆฌ์คํธํ
'''
def solution(n):
return sum(list(map(int, list(str(n)))))
'''
string์ list๋ก ๊ฐ์ฃผ๋๊ธฐ ๋๋ฌธ์ ๊ตณ์ด listํ ํ ํ์ ์์
return sum(list(map(int, str(n))))
''' |
5bf6917aeb5a4039fd83690a2b9a383adc2225bf | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level03.๋จ์ด_๋ณํ/sangmandu.py | 1,404 | 3.5625 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/43163
๋จ์ด ๋ณํ : ํ๊ธ์๋ง ๋ณ๊ฒฝํ๋ฉด ๊ฐ์์ง๋ ๊ธ์๋ฅผ ์ฐพ์ ์ด๋ํ๋ฉด์ ์ํ๋ ๋จ์ด๋ฅผ ๊ตฌํ ๋์ ์ด๋ํ์๋ฅผ ๊ตฌํ๋ ๋ฌธ์
1) ๋ชจ๋ ๋จ์ด๋ 50๊ฐ ์ดํ์ด๋ฏ๋ก 51๊ฐ์ min ๋น๊ต ๊ฐ๋ฅ
2) ์ ํ๋ ๋จ์ด๋ words์ ์ ๊ฑฐ๋๋ฉฐ words์ ํฌ๊ธฐ์ธ length๋ก ์ด๋ํ์ ํ์
๊ฐ๋ฅ
์ด ๋, words๋ mutable ํ๋ฏ๋ก slicingํ words๋ฅผ ์ธ์๋ก ๊ฒฐ์
3) ๋งค๋ฒ len์ ์กฐ์ฌํ๋ ์๊ฐ์ ์กฐ๊ธ์ด๋๋ง ์ค์ด๊ณ ์ lenWord์ lenWords ๊ทธ๋ฆฌ๊ณ length ์ฌ... |
62f04c0f44a5bb271b794b869c39e60de871d2d6 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.๋
๋ฐ๋จน๊ธฐ/Go-yj.py | 1,384 | 3.578125 | 4 | '''
๋งํฌ : https://programmers.co.kr/learn/courses/30/lessons/12913#
๋ฌธ์ : ๋
๋ฐ๋จน๊ธฐ
์ฒ์์๋ index๊ฐ ๊ฐ์ ๋ (์ง์ ๋ฐ๋ณต์์์ ๋๋ฒ์งธ๋ก ํฐ์+์ง๊ธ์ ์ ์ผ ํฐ์),
(์ง์ ๋ฐ๋ณต์์์ ์ ์ผ ํฐ์+์ง๊ธ์ ๋๋ฒ์งธ๋ก ํฐ ์)๋ฅผ ๊ตฌํด์ ๋น๊ตํด์
answer์ ๋ฐ๋ก๋ฐ๋ก ๋ํ๊ณ ์์ ํ๋ ๋ฐฉ์์ผ๋ก ํ์ดํ์์ต๋๋ค.
๊ทธ๋ฌ๋๊น ํ์ด๋ ๋๋ฌด ๋ณต์กํด์ง๊ณ ๋ค ํ๋ ธ๋ค๊ณ ๋์์ ๋ค๋ฅธ ์ฌ๋๋ค ์ง๋ฌธ์ ๋ณด๊ณ
๋์ ํ๋ก๊ทธ๋๋ฐ์ ์ฌ์ฉํด์ผ ํ๋ ๋ฌธ์ ์์ ์์์ต๋๋ค.
index๊ฐ ๊ฐ์ ๋๋ ์ง์ ์์ ๋๋ฒ์งธ๋ก ํฐ ๊ฐ์,
index๊ฐ ๋ค๋ฅผ ๋๋ ์ง์ ์์ ... |
3c4ea5575b001a3c0392cdc64f541b2d840a68ba | DKU-STUDY/Algorithm | /codility_training/lessons.lesson04.CountingElements.MaxCounters/sangmandu.py | 622 | 3.546875 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(N, A):
# write your code in Python 3.6
pass
arr = [0] * N
tog = 0
mx = 0
for i in A:
if(i == N+1):
if(tog == 0):
tog = 1
arr = ... |
5c55d872a6ffffabe4817b4698546e2f1e040ff8 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.x๋งํผ_๊ฐ๊ฒฉ์ด_์๋_n๊ฐ์_์ซ์/sangmandu.py | 208 | 3.5 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/12954
x๋งํผ ๊ฐ๊ฒฉ์ด ์๋ n๊ฐ์ ์ซ์
0. x์ ๋ฐฐ์๋ฅผ n๊ฐ๋งํผ ์ถ๋ ฅ
'''
def solution(x, n):
return [i*x for i in range(1, n+1)]
'''
''' |
29cdaadd450adac8d1769bd8e4d180728428a0a7 | DKU-STUDY/Algorithm | /BOJ/1141.์ ๋์ฌ/sangmandu.py | 823 | 3.53125 | 4 | '''
https://www.acmicpc.net/problem/1141
์ ๋์ฌ
[ํ์ด]
1. A๋จ์ด๊ฐ B๋จ์ด์ ์ ๋์ฌ๊ฐ ๋๋ ค๋ฉด ๋ ๋จ์ด๋ ์ฌ์ ์์ผ๋ก ๊ฐ๊น์ด์ ์์นํด์๋ค.
2. ์ฌ์ ์์ผ๋ก ์ ๋ ฌ๋(์ค๋ฆ์ฐจ์) ์ธ ๋จ์ด A, B, C๊ฐ ์๋ค๊ณ ํ์
=> A๊ฐ B์ ์ ๋์ฌ๊ฐ ์๋๊ณ B๋ C์ ์ ๋์ฌ๊ฐ ์๋ ๋ A๋ C์ ์ ๋์ฌ๊ฐ ๋ ์ ์๋ค.
=> ์ฌ์ ์์ผ๋ก ์ ๋ ฌ๋๋ค๋ ๊ฐ์ ์ ์๋ฐฐ๋๊ธฐ ๋๋ฌธ
=> ๋ฐ๋ผ์ ์ฌ์ ์์ผ๋ก ์ ์ ์์นํ ๋จ์ด๊ฐ ํ์ ์์นํ ๋จ์ด์ ์ ๋์ฌ๊ฐ ์๋๋ผ๋ฉด ์ดํ์ ์ด๋ ํ ๋จ์ด์ ์ ๋์ฌ๋ ์๋๋ค.
3. startswith๋ฅผ ์ฌ์ฉํ์ฌ ์กฐ์ฌํ๋ค.
=> ๋๋ find... |
f04576f4a421a56efac3628d2439341156fe3fe3 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.ํคํจ๋_๋๋ฅด๊ธฐ/sangmandu.py | 1,003 | 3.796875 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/67256
ํคํจ๋ ๋๋ฅด๊ธฐ
[ํ์ด]
1. ํคํจ๋๋ฅผ 1์ ์ค์ฌ์ผ๋ก (0,0)~(3,2)๋ก ์ค์ , ํด๋น ์ขํ๋ก๋ถํฐ์ ๊ฑฐ๋ฆฌ๋ฅผ ๊ธฐ์ค์ผ๋ก ์กฐ๊ฑด๋ฌธ
'''
def solution(numbers, hand):
answer = ''
l, r = (3, 0), (3, 2)
for i in numbers:
if i and i % 3 == 1:
answer += "L"
l = (i // 3, 0)
el... |
cfa062809841dee8a08fae13ac3e5a6ab0df7204 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.๊ฐ์ฅ_ํฐ_์/sangmandu.py | 515 | 3.59375 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/42746#
๊ฐ์ฅ ํฐ ์
[ํ์ด]
1. ์ฃผ์ด์ง ์ซ์ ๋ฆฌ์คํธ๋ก ๊ฐ์ฅ ํฐ ์ ๋ง๋ค๊ธฐ
2. ์๋ฆฌ ์ ๊ธธ์ด๋งํผ์ 10์ ์ ๊ณฑ์ผ๋ก ๋๋์ด์ 10๋ณด๋ค ์์ ์์ ๋ง๋ค์ด ๋น๊ต
'''
def solution(numbers):
return str(int(''.join([j[0] for j in sorted([(str(i), i / (10 ** len(str(i))-1)) for i in numbers], key = lambda x : -x[1])])))
'''
์ ๊ทผ๋ฐ ์ง์ง
nu... |
f919adcd5e2658ea2bbe5f45d0d26fceabb2bf49 | DKU-STUDY/Algorithm | /BOJ/9536.์ฌ์ฐ๋ ์ด๋ป๊ฒ ์ธ์ง?/6047198844.py | 405 | 3.75 | 4 | T = int(input())
for _ in range(T):
record_voices = input().split()
fox_voice = set(record_voices)
while True:
V = input()
if V == "what does the fox say?":
break
animal, goes, voice = V.split()
fox_voice.remove(voice)
for record_voice in record_voices:
... |
0590f82a8bfa468c7dfc4b788dbda3a0d71670a5 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.ํฐ_์_๋ง๋ค๊ธฐ/turquoiseluv.py | 1,422 | 3.53125 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/42883
๋งค๋ฒ ๋น๊ตํ๋ ค๋๊น ๋ฐํ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ณ ,
while k > 0 and len(ans) < len(number)-k:
if number[target] == max(number[target:target+k+1]):
ans += number[target]
๊ธฐ์กด์ ๋ฐฐ์ด์ ์์๊ฐ ๋ฐ๋์ง ์๋ ์ ์ ์ด์ฉํ์ฌ, que์ ๋ค์ด์ค๋ ์ซ์๋ค๋ง ๋ณด๋ฉฐ, ์ต์ ์ธ์ง ํ๋จํ ์ ์์๋ค.
1) que๋ฅผ ๋ง๋ค๊ณ , number์์ ํ๋์ฉ ๊ฐ(n... |
d13d2c39770f7eaecfb43281c1b82b9638d7e9bd | DKU-STUDY/Algorithm | /์๊ณ ์คํ/์ผ๊ฐํ ์์ ์ต๋ ๊ฒฝ๋ก/์ผ๊ฐํ ์์ ์ต๋ ๊ฒฝ๋ก.py | 1,588 | 3.5625 | 4 | from sys import stdin
def compute_sum(location):
global triang_list
global memo
line, number = location
if line == len(triang_list) - 1:
if location in memo:
return memo[location]
return_val = triang_list[line][number]
memo[location] = return_val
# print(f... |
33bb4b921dc87a75d4d8b49f8580fb79459d46e5 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.์ง์ง์ด_์ ๊ฑฐํ๊ธฐ/HyeonJeong.py | 250 | 3.578125 | 4 | def solution(s):
slist = [s[0]]
for x in s[1:]:
if slist != [] and x == slist[-1]:
slist.pop()
continue
slist.append(x)
return int(slist == [])
print(solution("baabaa") == 1, solution("cdcd") == 0) |
ba23daac6775f55d1cf33da39309afd711466585 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.์์_๋ง๋ค๊ธฐ/sangmandu.py | 447 | 3.5625 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/12977
์์ ๋ง๋ค๊ธฐ
'''
from itertools import combinations
def solution(nums):
nums = sorted([sum(i) for i in combinations(nums, 3)])
rear = nums[-1]
sieve = [True] * (rear + 1)
for i in range(2, rear + 1):
if sieve[i] == True:
for j i... |
948549780b9f57ed749d7697376169563f15393e | DKU-STUDY/Algorithm | /codility_training/lessons.lesson12.EuclideanAlgorithm.ChocolatesByNumbers/sAp00n.py | 183 | 3.546875 | 4 | def solution(N, M):
def gcd(N, M):
if N % M == 0:
return M
else:
return gcd(M, N % M)
return N // gcd(N, M)
print(solution(10, 4))
|
5d00c770506bd1a6cfa71cc14625e51dbe29fd13 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.๋ฌธ์์ด_๋ด_p์_y์_๊ฐ์/Go-yj.py | 543 | 3.578125 | 4 | '''
๋งํฌ : https://programmers.co.kr/learn/courses/30/lessons/12916
๋ฌธ์ : ๋ฌธ์์ด ๋ด p์ y์ ๊ฐ์
count() ํจ์๋ฅผ ์ด์ฉํด์ p์ y์ ๊ฐ์๋ฅผ ๊ตฌํ๊ณ ๋น๊ตํ์์ต๋๋ค.
if๋ฌธ์ ์ฌ์ฉํ์ฌ ํ๋ณํ๊ณ return ํ์๋๋ฐ
๋ค๋ฅธ ์ฌ๋ ์ฝ๋๋ฅผ ๋ณด๋ ๋จ์ํ ํ ์ค๋ก True, False๋ฅผ ํ๋ณํ๊ณ ๋ฐํํ ์ ์๋ค์
[๋ฉ๋ชจ]
return s.lower().count('p') == s.lower().count('y')
'''
def solution(s):
p = s.count('p') + s.count('P')
... |
1873dab0658cc65c00cf4e1ca42c7a96eca9f331 | DKU-STUDY/Algorithm | /BOJ/13460.๊ตฌ์ฌ ํ์ถ 2/6047198844.py | 3,253 | 3.5 | 4 | import collections
#์์ง์ด๊ณ ์ถ์ marble์ ์์น, ์์ง์ด๊ณ ์ถ์ ๋ฐฉํฅ์ y, ์์ง์ด๊ณ ์ถ์ ๋ฐฉํฅ์ x
#๊ฐ์ฅ ๋ฐ๊นฅ ํ๊ณผ ์ด์ ๋ชจ๋ ๋งํ์ ธ ์๋ค. (๋ฒ์ ์ฒดํฌํ์ง ์์๋ ๋จ.)
#๋ค ์ฎ๊ธด ํ์๋ ์ฎ๊ฒจ์ง marble์ ์์น, ์์ง์ธ ๊ธธ์ด๋ฅผ ๋ฐํํ๋ค.
#๋ฒฝ์ '#'์ผ๋ก ํํ๋๋ค.
#์๋ ์๋ฆฌ์์ ์์ง์ผ ์์น๊ฐ '#'์ด๋ฉด ์๋๊ณ ์๋ ์์น๊ฐ 'O'์ด๋ฉด ์์ง์์ ๋ฉ์ถ๋ค.
def move_marble(marble_position, dy, dx):
y, x = marble_position
moved_num = 0
while board... |
eb2b172070ed41020cb32d6acfa2759aed3e6517 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์์ฃผํ์ง_๋ชปํ_์ ์/dkdlelk99.py | 558 | 3.59375 | 4 | def solution(participant, completion):
participant.sort()
completion.sort()
answer = ''
for i in range(len(completion)):
if participant[i] != completion[i]:
answer = participant[i]
return answer
return participant[-1]
print(
solution(['leo', 'kiki', 'eden'], ['ed... |
ed3d0d3e043ad1ef2158dee280d4cf39df63cb21 | DKU-STUDY/Algorithm | /LeetCode/Array/Find_the_Duplicate_Number/6047198844.py | 449 | 3.65625 | 4 | class Solution(object):
def findDuplicate(self, nums):
for i in range(len(nums)):
if nums.count(nums[i])>1 :
return nums[i]
# How can we prove that at least one duplicate number must exist in nums?
# Can you solve the problem without modifying the array nums?
# Can you solve... |
ac6de49b5bb15141d15698e0a4c4878255fd4973 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์๋ฐ์๋ฐ์๋ฐ์/dkdlelk99.py | 234 | 3.734375 | 4 | def solution(n):
if n % 2 == 0:
return "์๋ฐ" * (n//2)
elif n % 2 == 1:
return "์" + "๋ฐ์" * (n//2)
print(solution(6) == '์๋ฐ์๋ฐ์๋ฐ')
print(solution(11) == '์๋ฐ์๋ฐ์๋ฐ์๋ฐ์๋ฐ์')
|
6474e9ad267a4ad34e6632a0ea050d731e136356 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.ํ๋ณดํค/sangmandu.py | 849 | 3.609375 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/42890
ํ๋ณดํค : ์ ์ผ์ฑ๊ณผ ์ต์์ฑ์ ๋ง์กฑํ๋ ๋ฐ์ดํฐ ์ฐพ๊ธฐ
L2 ์์ ์ ์ผ ์ด๋ ค์ด ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ๋ค. https://eda-ai-lab.tistory.com/505 ์ฐธ๊ณ
'''
from itertools import combinations
def solution(relation):
col, row = len(relation), len(relation[0])
cases = [j for i in range(1, row + 1) for j in combin... |
9dcb4d03b88eb3c9153f9e5e84bd07057ecf55ce | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.ํ๋ฆฐํฐ/dkdlelk99.py | 560 | 3.625 | 4 | def solution(priorities, location):
prioritiesMax = max(priorities)
bool_list = [False]*len(priorities)
bool_list[location] = True
count = 0
while True:
if priorities[0] < prioritiesMax:
priorities.append(priorities.pop(0))
bool_list.append(bool_list.pop(0))
... |
47fc5e3f8d606449587cea5fb0f6bfa60bf99775 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.์์ด_๋๋ง์๊ธฐ/sangmandu.py | 722 | 3.734375 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/12981
์์ด ๋๋ง์๊ธฐ
์ค๋ณต ํ๋ณ ๋ฐ ๋-์ฒซ ๊ธ์ ๋งค์นญ
'''
def solution(n, words):
prior = []
end = words[0][0]
for idx, word in enumerate(words):
if word in prior or end != word[0]:
return [(idx)%n+1,(idx)//n+1]
prior.append(word)
end = w... |
413860e261984ef4da7a81315d88f80784040ad5 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.3์ง๋ฒ_๋ค์ง๊ธฐ/6047198844.py | 280 | 3.609375 | 4 | def solution(n):
answer = 0
three_digit = ""
while n > 0:
# n์ 10๊ฐ์ฉ ๋ฌถ์ธ ์ํ์ด๋ค.
three_digit = str(n % 3) + three_digit
n //= 3
for idx, i in enumerate(three_digit):
answer += int(i) * pow(3, idx)
return answer |
015886b700e46c1421bffd26c06e3abee7e22778 | DKU-STUDY/Algorithm | /LeetCode/Array/Three Consecutive Odds/6047198844.py | 307 | 3.640625 | 4 | class Solution:
def threeConsecutiveOdds(self, arr: List[int]) -> bool:
cnt = 0
for x in arr:
# odd
if x % 2 == 1:
cnt += 1
if cnt == 3:
return True
else:
cnt = 0
return False |
728b4fc43f8fe16327cc2d97df7f23bce153e8eb | DKU-STUDY/Algorithm | /LeetCode/Queue/Design_Circular_Deque/HyeonJeong.py | 1,169 | 3.78125 | 4 | from collections import deque
class MyCircularDeque:
# ์ํ ์๋ฐฉํฅ ํ ๊ตฌํ์ ์ค๊ณ
def __init__(self, k: int):
self.q = deque()
self.k = k
def insertFront(self, value: int) -> bool:
if self.isFull():
return False
self.q.append(value)
return True
def insertLast(self... |
06c364598c158ced4fa1871b13aa332ad62c0df6 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.๋ก๋์_์ต๊ณ _์์์_์ต์ _์์/sangmandu.py | 300 | 3.71875 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/77484
๋ก๋์ ์ต๊ณ ์์์ ์ต์ ์์
[ํ์ด]
'''
def solution(lottos, win_nums):
rank = [6, 6, 5, 4, 3, 2, 1]
unk = lottos.count(0)
win = 6 - len(set(win_nums) - set(lottos))
return [rank[win + unk], rank[win]]
'''
''' |
082d9e565aec199d50fcb86a9d3e05fe5718e895 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์๋ฐ์๋ฐ์๋ฐ์/Jaewon0702.py | 151 | 3.578125 | 4 | def solution(n):
return "์๋ฐ" * int(n // 2) + "์" * int(n % 2)
print(solution(3) == "์๋ฐ์")
print(solution(4) == "์๋ฐ์๋ฐ")
|
193ae5765e9b7d8773b4828baa114f049dc5b3ec | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.๊ฐ์ฅ_ํฐ_์ ์ฌ๊ฐํ_์ฐพ๊ธฐ/sangmandu.py | 484 | 3.5 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/12905
๊ฐ์ฅ ํฐ ์ ์ฌ๊ฐํ ์ฐพ๊ธฐ
[ํ์ด]
1. https://github.com/DKU-STUDY/Algorithm/pull/997 ์ค๋ช
์ฐธ์กฐ
'''
def solution(board):
for i in range(1, len(board)):
for j in range(1, len(board[0])):
if board[i][j] == 1:
board[i][j] = min(board[i-1][j], ... |
2420dcd372a35cd8b3dca18d0973f4b0188e680e | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.๋ด์ค_ํด๋ฌ์คํฐ๋ง/sangmandu.py | 827 | 3.6875 | 4 | '''
https://programmers.co.kr/learn/courses/30/lessons/17677
๋ด์ค ํด๋ฌ์คํฐ๋ง
[ํ์ด]
1. ๋ ๊ธ์์ฉ ๋๊ณ lower์ isalpha ๊ฒ์ฌ. ์ดํ, union, intersection ๊ตฌํ๊ธฐ
'''
def solution(str1, str2):
str1, str2 = [str1[i] + str1[i + 1] for i in range(len(str1) - 1)], [str2[i] + str2[i + 1] for i in
... |
9ec4f0c9d7367edd022b1e7315c746fe1629ec1b | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level01.์ต๋๊ณต์ฝ์์_์ต์๊ณต๋ฐฐ์/Go-yj.py | 489 | 3.671875 | 4 | '''
๋งํฌ : https://programmers.co.kr/learn/courses/30/lessons/12940
๋ฌธ์ : ์ต๋๊ณต์ฝ์์ ์ต์๊ณต๋ฐฐ์
'''
def solution(n, m):
answer = []
big_num = max(n,m)
for i in range (big_num,0,-1) : # ์ต๋๊ณต์ฝ์ ๊ตฌํ๊ธฐ
if (m%i==0) and (n%i==0) :
answer.append(i)
break
for i in range(big_num,n*m+1) : # ์ต์๊ณต... |
a0894bb743a1f17213fdcde3646a333ffae4122f | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.์ซ์์_ํํ/Go-yj.py | 760 | 3.59375 | 4 | '''
๋งํฌ : https://programmers.co.kr/learn/courses/30/lessons/12924#
๋ฌธ์ : ์ซ์์ ํํ
๋จ์ํ ์ค์ฒฉ for๋ฌธ์ ์ด์ฉํด์ ์ ๋ง๋ก ์ฐ์ํ ์์ฐ์์ ํฉ์ด n๊ณผ ๊ฐ์์ง ํ์ธํ๋ ๋ฐฉ๋ฒ์ผ๋ก ๊ตฌํ๋ค.
๊ทธ๋ฐ๋ฐ ๋ค๋ฅธ ์ฌ๋๋ค ํ์ด๋ฅผ ๋ณด๋ ์ฝ์์ค ํ์์ ๊ฐ์๋ก ๊ตฌํ๋ฉด ๋๋ค๊ณ ํ๋ค.
์ฌ์ค ์ด์ฌํ ์ฝ์ด๋ณด๊ณ ์ดํดํด๋ณด๋ ค ํ์ผ๋ ์ดํด๊ฐ ์ ์๋จ...
[๋ฉ๋ชจ]
len([i for i in range(1,num+1,2) if num%i==0])
'''
def solution(n):
answer = 0
num = 0
for ... |
17b725de48ec18af175ad9ae554b1d603f7c4fd5 | DKU-STUDY/Algorithm | /programmers/๋์ด๋๋ณ/level02.์ ํ๋ฒํธ_๋ชฉ๋ก/dkdlelk99.py | 411 | 3.71875 | 4 | def solution(phone_book):
length = len(phone_book)
phone_book.sort()
for i in range(length):
for j in range(i+1, length):
if phone_book[j].find(phone_book[i]) >= 0:
return False
return True
print(solution( ["119", "97674223", "1195524421"]) == False)
print(solution([... |
229196ed958bf56dea71aaad2065a725c153706f | aquanette/Nima1 | /fileparser.py | 1,379 | 3.875 | 4 | import os
########## WRITING FILE OUT ##########
#open file to write
#open file to read/write
#to_write_file_pointer = open('to_read.txt', 'w')
to_write_file_pointer = open('read_write.txt','w+')
#FOR: number in range from 1 to 10, write the number and a new line to our file
for number in range(1, 10):
#write ... |
d7b477bb8691f756b9bbdd9b27cd62303f5d58c2 | mslabina/sf15to18 | /sf15to18.py | 753 | 3.703125 | 4 | def sf15to18 (id):
if not id:
raise ValueError('No id given.')
if not isinstance(id, str):
raise TypeError('The given id isn\'t a string')
if len(id) == 18:
return id
if len(id) != 15:
raise ValueError('The given id isn\'t 15 characters long.')
# Generate three last digits of the id
for i in range(0,3):
... |
922171f21f0bb40bf0a3713a6128b741517c94b4 | anirband/crcf | /crcf/crcf.py | 20,801 | 3.65625 | 4 | """
TODO: module doc string
"""
import numpy as np
from abc import abstractmethod, ABC
from graphviz import Digraph
class Rule(ABC):
"""
A generalized representation of a decision tree rule.
Public Methods:
- evaluate(x): determines whether the outcome is true or false from the rule
- gene... |
503b54a74953c77c16b0dc673cda1c8d0a18df2c | rtejada/Universidad-Python | /Funcionalidades/Mundo PC/order.py | 695 | 3.78125 | 4 | from computer import Computer
class Order:
count = 1
def __init__(self, computers):
Order.count += 1
self.__id_order = Order.count
self.__computers = computers
def add_computer(self, computer):
self.__computers.append(computer)
def __str__(self):
computer_st... |
321ae73a55e43967c9d8d4a37d2832f3fa601a64 | rtejada/Universidad-Python | /Funcionalidades/Contactos/lista_contactos.py | 706 | 3.5625 | 4 |
class ListaContactos(list):
def buscar(self, nombre):
'''Devuelve todos los contactos que contienen el valor de
busqueda en su nombre'''
contactos_coincidentes = []
for contacto in self:
if nombre in contacto.nombre:
contactos_coincidentes.append(contact... |
cc64fc52a06f6b91f9e686fdfb8d0598d7e2002a | ms-msn/lesson2 | /age.py | 293 | 3.84375 | 4 | age = int(input('ะกะบะพะปัะบะพ ะฒะฐะผ ะปะตั?'))
if age < 7 :
type_of_activity = 'ะกะฐะดะธะบ'
elif age >= 7 and age <= 18 :
type_of_activity = 'ะจะบะพะปะฐ'
elif age > 18 and age <= 23 :
type_of_activity = 'ะัะท'
elif age > 23 :
type_of_activity = 'ะ ะฐะฑะพัะฐ'
print(type_of_activity)
|
d2c97fe2f2c52c24a370757a18c4b85db97f1a4d | christianlira98/SOAtividade1 | /atividade_01/solutions/busy_wait/peterson/peterson_test.py | 796 | 3.546875 | 4 | import time
from solutions.busy_wait.peterson.peterson import PetersonProcess
from solutions.busy_wait.peterson.peterson import number_of_processes
number_of_processes = int(input('Nรบmero de processos: '))
number_of_iterations = int(input('Nรบmero de iteraรงรตes: '))
processes = [PetersonProcess(k, number_of_iteration... |
f261b5c4fe5f6ce42cf62898b7f24989f2ebaaab | rickoooooo/OSCE_tools | /Exploit_Dev/badchars/add_hex_numbers.py | 3,561 | 3.875 | 4 | #!/usr/bin/python
# Sometimes we run into a lot of bad chars and you need a way to get a certain hex value onto the stack.
# Usually you can do this by adding two values like if 0x00 is a bad char and you need 0x00000000 on the stack,
# You could subtract 0x11111111 - 0x11111111 and end up with 0x00000000. This script... |
d876d71f562046277548cae64f48a7794254bc40 | sai-reddy/codeeval | /solutions/primesbelownumber.py | 1,114 | 3.9375 | 4 | import sys
import array
def print_primes(number):
iter_list = array.array('c')
iter_list.append('0')
iter_list.append('0')
# Inititalize the list of length of argument plus 1 with all 1's for 1 based indexing
for i in xrange(2, number+1):
iter_list.append('1')
# Mark all non-primes as... |
ddac8e715d25670809f21d0b696d5aa6ab2c357a | tarak2014/pytest | /basicmath/util.py | 267 | 3.53125 | 4 | def add_num(first_no, second_no):
return first_no + second_no
def sub_num(first_no, second_no):
return first_no - second_no
def mul_num(first_no, second_no):
return first_no * second_no
def div_num(first_no, second_no):
return first_no / second_no
|
367cafa375b2b597ccd4ea3546450f324e09e50e | bioerrorlog/kent-beck-tdd-python | /chap_01/tests/money/test_money.py | 827 | 3.5625 | 4 | from src.currency.money import Money
class TestMoney:
def test_multiplication(self):
five = Money.dollar(5)
assert five.times(2) == Money.dollar(10)
assert five.times(3) == Money.dollar(15)
def test_equality(self):
assert Money.dollar(5).equals(Money.dollar(5))
assert ... |
735378906573b6be32c33f348d3f26812395269f | vnagouda/pythonExamples | /loops.py | 180 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 1 19:41:47 2021
@author: vnago
"""
fruits = ["apple", "banana", "papaya", "orange"]
for x in fruits:
print(x)
|
3c1df5473e799672314f855b6bf672f292522b48 | DW-CN/Python | /hello_world.py | 317 | 4.09375 | 4 | favorite_languages = {
'jen': 'Python',
'dennis': 'C',
'sarch': 'ruby',
'phil': 'Python',
}
friends = ['dennis','jen']
for name in favorite_languages.keys():
print(name.title())
if name in friends:
print(" Hello " + name.title() + ",I see your favorite language is " + favorite_languages[name]+"!")
|
0008a3899785cf3159fb124fd9e5fa04679778cf | Jayashankara-DM-135/Python_Programing | /Basics/13_tuple.py | 347 | 3.875 | 4 | """
Tuple: imutable : Means read-only, we can't change.
"""
mytuple = ('HAL', 'BEL', 'BHEL', 'ISRO')
print(mytuple)
#try to modify , It will not be allowed "tuple object does not support item assignment"
#mytuple[0] = "DRDO"
print(mytuple)
#Note: Rest of the operations is similar to List
#empty tuple
temptuple = ... |
512d992c8102d9336f3257c06dc202fb794918bd | Jayashankara-DM-135/Python_Programing | /Basics/23_sorting.py | 2,922 | 4.40625 | 4 | """
Sorting :
"""
print("************************ List sorting ***********************")
li = [9,7, 3, 8, 5, 6, 2, 1]
#in-place sorting with acescending order
li.sort()
print(li)
del li
#in-place sorting with descending order
li = [9,7, 3, 8, 5, 6, 2, 1]
li.sort(reverse=True)
print(li)
print("================Key====... |
07c74cab45ef2ef408ef6a6f29f0732da80f4a0b | Jayashankara-DM-135/Python_Programing | /Advance/Unit test in python/text_employee.py | 2,331 | 3.640625 | 4 | """
test module to text employee module:
Note:
1> Test cases will run in random order.
2> setUp() and tearDown() will get called for each test cases.
3> setUpClass() and tearDownClass() will get called before any test case execution and once all the test cases execution is done,
It is not per test case.
4> Test... |
de29035e1422d8cbc328577d38b3705dfc8d00a4 | Jayashankara-DM-135/Python_Programing | /Data strcure/Tree/level_order_traversal.py | 1,320 | 3.5 | 4 | from sys import stdin, stdout
from collections import deque
class Node:
def __init__(self, val):
self.info = val
self.left = None
self.right = None
self.level = None
class BST:
def __init__(self):
self.root = None
def create(self, val):
if self.root is None... |
e267f5683341335efccdbc1c2fdc9961349e960e | Jayashankara-DM-135/Python_Programing | /Basics/3_Logical_operator.py | 254 | 4.03125 | 4 | last_name = "DM"
age = 29
if last_name == 'DM' and age == 28:
print("Yes")
else:
print("No...")
if last_name == 'DM' or age == 28:
print("Yes")
else:
print("No...")
if not(last_name=='DM'):
print("Yes")
else:
print('No ....')
|
c93a91865f6196a9103d6d3904509350695bcf33 | Jayashankara-DM-135/Python_Programing | /Advance/Iterators and iterable/basic_iterators_and_iterable.py | 4,025 | 4.59375 | 5 | """
Iterators: One which knows it's state by it's self.
Object which supports next() will be called as iterator since with help of next() method object can gets it's next state.
Once it reached the end , further call to next() will throw StopIteration exception.
Note:
--> We can use for lo... |
ede0a40e61e3ca94a13773c41602911bfe2e8084 | Jayashankara-DM-135/Python_Programing | /Advance/OOP in python/overrdiing_special_funcation.py | 1,486 | 4.15625 | 4 | """
Special funcations overloading.
-----------------------------
It's similar to c++ operator overloading
"""
class Empolyee:
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + "." + last + "@company.com"
def getFullna... |
b21cd4ccc47e1ea9b865ca550c2b21c9b57b90a3 | andela/ah-backend-athena | /authors/apps/authentication/social/twitter_token_validator.py | 1,964 | 3.640625 | 4 | """
This module validates a twitter access token
"""
import os
import twitter
from dotenv import load_dotenv
load_dotenv()
class TwitterValidate:
"""
This class contains methods that handle both the verification and
decoding of the twitter access_token and returns decoded user data
"""
@staticmet... |
46c75b59690866013dad03096a85e82412b5c494 | motloch/coursera_stanford_algorithms | /c1_w3_quicksort.py | 3,040 | 4.28125 | 4 | """
Code of the Quick Sort algorithm using randomly chosen pivot
Based on the Week Three of the 'Divide and Conquer, Sorting and Searching, and Randomized
Algorithms' course on Coursera (Algorithms Specialization, Stanford University)
"""
import random
random.seed(41)
def choose_pivot_idx(arr, idx_start, idx_end):
... |
5c2363c008c2c05bd8b57e9fd3864849df6feba3 | vipulsingh24/Python | /Algorithm and Data Strucutre/Sorting/Heap_Sort.py | 688 | 4.0625 | 4 | '''
Implementation of Heap Sort
'''
def heapify(a, n, i):
largest = i
l = 2 * i + 1 # Left child
r = 2 * i + 2 # Right child
if l < n and a[i] < a[l]:
largest = l
if r < n and a[largest] < a[r]:
largest = r
if largest != i:
a[i], a[largest] = a[largest], a[i]
heapify(a, n, largest)
def heapSort(a):
... |
b6e1f551e902e0caac4c7b44354a102227d06ee7 | yoyonel/2018_papayoo | /src/logic/card.py | 3,969 | 3.640625 | 4 | """
"""
from enum import Enum
#
from logic.constants import *
class CardSuit(Enum):
SPADE = 1
HEART = 2
DIAMOND = 3
CLUB = 4
PAYOO = 5
@staticmethod
def to_int(cs):
return {
CardSuit.SPADE: 1,
CardSuit.HEART: 2,
CardSuit.DIAMOND: 3,
... |
7dd9becd079902c46ce8210f4eeb16fbfea4da2f | AvirathPaliwal/Functions | /FileOpration.py | 337 | 4.28125 | 4 | def CountWordFromFile():
fname = input('Enter Your File Name : ')
numbersOfWOrds=0
file = open(fname,'r')
for i in file :
words = i.split()
numbersOfWOrds = numbersOfWOrds + len(words)
#print(words)
print('Number of Word in A file : ' + str(numbersOfWOrds))
CountW... |
7f046aa1c53974c03e4dec5008b03392ff47be89 | vivienyuwenchen/InteractiveProgramming | /Game4.py | 8,920 | 3.8125 | 4 | """
Blockade is competitive arcade game. It has two players. Player 1 is a white
block that is continually moving forward. Player 2โs job is to stop Player 1 by
throwing obstacles in its way. Player 1 can avoid obstacles by jumping over or
ducking under them. Both players are limited by a stamina bar. Actions such
jump... |
6a723d8cf0470910002a6de67252b42d23df56cf | mostafa-elrosasy/ROV-chellenge | /image/shape_detection.py | 1,645 | 3.5 | 4 | import cv2
import numpy as np
import argparse
# the square is -1 because the image frame is counted a square
shapes={"square":-1,"circle":0,"line":0,"triangle":0}
# example command: python shape_detection.py -i shapes.png -l 0 -t 1 -s 3 -c 1
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=Tru... |
b9caeb6f3306078b40ee4d4200654261b9fac1e0 | tiny0little/handy-tools | /leetcode/0050.py | 1,765 | 3.59375 | 4 | #!/usr/bin/python3
"""
50. Pow(x, n)
Difficulty: Medium
Success
Runtime: 144 ms, faster than 5.92% of Python3 online submissions for Pow(x, n)
Memory Usage: 14.3 MB, less than 49.63% of Python3 online submissions for Pow(x, n)
"""
from typing import List
import time
class Solution:
def myPow(self, x: float, n: ... |
e5bad79bc591381aa366260b3f3ad711cd9af467 | tiny0little/handy-tools | /leetcode/0017.py | 1,742 | 3.6875 | 4 | #!/usr/bin/python3
"""
17 Letter Combinations of a Phone Number
Difficulty: Medium
Runtime: 32 ms, faster than 61.61% of Python3 online submissions for Letter Combinations of a Phone Number.
Memory Usage: 14.3 MB, less than 61.08% of Python3 online submissions for Letter Combinations of a Phone Number.
"""
from typin... |
0dfb771ffcaa395dbdf409592b8854b75054c6cc | amangarg1003/ia | /P04/qlearningAgents.py | 5,787 | 3.75 | 4 | # -*- coding: utf-8 -*-
from game import *
from learningAgents import ReinforcementAgent
from featureExtractors import *
import random,util,math
class QLearningAgent(ReinforcementAgent):
"""
Q-Learning Agent
Functions you should fill in:
- `getQValue`
- `getAction`
- `getValue`
... |
27b1c8e68f8df22e29e1238304f79a269183404a | sarvnazale/Wave-3 | /Is Number Prime.py | 649 | 4.1875 | 4 |
#function that determines whether number is prime
def isPrime(j):
for i in range(2, j):
if j % i == 0:
return False
elif j <= 1:
return False
else:
return True
#main function that intakes the number and calls on the prime function
def main():
number ... |
81b879e90018971abf0a8ccc9704eb2731a0aafb | megdesko/lpthw-me-edition | /ex39.py | 1,145 | 4.0625 | 4 | # create a string named ten_things
ten_things = "Apples Oranges Crows Telephone Light Sugar"
print "Wait, there's not 10 things in that list, let's fix that."
# break apart ten_things on ' ' into a list
stuff = ten_things.split(' ')
# make a list of strings called more_stuff
more_stuff = ["Day", "Night", "Song", "Fri... |
0365a4a8c5491b1ce637e0e6f029f35b87b3f37e | AweSong-Kor/Python | /pyget.py | 867 | 3.984375 | 4 | #!/usr/bin/python
# written by AweSong-kor
#
# Usage
# python pyget.py URL : Download a file from URL
# python pyget.py URL FILENAME : DOWNload a file from URL as FILENAME
#
import sys
import os
from urllib2 import urlopen
def DownloadFile(url,filename=None):
CHUNK = 16 * 1024
if filename is None:
filename = ... |
9b299188eb3c0fc1771e5b0cdb245f6a74f624d0 | Hapay/Python_Projects_2 | /Regular_Expressions/own_re.py | 468 | 3.859375 | 4 | import re
#Tutaj stworzona klasa regex przeze mnie
vowelRegex = re.compile(r'[aeiouyAEIOUY]')
# Two vowels in a row
#vowelRegex = re.compile(r'[aeiouyAEIOUY]{2}')
#This will match every char that isn't in a char class
#vowelRegex = re.compile(r'[^aeiouyAEIOUY]')
message = "2019 Microsoft Corporation. All rights rese... |
6c5910c21cc6ab4bf13562f7d3816a220e1cdc81 | JacobNegri/dictionaries | /date_of_birth.py | 814 | 4 | 4 | # take a user entered date of birth and name and return the age of that person
import datetime
dob_dictionary = {}
count = 0
while count < 1:
name = input("Enter a name:")
valid_dob = False
while not valid_dob:
try:
dob = input("Enter a DOB:(use spaces)")
dob = dob.split... |
70539e4d212f2a8a5f78e7f8c275ace5cf32961c | Honfeil/pythonWorkspace | /demo15_return_function.py | 1,864 | 3.640625 | 4 | # -*- coding:utf-8 -*-
# ้ซ้ถๅฝๆฐ้คไบๅฏไปฅๆฅๆถๅฝๆฐไฝไธบๅๆฐไนๅค๏ผ่ฟๅฏไปฅๅงๅฝๆฐไฝไธบ็ปๆๅผ่ฟๅ
# ไธ่ฌๆฑๅ
def calc_aum(*args):
ax = 0
for n in args:
ax += n
return ax
# ่ฟๅๅฝๆฐ
def lazy_sum(*args):
def sum():
ax = 0
for n in args:
ax += n
return ax
return sum
print(lazy_sum(1,2,3))
print(laz... |
32199adffa21f39096b45d87490ac0a7e1523bf0 | Honfeil/pythonWorkspace | /demo12_map_reduce.py | 1,261 | 4 | 4 | # -*- coding:utf-8 -*-
# python ๅ
ๅปบไบmap()ๅreduce()ๅฝๆฐ
# map()
# mapๆฅๅไธคไธชๅๆฐ๏ผไธไธชๆฏๅฝๆฐ๏ผไธไธชๆฏIterable๏ผmapๅฐไผ ๅ
ฅ็ๅฝๆฐไพๆฌกไฝ็จๅฐๅบๅ็ๆฏไธชๅ
็ด ๏ผๅนถๅฐ็ปๆไฝไธบๆฐ็Iterator่ฟๅ
# xๅนณๆน
from functools import reduce
def f(x):
return x * x
r = map(f, range(10))
print(next(r))
print(next(r))
print(next(r))
print(next(r))
print(list(r))
# ่ฝฌๅญ็ฌฆไธฒ
l = list(map(... |
134b6928087fc6c411bad7082dd4fb2fa8157275 | pedrobenevides2/Ciencia-de-Dados | /coursera/semana4/exerc2opc.py | 268 | 3.890625 | 4 |
n=input("Digeite um nรบmero: ")
i =int(len(n))
#print(i)
n=int(n)
while i!=1:
#print(n)
n1=n//(10**(i-1))
#print(n1)
n2=(n%(10**(i-1)))//(10**(i-2))
#print(n2)
n=(n%(10**(i-1)))
#print(n)
i=i-1
#print(i)
if i==0:
break |
7c6b5841a736bc6d354e04119ead083539fc6772 | pedrobenevides2/Ciencia-de-Dados | /coursera/semana 2/exerc1opc.py | 291 | 3.953125 | 4 | a = input("Digite o nome do cliente: ")
b = int(input("Digite o dia de vencimento:"))
c = input("Digite o mรชs de vencimento:")
d= input("Digite o valor da fatura: ")
print("Olรก, {}".format(a))
print("A sua fatura com vencimento em {} de {} no valor de R$ {} estรก fechada.".format(b,c,d)) |
34d8bd4afef48ad58df3510a158aa4f91bffc885 | pedrobenevides2/Ciencia-de-Dados | /guanabara/mundo2/ex49.py | 193 | 3.828125 | 4 |
m1 = 0
m2 = 0
produto = 0
for m1 in range (0,10):
#print(m1)
for m2 in range (0,10):
# print(m2)
produto = m1*m2
print(" {} x {} = {} ".format(m1, m2, produto)) |
a1b271c9b05d41b13c5475990523333497f7a19c | pedrobenevides2/Ciencia-de-Dados | /coursera/semana 2/exerc3opc.py | 112 | 4.0625 | 4 | n = str(input(" Digite um numero inteiro "))
a = n[-2]
a=int(a)
print ("O dรญgito das dezenas รฉ {} ".format(a)) |
c7230de2864ce380e3acb89b382885243ca338d2 | pedrobenevides2/Ciencia-de-Dados | /coursera/semana 3/principal/exerc5_crescente.py | 307 | 4 | 4 | # Crescente
#print(" Tu acha que acabou porque hoje รฉ sexta")
#print("Vamos lรก.... preciso de trรชs numeros")
a = int(input( " primeiro numer: "))
b = int(input(" segundo numero: "))
c = int(input(" terceiro numero: "))
if (a<b<c):
print("crescente")
else:
print("nรฃo estรก em ordem crescente")
|
c778e5bc05491e57cb4e8b8d6d7ccbb878779ffe | pedrobenevides2/Ciencia-de-Dados | /guanabara/mundo1/desafio28.py | 284 | 3.859375 | 4 | import random
n = int(random.randrange(0,5))
z = int(input(" Qual foi o numero que o PC escolheu?"))
if n==z:
print(" parabens, vocรช acertou. Confirmando o nรบmero, ele foi {}".format (n))
else:
print ( " Vc errou o numero, o numero escolhido pel o Pc foi {}". format (n))
|
710af383d61c9f99784e897d3fd32e9c8cc465d3 | pedrobenevides2/Ciencia-de-Dados | /coursera/rascunho/exerc2_fizz.py | 507 | 4.21875 | 4 |
# Receba um nรบmero inteiro na entrada e imprima se o nรบmero for divisรญvel por 3.
# Caso contrรกrio, imprima o mesmo nรบmero que foi dado na entrada.
a = float(input("Digite um nรบmero: "))
#print (" O numero inteiro que vocรช escreveu foi", a, " correto?")
b = (a % 3)
c = int(a)
d = 3
if (b==0):
print ( " Esse n... |
627cc16046aad848d66452b601e935b973506e4e | pedrobenevides2/Ciencia-de-Dados | /coursera/rascunho/boo.py | 385 | 4.03125 | 4 |
dec = True
anterior = int(input("Digite o primeiro nรบmeroda sequencia: "))
valor = 1
while valor!= 0 and dec:
valor = int(input("Digite o prรณximo nรบmero da sequรชncia: "))
if valor > anterior:
dec = False
anterior = valor
if dec:
print( " A sequรชncia estรก em ordem descrescente!!")
else:
p... |
5d3e7eb00f54ac034bbc5fde94be28d8831f5ec1 | Jerllina/GrokkingAlgorithms_LearningRecords | /CallStack.py | 564 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 30 14:23:31 2018
@author: lijie
"""
#Function stack
def greet(name):
print('hello,',name,'!')
greet2(name)
print('getting ready to say good bye')
bye()
def greet2(name):
print('how are you,',name,'?')
def bye():
print('ok bye... |
250c5ee28780ba082608aa9a1d93bf0feb49567f | fl00r/problems | /largest-number/solution1.py | 343 | 3.5625 | 4 | #!/bin/python3
def trick(n):
return n + n[-1]
def largest_number(data):
data_ = sorted(map(str, data), key=trick, reverse=True)
number = int("".join(data_))
return number
#
# TESTS
#
data = [10, 68, 75, 7, 21, 12]
res = 77568211210
res_ = largest_number(data)
if res_ != res:
raise(Exception("Expected %s, ... |
920a5947189992d8d32bfb6374fb2f13ed700c6d | gorebr/CS325_HW1 | /mergeTime.py | 1,709 | 3.828125 | 4 | import random as r
import time as t
#recursive merge sort; devloped from C code made for cs261
def m_sort(arr):
#exit condition
if(len(arr) > 1):
#find mid and split array
m = len(arr) // 2
left = arr[:m]
right = arr[m:]
#sort left and right arrays
m_sort(left)
... |
01156e6dc04aec0a8f097f41b413fc4067c3694e | joekonieczny/CS5 | /hw0pr2a.py | 2,578 | 3.96875 | 4 | # coding: utf-8
#
# hw0pr2a.py
#
import random # imports the library named random
def rps():
user = input("Welcome to RPS, Grutors of CS5! Choose your weapon: ")
comp = random.choice( ['rock','paper','scissors'] )
print()
print('the user (you) chose', user)
print('the comp (I) chose',... |
2cc387731e9a83fa320d09fa448b31b3730c27a3 | foolusion/dsa-challenge | /challenge/fill.py | 6,299 | 3.828125 | 4 | from collections import namedtuple
from pathlib import Path
from PIL import Image
from util import crop, combine
def fill(image, position, color):
"""
Fills image with color starting at position.
This fills the image modifying the original image passed in. If you do not
want to modify the image you... |
2e2f8cb0e5f3ecad1f1e6efe21b09a01de133f95 | placeboooo/iglovikov_helper_functions | /iglovikov_helper_functions/data_processing/image_processing/png2jpg.py | 1,497 | 3.59375 | 4 | """
Reads all png images in one folder and save to other as jpgs, in flatten way.
One can specify the strength of the jpeg compression
"""
import argparse
from pathlib import Path
import cv2
from tqdm import tqdm
def parse_args():
"""Parse input arguments."""
parser = argparse.ArgumentParser(description="Co... |
f47c9ff9d2bbc2cbde35aa9e2444fdd0494517ff | McarvalhoM/EstruturaDeDecisao | /e006.py | 307 | 4.09375 | 4 | # Faรงa um Programa que leia trรชs nรบmeros e mostre o maior deles.
num1 = int(input('Digite um nรบmero'))
num2 = int(input('Digite um nรบmero'))
num3 = int(input('Digite um nรบmero'))
if num1 > num2 and num1 > num3:
print(num1)
elif num1 < num2 and num2 > num3:
print(num2)
else:
print(num3)
|
0f1babdb9170edeae7453bfc13313dbd2a69908a | realsung/Writeup | /ctf/codegate/2018-Final/misc/Random Picross/test.py | 6,854 | 3.734375 | 4 | # -*- coding: utf-8 -*-
from PIL import Image, ImageDraw
SYMBOL_EMPTY = 0
SYMBOL_X = 1
SYMBOL_FILLED = 2
#
def fixed_sum_digits(digits, Tot):
"""
adapted from http://stackoverflow.com/a/8617750
Given digits and Tot, it generates an array of all ways to arrange "digits" x digits so that
the sum of t... |
89a0da31ebae3b818d2f0128411bd9d7294860de | robert780612/python-technique | /inheritance.py | 504 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 1 00:04:33 2017
A simple example to implement stack by inheritance
@author: Robert
"""
class Stack(list):
"""
Inheritance list
"""
def push(self, x):
self.insert(0, x)
def popout(self):
return self.pop(0)... |
396f7aa93338abf7ae96773f30fd0052ce80e6f5 | TanvirMobasshir/CSE246 | /rough_codes/fib.py | 804 | 3.953125 | 4 | def fib(n: int, start: int, second: int, count: int): # time complexity: O(n)
count+=1
# print(start)
if count==n:
return start
return fib(n, second, start+second, count)
def Fib(n: int): # time complexity: O(n^2)
if n == 1: return 0
if n == 2: return 1
return Fib(n-1)+Fib(n-2)
def fib_dynamic(... |
2e07b4545a6c789551afb3512a40fcf0bab746e3 | TanvirMobasshir/CSE246 | /lab_2/lab_2_practice/1.py | 592 | 3.734375 | 4 | def binary_search(my_list, data):
start = 0
end = len(my_list) - 1
while end >= start:
idx = int((end - start) / 2) + start
if data == my_list[idx]:
return idx
elif data > my_list[idx]:
start = idx + 1
else:
end = idx - 1
return -1
if... |
3bb91f9464b950e32e487f9f904022556eb1fc8d | SwimLurker/vigenere_py | /src/vigenere.py | 1,440 | 3.90625 | 4 | def main(args):
if len(args) != 4:
printUsage()
elif args[1] == '-e':
print(encrypt(args[2], args[3]))
elif args[1] == '-d':
print(decrypt(args[2], args[3]))
else:
printUsage()
def printUsage():
print("""
Usage: main -e <srouce string> <cipher> //Encrypt source st... |
36bb21d1658f219570fb9a5b5104d2cba33c4b9e | supenova1604/sorting | /radix_sort.py | 737 | 3.71875 | 4 | def radix_sort(array):
max_len = len(str(max(array)))
array = [str(x).zfill(max_len) for x in array]
result = group_in_buckets(array=array,
digit=max_len-1)
return [int(x) for x in result]
def group_in_buckets(array, digit):
print(digit)
buckets = [[] for _ in ran... |
a8bd6062e21256c3f6d3a26b066003edccbe24eb | UjwalAgrawal/Data-Structure-Algorithms | /Binary Search Tree.py | 3,231 | 3.875 | 4 | class Node:
def __init__(self, value):
self.value = value
self.right = None
self.left = None
class BinarySearchTree:
def __init__(self):
self.root = None
def add(self, value):
if(not self.root):
self.root = Node(value)
else:
cur = sel... |
e24607a787569a7cfc089810f9aa66c3a57e47c9 | UjwalAgrawal/Data-Structure-Algorithms | /Largest rectangle.py | 721 | 3.609375 | 4 | def LargestRectangle(arr):
stack = []
maxArea = -1
i, l=0, len(arr)
while(i<l):
if(not stack or arr[stack[-1]]<=arr[i]):
stack.append(i)
i+=1
else:
t = stack.pop()
if(stack):
area = arr[t] * (i-stack[-1]-1)
else:... |
d19405297aec6d65cda25b8ef29e1b1d4dc7712b | j2k2020/basic_git | /python/sec04/05_while2.py | 363 | 3.984375 | 4 | # 7์ ์
๋ ฅํ ๋๊น์ง ๊ณ์ ์
๋ ฅํ๋ ํ๋ก๊ทธ๋จ
# 7์ ์
๋ ฅํ๋ฉด ํ๋ก๊ทธ๋จ ์ข
๋ฃ (while๋ฌธ ์ฌ์ฉ)
#
# ์ซ์ ์
๋ ฅ: 3
# ๋ค์ ์
๋ ฅ: 9
# ๋ค์ ์
๋ ฅ: 1
# ๋ค์ ์
๋ ฅ: 7
# 7 ์
๋ ฅํ์ต๋๋ค. ์ข
๋ฃ
num = int(input("์ซ์ ์
๋ ฅ: "))
while num != 7:
num = int(input("๋ค์ ์
๋ ฅ: "))
print(num, "์
๋ ฅํ์ต๋๋ค. ์ข
๋ฃ~") |
863f4fdcf6e5420f661b8bffca37bf166b9eacff | j2k2020/basic_git | /python/sec03/06_if_elif_else_ex2.py | 510 | 3.9375 | 4 | # ๊ฐ์๋ฐ์๋ณด ๊ฒ์
# ํ๊ธธ๋ ์
๋ ฅ: ๋ฐ์ ์
๋ ฅํ ๊ฒฝ์ฐ
# ์ด๋ชฝ๋ฃก ์
๋ ฅ: ๊ฐ์
# ํ๊ธธ๋์ด ์ด๊ฒผ์ต๋๋ค.
# choice=input("1:๊ฐ์, 2:๋ฐ์, 3:๋ณด ์
๋ ฅํ์ธ์: ")
print("1:๊ฐ์, 2:๋ฐ์, 3:๋ณด ์ซ์๋ก ์
๋ ฅํ ๊ฐ์๋ฐ์๋ณด ๊ฒ์\n")
hong: int = int(input("ํ๊ธธ๋ ์
๋ ฅ: "))
mong: int = int(input("์ด๋ฉ๋ น ์
๋ ฅ: "))
if hong > mong:
print("ํ๊ธธ๋์ด ์ด๊ฒผ์ต๋๋ค.")
elif hong < mong:
print("์ด๋ฉ๋ น์ด ์ด๊ฒผ์ต๋๋ค.")
else:
print("๋น๊ฒผ์ต๋๋ค.") |
0beacb8bfbd08eab78881c701d15bdccf6a0a9fc | j2k2020/basic_git | /python/sec03/04_if_elif_slse_exe1.py | 220 | 3.875 | 4 | # ์ ์ 3๊ฐ๋ฅผ ์
๋ ฅ ๋ฐ์์ ์ ์ผ ํฐ ์ ์ถ๋ ฅ
num1 = int(input("์ ์1 ์
๋ ฅ: "))
num2 = int(input("์ ์2 ์
๋ ฅ: "))
num3 = int(input("์ ์3 ์
๋ ฅ: "))
if num1 > num2 and num1 > num3:
maxNum = num1 |
0c06f00f2efd7eae45b606eec67b0595a67f40fe | rometsch/wana | /src/wana/integration.py | 3,486 | 3.5625 | 4 | """ Integration of acceleration to estimate velocities and positions. """
import numpy as np
from wana.analysis import calculate_norm
def estimate_velocities(sensor, frame, perstep=False):
""" Use accelerations with g removed to estimate velocities in the iss.
iss = initial sensor system
lab = laboratory ... |
bb21469ed3e19053af6582c6a85b12f0dda58cfb | Isaiahg123/variables | /variables_primary.py | 3,244 | 4.3125 | 4 | # author: <name here>
# date: <date here>
#
# description: <fill in>
# --------------- Section 1 --------------- #
# 1.1 | Variable Creation | Strings
#
# Relevant Documentation
# - https://www.w3schools.com/python/python_variables.asp
# - https://www.w3schools.com/python/python_variables_names.asp
#
# Variables
... |
82bbe478046e35923869e60a62c605a5f4aa9ce3 | MATNaruse/COMP309_BikeTheftAnalysis | /ToRemove/SupportFunctions.py | 3,870 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
COMP309 Bike Theft Analysis
===========================
301 063 251 : Arthur Batista
300 549 638 : Matthew Naruse
301 041 132 : Trent B Minia
300 982 276 : Simon Ducuara
300 944 562 : Zeedan Ahmed
"""
import pandas as pd
import datetime
def get_cat_col(df: pd.DataFrame, df_label:str = None,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.