본문 바로가기

udemy77

Udemy : Python 행맨 프로젝트 Udemy : Python 행맨 프로젝트 행맨은 알파벳을 입력하면서, 단어를 찾아내는 것이다. 알파벳을 고를 수 있는 차례는 주어져 있다 import random from hangman_art import logo, stages from hangman_words import word_list print(logo) word = random.choice(word_list) result = ["_"] * len(word) letter_choice = [] count = 6 flag = False while count != 0: letter = input("Guess a letter: ").lower() if letter.isalpha(): if letter in word: if letter not in let.. 2023. 1. 8.
Udemy : Python 함수와 카렐 Udemy : Python 함수와 카렐 Function function() - 앞에 function의 이름이 있고, 뒤에 괄호가 붙는다 왜 사용는건가? 지속적으로 똑같은 코드를 쓰기보단, 함수로 만들어서, 그 함수를 지속적으로 사용하면 된다 코드를 줄일 때, 유용하게 쓸 수 있다 function 만들기 def my_function() : print("My Function") print("Wow") my_function() # 함수 부르기 While Loop while something_is_true: #Do this #Then do this #Then do this while문은, 써 놓은 조건이 거짓일때까지, 지속적으로 코드를 실행하는 것이다 확실한 길이의 데이터가 주어지지 않을 때 while문을 사용.. 2023. 1. 7.
5.3_Javascript - Sliding Window 문제풀이 Udemy - Javascript - Sliding Window Sliding Window - maxSubarraySum Given an array of integers and a number, write a function called maxSubarraySum, which finds the maximum sum of a subarray with the length of the number passed to the function. Note that a subarray must consist of consecutive elements from the original array. In the first example below, [100, 200, 300] is a subarray of the origi.. 2023. 1. 7.
5.2_Javascript - Multiple Pointers 문제풀이 Udemy - Javascript - Multiple Pointers Multiple Pointers - averagePair Multiple Pointers - averagePair Write a function called averagePair. Given a sorted array of integers and a target average, determine if there is a pair of values in the array where the average of the pair equals the target average. There may be more than one pair that matches the average target. Bonus Constraints: Time: O(N).. 2023. 1. 7.
5.1_Javascript - Frequency Counter 문제풀이 Udemy - Javascript - Frequency Counter Frequency Counter Write a function called sameFrequency. Given two positive integers, find out if the two numbers have the same frequency of digits. Your solution MUST have the following complexities: Time: O(N) Sample Input: sameFrequency(182,281) // true sameFrequency(34,14) // false sameFrequency(3589578, 5879385) // true sameFrequency(22,222) // false s.. 2023. 1. 7.
Udemy : Python 반복문 Udemy : Python 반복문 For 문으로 평균 구하기 student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) total_height = 0 student_num = 0 for height in student_heights: total_height += height student_num += 1 print(round(total_height / student_num)) sum() 과 len()을 사용하지 않고 구하기 total_height : 학생들의 키를 구하기 student_num.. 2023. 1. 6.
4_Udemy - Javascript 일반적인 문제풀이 패턴 Udemy - Javascript 일반적인 문제풀이 패턴 빈도수 세기 패턴 다중의 입력값들을 비교할 때 유용 배열을 이용하는 것이 아닌 / 주어진 입력값을 객체 ({}) 에 넣고, 문제를 해결하는 것이다 function anagram(word1, word2) { if (word1.length !== word2.length) { return false } else if (word1.length === 0 & word2.length === 0) { return true } let anagramObject1 = {} let anagramObject2 = {} for (let word = 0; word < word1.length ; word++) { if (word1[word] in anagramObject1).. 2023. 1. 6.
3_Javascript - 문제 해결 접근법 Udemy - Javascript 문제 해결 접근법 알고리즘이란? 특정한 작업을 끝내기 위한 과정 또는 단계다 알고리즘 풀이를 더 잘 하기 문제를 해결하기 위해 계획을 짜는 것 일반적인 문제 해결 패턴을 파악하는 것 문제 해결 문제의 이해 코드를 직접 치기 전에, 문제를 이해하는 것이 중요하다 문제를 내가 이해할 수 있도록 정리를 한다 문제에 어떤 입력값이 들어가는가? 내가 짠 코드를 통해 어떤 결과가 나오는지 생각한다 입력값이 있으면, 결과가 잘 나오는가? 데이터를 어떻게 표시할 것인가? 구체적 예제들 쉬운 예제들을 먼저 써놓은다 그리고 그보다 더 어려운 예제들로 진행한다 입력값이 없는 상태에서도 어떻게 결과나 나오는지 생각해본다 유효하지 않은 입력값을 넣어본다 세부 분석 문제에 대한 단계들을 실제로 .. 2023. 1. 5.
2_Javascript - 객체와 배열의 빅오 Udemy - Javascript 객체의 빅오 let instructor = { firstName : "Kelly", isInstructor: true, favoriteNumbers: [1,2,3,4], } Key와 Value가 있다 객체를 사용할 때 정렬이 필요하지 않을 때 데이터를 빠르게 접근을 하거나, 추가를 하거나, 삭제를 할 때 객체의 빅오 추가하기 (Insertion) : O(1) 삭제하기 (Removal) : O(1) 찾기 (Searching) : O(N) Value를 찾는 것 데이터에 접근하기 (Access) : O(1) 객체의 메서드 (Object Methods) object.keys : O(N) object.values : O(N) object.entries : O(N) hasOwnPr.. 2023. 1. 5.