Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more

yaksok.ts

ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ๋กœ ๊ตฌํ˜„ํ•œ ์•ฝ์† ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์˜ ์ธํ„ฐํ”„๋ฆฌํ„ฐ

์™œ ๋งŒ๋“ค์—ˆ๋‚˜์š”?

์•ฝ์† ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋Š” ๊ต์œก์ ์œผ๋กœ ํ›Œ๋ฅญํ•œ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ์—์„œ ํŽธ๋ฆฌํ•˜๊ฒŒ ์•ฝ์†์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ๋กœ ์ƒˆ ๋Ÿฐํƒ€์ž„์„ ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๊ธฐ์ค€ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์€ Deno(1.38.4)์ž…๋‹ˆ๋‹ค.

์•„์ง Unstableํ•ฉ๋‹ˆ๋‹ค!

์‹คํ–‰๋˜์ง€ ์•Š๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋‹ค๋ฉด ์ด์Šˆ์— ๋‚จ๊ฒจ์ฃผ์„ธ์š”. ํŒŒ์•…๋œ ์ด์Šˆ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  1. if-else if-else ๊ตฌ๋ฌธ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ํŒŒ์‹ฑ๋˜์ง€ ์•Š์Œ
์‹œ๋ฆฌ์–ผ: "1032"

๋งŒ์•ฝ ์‹œ๋ฆฌ์–ผ = "1032" ์ด๋ฉด
    ๊ฒฐ๊ณผ: "1.0.0"
์•„๋‹ˆ๋ฉด ๋งŒ์•ฝ ์‹œ๋ฆฌ์–ผ = "1033" ์ด๋ฉด
    ๊ฒฐ๊ณผ: "1.0.1"
์•„๋‹ˆ๋ฉด
    ๊ฒฐ๊ณผ: "UNKNOWN"

ํ…Œ์ŠคํŠธํ•ด๋ณด๊ธฐ

import { yaksok } from './index.ts'

let stderr = ''

yaksok({
    main: `
๋ณด๋“œ_์‹œ๋ฆฌ์–ผ: "1032"

๋งŒ์•ฝ @์•„๋‘์ด๋…ธ ๋ชจ๋ธ๋ช… = "Arduino Uno" ์ด๋ฉด
    "์•„๋‘์ด๋…ธ ๋ชจ๋ธ๋ช…์ด ๋งž์Šต๋‹ˆ๋‹ค." ๋ณด์—ฌ์ฃผ๊ธฐ
    @์•„๋‘์ด๋…ธ ๋ณด๋“œ_์‹œ๋ฆฌ์–ผ ๋ฒ„์ „ ๋ณด์—ฌ์ฃผ๊ธฐ
`,
    ์•„๋‘์ด๋…ธ: `
์•ฝ์† ์‹œ๋ฆฌ์–ผ "๋ฒ„์ „"
    ๋งŒ์•ฝ ์‹œ๋ฆฌ์–ผ = "1032" ์ด๋ฉด
        ๊ฒฐ๊ณผ: "1.0.0"
    ์•„๋‹ˆ๋ฉด
        ๋งŒ์•ฝ ์‹œ๋ฆฌ์–ผ = "1033" ์ด๋ฉด
            ๊ฒฐ๊ณผ: "1.0.1"
        ์•„๋‹ˆ๋ฉด
            ๊ฒฐ๊ณผ: "UNKNOWN"

๋ชจ๋ธ๋ช…: "Arduino Uno"
`,
})
์•ฝ์† "ํ”ผ๋ณด๋‚˜์น˜" ์ˆ˜
    ๋งŒ์•ฝ ์ˆ˜ < 3 ์ด๋ฉด
        ๊ฒฐ๊ณผ: 1
    ์•„๋‹ˆ๋ฉด
        ๊ฒฐ๊ณผ: (ํ”ผ๋ณด๋‚˜์น˜ (์ˆ˜ - 1)) + (ํ”ผ๋ณด๋‚˜์น˜ (์ˆ˜ - 2))

ํšŸ์ˆ˜: 1

๋ฐ˜๋ณต
    ํšŸ์ˆ˜ + "๋ฒˆ์งธ ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜๋Š” " + (ํ”ผ๋ณด๋‚˜์น˜ ํšŸ์ˆ˜) + "์ž…๋‹ˆ๋‹ค" ๋ณด์—ฌ์ฃผ๊ธฐ
    ํšŸ์ˆ˜: ํšŸ์ˆ˜ + 1

    ๋งŒ์•ฝ ํšŸ์ˆ˜ > 10 ์ด๋ฉด
        ๋ฐ˜๋ณต ๊ทธ๋งŒ
์•ฝ์† ๊ณผ์ผ"์„/๋ฅผ ๋ฉ‹์žˆ๋Š” " ์‚ฌ๋žŒ "์™€/๊ณผ ๋จน๊ธฐ"
    ์‚ฌ๋žŒ + ": " + ๊ณผ์ผ + " ๋จน์Œ" ๋ณด์—ฌ์ฃผ๊ธฐ

"์‚ฌ๊ณผ"๋ฅผ ๋ฉ‹์žˆ๋Š” "๊น€์ฒ ์ˆ˜"์™€ ๋จน๊ธฐ

Made by Rycont, with โค๏ธ, in ์‚ฌ์ด๋ฒ„์ง€์‹์ •๋ณด๋ฐฉ