s = list(input()) n = len(s) choose = [] check = [False] * len(s) ans = [] def check_ad(s): for i in range(len(s)-1): if s[i] == s[i+1]: return False return True def make(level): if level == n and check_ad(choose): result = ''.join(choose) if result not in ans: ans.append(result) for i in range(n): if check[i]: continue choose.append(s[i]) check[i] = True make(level + 1) choose.pop() check[i] = False make(0) print(len(ans)) 안녕하세요 강사님! 위 코드는 시간 초과가 나는데 순열 강의 알고리즘을 그대로 사용한 것입니다! 강사님의 순열 코드는 시간 초과가 안나는데 왜 이거는 시간초과가 날까요? 내장된 permutation이 효율적으로 구현된 것일까요?
now = datetime(year=2023, month=3, day=30) print('현재시간:' + str(now)) print('-----------------월 연산 --------------------') print(now + relativedelta.relativedelta(months=1)) print(now.replace(month=1)) 위의 코드 실행 결과가 다르게 나오는 것 같은데요..1개월 후면 4월30일이 맞는 것 아닌가요? 현재시간:2023-03-30 00:00:00 -----------------월 연산 -------------------- 2023-04-30 00:00:00 2023-01-30 00:00:00 감사합니다.
cv2.imread() 함수를 통해 이미지를 읽어 들일 때, 한글을 읽어오지 못해 오류가 발생하는 경우가 있습니다. 아래의 코드로 해결하시면 됩니다. 참고로, 아래 코드 사용 시 cvtColor() 함수를 사용해서 색상을 변경하지 않아도 됩니다. import numpy as np img_path = "이미지 파일 경로" img_file= np.fromfile(img_path, np.uint8) cv_decode = cv2.imdecode(img_file, cv2.IMREAD_COLOR) qr_reader = pyzbar.decode(cv_decode) print(qr_reader)
const Editor = ({ onSubmit, initData }) => { const nav = useNavigate(); const [input, setInput] = useState({ createdDate: new Date(), // 여기서 그냥 getTime하면 안되나요? emotionId: 8, content: "", }); useEffect(() => { if (initData) { setInput({ ...initData, createdDate: new Date(Number(initData.createdDate)), }); } input의 createdDate와 initData의 createdDate 비교 기준이 new Date() 과 new Date().getTime() 로 달라서 useEffect안에서 createdDate: new Date(Number(initData.createdDate)), 이렇게 한다는 건 이해가 갑니다. 다만 처음부터 input의 createdDate를 new Date().getTime()으로 만들면 되지 않을까요?
강의 보면서 '퍼널별 유저 수 집계' 쿼리 작성했는데 결과값이 올바르게 나오지 않아요... 어디서 잘못 되었을까요? WITH base AS( SELECT event_date, event_name, DATETIME(TIMESTAMP_MICROS(event_timestamp),'Asia/Seoul') as event_timestamp, event_param, user_id, user_pseudo_id, platform, -- event_parma.key PIVOT MAX(IF(event_param.key='firebase_screen',event_param.value.string_value,null)) AS firebase_screen, -- MAX(IF(event_param.key='food_id',event_param.value.int_value,null)) AS food_id, MAX(IF(event_param.key='session_id',event_param.value.string_value,null)) AS session_id FROM advanced.app_logs CROSS JOIN UNNEST(event_params) as event_param GROUP BY ALL) -- event_name + screen (필요한 이벤트만 where 조건에 걸어서 사용) ,filter_event as( SELECT * except(event_name,firebase_screen), concat(event_name,'-',firebase_screen) AS event_name_with_screen FROM base WHERE event_name in ('screen_view','click_payment')) SELECT event_name_with_screen, -- step_number case when event_name_with_screen='screen_view-welcome' then 1 when event_name_with_screen='screen_view-home' then 2 when event_name_with_screen='screen_view-food_category' then 3 when event_name_with_screen='screen_view-restaurant' then 4 when event_name_with_screen='screen_view-cart' then 5 when event_name_with_screen='click_pavement-cart' then 6 else null end AS Step_number, count(DISTINCT user_pseudo_id) as cnt FROM filter_event GROUP BY ALL HAVING step_number IS NOT NULL
안녕하세요 6장 상품 등록을 이미지 없이 등록을 해봤는데요 예를 들어 상품번호가 17번이면 product_image_list 테이블에 17번(product_pno)이 등록되지 않아서 left join이 걸리지 않아 리스트를 호출시 해당 번호의 상품만 호출이 안되더라구요 이럴 경우에는 어떠한 방법으로 해결할 수 있을지 궁금하여 질문드립니다.
강의에서 보면 예를 들어 goog의 연평균 주식 구하실때, pct_change() 구한값에 mean()을 취하셔서 working day 252를 곱하셨는데, 복리 개념을 생각해보면 (df_daily['goog'].pct_change() + 1).prod() ** (252/len(df_daily)) - 1 이렇게 되야 하는게 아닌가 궁금하여 문의드립니다! 값이 거의 비슷하다고 가정하시고 그냥 복리 개념은 생략하신건지요! 감사합니다
안녕하세요! 2분 쯤에 구조체 선언하는 2가지 형태에 대해서 비교해 주실때 오른쪽에서 구조체 선언할때 (왼쪽과는 달리)그냥 struct 라고만 되어있는데 struct Person {//내용}person1 ; 이렇게 Person(구조체명)이 들어가야 하는데 실수로 빠진 건지 아니면 이 경우에는 구조체명을 쓰지 않아도 되는 건지 궁금합니다! 그리고 왼쪽 케이스 아랫부분 사용시 용례에 struct 구조체명 타입명; 이라고 되어있는데 여기서 타입명을 변수명이라고 이해해도 될까요? 뒷 강의에서 typedef를 다루면서 타입명이 나오기는 하는데 여기서도 typedef 키워드가 있을때를 의미하는 건지 헷갈려서요ㅜㅜ
# base 쿼리 작성 전 생각 흐름 ---------------------------------------------------- ## 1. 테이블 내 데이터 구조 파악 -- select -- * -- from advanced.app_logs -- where -- event_date = '2022-08-01' -- 목적에 맞는 쿼리를 기존 데이터로 구현할 수 있는지 여부 확인 -- 연습문제 결과물 컬럼인 'event_name_with_screen', 'step_number', 'cnt'는 기존 컬럼에 없음. -- 기존 컬럼에 없기 때문에 해당 컬럼을 어떻게 구현해내야 할 지 생각해보기 ## 2. event_name_with_screen 컬럼 구현 순서 및 방법 -- event_name_with_screen는 다음과 같은 value를 가짐 -- 1. screen_view-welcome -- 2. screen_view-home -- 3. screen_view-food_vategory -- 4. screen_view-restaurant -- 5. screen_view-cart -- 6. click_payment-cart -- 위 6가지 value가 기존 컬럼에 있는지 확인해보기 -- 있는 경우 -- 기존 컬럼 활용 -- 없는 경우 -- concat 등으로 새롭게 구현 -- 연습문제에서는 event_name과 event_params.key에 있는 value를 concat 했음. -- event_params.key는 데이터타입이 struct이기 때문에 unnest 필요. -- select -- event_name, -- unnest_event_params -- from advanced.app_logs -- cross join unnest(event_params) as unnest_event_params -- where -- event_date = '2022-08-01' -- unnest 결과물에 피봇테이블 적용하기 -- 피봇테이블로 만들면 직관적으로 event_name과 concat 하기가 용이해서. -- select -- event_name, -- event_date, -- event_timestamp, -- user_pseudo_id, -- max(if(unnest_event_params.key = 'firebase_screen', unnest_event_params.value.string_value, null)) as firebase_screen, -- max(if(unnest_event_params.key = 'food_id', unnest_event_params.value.int_value, null)) as food_id, -- max(if(unnest_event_params.key = 'session_id', unnest_event_params.value.string_value, null)) as session_id -- from advanced.app_logs -- cross join unnest(event_params) as unnest_event_params -- where event_date between '2022-08-01' and '2022-08-18' -- group by 1, 2, 3, 4 ---------------------------------------------------- with base as ( select event_name, event_date, event_timestamp, user_pseudo_id, max(if(unnest_event_params.key = 'firebase_screen', unnest_event_params.value.string_value, null)) as firebase_screen, max(if(unnest_event_params.key = 'food_id', unnest_event_params.value.int_value, null)) as food_id, max(if(unnest_event_params.key = 'session_id', unnest_event_params.value.string_value, null)) as session_id from advanced.app_logs cross join unnest(event_params) as unnest_event_params where event_date between '2022-08-01' and '2022-08-18' group by 1, 2, 3, 4 ), base2 as ( select *, concat(event_name, '-', firebase_screen) as event_name_with_screen from base ) ## 일자별 퍼널 쿼리 , base3 as (select event_date, event_name_with_screen, # 2개 이상 조건을 한 개 컬럼에 적용해야 하기 때문에 case when 사용 case when event_name_with_screen = 'screen_view-welcome' then 1 when event_name_with_screen = 'screen_view-home' then 2 when event_name_with_screen = 'screen_view-food_category' then 3 when event_name_with_screen = 'screen_view-restaurant' then 4 when event_name_with_screen = 'screen_view-cart' then 5 when event_name_with_screen = 'click_payment-cart' then 6 else null end as step_number, # 중복되지 않은 사용자수(비로그인 이용자까지)를 파악하기 위해서 count(distinct 컬럼명) 사용 count(distinct user_pseudo_id) as cnt from base2 group by all # null 값 제외하기 위해서 그룹에 필터링 거는 having 사용 having step_number is not null # 1일부터 보고 싶기 때문에 오름차순(asc) 적용 order by 1 asc) ## 일자별 쿼리 (피벗테이블 적용) select event_date, max(if(event_name_with_screen = 'screen_view-welcome', cnt, 0)) as screen_view_welcome, max(if(event_name_with_screen = 'screen_view-home', cnt, 0)) as screen_view_home, max(if(event_name_with_screen = 'screen_view-food_category', cnt, 0)) as screen_view_food_category, max(if(event_name_with_screen = 'screen_view-restaurant', cnt, 0)) as screen_view_restaurant, from base3 group by all order by 1 asc
안녕하세요. 한가지 문의 드립니다. 부록_AWS 빈즈톡, RDS, S3 자료.pdf 를 보고 있습니다. 7 (/ 45) 페이지에서 보면 정상적으로 환경 구성이 완료되면 configurations 결과 화면이 잘 출력됩니다. 헌데 일부 계정 아마도 최근에 생성한 aws 계정은 이게 정상적으로 진행이 안되고 아래와 같은 메시지가 나옵니다. Creating Auto Scaling launch configuration failed Reason: Resource handler returned message: "The Launch Configuration creation operation is not available in your account. Use launch templates to create configuration templates for your Auto Scaling groups. (Service: AutoScaling, Status Code: 400, Request ID: 850290f7-96b3-4229-81dc-966dbee4d735)" (RequestToken: 44311bf6-616a-3270-9235-5c2d1993a1b7, HandlerErrorCode: GeneralServiceException) AWS EC2 Launch Template을 반드시 생성해야 7 (/ 45) 페이지에서 보이는 환경 구성이 정상적으로 완료가 되고 그 결과 configurations 화면이 잘 출력되는 것으로 최근 변경 된 것 같습니다. 문제는 이 AWS EC2 Launch Template 생성에 대한 부분에서 벽에 막힌 상태입니다. 어떻게 하면 좋은지 요청 드려 봅니다. 감사합니다.
패키지 매니저를 pnpm으로 사용하고 pnpm i 후 pnpm run build && pnpm run start 시 validator 모듈이 없다고 나와서 rm -rf node_modules pnpm-lock.yaml 후 npm으로 모듈들 설치 및 빌드, 서버 실행이 됩니다. npm이 유령 의존성 이슈가 있다고 들어서 pnpm 또는 yarn을 이용하려 한 건데, 오히려 npm을 사용해야만 문제없이 돌아가는 상황에 대해, 이게 어떤 상황인지 알 수 있을까요?