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,...