본문 바로가기
✨ Club/Ec.crew 코딩 스터디

Ec.crew 4회차 정기 모임 문제

by 정람지 2022. 7. 26.

솔민 <문자열 거꾸로 출력하기!>

name = True
while (name):
    n = input()
    if n == '#':
        name = False
    else:
        n = list(n)
        n.reverse()
        result = ' '.join(map(str, n))
        print(result)

은솜 - <백준3052 -나머지> 

 

newList =[] # newList =list()도 마즘~
for i in range(10):
    N = int(input())
    newList.append(N%42)
    # 맨 처음에 newList += (N%42)라고 썼다가..ㅎㅎ 안 된다
    # 근데 newList += str(N%42)라고 하면 따옴표 넣어서 들어간다
    # 근데 newList += int(N%42)는 숫자형이라서 안 된대
    # 근데 newList.append(N%42)로 하면 리스트 요소들 따옴표 없는데? type() 찍어도 숫자형 나온다.
    # ?
K = set(newList)
print(len(K))
list() 함수 원형
list([iterable]) 

여기서 iterable은 단일 객체가 아닌 반복할 수 있는 문자열, 튜플, 딕셔너리, range() 함수 등을 의미합니다.
인자로 정수가 사용되면 문법에 맞지 않습니다.
1) append 함수
arry.append(x) 형태로 사용한다. x를 arry의 맨 끝에 객체로 추가다. x가 iterable 자료형이더라도 전체를 하나의 객체로 해서 요소로 추가한다. !!
였습니다 문제 해결

2) extend 함수
array.extend(iterable) 형태로 사용한다. iterable의 각 요소를 하나씩 array의 끝에 요소로 추가한다. append 함수와 다른 점은 괄호 안에 iterable 자료형만 올 수 있다.

3) insert 함수
array.insert(i, x) 형태로 사용한다. 원하는 위치 i에 x를 삽입할 수 있다. 값 x는 객체로 추가된다. append 함수와 마찬가지로 iterable 자료형이더라도 하나의 요소로 삽입된다.

-중복삭제하는 set() 함수 - 편리하지만 시간복잡도 상승

 

newList = []
otherList=[]
for i in range(10):
    N = int(input())
    newList.append(N%42)
    otherList.append(N%42)
result = 10
for i in range(9):
    otherList.pop(-1)
    if newList[9-i] in otherList :
        result -= 1
print (result)

set 함수 없는 버전


은채 <백준 2884번 알람시계>

 

import sys  #from sys import stdin를 쓰자~
H, M = map(int,sys.stdin.readline().split())
if M >= 45:
    M -= 45
else:
    if H == 0:
        H = 23
        M += 15
    else:
        H -= 1
        M += 15
print(H, M)

 


재현언니 -<문자열 길이 구하기-구름>

n=input()
print(len(n))

c 문제 // 파이썬은 len()이 있어서 두줄끝!

myList = input()
result=0
for i in myList:
    result += 1
print(result)

len() 함수 없이도 만들어봄


정화 언니 <막대기-구름>

 

#시간 없어서 아직~

수연-<주차>

 

N = int(input())
allcarList=[]
carList =[]
checkList =[]
result =[]

for i in range(N):
    checkList.clear()
    a, b, c, d, e, f= map(int,input().split())
    checkList.append(a)
    checkList.append(b)
    checkList.append(c)
    checkList.append(d)
    checkList.append(e)
    checkList.append(f)
    carList = checkList
    allcarList.append(checkList)
for i in range(N):
    if allcarList[i][2] in checkList:
        result.append(allcarList[i][2])
result.sort()
print(result)
#는 사실 안 돌아감ㅎㅎㅠ

 


소은 <택시기사>

#시간 없어서 아직~

 

+

붕어빵틀 = 클래스

붕어빵 = 객체

메서드

초코칩이 추가된 붕어빵 = 상속