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()으로 만들면 되지 않을까요?
강의에서 보면 예를 들어 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 키워드가 있을때를 의미하는 건지 헷갈려서요ㅜㅜ
#!/usr/bin/env node /** * Module dependencies. */ var app = require('../app'); var debug = require('debug')('suzil:server'); var http = require('http'); const mongoose = require("mongoose"); const userConfig = require("../config/userConfig.json"); let db = mongoose.connection; db.on("error",console.error); db.once("open",()=>{ console.log("Connected to mongo Server"); }); mongoose.connect( `mongodb+srv://wiyuchan1021:${userConfig.PW}>@suzilo.i1je5.mongodb.net/suzilo?retryWrites=true&w=majority`, {useNewUrlParser: true, useUnifiedTopology: true} ) /** * Get port from environment and store in Express. */ var port = normalizePort(process.env.PORT || '3000'); app.set('port', port); /**f * Create HTTP server. */ var server = http.createServer(app); /** * Listen on provided port, on all network interfaces. */ server.listen(port); server.on('error', onError); server.on('listening', onListening); /** * Normalize a port into a number, string, or false. */ function normalizePort(val) { var port = parseInt(val, 10); if (isNaN(port)) { // named pipe return val; } if (port >= 0) { // port number return port; } return false; } /** * Event listener for HTTP server "error" event. */ function onError(error) { if (error.syscall !== 'listen') { throw error; } var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; // handle specific listen errors with friendly messages switch (error.code) { case 'EACCES': console.error(bind + ' requires elevated privileges'); process.exit(1); break; case 'EADDRINUSE': console.error(bind + ' is already in use'); process.exit(1); break; default: throw error; } } /** * Event listener for HTTP server "listening" event. */ function onListening() { var addr = server.address(); var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; debug('Listening on ' + bind); } 코드 실행하면 PS C:\Users\yuchan\suzil> npm start > suzil@0.0.0 start > nodemon ./bin/www [nodemon] 3.1.7 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node ./bin/www (node:13580) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version (Use node --trace-warnings ... to show where the warning was created) (node:13580) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version MongoServerError: bad auth : authentication failed at Connection.sendCommand (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:289:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.command (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:312:26) at async continueScramConversation (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:131:15) at async executeScram (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:80:5) at async ScramSHA1.auth (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:39:16) at async performInitialHandshake (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:104:13) at async connect (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:24:9) { errorResponse: { ok: 0, errmsg: 'bad auth : authentication failed', code: 8000, codeName: 'AtlasError' }, ok: 0, code: 8000, codeName: 'AtlasError', connectionGeneration: 0, [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' } } node:internal/process/promises:391 triggerUncaughtException(err, true /* fromPromise */); ^ MongoServerError: bad auth : authentication failed at Connection.sendCommand (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:289:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.command (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connection.js:312:26) at async continueScramConversation (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:131:15) at async executeScram (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:80:5) at async ScramSHA1.auth (C:\Users\yuchan\node_modules\mongodb\lib\cmap\auth\scram.js:39:16) at async performInitialHandshake (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:104:13) at async connect (C:\Users\yuchan\node_modules\mongodb\lib\cmap\connect.js:24:9) { errorResponse: { ok: 0, errmsg: 'bad auth : authentication failed', code: 8000, codeName: 'AtlasError' }, ok: 0, code: 8000, codeName: 'AtlasError', connectionGeneration: 0, [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' } } Node.js v20.17.0 [nodemon] app crashed - waiting for file changes before starting... 이러한 오류가 터미널에 뜨는데 왜 그런걸까요?
사물인터넷 통신은 내 손에 (Arduino, MQTT, Nodejs, MongoDB, Android,VS Code)
Drivers를 선택해서 나온 url주소로도 MongoDB for VS Code를 선택해서 나온 url주소로도 접속이 실패합니다. Node.js 코드는 다음과 같이 작성했습니다. const mongoose = require("mongoose"); const MONGODB_URL = "mongodb+srv://root:1234@education.sidnf.mongodb.net/"; mongoose .connect(MONGODB_URL) .then(() => console.log("Connected to database!")) .catch(() => console.log("Connection failed...")) Connection failed... 라고 나옵니다. Network Access에서도 0.0.0.0으로도 해보고, 제 컴퓨터의 IP주소로도 해보았습니다. 전부 접속 실패가 뜹니다. 이유를 알 수 있을까요?!
강의 12.3 보다가 의문이 들어서 질문 남깁니다. 강의에서 설명하고 사용하셨던 방법과 공식문서에서 BrowserRouter를 사용하는 방법이 달라서 헷갈립니다. 두가지 방법이 같은 것인지, 다르다면 어떻게 다른지 알려주세요 function App () { return ( < BrowserRouter basename = " /app "> < Routes > < Route path = " / " /> </ Routes > </ BrowserRouter > ); } =>공식문서에서는 이렇게 Routes를 BrowserRouter로 감싸서 사용했는데 강의 에서는 그러지 않아서 궁금합니다.!
t1 >> t3 t2 >> t3 이렇게 테스크를 연결했을때 case 1 : t1, t2 둘다 종료되어야 t3가 실행되는지 case 2 : t1이 종료되었을떄, t2가 종료되었을때 각각 t3가 한번씩 실행되는지 궁금합니다. 위의 방법과 [t1, t2] >> t3 가 동등하다고 설명해주셨는데 case 1, case2 두가지 방법을 설정하고싶을때는 어떻게 처리하면 될까요?