🧑🏻💻(63)
-
[C] STANDARD C LANGUAGE / C 언어 / C언어 명령어 / C 명령어 정리
stdcxp 명령어 정리.
2021.09.07 -
중복되는 수
arr = [1,2,3,3,3,4,4] def solution(arr): answer = [] for v in arr: if(not answer) or (v not in list(zip(*answer))[1]): answer.append([1,v]) else: for i in range(len(answer)): if answer[i][1] == v: answer [i][0] += 1 answer = [cnt for cnt, value in answer if cnt > 1] if answer : return answer else : return [-1]
2021.06.24 -
소수 구하기
from itertools import permutations import math def check(n): k = math.sqrt(n) if n < 2: return False for i in range(2, int(k)+1): if n % i == 0: return False return True def solution(numbers): answer = [] for k in range(1, len(numbers)+1): perlist = list(map(''.join, permutations(list(numbers), k))) for i in list(set(perlist)): if check(int(i)): answer.append(int(i)) answer = len(set(answer)) re..
2021.06.24 -
완주하지 못한 선수
def solution(participant, completion): answer ='' participant.sort() completion.sort() for i in range (len(participant)): if participant[i-1] != completion[i-1]: return participant[i-1] return answer
2021.06.24 -
[Python] Dictionary sorted
fruit = {'apple':3, 'grape':10, 'banna':7,'peach':3,'melon':2} sorted1 = sorted(fruit.items()) print(sorted1) sorted1 = sorted(fruit.items(), reverse = True) print(sorted1) def f1(x): return x[0] def f2(x): return x[1] sorted2 = sorted(fruit.items(), key=f1) print("key:", sorted2) sorted2 = sorted(fruit.items(), key=f2) print("value:", sorted2) sorted2 = sorted(fruit.items(), key=f2, reverse = T..
2021.06.24