본문 바로가기

Algorithm220

[코딩 + 알고리즘 완주반] 11일차. Object Reference # is , __eq__ is, id : id 비교 ( 같은 객체 인지) __eq__, == : 값이 같은지 비교 # 객체 참조 중요한 특징들 # python object reference print("ex1-1") print(dir()) # id vs __eq__ (== 증명) x = {'name':'kim','age':33,'city':'Seoul'} y=x # 얕은 복사 print('ex-2-1 - ', id(x),id(y)) print('ex-2-2 - ', x==y) print('ex-2-3 - ', x is y) print('ex-2-4 - ', x,y) x['class'] = 10 # x가 수정되면 y도 수정됨 print('ex2-5 - ',x,y) print() z = {'name':'ki.. 2021. 3. 25.
[코딩 + 알고리즘 완주반] 10일차. 타이핑 게임 프로젝트 # 타이핑 게임 제작,효과음 적용, DB 연동 # 업그레이드 타이핑 게임 제작 # 타이핑 게임 제작 및 기본 완성 import random import time # 사운드 import pygame import sqlite3 import datetime # DB 생성 & 오토 커밋 conn = sqlite3.connect('./resource/records.db',isolation_level=None) # Cursor cursor = conn.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS records( id INTEGER PRIMARY KEY AUTOINCREMENT, cor_cnt INTEGER, record text, regdate text)") word.. 2021. 3. 25.
❗️[LEET CODE] 316. Remove Duplicate Letters # Problem Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/ Constraints: 1 str: counter, seen, stack = collections.Counter(s), set(), [] for.. 2021. 3. 23.
[LEET CODE] 20. Valid Parentheses # Problem Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Constraints: 1 bool: stack = [] table = { ')': '(', '}': '{', ']': '[', } # 스택 이용 예외 처리 및 일치 여부 판별 for char in s: if char not in.. 2021. 3. 23.
[LEET CODE] 92. Reverse Linked List II # Problem Given the head of a singly linked list and two integers left and right where left 2021. 3. 23.
[코딩 + 알고리즘 완주반] 9일차. 데이터베이스 연동 (SQLite) # 데이터베이스 및 테이블 생성 # 테이블 생성 및 삽입 import sqlite3 import datetime #삽입 날짜 생성 now = datetime.datetime.now() print(now) # 날짜를 스트링으로 변환 nowDatetime = now.strftime('%Y-%m-%d %H:%M:%S') print(nowDatetime) #sqlite3 print(sqlite3.version) print(sqlite3.sqlite_version) # DB 생성 & Auto commit(Rollback) conn = sqlite3.connect('./resource/database.db',isolation_level=None) # cursor c = conn.cursor() print('Curs.. 2021. 3. 23.
반응형