일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- mac hadoop 3
- 기업 조사 빨리 하는 법
- 카카오 2020 코테
- 자소서 너무 오래 걸림
- hive beeline 실행
- Resources are low on NN
- mac hadoop 설치
- hive beeline
- is not allowed to impersonate hive (state=08S01
- mac hadoop 설정
- Safe mode is ON
- hadoop safe mode leave
- 백준 18428
- mac hadoop
- hive beeline 설정
- 카카오 자물쇠와 열쇠
- hive beeline 에러
- 자소서 시간 줄이기
- mac hive
- 자소서 빨리
- mac hive 3
- 카카오 2020 코딩테스트
- 도커 교과서
- 이더리움 #ethereum
- Failed to connect to localhost:10000
- 이더리움
- hadoop safe mode
- Could not open client transport with JDBC Uri: jdbc:hive2://localhost:10000
- 자소서 빨리 쓰는 법
- code=0)
Archives
- Today
- Total
A seeker after truth
exercism pangram solution 본문
P)
Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma,
"every letter") is a sentence using every letter of the alphabet at least once.
The best known English pangram is:
> The quick brown fox jumps over the lazy dog.
The alphabet used consists of ASCII letters `a` to `z`, inclusive, and is case
insensitive. Input will not contain non-ASCII symbols.
mysol)
def is_pangram(sentence):
alpha_dic = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
for i in sentence:
if 65 <= ord(i) <= 90: # upper char
alpha_dic[chr(ord(i)+32)] += 1
elif 97 <= ord(i) <= 122: # lower char
alpha_dic[i] += 1
else:
continue
for value in alpha_dic.values():
if value >= 1:
continue
else:
return False
return True
ord가 아스키 코드 상의 번호를 반환하는 기능이라는 것을 알면 좋다.
sol2)
from string import ascii_lowercase
ALPHABET = set(ascii_lowercase)
def is_pangram(string):
return ALPHABET.issubset(string.lower())
이런 라이브러리가 있다는 것 알면 참 편하게 풀 수 있다. 그리고 issubset 함수를 활용하는 대표적인 사례
sol3)
from string import ascii_lowercase
def is_pangram(sentence):
return all(letter in sentence.lower() for letter in ascii_lowercase)
all이라는 기능...
sol4)
from string import ascii_lowercase
def is_pangram(sentence):
sentence_set = set(sentence.lower())
alpha_set = set(ascii_lowercase)
if alpha_set - sentence_set == set([]):
return True
return False
2번째 풀이의 issubset 함수 기능을 풀어쓴 것이라 생각하면 된다.
sol5)
def is_pangram(string):
return set('abcdefghijklmnopqrstuvwxyz') <= set(string.lower())
길이가 짧은걸로는 압도적,..
'Algorithm > 문제풀이' 카테고리의 다른 글
exercism raindrops solution (0) | 2020.01.24 |
---|---|
exercism RNA-transcription solution (0) | 2020.01.24 |
exercism leap solution (0) | 2020.01.24 |
exercism reverse-string solution (0) | 2020.01.24 |
프로그래머스 정렬 문제풀이(1) (0) | 2020.01.24 |