본문 바로가기

전체 글102

Find Numbers with Even Number of Digits 숫자의 자리수가 짝수인 것들의 개수 구하기 Input: nums = [12,345,2,6,7896] Output: 2 1. python이니까.. string으로 변환해서 길이를 측정함 class Solution: def findNumbers(self, nums: List[int]) -> int: ans=0 for num in nums: if len(str(num)) % 2 == 0: ans+=1 return ans 104 / 104 test cases passed. Status: Accepted Runtime: 52 ms Memory Usage: 14.3 MB 2. sample 28 ms submission string으로 변환하지 않아도 밑이 10인 log를 써서 정수부분만 보면 그게 길이-1 이다! .. 2021. 1. 22.
485. Max Consecutive Ones 0, 1로만 이루어진 array에서 연속적으로 가장 긴 1의 길이 구하기 array 길이는 int: zeros = [] for idx, num in enumerate(nums): if num.. 2021. 1. 22.
Django 앱 만들기 - Models method, upload image * Models에 method를 만드는 기준 - FE, BE 모두에 사용되고 여기저기서 갖다 쓸 때 class Review(core_models.TimeStampedModel): """ Review Model Definition """ review = models.TextField() accuracy = models.IntegerField() communication = models.IntegerField() cleanliness = models.IntegerField() location = models.IntegerField() check_in = models.IntegerField() value = models.IntegerField() user = models.ForeignKey( "users.Us.. 2021. 1. 21.
Django 앱 만들기 - admin 패널 꾸미기, QuerySet, UserManager django.contrib의 admin.ModelAdmin을 상속 받아서 사용할 수 있는 변수들을 알아보자 * list_display admin 패널에 보여줄 변수 적기 * list_filter 필터링 기준이 될 변수 적기 * search_fields admin 패널에 search 바를 만듦. 검색할 필드를 지정할 수 있음 필드 이름 앞에 prefix를 지정해줄 수 있는데 아무것도 없으면 대소문자 구분없이 검색어를 포함하는 내용으로 찾아줌 = : 완전히 같아야 함(대소문자 구분 안함) ^ : 이 단어로 시작해야 함 * filter_horizontal ManyToManyField 관계에 있는 것들을 검색할 수 있는 필터를 만듦 RoomAdmin 패널에서 Room을 추가할 때 amenities 등 ManyT.. 2021. 1. 21.
AWS 솔루션 AWS CloudFormation, AWS OpsWorks - SW 개발 프로젝트를 위한 개발, 실험, 운영환경에 필요한 인프라 배포 AWS CodeCommit, AWS CodeBuild : CI 환경에서 사용하는 옵션 AWS CodePipeline : CI/CD(지속적 통합, 지속적 전달) 파이프라인 설계, 구현 AWS CodeStar : 모든 SW개발 작업을 한 곳에서 관리 블루/그린 배포, A/B 테스트 등을 AWS를 사용해 CD(지속적 배포) 구현하기 AWS CodeDeploy, OpsWorks, Elastic Beanstalk, EC2 Container Service, EC2 Container Registry 등에서 제공한느 앱 배포 기술 구분하기 AWS EC2 System Manager를 사용.. 2021. 1. 20.
Django 앱 만들기 - abstract class, ForeignKey, __str__, ManyToManyField 1) abstract class 만들기 다른 앱에서 사용하는 공통 필드들을 한 곳에 모아서 상속 받아서 사용하면 편하다 Abstract base classes are useful when you want to put some common information into a number of other models. 1. models.py에 다른 곳에서 import할 class를 정의해준다 2. 그 클래스 내부에 Meta class를 만든다 3. abstract = True => 이 클래스는 DB가 생성되지 않고 얘를 상속 받는 곳에서 DB가 만들어진다 class TimeStampedModel(models.Model): """ Time Stamped Model """ created = models.DateT.. 2021. 1. 19.