PageSourceSearch

https://teddygood.github.io/assets/js/2af0a1c8.65c30c0b.js

js teddygood.github.io collected 2026-10-03 10:05:54 UTC 3,444 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkmy_blog=globalThis.webpackChunkmy_blog||[]).push([[3545],{28453(e,n,r){r.d(n,{R:()=>l,x:()=>s});var t=r(96540);const o={},i=t.createContext(o);function l(e){const n=t.useContext(i);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:l(e.components),t.createElement(i.Provider,{value:n},e.children)}},45036(e,n,r){r.r(n),r.d(n,{assets:()=>c,contentTitle:()=>s,default:()=>d,frontMatter:()=>l,metadata:()=>t,toc:()=>a});const t=JSON.parse('{"id":"Algorithm/Programmers-\ub178\ub780\ubd88 \uc2e0\ud638\ub4f1","title":"Programmers \ub178\ub780\ubd88 \uc2e0\ud638\ub4f1","description":"\ubb38\uc81c","source":"@site/wiki/Algorithm/Programmers-\ub178\ub780\ubd88 \uc2e0\ud638\ub4f1.md","sourceDirName":"Algorithm","slug":"/Algorithm/Programmers-\ub178\ub780\ubd88 \uc2e0\ud638\ub4f1","permalink":"/wiki/Algorithm/Programmers-\ub178\ub780\ubd88 \uc2e0\ud638\ub4f1","draft":false,"unlisted":false,"editUrl":"https://github.com/teddygood/teddygood.github.io/tree/main/wiki/Algorithm/Programmers-\ub178\ub780\ubd88 \uc2e0\ud638\ub4f1.md","tags":[],"version":"current","frontMatter":{"title":"Programmers \ub178\ub780\ubd88 \uc2e0\ud638\ub4f1","date":"2026-05-16 09:20"},"sidebar":"sidebar","previous":{"title":"LeetCode 88","permalink":"/wiki/Algorithm/LeetCode-88"},"next":{"title":"JIT","permalink":"/wiki/Compiler/JIT"}}');var o=r(74848),i=r(28453);const l={title:"Programmers \ub178\ub780\ubd88 \uc2e0\ud638\ub4f1",date:"2026-05-16 09:20"},s=void 0,c={},a=[{value:"\ubb38\uc81c",id:"\ubb38\uc81c",level:2},{value:"Solution",id:"solution",level:2}];function m(e){const n={code:"code",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h2,{id:"\ubb38\uc81c",children:"\ubb38\uc81c"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"2025 \uce74\uce74\uc624 \ud558\ubc18\uae30 1\ucc28"}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"solution",children:"Solution"}),"\n",(0,o.jsxs)(n.p,{children:["\ub808\ubca8 1\uc774\ub77c\uae38\ub798 \ud480\uc5c8\ub294\ub370 \ub808\ubca8 1\uc774 \uc544\ub2cc \ub290\ub08c\uc758 \ubb38\uc81c. lcm\uacfc \uc8fc\uae30, ",(0,o.jsx)(n.code,{children:"%"}),"\ub97c \ud65c\uc6a9\ud560 \uc218 \uc788\uc73c\uba74 \ud480 \uc218 \uc788\ub2e4."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"from math import gcd\nfrom functools import reduce\n\ndef lcm(a, b):\n    return a * b // gcd(a, b)\n\ndef solution(signals):\n    # \uc2e0\ud638\ub4f1 \uc8fc\uae30\n    cycles = [g + y + r for g, y, r in signals]\n    \n    # \uc804\uccb4 \ubc18\ubcf5 \uc8fc\uae30\n    limit = reduce(lcm, cycles)\n    \n    # \uc2dc\uac04 \ud0d0\uc0c9\n    for t in range(1, limit + 1):\n        ok = True\n        # \ubaa8\ub4e0 \uc2e0\ud638\ub4f1 \uac80\uc0ac\n        for g, y, r in signals:\n            cycle = g + y + r\n            \n            x = (t - 1) % cycle + 1\n            \n            # \ub178\ub780\ubd88\uc778\uc9c0 \uac80\uc0ac\n            if not (g < x <= g + y):\n                ok = False\n                break\n                \n        if ok:\n            return t\n\n    return -1\n"})})]})}function d(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(m,{...e})}):m(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.