목록python3 (77)
규도자 개발 블로그
[프로그래머스/Level1/파이썬3(python3)] 나누어 떨어지는 숫자 배열 문제 array의 각 element 중 divisor로 나누어 떨어지는 값을 오름차순으로 정렬한 배열을 반환하는 함수, solution을 작성해주세요. divisor로 나누어 떨어지는 element가 하나도 없다면 배열에 -1을 담아 반환하세요. 제한사항 arr은 자연수를 담은 배열입니다. 정수 i, j에 대해 i ≠ j 이면 arr[i] ≠ arr[j] 입니다. divisor는 자연수입니다. array는 길이 1 이상인 배열입니다. 입출력 예 arrdivisorreturn [5, 9, 7, 10]5[5, 10][2, 36, 1, 3]1[1, 2, 3, 36][3,2,6]10[-1] 입출력 예 설명 입출력 예#1 arr의 원..
[프로그래머스/Level1/파이썬3(python3)] 크레인 인형뽑기 게임 (2019 카카오 개발자 겨울 인턴십) 문제 게임개발자인 "죠르디"는 크레인 인형뽑기 기계를 모바일 게임으로 만들려고 합니다.게임개발자인 죠르디는 크레인 인형뽑기 기계를 모바일 게임으로 만들려고 합니다. "죠르디"는 게임의 재미를 높이기 위해 화면 구성과 규칙을 다음과 같이 게임 로직에 반영하려고 합니다. 게임 화면은 "1 x 1" 크기의 칸들로 이루어진 "N x N" 크기의 정사각 격자이며 위쪽에는 크레인이 있고 오른쪽에는 바구니가 있습니다. (위 그림은 "5 x 5" 크기의 예시입니다). 각 격자 칸에는 다양한 인형이 들어 있으며 인형이 없는 칸은 빈칸입니다. 모든 인형은 "1 x 1" 크기의 격자 한 칸을 차지하며 격자의 가..
Welcome to Day 18! Today we're learning about Stacks and Queues. Check out the Tutorial tab for learning materials and an instructional video! A palindrome is a word, phrase, number, or other sequence of characters which reads the same backwards and forwards. Can you determine if a given string, , is a palindrome? To solve this challenge, we must first take each character in , enqueue it in a qu..
파이썬3.x[python3.x]에서 요소가 하나인 튜플을 문자열이 아닌 튜플로 인식시키기 i_wanna_be_tuple = ('really') print(i_wanna_be_tuple) print(type(i_wanna_be_tuple)) u_need_to_do_like_this = ('like this',) print(u_need_to_do_like_this) print(type(u_need_to_do_like_this)) 어제 부딪힌 문제였다. django로 작업을 하던 와중 django form을 이용해 입력란을 만들고 있었는데 modelform은 상속받은 model을 기반으로 해서 입력 form을 작성해준다. 하필 입력받을 form 요소가 딱 하나였는데 이를 tuple형태로 정의해야하는 지라 단순..
[백준/1978/파이썬(python3)] 소수 찾기 문제 주어진 수 N개 중에서 소수가 몇 개인지 찾아서 출력하는 프로그램을 작성하시오. 입력 첫 줄에 수의 개수 N이 주어진다. N은 100이하이다. 다음으로 N개의 수가 주어지는데 수는 1,000 이하의 자연수이다. 출력 주어진 수들 중 소수의 개수를 출력한다. 입출력 예 입력출력 4 1 3 5 73 풀이 def prime_list(n): n = n + 1 #추가된 부분 sieve = [True] * n m = int(n ** 0.5) for i in range(2, m + 1): if sieve[i]: for j in range(i+i, n, i): sieve[j] = False return [i for i in range(2, n) if sieve[..
Objective Today we're working with Linked Lists. Check out the Tutorial tab for learning materials and an instructional video!A Node class is provided for you in the editor. A Node object has an integer data field, , and a Node instance pointer, , pointing to another node (i.e.: the next node in a list).A Node insert function is also declared in your editor. It has two parameters: a pointer, , p..
Objective Today we're discussing scope. Check out the Tutorial tab for learning materials and an instructional video!The absolute difference between two integers, and , is written as . The maximum absolute difference between two integers in a set of positive integers, , is the largest absolute difference between any two integers in .The Difference class is started for you in the editor. It has a..
Objective Today, we're taking what we learned yesterday about Inheritance and extending it to Abstract Classes. Because this is a very specific Object-Oriented concept, submissions are limited to the few languages that use this construct. Check out the Tutorialtab for learning materials and an instructional video!Task Given a Book class and a Solution class, write a MyBook class that does the fo..
Objective Today, we're delving into Inheritance. Check out the attached tutorial for learning materials and an instructional video!Task You are given two classes, Person and Student, where Person is the base class and Student is the derived class. Completed code for Person and a declaration for Student are provided for you in the editor. Observe that Student inherits all the properties of Person..
Objective Today, we're building on our knowledge of Arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video!Context Given a 2D Array, :1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation:a b c d e f g T..