๐Ÿ›…[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ์•”ํ˜ธ ํ•ด๋…

Chobbyยท2022๋…„ 10์›” 13์ผ
1

Programmers

๋ชฉ๋ก ๋ณด๊ธฐ
104/349
post-custom-banner

๐Ÿงก๋ฌธ์ œ ์„ค๋ช…

๊ตฐ ์ „๋žต๊ฐ€ ๋จธ์“ฑ์ด๋Š” ์ „์Ÿ ์ค‘ ์ ๊ตฐ์ด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์•”ํ˜ธ ์ฒด๊ณ„๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•„๋ƒˆ์Šต๋‹ˆ๋‹ค.

  • ์•”ํ˜ธํ™”๋œ ๋ฌธ์ž์—ด cipher๋ฅผ ์ฃผ๊ณ ๋ฐ›์Šต๋‹ˆ๋‹ค.
  • ๊ทธ ๋ฌธ์ž์—ด์—์„œ code์˜ ๋ฐฐ์ˆ˜ ๋ฒˆ์งธ ๊ธ€์ž๋งŒ ์ง„์งœ ์•”ํ˜ธ์ž…๋‹ˆ๋‹ค.

๋ฌธ์ž์—ด cipher์™€ ์ •์ˆ˜ code๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ ํ•ด๋…๋œ ์•”ํ˜ธ ๋ฌธ์ž์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.


๐Ÿ’›์ œํ•œ์‚ฌํ•ญ

  • 1 โ‰ค cipher์˜ ๊ธธ์ด โ‰ค 1,000
  • 1 โ‰ค code โ‰ค cipher์˜ ๊ธธ์ด
  • cipher๋Š” ์†Œ๋ฌธ์ž์™€ ๊ณต๋ฐฑ์œผ๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๊ณต๋ฐฑ๋„ ํ•˜๋‚˜์˜ ๋ฌธ์ž๋กœ ์ทจ๊ธ‰ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’š์ž…์ถœ๋ ฅ ์˜ˆ

ciphercoderesult
"dfjardstddetckdaccccdegk"4"attack"
"pfqallllabwaoclk"2"fallback"

๐Ÿ’™์ž…์ถœ๋ ฅ ์˜ˆ ์„ค๋ช…

์ž…์ถœ๋ ฅ ์˜ˆ #1

  • "dfjardstddetckdaccccdegk" ์˜ 4๋ฒˆ์งธ, 8๋ฒˆ์งธ, 12๋ฒˆ์งธ, 16๋ฒˆ์งธ, 20๋ฒˆ์งธ, 24๋ฒˆ์งธ ๊ธ€์ž๋ฅผ ํ•ฉ์นœ "attack"์„ returnํ•ฉ๋‹ˆ๋‹ค.

์ž…์ถœ๋ ฅ ์˜ˆ #2

  • "pfqallllabwaoclk" ์˜ 2๋ฒˆ์งธ, 4๋ฒˆ์งธ, 6๋ฒˆ์งธ, 8๋ฒˆ์งธ, 10๋ฒˆ์งธ, 12๋ฒˆ์งธ, 14๋ฒˆ์งธ, 16๋ฒˆ์งธ ๊ธ€์ž๋ฅผ ํ•ฉ์นœ "fallback"์„ returnํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’œ๋‚˜์˜ ํ’€์ด

const solution = (cipher, code) => [...cipher].filter((a,i) => (i+1)%code === 0).join("")
profile
๋‚ด ์ง€์‹์„ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋Š” ๋Œ€๋‹ดํ•จ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€