HackerRank-Python(90)
-
Prepare > Python > Sets > Introduction to Sets
[python] 파이썬 set (집합) 자료형 정리 및 예제 안녕하세요. BlockDMask 입니다. 오늘은 파이썬에서 집합 자료형인 set 자료형에 대해서 이야기 해보려 합니다. 집합 자료형은 다른 자료형의 중복 제거할때 사용을 하기도 하는데요. 자세한것은 예 blockdmask.tistory.com 문제 Now, let's use our knowledge of sets and help Mickey. Ms. Gabriel Williams is a botany professor at District College. One day, she asked her student Mickey to compute the average of all the plants with distinct heights in her..
2023.07.17 -
Prepare > Python > Strings > Capitalize!
Capitalize! | HackerRank Capitalize Each Word. www.hackerrank.com 문제 You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck. 코드 def solve(s): return ' '.join(map(str.capitalize, s.split(' '))) 노트 map은 리스트의 요소를 지정된 함수로 처리해주는 함수(원본 리스트 보존, 새 리스트 리턴) # 반복문 이용 a = [1.2, 2...
2023.07.15 -
Prepare > Python > Strings > Alphabet Rangoli
Alphabet Rangoli | HackerRank Let's draw rangoli. www.hackerrank.com 문제 You are given an integer, N. Your task is to print an alphabet rangoli of size N. (Rangoli is a form of Indian folk art based on creation of patterns.) 코드 def print_rangoli(size): al = 'abcdefghijklmnopqrstuvwxyz' for i in range(size): half_up = '-'.join(al[size-1: size-i-1: -1] + al[size-i-1:size]) print( half_up.center(4*s..
2023.07.14 -
Prepare > Python > Strings > String Formatting
String Formatting | HackerRank Print the formatted decimal, octal, hexadecimal, and binary values for $n$ integers. www.hackerrank.com 문제 The four values must be printed on a single line in the order specified above for each i from to N. Each value should be space-padded to match the width of the binary value of N and the values should be separated by a single space. => 4개의 값은 각 i에서 N까지 위에 지정된 순..
2023.07.12 -
Prepare > Python > Strings > Designer Door Mat
Designer Door Mat | HackerRank Print a designer door mat. www.hackerrank.com 문제 Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications: Mat size must be NXM. (N is an odd natural number, and M is 3 times N.) The design should have 'WELCOME' written in the center. The design pattern should only use |, . and - characters. Size: ..
2023.07.11 -
Prepare > Python > Strings > Text Wrap
Text Wrap | HackerRank Wrap the given text in a fixed width. www.hackerrank.com 문제 You are given a string S and width w. Your task is to wrap the string into a paragraph of width w. string: a single string with newline characters ('\n') where the breaks should be => 문자열 S와 너비값 w가 주어진다. 길이w의 문단으로 문자열을 랩핑하라 코드 import textwrap def wrap(string, max_width): return textwrap.fill(string, max_width) if ..
2023.07.10 -
Prepare > Python > Strings > Text Alignment
Text Alignment | HackerRank Generate the Hackerrank logo with alignments in Python. www.hackerrank.com 문제 You are given a partial code that is used for generating the HackerRank Logo of variable thickness. Your task is to replace the blank (______) with rjust, ljust or center. => 주어진 코드의 _____ 에 rjust, ljust, center 중 하나를 넣어라 코드 #Replace all ______ with rjust, ljust or center. thickness = int(in..
2023.07.09