Problem:
An email address such as "John.Smith@example.com" is made up of a local part ("John.Smith"), an "@" symbol, then a domain part ("example.com").
The domain name part of an email address may only consist of letters, digits, hyphens and dots. The local part, however, also allows a lot of different special characters. Here you can look at several examples of correct and incorrect email addresses.
Given a valid email address, find its domain part.
Example
- For address = "prettyandsimple@example.com", the output should be
findEmailDomain(address) = "example.com"; - For address = "fully-qualified-domain@codesignal.com", the output should be
findEmailDomain(address) = "codesignal.com".
-Summary-
1. email address를 뒤에서부터 읽어 special chracter인 '@'을 만날때까지 리스트에 character들을 넣어준다.
2. 끝나고 list 안에 담겨있는 character들을 join()함수로 return.
풀고 난 후에 사람들이 푼 답을 보니 .split() 함수로 너무 쉽게 표현되 있어 오늘도 배운다.
return address.split('@')[-1]
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [46/60] electionsWinners (0) | 2020.05.27 |
---|---|
CodeSignal [45/60] buildPalindrome (0) | 2020.05.27 |
CodeSignal [43/60] isBeautifulString (0) | 2020.05.26 |
CodeSignal [42/60] bishopAndPawn (0) | 2020.05.26 |
CodeSignal [41/60] digitDegree (0) | 2020.05.26 |
댓글