<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>티바이트</title>
    <link>https://tibyte.tistory.com/</link>
    <description>프로그래밍 블로그</description>
    <language>ko</language>
    <pubDate>Fri, 8 May 2026 15:06:23 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>티바이트</managingEditor>
    <image>
      <title>티바이트</title>
      <url>https://t1.daumcdn.net/cfile/tistory/2579C84455B4F9981E</url>
      <link>https://tibyte.tistory.com</link>
    </image>
    <item>
      <title>블로그 이전 준비중..</title>
      <link>https://tibyte.tistory.com/299</link>
      <description>&lt;p&gt;github 블로그로 이전 중입니다..&lt;br /&gt;&lt;/p&gt;</description>
      <category>자유주제</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/299</guid>
      <comments>https://tibyte.tistory.com/299#entry299comment</comments>
      <pubDate>Fri, 7 Dec 2018 02:23:56 +0900</pubDate>
    </item>
    <item>
      <title>Jekyll new에서 bundler 에러 (No such file..)</title>
      <link>https://tibyte.tistory.com/298</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;$jekyll new sitename&lt;br /&gt;&lt;/p&gt;&lt;p&gt;로 새로운 사이트를 만들 때 아래와 같은 에러가 발생했다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Bundler: ruby: No such file or directory -- /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/exe/bundle (LoadError)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;$gem env&lt;/p&gt;&lt;p&gt;로 환경설정을 보면 경로가 아래와 같이 나온다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;/var/lib/gems/2.3.0&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;해당 경로로 심볼릭 링크를 걸어주거나, jekyll 설정을 변경하면 해결된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>프로그래밍</category>
      <category>Jekyll</category>
      <category>블로그</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/298</guid>
      <comments>https://tibyte.tistory.com/298#entry298comment</comments>
      <pubDate>Sat, 12 May 2018 13:23:19 +0900</pubDate>
    </item>
    <item>
      <title>Grafana에서 y축 2개 사용하기</title>
      <link>https://tibyte.tistory.com/297</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;오픈소스 데이터 분석 및 모니터링 도구인 그라파나(&lt;a href=&quot;https://grafana.com/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;Grafana&lt;/a&gt;)에서 그래프를 표시할 때 오른쪽 y 축(right y-axis)을 사용할 수 있다. 이 글에서 사용한 그라파나 버전은 4.6.3이다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;InfluxDB 등에서 가져온 2가지 메트릭을 그래프로 표시하면 처음에는 아래와 같이 된다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99F6853E5A9BC31D0C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99F6853E5A9BC31D0C&quot; width=&quot;618&quot; height=&quot;256&quot; filename=&quot;graf1.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;해당 그래프에서 Display탭의 Series overrides로 들어가 오버라이드할 항목의 alias와 Y축 관련 설정을 추가한다. &lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99A51B3E5A9BC31E11&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99A51B3E5A9BC31E11&quot; width=&quot;618&quot; height=&quot;310&quot; filename=&quot;graf2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;아래 그림과 같이 우측에도 y축이 생기는 것을 볼 수 있다. 축의 수치 범위는 Axes 탭에서 설정이 가능하다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9947BD3E5A9BC31E17&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9947BD3E5A9BC31E17&quot; width=&quot;618&quot; height=&quot;246&quot; filename=&quot;graf3.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>컴퓨터 일반</category>
      <category>grafana</category>
      <category>그라파나</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/297</guid>
      <comments>https://tibyte.tistory.com/297#entry297comment</comments>
      <pubDate>Sun, 4 Mar 2018 19:04:54 +0900</pubDate>
    </item>
    <item>
      <title>온라인저지 HUSTOJ 설치하기 (2018. 02)</title>
      <link>https://tibyte.tistory.com/296</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예전에 '&lt;a href=&quot;http://tibyte.kr/291&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;온라인저지 구축기&lt;/a&gt;' 라는 글을 올린 적이 있었는데, HUSTOJ가 버전업이 계속 되었고, 설치방법에 대한 문의가 있어 다시 적어봅니다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;설치 OS : Ubuntu 16.04.2 LTS&lt;/p&gt;&lt;p&gt;HUSTOJ repo : &lt;a href=&quot;https://github.com/zhblue/hustoj&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/zhblue/hustoj&lt;/a&gt; (2018년 2월 28일 버전)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. git을 설치한다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;sudo apt-get install git&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2. git clone으로 저장소에서 파일을 복사해온다.&lt;/p&gt;&lt;p&gt;아래 명령어는 항상 최신 버전을 받아오기 때문에, 이전 버전이 필요하다면 github에서 이전 커밋을 찾아보아야 한다.&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;git clone &lt;a href=&quot;https://github.com/zhblue/hustoj&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/zhblue/hustoj&lt;/a&gt; &lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3. 받은 파일의 trunk/install 경로에서 install-ubuntu16+.sh 파일을 실행한다.&lt;/p&gt;&lt;p&gt;여기서는 문제 발생을 위해 기본 설정을 따를 것이므로, mysql이나 nginx가 이미 설정되어 있는 환경에서는 충돌이 발생할 수도 있다. (위의 repo에서 Docker 이미지도 제공하고 있으므로, 도커 사용에 익숙하다면 해당 이미지를 이용하여 쉽게 설치할 수 있다.)&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;sudo bash ./install-ubuntu16+.sh&lt;br /&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4. 설치 도중에 mysql을 설치하고, 비밀번호를 설정하는 창이 나온다. 비밀번호를 입력하여 설치를 계속한다. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;5. 수 분을 기다리면 설치가 완료된다. 경우에 따라 경고 메시지가 뜰 수 있는데, 심각한 내용이 아니면 일단 넘어간다. judge 라는 리눅스 계정이 생성되고, /home/judge 라는 홈 디렉터리가 만들어진다. 이 경로에 들어가서 파일이 제대로 설치되있는지 확인한다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;6. ps -ef | grep judged 를 실행하여 judged 데몬이 제대로 실행되고 있는지 확인한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;7. 브라우저를 열고 127.0.0.1 (원격 접속중이라면, 해당 서버의 IP) 으로 접속하여 페이지가 잘 나오는지 확인한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;8. /home/judge/src/web/include/db_info.inc.php 을 수퍼유저 권한으로 열어서(sudo) 언어를 수정한다. 언어 설정과 관련되어 있는 'cn'(중국어)이 2개 있다 이것을 en으로 바꿔준다.&lt;/p&gt;&lt;p&gt;zh-CN 라고 되어있는 것은 en-US로 수정한다. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;9. 이제 관리자 계정을 생성해야 하는데, 기본 관리자 계정이 없어서 아이디를 만들고 DB를 수정해야 한다. 상단의 Login 메뉴에서 회원가입을 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;10. mysql -u root -p로 mysql 클라이언트를 열고 4번에서 지정한 비밀번호를 입력한다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;11. use jol; 을 입력하여 데이터베이스를 선택한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;12. INSERT INTO privilege(user_id, rightstr) VALUES('생성한 아이디', 'administrator'); 쿼리를 입력하여 유저권한을 지정한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;13. exit를 쳐서 DB에서 빠져나온다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;14. 9번에서 만든 관리자 ID로 로그인한다. 문제와 테스트케이스를 만들고 저장한다. 추가적인 테스트케이스를 입력하라는 버튼이 나오는데, 이 페이지는 다음에 다시 들어갈 수 있다. 관리자 페이지와 문제 추가에 대한 설명은 생략한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;참고) 테스트용 문제를 추가할 때, 입력 테스트케이스에 아무 숫자나 입력하고, 출력 테스트케이스에는 Hello 등의 간단한 문자열을 지정한다. 그러면 테스트용 코드를 작성할 때 간단하다. &lt;u&gt;테스트 케이스를 입력하지 않으면 채점이 되지 않을 수도 있다.&lt;/u&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;15. 관리자 페이지에서 빠져나와, 문제를 풀고 평가가 제대로 되는지 확인한다. Pending이 지속되지 않고, Accepted 혹은 Wrong Answer, Compile Error 등의 결과가 나오면 성공!&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 607px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/990580455A96F49E16&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F990580455A96F49E16&quot; width=&quot;607&quot; height=&quot;205&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;16. 관리 페이지의 문제 리스트에서 Reserved 되어 있는 문제의 status를 클릭하여 Available 상태로 만든다. 이 상태가 되면 관리자가 아닌 일반 유저도 문제를 볼 수 있게 된다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99F3AE455A96F49E18&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99F3AE455A96F49E18&quot; width=&quot;618&quot; height=&quot;161&quot; filename=&quot;캡2처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;※ Troubleshootings&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;- /home/judge/ 디렉터리 내에서 hustoj 관련 파일을 찾을 수 없을 때&lt;/b&gt;&lt;/p&gt;&lt;p&gt;install-ubuntu16+.sh 파일 실행 중에 실패한 것이다. &lt;b&gt;슈퍼유저 권한을 주지 않고 실행했거나&lt;/b&gt;, 기존에 설치되어 있던 mysql 또는 nginx 설정과 충돌했을 가능성이 있다. install 파일을 실행할 때 발생한 출력 메시지를 확인하여 에러를 수정한다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;- 웹 사이트가 뜨지 않을 때&lt;/b&gt;&lt;/p&gt;&lt;p&gt;에러 메시지에 따라 nginx나 mysql 설정을 확인한다. (구글링..)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;- 코드를 제출했는데 pending 상태에서 무한히 대기할 때&lt;/b&gt;&lt;/p&gt;&lt;p&gt;ps -ef | grep judged 명령으로 judged 데몬이 실행중인지 확인한다. 실행중이라면 프로세스를 (kill -9 등으로) 죽이고 재실행해 본다. 실행중이 아니라면, 실행한다.(sudo service judged start)&lt;/p&gt;&lt;p&gt;문제가 해결되지 않으면 /home/judge/src/core/judged 경로로 들어가 해당 프로세스를 포그라운드로 실행하여 에러 메시지를 확인 후 조치한다. 파일 접근 권한 문제이거나 DB 접속 문제라면 관련 에러가 뜰 것이다.&lt;/p&gt;&lt;p&gt;만약 아무 에러도 뜨지 않는다면, 관리 페이지에서 테스트케이스 데이터를 확인해 본다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;- 입력 테스트케이스의 문자열 길이가 잘못 측정될 때&lt;/b&gt;&lt;/p&gt;&lt;p&gt;테스트케이스 추가페이지에서는 줄바꿈에 \r\n을 사용한다. 이 부분은 관리페이지의 내부 php 코드를 수정하여 캐리지리턴(\r)을 빼고 라인피드(\n)만 저장되도록 수정해야 한다. (이런 잔문제들이 많다..)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;HUSTOJ를 사용하여 &lt;a href=&quot;https://judge.zetagate.com&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://judge.zetagate.com&lt;/a&gt;을 운영하고 있었으나, 여러가지 문제가 많고, 확장성이 없다고 판단하여 새로 제작 중이다. &lt;a href=&quot;https://github.com/ice-judge&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/ice-judge&lt;/a&gt; 아직 Github 저장소만 만들어 놓은 시작 단계다... &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>제작일기</category>
      <category>알고리즘</category>
      <category>온라인저지</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/296</guid>
      <comments>https://tibyte.tistory.com/296#entry296comment</comments>
      <pubDate>Thu, 1 Mar 2018 03:45:12 +0900</pubDate>
    </item>
    <item>
      <title>2017 블로그 결산</title>
      <link>https://tibyte.tistory.com/295</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9984BF445A53914730&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9984BF445A53914730&quot; width=&quot;618&quot; height=&quot;352&quot; filename=&quot;1.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/999899445A5391472D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F999899445A5391472D&quot; width=&quot;618&quot; height=&quot;338&quot; filename=&quot;2.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99472D445A53914813&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99472D445A53914813&quot; width=&quot;618&quot; height=&quot;343&quot; filename=&quot;3.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 311px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/998F53445A53914807&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F998F53445A53914807&quot; width=&quot;311&quot; height=&quot;188&quot; filename=&quot;4.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;티스토리에서 연초마다 블로그결산 기능을 제공하여 이번에도 한번 돌려 보았습니다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;올해는 블로그를 좀더 해봐야겠습니다. 근데 github으로 옮길까 하는 생각도...&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>블로그소식</category>
      <category>2017 블로그 결산</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/295</guid>
      <comments>https://tibyte.tistory.com/295#entry295comment</comments>
      <pubDate>Tue, 9 Jan 2018 00:43:58 +0900</pubDate>
    </item>
    <item>
      <title>2018년 1월 1일 남한산성 일출</title>
      <link>https://tibyte.tistory.com/294</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;일출을 보기 위해 아침 6시경 남한산성으로 향했다. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;성남시 쪽에서 올라가는 도로가 몰려든 인파로 매우 붐볐기 때문에 늦지 않을까 걱정하였지만, 다행히 해 뜨기 전 7시 26분에 남문 앞에 도착할 수 있었다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;원래 계획은 수어장대(守禦將臺)까지 올라가려고 했으나, 시간이 늦어지는 관계로 남문과 수어장대 사이에 있는 영춘정(迎春亭)에서 해가 뜨는 것을 보게 되었다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;성남시 방향을 내려다 보며..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/995E6B355A4A4B8E20&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F995E6B355A4A4B8E20&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;1.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;7시 49분이 되자 해가 보이기 시작했다.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/995A05355A4A4B8F04&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F995A05355A4A4B8F04&quot; width=&quot;618&quot; height=&quot;387&quot; filename=&quot;2.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9979F6355A4A4B9001&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9979F6355A4A4B9001&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;3.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/990967355A4A4B900D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F990967355A4A4B900D&quot; width=&quot;618&quot; height=&quot;367&quot; filename=&quot;4.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99D045355A4A4B9113&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99D045355A4A4B9113&quot; width=&quot;618&quot; height=&quot;372&quot; filename=&quot;5.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;핸드폰 카메라가 좋지 않아서(혹은 찍는 실력이 없어서) 해가 완전히 뜬 이후의 사진은 제대로 찍히지 않았다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99D94C355A4A4B9234&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99D94C355A4A4B9234&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;6.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;수어장대에서 서문(우익문) 방향으로 내려는 길.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99E860355A4A4B9432&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99E860355A4A4B9432&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;7.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;송파구 방향을 내려다보며.. 멀리 롯데월드타워가 보인다. 사진에는 잘 보이지 않지만 날씨가 맑아서 북한산까지 볼 수 있었다. &lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/993337415A4A4B9529&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F993337415A4A4B9529&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;8.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;서문(우익문)에 도착. 이후 왔던 길을 되돌아왔다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9956E9415A4A4B9624&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9956E9415A4A4B9624&quot; width=&quot;618&quot; height=&quot;348&quot; filename=&quot;9.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;날씨가 추워서인지 폰 배터리가 빠르게 방전되는 바람에 사진을 많이 찍지 못한 것이 아쉬웠다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9976283E5A4A4ED40F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9976283E5A4A4ED40F&quot; width=&quot;618&quot; height=&quot;629&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>자유주제</category>
      <category>2018년</category>
      <category>남한산성</category>
      <category>일출</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/294</guid>
      <comments>https://tibyte.tistory.com/294#entry294comment</comments>
      <pubDate>Mon, 1 Jan 2018 23:54:52 +0900</pubDate>
    </item>
    <item>
      <title>testtitle</title>
      <link>https://tibyte.tistory.com/pages/testpage</link>
      <description>&lt;p&gt;testcontent&lt;/p&gt;</description>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/pages/testpage</guid>
      <pubDate>Mon, 27 Nov 2017 14:03:33 +0900</pubDate>
    </item>
    <item>
      <title>기수정렬(radix sort) 빠르게 수행하기</title>
      <link>https://tibyte.tistory.com/292</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;기수정렬(Least Significant Digit 방식)&amp;nbsp;관련 글들을 찾아보면 개념을 쉽게 설명하기 위해 십진수 단위를(base 10) 사용한 것들이 많은데 실제로 이것을 구현하면 생각보다 느린 것을 볼 수 있다. 나눗셈 연산과 나머지연산이 수행되기 때문이다.&amp;nbsp;&amp;nbsp;예를 들어 100의 자리에서 기수정렬할 단계를 보면, (현 상태에서 m은 100이라고 가정한다.)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;arr[i]/m%10&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;위와 같이 / 연산과 % 연산이 사용된다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;이러한 문제를 개선하기 위해 버킷의 개수를 2의 거듭제곱으로 하면 속도가 빠른 비트연산을 사용할 수 있다. 버킷의 개수를 8로 하면 위 연산식이 아래와 같이 된다. (현 상태에서 m은 64라고 가정)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(arr[i]&amp;gt;&amp;gt;m)&amp;amp;7&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;2의 거듭제곱으로 나누었을 때의 나머지는, 굳이 나누어서 계산해볼 필요 없이 해당 위치의 비트만 AND연산으로 추출하면 되는 것이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;구현&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;아래 코드는 0부터 99,999,999까지의 정수 데이터들을 정렬할 수 있는 기수정렬(base 8) 알고리즘을 코드로 구현한 것이다.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;idx &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(255, 255, 255);&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;       &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
            counts&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
        &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
     
        &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
            digit &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
            bucket&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;digit&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;counts&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;digit&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; arr&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
        &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
    
        &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
            &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 0); font-weight: bold; font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 140, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; k&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;counts&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
                arr&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;idx&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt; bucket&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 128, 48); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
            &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
        &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;
    &lt;/span&gt;&lt;span style=&quot;color: rgb(128, 0, 128); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;비트시프트 연산을 보면, i는 데이터를 8진수로 나타냈을 때 특정 자리의 숫자를 얻을 때 사용된다. i를&amp;nbsp;8이 될때까지만 반복시키는 이유는&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/991D33335A1935811A&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%7B%208%20%7D%5E%7B%208%20%7D%5Cquad%20%3D%5Cquad%2016%2C777%2C216%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A12%2C%0A0xFFFFFF&quot; width=&quot;151&quot; height=&quot;24&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;으로, 99,999,999를 8진수로 나타낼 수 있는 가장 큰 자릿수가 8이기 때문이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;수행시간 분석&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;base 8 기수정렬에서 전체 데이터의 양을 N개라고 했을 때 버킷의 크기는 bucket[8][N]이다. base 8 대신 base 4나 base 2를 사용하면 메모리 사용량은 각각 2배, 4배 줄어들게 된다. 반면, 기수정렬의 시간복잡도가 O(dN)이므로,&amp;nbsp;수행시간은 더 늘어난다. (d는 해당 base에서 데이터의 최대 자릿수이다.) 표 1은 내림차순으로 정렬된 100만개 ~ 500만개 데이터를 오름차순으로 정렬했을 때 각 알고리즘의 수행 시간(ms)이다. 표 2는 랜덤함수로 생성한 무작위 데이터를 오름차순으로 정렬했을때의 결과이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;표 1&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 442px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9937E3335A1937BE0E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9937E3335A1937BE0E&quot; width=&quot;442&quot; height=&quot;144&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;표 2&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 442px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99A04C335A1937BE07&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99A04C335A1937BE07&quot; width=&quot;442&quot; height=&quot;145&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;표 1의 결과를 그래프로 나타내 보면 다음과 같다.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 579px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99CABC335A1939961B&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99CABC335A1939961B&quot; width=&quot;579&quot; height=&quot;396&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif;&quot;&gt;&amp;nbsp;base 8 대신 16이나 32를 사용하면 메모리 사용량이 늘어나고, 속도가 약간 줄어들겠지만, 값 복사시간이 기본적으로 존재하기 때문에 속도가 줄어드는 데에는 한계가 있다. 수행시간이 카운팅 정렬을 사용했을때 이하로 떨어지지는 않을 것이다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘,수학</category>
      <category>알고리즘</category>
      <category>코딩</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/292</guid>
      <comments>https://tibyte.tistory.com/292#entry292comment</comments>
      <pubDate>Sat, 25 Nov 2017 18:40:45 +0900</pubDate>
    </item>
    <item>
      <title>온라인저지 구축기</title>
      <link>https://tibyte.tistory.com/291</link>
      <description>&lt;p&gt;&amp;nbsp;Dovelet이나 &lt;a href=&quot;https://www.acmicpc.net/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;BOJ&lt;/a&gt; 같은 사이트들을 풀어보면서 직접 문제들을 만들어 보고 싶었고, 알고리즘을 공부하는 사람들과 소규모 대회를 열어보기 위해 온라인저지(Online Judge)시스템을 구축하게 되었다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;DMOJ 설치&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;DMOJ는 Django 기반으로 되어 있는 온라인저지 시스템으로, github 커밋이 꾸준히 올라오고 있고 현대적인 사이트 디자인이 특징이다. 설치 가이드에 따라 설치를 진행하였는데 마지막 단계에서 nginx 권한 관련 오류를 해결하지 못하여 진행하지 못하였다. 도커이미지도 제공되고 있어서 컨테이너를 실행해 보았더니 이번에는 Django 내부 코드에서 오류가 발생하여 포기.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;HUSTOJ 설치&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;* 2018년 2월에 갱신되었습니다. 아래 글 보다는 &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;/span&gt;&lt;a href=&quot;http://tibyte.kr/296&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;이 글&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;을 참고하세요.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;일단 구동이 되는 것을 찾다가 HUSTOJ를 설치해보기로 하였다. HUSTOJ는 교내 프로그래밍 대회에 사용되고 있고, CodeUp 및 여러 온라인저지에서 사용하고 있는 오픈소스 프로젝트이다. 채점기는 C++로 짜여져 있으며 웹페이지는 PHP로 구동된다. 설치할 때&amp;nbsp;&lt;a href=&quot;https://github.com/zhblue/hustoj&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;공식 페이지&lt;/a&gt;와 &lt;a href=&quot;http://blog.esukmean.com/2015/07/21/hustoj-%EC%84%A4%EC%B9%98%EB%B0%A9%EB%B2%95/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;이&lt;/a&gt;&lt;a href=&quot;http://blog.esukmean.com/2015/07/21/hustoj-%EC%84%A4%EC%B9%98%EB%B0%A9%EB%B2%95/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;&amp;nbsp;블로그 포스팅&lt;/a&gt;을 참고하여 진행하였다. 설치 과정은 아래와 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1) install/install.sh에서 WEBBASE, APACHEUSER, DBUSER, DBPASS, core 디렉터리 경로, web 디렉터리 경로를&amp;nbsp;환경에 맞게 설정한다. subversion 관련 코드들은 삭제한다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2) install/judge.conf를 확인한다. OJ_HOST_NAME, OJ_USER_NAME, OJ_PASSWORD와 MySQL관련 설정들을 환경에 맞게 수정하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3) web/include/db_info.inc.php 파일에서 원하는 설정을 한다. 이 부분은 설치 후에도 변경할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4) install.sh를 실행하여 설치를 진행한다. 이 프로젝트는 Ubuntu 14에서 테스트되었고, Ubuntu 16을 비추천한다고 하는데, 16에서도 잘 구동된다. php5 대신 php7을, apache대신 nginx를 이용하는 것은 install 디렉터리에 함께 있는 ubuntu16용 설치 sh파일을 참고한다. sh파일을 실행하면,&lt;/p&gt;&lt;p&gt;/etc/nginx/site-enabled에서 root은 /home/judge/src/web이 되고, php관련 location설정은&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;location ~ \.php$ {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; include snippets/fastcgi-php.conf;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# With php7.0-cgi alone:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fastcgi_pass 127.0.0.1:9000;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fastcgi_pass unix:/run/php/php7.0-fpm.sock;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;와 같이 작성된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;사이트 수정&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;레이아웃을 비롯하여 회원가입, 관리자페이지, 채점기 등 많은 부분을 수정하였다. judge 기본 디렉터리에서 data에는 문제의 테스트케이스가 있고, src/core에는 채점 프로그램 관련 소스와 makefile이 존재한다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;웹페이지는 src/web 디렉터리에 있는데, src/web에는 SQL에서 데이터를 받아오는 부분이 있고,&amp;nbsp;&amp;nbsp;src/web/template/bs3에는 주로 뷰 관련 코드(html)가 들어&amp;nbsp;있다. 그러나 잘 분리되어 있지 않아 수정이 번거롭다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;PHP와 SQL, html이 섞여 있어 구조적으로 알아보기 불편하고, SQL튜닝이 잘 되어있지 않아 데이터가 많아지면 상당한 오버헤드가 예상된다. 일단 이 프로젝트를 사용하여 회원탈퇴, 소스공유, 랭킹시스템 등 필수적인 기능을 구현할 것이다. 그리고 저지사이트 구축을 공부해볼겸 하여 기존의 코드를 버리고 프레임워크를 새로 만들어 보기로 계획하였다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;현재 진행중인 사이트는 &lt;a href=&quot;https://judge.zetagate.com/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;여기&lt;/a&gt;다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9995BE335A0193E407&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9995BE335A0193E407&quot; width=&quot;618&quot; height=&quot;352&quot; filename=&quot;sr.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>제작일기</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/291</guid>
      <comments>https://tibyte.tistory.com/291#entry291comment</comments>
      <pubDate>Tue, 7 Nov 2017 20:08:18 +0900</pubDate>
    </item>
    <item>
      <title>선분의 교차 여부 판단과 선분 끝부분 고려하기</title>
      <link>https://tibyte.tistory.com/288</link>
      <description>&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;2차원 평면상에서 선분 AB와 CD의 정보가 주어질 때, 두 선분의 교차 여부를 빠르게 판단할 수 있는 방법이 있다. 벡터의 외적(벡터곱)을 이용하는 방법이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 1과 같이 두 선분이 교차하는 경우를 생각해 보자. 벡터 BA를 기준으로 점 C와 점 D가 서로 다른 회전방향에 있으므로, 아래 두 경우는 벡터곱 연산의 결과로 나온 z값의 부호가 다르다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;- 벡터 BA와 벡터 BC를 외적한 결과&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;- 벡터 BA와 벡터 BD를 외적한 결과&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;벡터 DC에 대해서도 역시 부호가 다르게 된다.&lt;/p&gt;&lt;p style=&quot;clear: none; float: none; text-align: left;&quot;&gt;- 벡터 DC와 벡터 DA를 외적한 결과&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;- 벡터 DC와 벡터 DB를 외적한 결과&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 206px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/997B603359E0916919&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F997B603359E0916919&quot; width=&quot;206&quot; height=&quot;229&quot; filename=&quot;yes.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none; text-align: left;&quot;&gt;그림 1. 교차하는 두 선분&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;즉, 벡터곱 연산을 이용하여 한 선분의 벡터를&amp;nbsp;기준으로, 다른 선분의 두 점들이 같은 회전뱡향에 있는지, 다른 회전방향에 있는지 검사하면 교차 여부를 판단할 수 있는 것이다.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;두 선분에 대해 이러한 판단을 수행하여 모두 만족하면 교차하는 것으로 판정한다.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;그림 2에서는 벡터&amp;nbsp;CD에 대해 다른 선분의 두 점(A, B)는 서로 다른 회전방향이지만, 벡터 AB에 대해서는 두 점(C ,D)가 같은 회전방향에 있기 때문에 교차하지 않는 것으로 판정한다.&lt;/div&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 224px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/994FD43359E0916A04&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F994FD43359E0916A04&quot; width=&quot;224&quot; height=&quot;249&quot; filename=&quot;no.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 2. 교차하지 않는 두 선분&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Javascript로 표현하면 아래와 같이 쓸 수 있다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p1 = line1.p1;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let p2 = line1.p2;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let p3 = line2.p1;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let p4 = line2.p2;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let sign1 = (p2.x-p1.x)*(p3.y-p1.y) - (p3.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let sign2 = (p2.x-p1.x)*(p4.y-p1.y) - (p4.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let sign3 = (p4.x-p3.x)*(p1.y-p3.y) - (p1.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; let sign4 = (p4.x-p3.x)*(p2.y-p3.y) - (p2.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;&amp;nbsp; &amp;nbsp; return sign1*sign2&amp;lt;0 &amp;amp;&amp;amp; sign3*sign4&amp;lt;0;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그러나 위 코드에는 문제점이 있는데, 그림 3과 같이 두 선분의 기울기가 같을 때는 교차하지 않는 것으로 판단한다는 것이다. (이런 결과를 의도했다면 문제가 되지 않겠지만..)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 311px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9968553359E0916B1A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9968553359E0916B1A&quot; width=&quot;311&quot; height=&quot;226&quot; filename=&quot;error2.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 3. 두 선분의 기울기가 같고, 교차점이 무수히 많은 경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 3과 같은 경우에도 두 선분이 교차하는 것으로 판정하기 위해, 비교문을 아래와 같이 고치면 또다른 문제가 발생한다. 그림 4와 같이 기울기가 같고 서로 떨어져 있을 때 잘못 판정한다는 것이다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt; return sign1*sign2&amp;lt;=0 &amp;amp;&amp;amp; sign3*sign4&amp;lt;=0;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 229px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9907DD3359E0916A0C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9907DD3359E0916A0C&quot; width=&quot;229&quot; height=&quot;162&quot; filename=&quot;error1.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 4. 교차 여부를 잘못 판정한 경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;두 선분이 완전히 떨어져 있을 경우(더 정확히 말하면, 각각의 선분이 이루는 직사각형 영역이 서로 겹치지 않는 경우)에 false를 리턴하면 이 문제를 해결할 수 있다. 외적 연산에 앞서 사전 영역 검사를 하는 것이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;아래 코드에서 모든 부호가 0일 때 true를 반환하는 부분을 추가한 이유는, 그림 3과 같이 교차점이 무수히 많은 경우도 교차하는 것으로 판단하기 위해서이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p1 = line1.p1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p2 = line1.p2;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p3 = line2.p1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p4 = line2.p2;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.max(p1.x, p2.x) &amp;lt; Math.min(p3.x, p4.x)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.min(p1.x, p2.x) &amp;gt; Math.max(p3.x, p4.x)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.max(p1.y, p2.y) &amp;lt; Math.min(p3.y, p4.y)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.min(p1.y, p2.y) &amp;gt; Math.max(p3.y, p4.y)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign1 = (p2.x-p1.x)*(p3.y-p1.y) - (p3.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign2 = (p2.x-p1.x)*(p4.y-p1.y) - (p4.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign3 = (p4.x-p3.x)*(p1.y-p3.y) - (p1.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign4 = (p4.x-p3.x)*(p2.y-p3.y) - (p2.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(sign1==0 &amp;amp;&amp;amp; sign2==0 &amp;amp;&amp;amp; sign3==0 &amp;amp;&amp;amp; sign4==0) return true;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return sign1*sign2&amp;lt;=0 &amp;amp;&amp;amp; sign3*sign4&amp;lt;=0;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 204px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9935043359E0916A07&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9935043359E0916A07&quot; width=&quot;204&quot; height=&quot;209&quot; filename=&quot;straight.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 5. 교차 여부를 정상적으로&amp;nbsp;판정한 경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;경우에 따라서 그림 6과 같이 선분의 끝점이 교차할 때는 교차하지 않는 것으로 판단하는 것이 필요할 때가 있다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 186px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/993E573359E0916B36&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F993E573359E0916B36&quot; width=&quot;186&quot; height=&quot;158&quot; filename=&quot;tan1.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 187px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99CA593359E0916B12&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99CA593359E0916B12&quot; width=&quot;187&quot; height=&quot;150&quot; filename=&quot;tan2.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그림 6, 7. 두 선분이 교차하는 것으로 판단하는&amp;nbsp;경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;아래 코드에서와 같이 사전 영역 검사에 동등 조건을 넣어&amp;nbsp;&amp;nbsp;좀더 엄격하게 바꾸고(그림 6과 관련), 마지막의 리턴 코드에서 동등 조건을 제거한다.(그림 7과 관련)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p1 = line1.p1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p2 = line1.p2;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p3 = line2.p1;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let p4 = line2.p2;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &lt;b&gt;if(Math.max(p1.x, p2.x) &amp;lt;= Math.min(p3.x, p4.x)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.min(p1.x, p2.x) &amp;gt;= Math.max(p3.x, p4.x)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.max(p1.y, p2.y) &amp;lt;= Math.min(p3.y, p4.y)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; if(Math.min(p1.y, p2.y) &amp;gt;= Math.max(p3.y, p4.y)) return false;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign1 = (p2.x-p1.x)*(p3.y-p1.y) - (p3.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign2 = (p2.x-p1.x)*(p4.y-p1.y) - (p4.x-p1.x)*(p2.y-p1.y);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign3 = (p4.x-p3.x)*(p1.y-p3.y) - (p1.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; let sign4 = (p4.x-p3.x)*(p2.y-p3.y) - (p2.x-p3.x)*(p4.y-p3.y);&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; if(sign1==0 &amp;amp;&amp;amp; sign2==0 &amp;amp;&amp;amp; sign3==0 &amp;amp;&amp;amp; sign4==0) return true;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;b&gt;&amp;nbsp; return sign1*sign2&amp;lt;0 &amp;amp;&amp;amp; sign3*sign4&amp;lt;0;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;결론&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;만들고자 하는 프로그램에 따라 선분 끝점을 어떻게 판단해야할지가 달라진다. 위 코드를 활용하여 비교문들을 조정하면 선분의 교차 판단을 목적에 맞게 할 수 있을 것이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;소스코드&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;동작하는 전체 코드는(Javascript)는 아래 github에서 다운로드할 수 있습니다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;a href=&quot;https://github.com/tibyte/algorithms/tree/master/line-intersection&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/algorithms/tree/master/line-intersection&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘,수학</category>
      <category>수학</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/288</guid>
      <comments>https://tibyte.tistory.com/288#entry288comment</comments>
      <pubDate>Fri, 13 Oct 2017 19:56:03 +0900</pubDate>
    </item>
    <item>
      <title>깃허브 페이지에 SSL 설정하여 HTTPS 사용하기</title>
      <link>https://tibyte.tistory.com/287</link>
      <description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;깃허브 페이지(github page)는 tibyte.github.io와 같은 github.io&amp;nbsp;주소로 접속하였을 때 HTTPS를 지원하지만 커스텀 도메인을 설정하였을 경우 그림 1과 같이 지원되지 않는 것을 볼 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 262px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99EF993359870DED2E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99EF993359870DED2E&quot; width=&quot;262&quot; height=&quot;108&quot; filename=&quot;ssl0.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 1. 커스텀 도메인 설정한 &lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;깃허브 페이지를 접속하였을 때의&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&amp;nbsp;주소창&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;커스텀 도메인을 연결한 깃허브 페이지에 SSL(Secure Sockets Layer)을 설정하기 위해서는 먼저 SSL 인증서를 발급받아 설치해야 하는데, Cloudflare의 네임서버를 사용하면 이 과정을&amp;nbsp;간단하게 할 수 있다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;Cloudflare의 &lt;a href=&quot;https://www.cloudflare.com/a/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;Add Website&lt;/a&gt; 페이지에서 도메인을 등록하면 DNS 레코드들을 자동으로 불러온다. 목록을 확인한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/996BE33359870DED39&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F996BE33359870DED39&quot; width=&quot;618&quot; height=&quot;385&quot; filename=&quot;ssl1.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 2. DNS 레코드 설정화면&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;DNS 레코드를 확인 후 설정을 저장하고, 소유하고 있는 도메인의 관리 페이지(도메인 등록 대행업체)로 들어가서 네임서버를 Cloudflare에서 안내한 주소로 연결한다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 578px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9935D33359870DEE25&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9935D33359870DEE25&quot; width=&quot;578&quot; height=&quot;237&quot; filename=&quot;ssl2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 3. 네임서버 설정&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;도메인 네임서버 주소 변경은 전파되는 데 수 분에서 수 일까지 걸릴 수 있다. 정상적으로 전파되었다면,&amp;nbsp;Cloudflare의 Crypto 메뉴에서 SSL 사용여부를 선택할 수 있다. 여기서 옵션이 있는데 github 페이지는 HTTPS를 지원하므로 권장방식인 Full SSL을 선택한다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/9999CB3359870DEE35&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F9999CB3359870DEE35&quot; width=&quot;618&quot; height=&quot;244&quot; filename=&quot;ssl3.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 4. SSL 설정&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;설정을 완료하고, https:// 를 명시한&amp;nbsp;커스텀 도메인을 사용하여 github 페이지를 접속해 보면 HTTPS가 적용된 것을 볼 수 있다. CA는 COMODO사의 것으로 나온다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 315px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/994D683359870DEF25&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F994D683359870DEF25&quot; width=&quot;315&quot; height=&quot;96&quot; filename=&quot;ssl4.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 199px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/999A72335987164E1C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F999A72335987164E1C&quot; width=&quot;199&quot; height=&quot;111&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 5. 커스텀 도메인 설정한&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;깃허브 페이지를 접속하였을 때의&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&amp;nbsp;주소창&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&amp;nbsp; 주소창에 https://를 입력하지 않고 접속하였을 경우엔 이전과 같이 HTTPS가 미적용된 페이지가 나오는데, 코드상에서 리다이렉팅을 시키면 되지만 Page Rule을 적용하여도 이 효과를 볼 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99AE2C3359870DEF06&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99AE2C3359870DEF06&quot; width=&quot;618&quot; height=&quot;347&quot; filename=&quot;ssl5.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;그림 6. HTTPS 강제 리다이렉트 설정&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <category>네트워크,웹</category>
      <category>github</category>
      <category>https</category>
      <category>ssl</category>
      <category>깃허브</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/287</guid>
      <comments>https://tibyte.tistory.com/287#entry287comment</comments>
      <pubDate>Sun, 6 Aug 2017 22:11:19 +0900</pubDate>
    </item>
    <item>
      <title>[Git] 서로 다른 원격 브랜치간 push/pull</title>
      <link>https://tibyte.tistory.com/286</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;브랜치명이 다른 원격 브랜치에 push해야 하는 경우에는&lt;/p&gt;&lt;p&gt;아래와 같은 형식으로 쓰면 된다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt; git push 원격저장소명 로컬브랜치:원격브랜치&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예시)&lt;/p&gt;&lt;p&gt;&lt;i&gt;git push origin patch:gh-pages&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;원격 저장소로부터 pull을 받는 경우&amp;nbsp;&lt;/p&gt;&lt;p&gt;아래와 같이 순서를 바꾸어서 쓴다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width: 582px; height: 24px; border-width: 1px; border-style: solid; border-color: rgb(204, 204, 204);&quot;&gt;&lt;p&gt; git pull&amp;nbsp;원격저장소명 원격브랜치:로컬브랜치&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;만약 대상 브랜치가 HEAD가 가리키고 있는 브랜치이면 로컬 브랜치를 생략하여&lt;/p&gt;&lt;p&gt;&lt;i&gt;git pull&amp;nbsp;원격저장소명 원격브랜치&lt;/i&gt;&lt;/p&gt;&lt;p&gt;와 같이 쓸 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>컴퓨터 일반</category>
      <category>GIT</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/286</guid>
      <comments>https://tibyte.tistory.com/286#entry286comment</comments>
      <pubDate>Sat, 17 Jun 2017 13:03:43 +0900</pubDate>
    </item>
    <item>
      <title>공유메모리와 POSIX세마포어 사용</title>
      <link>https://tibyte.tistory.com/285</link>
      <description>&lt;p&gt;&amp;nbsp;리눅스 환경에서 C언어를 사용하여 빠른 프로세스간 통신(IPC)를 구현해야 할 때에 공유메모리를 사용할 수 있다. 그러나 한 프로세스가 데이터를 읽는&amp;nbsp;도중에 다른 프로세스가 해당 공간에 대해 쓰기 작업을 한다면&amp;nbsp;데이터 부정합이 발생할 수 있다. POSIX 세마포어 중 이름 있는 세마포어(named semaphore)를 사용하여 공유자원에 대한 동시 접근 문제를 해결할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;공유메모리를 사용하기 위해 아래와 같은 함수들을 사용해야 한다.&lt;/p&gt;&lt;p&gt;&lt;b&gt;shmget()&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;임의의 키값과 메모리크기를 매개면수로 주어 공유메모리 생성을 커널에 요청하고, 정상적으로 생성되었을시 id를 받아온다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;shmat()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;공유메모리를 현재 프로세스에 붙인다(attach) 반환값으로는 공유메모리의 포인터가 나오고 이 포인터를 통해 메모리에 접근할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;shmdt()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;공유메모리를 현재 프로세스에서&amp;nbsp;분리한다(detach)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;shmctl()&lt;/b&gt;&lt;/p&gt;&lt;div&gt;공유메모리에 대한 제어를 한다. 여기서는 삭제를 위해 사용.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;생성된 공유메모리에 대한 정보는&lt;/div&gt;&lt;div&gt;ipcs -m&lt;/div&gt;&lt;div&gt;명령으로 확인할 수 있다.&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 587px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2169324459020E4F09&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2169324459020E4F09&quot; width=&quot;587&quot; height=&quot;216&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;POSIX named 세마포어는 아래 함수들을 통해 사용할 수 있다.&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_open()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;named 세마포어를 생성하고 세마포어 구조체 포인터(sem_t *)를 받아온다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_wait()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;공유자원에 접근하기 전에 세마포어를 잠근다. 만약 해당 자원에 접근할 수 있는 프로세스가 최대 1개이고, 잠겨있는 상태이면 block되어 풀릴 때까지 대기한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_trywait()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;sem_wait()의 논블로킹 함수로, 자원이 잠겨 있어도 일단 -1을 반환하며 함수가 종료되고,&amp;nbsp;errno를 통해 추가적인 처리를 할 수 있다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_post()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;공유자원에 대한 접근이 끝났을 때 세마포어 잠금을 해제한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_close()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;해당 프로세스에서 세마포어를 닫는다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;sem_unlink()&lt;/b&gt;&lt;/p&gt;&lt;p&gt;세마포어를 파괴한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예제코드는 아래와 같이 컴파일하였다.&lt;/p&gt;&lt;p&gt;clang provicer.c -o provider -std=gnu99 -lpthread&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;provider.c&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;#include &amp;lt;semaphore.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/ipc.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/shm.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int shmid;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size_t shsize = 1024;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const int key = 16000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *shm;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sem_t *mysem;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_unlink&lt;/span&gt;&lt;/b&gt;(&quot;mysem&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((mysem =&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_open&lt;/span&gt;&lt;/b&gt;(&quot;mysem&quot;, O_CREAT, 0777, 1)) == NULL) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;Sem Open Error&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((shmid =&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmget&lt;/span&gt;&lt;/b&gt;((size_t)key, shsize, IPC_CREAT|0666))&amp;lt;0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;shmget&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((shm = (char*)&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmat&lt;/span&gt;&lt;/b&gt;(shmid, NULL, 0)) == (char*)-1) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;shmat&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i=0; i&amp;lt;100; i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shm[i] = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_wait&lt;/span&gt;&lt;/b&gt;(mysem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i=0; i&amp;lt;100; i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shm[i] = (shm[i]+1)%10;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usleep(1000*1000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_post&lt;/span&gt;&lt;/b&gt;(mysem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usleep(1000*1000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; getchar();&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; sem_close(mysem);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; sem_unlink(&quot;mysem&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmdt&lt;/span&gt;&lt;/b&gt;(shm);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmctl&lt;/span&gt;&lt;/b&gt;(shmid, IPC_RMID, 0);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;}&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;consumer.c&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;#include &amp;lt;semaphore.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;#include &amp;lt;time.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/ipc.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/shm.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int shmid;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size_t shsize = 1024;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const int key = 16000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *shm;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sem_t *mysem;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((mysem =&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_open&lt;/span&gt;&lt;/b&gt;(&quot;mysem&quot;, 0, 0777, 0)) == SEM_FAILED) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;Sem Open Error&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((shmid =&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmget&lt;/span&gt;&lt;/b&gt;((key_t)key, shsize, IPC_CREAT|0666))&amp;lt;0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;shmget&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((shm = (char*)&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmat&lt;/span&gt;&lt;/b&gt;(shmid, NULL, 0)) == (char*)-1) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; perror(&quot;shmat&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_trywait&lt;/span&gt;&lt;/b&gt;(mysem) == 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int i=0; i&amp;lt;100; i++) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%d&quot;, (shm[i]));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; putchar('\n');&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_post&lt;/span&gt;&lt;/b&gt;(mysem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(errno) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case EAGAIN:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;EAGAIN\n&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case EDEADLK:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;EDEADLK\n&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case EINTR:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;EINTR\n&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usleep(100*1000);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;sem_close&lt;/span&gt;&lt;/b&gt;(mysem);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;shmdt&lt;/span&gt;&lt;/b&gt;(shm);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Linux</category>
      <category>c</category>
      <category>리눅스</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/285</guid>
      <comments>https://tibyte.tistory.com/285#entry285comment</comments>
      <pubDate>Fri, 28 Apr 2017 00:25:52 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 숫자 이어 붙이기</title>
      <link>https://tibyte.tistory.com/284</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;출처&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech Online Judge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1068&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제이해&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;양의 정수를 1부터 일렬로 나열했을 때 (ex 123456789101112...) P번째에 오는 숫자를 구하는 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제접근&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;자리수가 1개인 수(1~9),&amp;nbsp;2개인 수(10~99), 3개인 수(100~999), ... 를 구분하여 계산한다&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;구현&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;아래와 같은 규칙이 있다.&lt;/p&gt;&lt;p&gt;- 자리수가 1개인 수를 모두 썼을 때는 길이가 9인 문자열이 생성된다.&lt;/p&gt;&lt;p&gt;- 자리수가 2개인 수를 모두 썼을 때는 길이가 90*2 = 180 인 문자열이 생성된다.&lt;/p&gt;&lt;p&gt;- 자리수가 3개인 수를 모두 썼을 때는 길이가 900*3 = 2700인 문자열이 생성된다.&lt;/p&gt;&lt;p&gt;만약 P 값으로 2889가 입력된다면, 그 수는 9+180+2700 이므로 세 자리 숫자 중 가장 마지막에 오는 숫자(999)일 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;같은 방법으로, 임의의 P가 있을 때 이 수가 몇 자리 수로 이루어진 정수까지 썼을&amp;nbsp;때 나온 길이인지 계산할 수 있으며, 해당 자리 수를 가진 수 중 가장 작은 수까지 썼을 때 문자열의 길이도 구할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1부터 n까지 수를 일렬로 나열했을 때 문자열의 길이를 f(n)이라 한다면,&lt;/p&gt;&lt;p&gt;예를 들어, f(1000)과 f(10000)을&amp;nbsp;미리 계산할 수 있으므로, P가 이 사이의 값이라면 P는 네 자리 수까지 썼을 때의 값이다. 이 P값에서 f(1000)을 뺀 후 4로 나누고, 1000을 더하면, n값을 알 수 있는 것이다.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;실행결과&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 151px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2534803D58E6609202&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2534803D58E6609202&quot; width=&quot;151&quot; height=&quot;185&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;a href=&quot;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1068/1068.cpp&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1068/1068.cpp&lt;/a&gt;&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>코딩</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/284</guid>
      <comments>https://tibyte.tistory.com/284#entry284comment</comments>
      <pubDate>Fri, 7 Apr 2017 00:38:48 +0900</pubDate>
    </item>
    <item>
      <title>한표 (수강신청 시간표 짜기 프로그램)</title>
      <link>https://tibyte.tistory.com/282</link>
      <description>&lt;p&gt;2015년 12월부터 만들기 시작한 시간표 프로그램.&lt;/p&gt;&lt;p&gt;수강신청을 할 때 선택한 과목의 시간을 바로바로 알 수 있는 웹페이지이다.&lt;/p&gt;&lt;p&gt;과목코드, 과목명, 교수님 검색이 가능하며 이미지저장기능과 공유기능이 있다.&lt;/p&gt;&lt;p&gt;아직 전체적으로 미완성인 상태이며 점차 새로운 기능을 추가할 계획...&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Javascript, jQuery3, Ajax 사용.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;사이트 주소 : &lt;a href=&quot;http://hanpyo.com&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://hanpyo.com&lt;/a&gt;&lt;/p&gt;&lt;p&gt;소스코드 :&amp;nbsp;https://github.com/zetagate/hanpyo (라이센스 : GPL v3)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 403px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2413AE4E5896068E01&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2413AE4E5896068E01&quot; width=&quot;403&quot; height=&quot;341&quot; filename=&quot;캡처.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>만든프로그램</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/282</guid>
      <comments>https://tibyte.tistory.com/282#entry282comment</comments>
      <pubDate>Sat, 4 Feb 2017 23:48:21 +0900</pubDate>
    </item>
    <item>
      <title>2016년 블로그 결산</title>
      <link>https://tibyte.tistory.com/281</link>
      <description>&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;티스토리 블로그 결산(&lt;a href=&quot;http://tistory.com/thankyou/2016&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://tistory.com/thankyou/2016&lt;/a&gt;)기능을 사용해보았습니다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2626DA37586E45532C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2626DA37586E45532C&quot; width=&quot;618&quot; height=&quot;399&quot; filename=&quot;캡처5.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/263AEA37586E45541D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F263AEA37586E45541D&quot; width=&quot;618&quot; height=&quot;377&quot; filename=&quot;캡처9.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2222A937586E45542F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2222A937586E45542F&quot; width=&quot;618&quot; height=&quot;376&quot; filename=&quot;캡처6 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/264D6037586E45550D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F264D6037586E45550D&quot; width=&quot;618&quot; height=&quot;455&quot; filename=&quot;캡처6.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/273A9037586E45561D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F273A9037586E45561D&quot; width=&quot;618&quot; height=&quot;404&quot; filename=&quot;캡처91.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 420px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/263C3B33586E46550A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F263C3B33586E46550A&quot; width=&quot;420&quot; height=&quot;302&quot; filename=&quot;캡처4 (2).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>블로그소식</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/281</guid>
      <comments>https://tibyte.tistory.com/281#entry281comment</comments>
      <pubDate>Thu, 5 Jan 2017 22:13:05 +0900</pubDate>
    </item>
    <item>
      <title>XOR연산자를 이용한 그림</title>
      <link>https://tibyte.tistory.com/280</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;xor연산자를 사용하여 Javascript로 canvas에 간단한 패턴 이미지를 그려보았다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;for(var i=0; i&amp;lt;height; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;for(var j=0; j&amp;lt;width; j++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pixels[i*width + j] = (i^j)%256;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;}&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 400px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2618FB355867E9A901&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2618FB355867E9A901&quot; width=&quot;400&quot; height=&quot;400&quot; filename=&quot;캡처4 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;xor연산자 대신 atan2()함수를 사용한 결과&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for(var i=0; i&amp;lt;height; i++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(var j=0; j&amp;lt;width; j++) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var dist = getDist(j-width/2, i-height/2); &amp;nbsp;//거리&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var dir = getDir(j-width/2, i-height/2); &amp;nbsp;//각도&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pixels[i*width + j] = (256-dist)/(dir/96);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 411px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/25190A355867E9A901&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F25190A355867E9A901&quot; width=&quot;411&quot; height=&quot;417&quot; filename=&quot;캡처6 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;전체 소스코드 : https://github.com/tibyte/visual/tree/master/xor&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>만든프로그램</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/280</guid>
      <comments>https://tibyte.tistory.com/280#entry280comment</comments>
      <pubDate>Sun, 1 Jan 2017 02:26:14 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 유일한 수 두개</title>
      <link>https://tibyte.tistory.com/279</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;출처&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech Onlinejudge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1074&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제이해&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;-50000이상 50000이하 정수로 이루어진&amp;nbsp;배열이 입력된다. 두 개의 수를 제외한 나머지 수는 모두 2개씩 존재한다. 단 하나씩만 존재하는 두 수를 크기가 작은 것부터 출력하는 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제접근&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;유일한 수를 찾는 문제에서는(&lt;a href=&quot;http://tibyte.kr/226&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;) 모든 배열원소들을 XOR연산으로 누적하여 쉽게 구할 수 있었다. 그러나 이 문제에서는 2개를 찾아야 하므로 단순히 XOR로는 구할 수 없다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;1. 배열 이용&lt;/b&gt;&lt;/p&gt;&lt;p&gt;입력되는 수의 범위가 -50000부터 50000까지 100001크기의 범위이므로 크기 100001짜리 배열을 만들고, 모든 인자를 0으로 초기화한 후, 입력배열을 순차탐색하면서 해당 입력값을 인덱스로 하는 배열위치에 1을 더한다. 이 과정이 끝났을 때 1이 기록되어 있는 위치를 출력하면 된다.&amp;nbsp;이 방법의 한계는&amp;nbsp;입력되는 수의 범위가 더 클 경우 적용할 수 없다는 것이다.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. std::map 이용&lt;/b&gt;&lt;/p&gt;&lt;p&gt;입력되는 수를 std::find()로 찾아서 값이 있으면 std::erase()로 지우고 없으면 추가한다.&lt;/p&gt;&lt;p&gt;최종적으로 남은 요소를 출력하면 된다&lt;/p&gt;&lt;p&gt;std::map은 rbtree로 되어있기 때문에 각 연산이 O(logn)이며 입력의 수만큼 반복하게 되므로 복잡도는 O(nlogn)이 된다.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;3. 비트연산(XOR) 이용&lt;/b&gt;&lt;/p&gt;&lt;p&gt;(참고 :&amp;nbsp;&lt;a href=&quot;http://www.geeksforgeeks.org/find-two-non-repeating-elements-in-an-array-of-repeating-elements/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://www.geeksforgeeks.org/find-two-non-repeating-elements-in-an-array-of-repeating-elements/&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;XOR연산으로도 이 문제를 풀 수 있다. 우선 모든 수를 XOR연산으로 누적하면 하나의 수가 나오는데, 이것은 답으로 출력해야 할 두 수의 XOR연산결과이다. 이 결과에서&amp;nbsp;rightmost set bit(낮은 비트부터 봤을 때 1이 처음으로 나타나는 위치)을 찾는다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;예를 들어 XOR결과가 이진수로 1101000라고 하자. rightmost set bit을 제외한 나머지 비트들을 0으로 하면 0001000이 된다. 이것은 모든 입력값들 중에서 해당 위치에 1이 쓰여진 원소가 홀수 개라는 뜻이 된다. 즉, 구하고자 하는 답 중에서 하나는 해당 위치에 1이 쓰여진 원소들 중에서 나오고, 다른 하나는 해당 위치에 0이 쓰여진 원소들 중에서 나온다는 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이제 다시 모든 원소들을 위에서 구한 XOR값(위 예시에서는 0001000)과 비트 AND 연산을 하면서, 결과가 1인 경우와, 결과가 0인 경우로 나누어&amp;nbsp;각각 XOR연산으로 누적한다.&amp;nbsp;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp;for(int i=0; i&amp;lt;N; ++i) {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if(arr[i]&amp;amp;det) {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;xora ^= arr[i];&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;xorb ^= arr[i];&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;문제의 조건에 따라, 구한 두 값을 크기순서로 출력하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;구현&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;이 문제에서 필요한 rightmost set bit의 형태는 위치값이 아니라, 해당 비트만 1로 세팅된 수이기 때문에 아래와 같은 간단한 연산으로 구할 수 있다. &amp;nbsp;(1101000을 예시로 하여 직접 계산해 보면 이해할 수 있다.)&lt;/p&gt;&lt;p&gt;num&amp;amp;(~num+1)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이 연산을 잘 보면, 2의보수를 구하고 있는 형태이기 때문에&lt;/p&gt;&lt;p&gt;num&amp;amp;-num 으로도 쓸 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1074/1074.c&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/279</guid>
      <comments>https://tibyte.tistory.com/279#entry279comment</comments>
      <pubDate>Thu, 8 Dec 2016 02:17:00 +0900</pubDate>
    </item>
    <item>
      <title>오각형 테셀레이션 그리기</title>
      <link>https://tibyte.tistory.com/278</link>
      <description>&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;보로노이 다이어그램을 이용하여 오각형 Type 5 테셀레이션을 그려보았다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;(1) 사잇각이&amp;nbsp;60도인 기준점들을 찍는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 200px; width: 200px; height: 201px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/251A85455839A0D522&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F251A85455839A0D522&quot; width=&quot;200&quot; height=&quot;201&quot; filename=&quot;캡처8.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 200px; height: 201px;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;(2) 기준점을 중심으로 하여 일정한 각도로 6개의 시드 점을 찍는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 200px; width: 200px; height: 201px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2359FF455839A0D528&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2359FF455839A0D528&quot; width=&quot;200&quot; height=&quot;201&quot; filename=&quot;캡처9.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 200px; height: 201px;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;(3) 시드점을 기준으로 시드점에서 가장 가까운 거리에 있는 픽셀들끼리 묶어서 평면을 분할한다.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 200px; width: 200px; height: 201px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/21613C455839A0D626&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F21613C455839A0D626&quot; width=&quot;200&quot; height=&quot;201&quot; filename=&quot;캡처91.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 200px; height: 201px;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;(4) 완성된 테셀레이션&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 200px; width: 200px; height: 200px;; height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2363CA455839A0D71D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2363CA455839A0D71D&quot; width=&quot;200&quot; height=&quot;200&quot; filename=&quot;캡처92.PNG&quot; filemime=&quot;image/jpeg&quot; style=&quot;width: 200px; height: 200px;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;소스코드&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;a href=&quot;https://github.com/tibyte/visual/blob/master/tessellation&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/visual/blob/master/tessellatio&lt;/a&gt;&lt;a href=&quot;https://github.com/tibyte/visual/blob/master/tessellation&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;n&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;캔버스의 크기가 작아서 외접원을 구하지 않고 단순 반복문으로 구현...&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;table class=&quot;highlight tab-size js-file-line-container&quot; data-tab-size=&quot;8&quot; style=&quot;box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 8; color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; width: 537px;&quot; width=&quot;537&quot;&gt;&lt;tbody style=&quot;box-sizing: border-box;&quot;&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC9&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; ctx;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC10&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC11&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; width;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC12&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; height;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC13&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC14&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; pixels &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; [];&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC15&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; points &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; [];&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC16&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC17&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; numPoints &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC18&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC19&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;init&lt;/span&gt;()&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC20&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC21&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  canvas &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;getElementById&lt;/span&gt;(&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;canvas&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC22&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  ctx &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;canvas&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;getContext&lt;/span&gt;(&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;2d&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC23&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC24&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;canvas&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;width&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC25&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  height &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;canvas&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;height&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC26&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC27&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;height; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC28&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;width; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC29&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC30&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC31&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC32&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC33&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC34&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;10&lt;/span&gt;; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC35&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;10&lt;/span&gt;; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC36&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; cx &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;100&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC37&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; cy &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;92&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;250&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC38&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;6&lt;/span&gt;; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC39&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        points[numPoints] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; {};&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC40&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; cx &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;cos&lt;/span&gt;(k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;PI&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;180&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;PI&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC41&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; cy &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;sin&lt;/span&gt;(k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;PI&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;180&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;PI&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC42&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC43&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; rr &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; (points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt;)&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;8&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC44&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; rg &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; (points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;4&lt;/span&gt;)&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;8&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC45&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; rb &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; (points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;points[numPoints].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;8&lt;/span&gt;)&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;8&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC46&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC47&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        rr &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;floor&lt;/span&gt;(rr);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC48&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        rg &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;floor&lt;/span&gt;(rg);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC49&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        rb &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;floor&lt;/span&gt;(rb);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC50&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC51&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        points[numPoints].&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;rgb(&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;rr&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;rg&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;rb&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;)&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC52&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC53&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;numPoints;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC54&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC55&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC56&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC57&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC58&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;fill&lt;/span&gt;(ctx);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC59&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;edge&lt;/span&gt;(ctx);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC60&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-c&quot; style=&quot;box-sizing: border-box; color: rgb(150, 152, 150);&quot;&gt;//point(ctx);&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC61&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC62&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC63&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC64&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;fill&lt;/span&gt;(&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC65&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC66&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;height; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC67&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;width; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC68&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; min &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; width&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;height&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;height;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC69&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; minK &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC70&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;numPoints; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC71&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; dy &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;points[k].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC72&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; dx &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;points[k].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC73&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; dist &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; dx&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;dx&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;dy&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;dy;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC74&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;if&lt;/span&gt;(dist &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt; min) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC75&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;          min &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; dist;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC76&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;          minK &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; k;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC77&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC78&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC79&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; points[minK].&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;c&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC80&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;fillStyle&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; points[minK].&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;c&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC81&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;fillRect&lt;/span&gt;(j, i, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC82&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    }&lt;span class=&quot;pl-c&quot; style=&quot;box-sizing: border-box; color: rgb(150, 152, 150);&quot;&gt;//end j loop&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC83&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC84&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC85&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC86&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;edge&lt;/span&gt;(&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC87&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC88&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;height; i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC89&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;width; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC90&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;if&lt;/span&gt;(pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;!=&lt;/span&gt; pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;||&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC91&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;          pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;!=&lt;/span&gt; pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;||&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC92&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;          pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;!=&lt;/span&gt; pixels[(i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;)&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;||&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC93&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;          pixels[i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j] &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;!=&lt;/span&gt; pixels[(i&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;)&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;*&lt;/span&gt;width &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;+&lt;/span&gt; j]) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC94&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;fillStyle&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC95&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;        &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;fillRect&lt;/span&gt;(j, i, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;1&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC96&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;      }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC97&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC98&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC99&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC100&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC101&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;point&lt;/span&gt;(&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC102&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC103&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;var&lt;/span&gt; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;0&lt;/span&gt;; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;&amp;lt;&lt;/span&gt;numPoints; k&lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;++&lt;/span&gt;) {&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC104&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;aa&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC105&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;fillStyle&lt;/span&gt; &lt;span class=&quot;pl-k&quot; style=&quot;box-sizing: border-box; color: rgb(167, 29, 93);&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;pl-s&quot; style=&quot;box-sizing: border-box; color: rgb(24, 54, 145);&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;#000000&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC106&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;    &lt;span class=&quot;pl-smi&quot; style=&quot;box-sizing: border-box;&quot;&gt;ctx&lt;/span&gt;.&lt;span class=&quot;pl-en&quot; style=&quot;box-sizing: border-box; color: rgb(121, 93, 163);&quot;&gt;fillRect&lt;/span&gt;(points[k].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;x&lt;/span&gt;, points[k].&lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;y&lt;/span&gt;, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;pl-c1&quot; style=&quot;box-sizing: border-box; color: rgb(0, 134, 179);&quot;&gt;2&lt;/span&gt;);&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC107&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;  }&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;box-sizing: border-box;&quot;&gt;&lt;td id=&quot;LC108&quot; class=&quot;blob-code blob-code-inner js-file-line&quot; style=&quot;box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 12px; color: rgb(51, 51, 51); word-wrap: normal; white-space: pre;&quot;&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>만든프로그램</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/278</guid>
      <comments>https://tibyte.tistory.com/278#entry278comment</comments>
      <pubDate>Sun, 27 Nov 2016 00:02:51 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 펠린드롬 만들기</title>
      <link>https://tibyte.tistory.com/277</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;출처&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech OnlineJudge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1060&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제이해&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;5000자 이하의 문자가 입력으로 주어지고, 임의의 위치에 문자를 추가하여 펠린드롬으로 만들 때 추가하는 문자의 개수를 최소화하면, 몇 개인지를 구하는 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제접근&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;동적 프로그래밍 문제이다.&lt;/p&gt;&lt;p&gt;인덱스 a부터 인덱스 b까지의 구역에 대해 펠린드롬을 만들기 위한 최소비용을 D[a][b]라고 하자. D[a][b]를 한 단계 작은 계산결과로 구하기 위해 두 가지 조건을 따져봐야 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1. 구역의 맨 앞과 맨 뒤가 같은 문자인 경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 305px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/225B2C415834409C34&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F225B2C415834409C34&quot; width=&quot;305&quot; height=&quot;57&quot; filename=&quot;캡처8.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;D[a][b] (구역의 전체)는 D[a+1][b-1] (회색 부분)와 같다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;2. 구역의 맨 앞과 맨 뒤가 다른 문자인 경우&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 301px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/240599415834409D10&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F240599415834409D10&quot; width=&quot;301&quot; height=&quot;60&quot; filename=&quot;캡처9.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 304px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/217A59415834409D1A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F217A59415834409D1A&quot; width=&quot;304&quot; height=&quot;63&quot; filename=&quot;캡처91.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;D[a][b] = 1+min(D[a][b-1], D[a+1][b])&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;a부터 b-1까지의 부분구역과, a+1부터 b까지의 부분구역 중에서 비용이 작은 것을 선택하여 거기에 1을 더한 값을 D[a][b]로 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Top-down 방식으로 점화식을 해결하면 시간복잡도가 지수함수가 되므로, 아래에서부터 누적하여 구해야 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;구간의 길이를 1부터 전체까지 늘려 가며 데이터를 얻는 것이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;a href=&quot;http://tibyte.kr/271&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;전에 포스팅했던 이 문제&lt;/a&gt;와 같은 아이디어이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 301px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2502FA44583442E52F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2502FA44583442E52F&quot; width=&quot;301&quot; height=&quot;116&quot; filename=&quot;캡처3.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 301px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/24139D44583442E61F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F24139D44583442E61F&quot; width=&quot;301&quot; height=&quot;114&quot; filename=&quot;캡처4 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 301px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/272EF144583442E606&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F272EF144583442E606&quot; width=&quot;301&quot; height=&quot;114&quot; filename=&quot;캡처4 (2).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 304px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2514B444583442E71E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2514B444583442E71E&quot; width=&quot;304&quot; height=&quot;105&quot; filename=&quot;캡처5 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 303px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/242F1344583442E706&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F242F1344583442E706&quot; width=&quot;303&quot; height=&quot;102&quot; filename=&quot;캡처6 (1).PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;구현&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;다음과 같이 전처리하면 복잡하지 않게 반복문을 짤 수 있다.&lt;/p&gt;&lt;p&gt;- 구간의 길이가 1인 경우 D값은 0으로 한다.&lt;/p&gt;&lt;p&gt;- 구간의 길이가 2인 경우 D값은, 두 문자가 같을 때 0, 다를 때 1로 한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1060/1060.cpp&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/277</guid>
      <comments>https://tibyte.tistory.com/277#entry277comment</comments>
      <pubDate>Tue, 22 Nov 2016 22:11:06 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 순환 소수</title>
      <link>https://tibyte.tistory.com/276</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;출처&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech OnlineJudge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1008&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제이해&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;입력으로 두 수 A, B가 주어지고 A/B를 순환마디를 표시하여 출력하는 문제이다.&lt;/p&gt;&lt;p&gt;예를 들어 0.123579579579... 를 출력한다고 하면 0.123(579)와 같이 출력하는 것이다.&lt;/p&gt;&lt;p&gt;만약 입력이 1, 4로 계산결과가 0.25가 되어 나누어 떨어진다면 0.25(0)처럼 표현한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제접근&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 406px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/224F0D415831930734&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F224F0D415831930734&quot; width=&quot;406&quot; height=&quot;127&quot; filename=&quot;캡처5.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;출력해야 할 수가 그림과 같이 0.123579579579... 라면&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;순환마디 시작점인 a와 끝점인 b를 구해야 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그렇다면 순환마디가 어디까지인지는 어떻게 구해야 할까?&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;나눗셈을 할 때 매 과정마다 몫과 나머지가 나오고 나머지를 다시 나누는 과정을 반복하는데, 매 과정마다 이 나머지 값을 저장해 두고, 저장됐던 나머지와 같은 값이 나올 때 반복을 종료한다. 이 때 해당 나머지 값이 처음 나온 부분이 순환마디의 시작이며, 다시 나온 부분이 순환마디의 끝이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;구현&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;매 과정마다 나머지 값이 이미 저장되어 있는지 검사해야 하므로 STL map을 사용하면 적절하다. STL map은 레드-블랙 트리를 사용하고, map::find()는 O(logn)으로 어떤 원소가 존재하고 있는지 검사할 수 있다.&lt;/p&gt;&lt;p&gt;반복문의 종료조건은 아래와 같이 두 가지이다.&lt;/p&gt;&lt;p&gt;- 나머지가 0이 되었을 때 (유한소수)&lt;/p&gt;&lt;p&gt;- map::find()값이 map::end()와 다를 때 (나머지값이 중복하여 등장했을 때)&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;printf()함수를 사용하여 출력할 때&lt;/p&gt;&lt;p&gt;printf(&quot;%.*s&quot;, length, str);&lt;/p&gt;&lt;p&gt;의 형태로 사용하면 str이라는 char배열을 length길이만큼 출력할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;실행결과&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 415px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2754A73A583196B22D&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2754A73A583196B22D&quot; width=&quot;415&quot; height=&quot;92&quot; filename=&quot;캡처6.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;코드에서 for(;~scanf.... 와 같이 되어 있는 부분은 문제를 빨리 풀기 위해 작성한 것으로, 데이터를 입력할 때 EOF를 입력해 주어야 프로그램이 제대로 완료된다.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1008/1008.cpp&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1008/1008.cpp&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/276</guid>
      <comments>https://tibyte.tistory.com/276#entry276comment</comments>
      <pubDate>Sun, 20 Nov 2016 21:32:52 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 걸기 쉬운 전화번호</title>
      <link>https://tibyte.tistory.com/275</link>
      <description>&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;출처&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech OnlineJudge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1057&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제이해&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;전화번호를 누를 때 연속된 각 번호가 상하좌우로 한 칸씩만 떨어져 있는 번호를 '걸기 쉬운 전화번호'라고 한다. 예를 들어 1236987412는 '걸기 쉬운 전화번호'이다.&lt;/p&gt;&lt;p&gt;999와 같이 같은 숫자가 연속하여 나오면 이에 해당하지 않는다.&lt;/p&gt;&lt;p&gt;길이가 N인 '걸기 쉬운 전화번호'를 구하는 문제이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 342px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/256E803B582C72D105&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F256E803B582C72D105&quot; width=&quot;342&quot; height=&quot;262&quot; filename=&quot;캡처3.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;문제접근&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;DP(동적 프로그래밍)로 해결할 수 있는 문제이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;길이가 n이고, m으로 끝나는 '걸기 쉬운 전화번호'를 f(n, m)으로 정의한다.&lt;/p&gt;&lt;p&gt;그러면 길이가 n인 '걸기 쉬운 전화번호'의 개수는&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/2179AF3A582C723608&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28%5Csum%20_%7B%20k%3D0%20%7D%5E%7B%2010%20%7D%7B%20f%28n%2C%5Cquad%20k%29%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;107&quot; height=&quot;65&quot;&gt;&lt;/p&gt;&lt;p&gt;이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 길이가 n일 때의 경우의 수는 길이가 n-1일 때를 사용하여 구할 수 있다.&lt;/p&gt;&lt;p&gt;예를 들어, f(n, 2)는 f(n-1, 1) + f(n-1, 3) + f(n-1, 5)로 나타낼 수 있는데, 2와 인접해 있는 숫자가 1, 3, 5이기 때문이다.&lt;/p&gt;&lt;p&gt;다시 말하면 끝자리가 1이나 3, 또는 5인 전화번호 다음에만 2가 붙을 수 있다는 것이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이런 방법으로 0부터 9까지의 숫자에 대해 점화식을 세워 보면 다음과 같다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;f(n, 0) = f(n-1, 8)&lt;/p&gt;&lt;p&gt;f(n, 1) = f(n-1, 2) + f(n-1, 4)&lt;/p&gt;&lt;p&gt;f(n, 2) = f(n-1, 1) + f(n-1, 3)&amp;nbsp;+ f(n-1, 5)&amp;nbsp;&lt;/p&gt;&lt;p&gt;f(n, 3) = f(n-1, 2) + f(n-1, 6)&lt;/p&gt;&lt;p&gt;f(n, 4) = f(n-1, 1) + f(n-1, 5) + f(n-1, 7)&lt;/p&gt;&lt;p&gt;f(n, 5) = f(n-1, 2) + f(n-1, 4) + f(n-1, 6) + f(n-1, 8)&lt;/p&gt;&lt;p&gt;f(n, 6) = f(n-1, 3) + f(n-1, 5) + f(n-1, 9)&lt;/p&gt;&lt;p&gt;f(n, 7) = f(n-1, 4) + f(n-1, 8)&lt;/p&gt;&lt;p&gt;f(n, 8) = f(n-1, 0) + f(n-1, 5) + f(n-1, 7) + f(n-1, 9)&lt;/p&gt;&lt;p&gt;f(n, 9) = f(n-1, 6) + f(n-1, 8)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;bottom-up 방식으로 메모이제이션을 하면 답을 구할 수 있다.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;구현&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;각 번호에 대해, 길이가 1일 때의 초기값은 1로 한다.&lt;/p&gt;&lt;p&gt;f(1, 0) = f(1, 1) = f(1, 2) = ... = f(1, 8) = f(1, 9) = 1&lt;/p&gt;&lt;p&gt;이기 때문이다. (이 경우에 답은 10이 된다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;길이가 2일때 위 0~9에 대해 점화식을 한 번 시행하면 되고,&lt;/p&gt;&lt;p&gt;길이가 3일때는 두 번 시행하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;주의할 점은 mod 1,000,000,007을 연산해야 한다는 것인데,&lt;/p&gt;&lt;p&gt;점화식에서 최대 4개의 항을 더하므로 32비트 unsigned int이상의 자료형을 사용하면 편하게 구현할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;코드&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1057/1057.c&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1057/1057.c&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/275</guid>
      <comments>https://tibyte.tistory.com/275#entry275comment</comments>
      <pubDate>Thu, 17 Nov 2016 00:14:45 +0900</pubDate>
    </item>
    <item>
      <title>Django에서 MySQL/MariaDB 사용시 Strict Mode Warning</title>
      <link>https://tibyte.tistory.com/274</link>
      <description>&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;
Django에서 MySQL이나 MariaDB를 사용할 때 해당 데이터베이스가 Strict Mode가 아니면&lt;/p&gt;&lt;p&gt;&quot;MySQL Strict Mode is not set for database connection 'default'&quot; 라는 경고가 발생한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/223532485829332432&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F223532485829332432&quot; width=&quot;618&quot; height=&quot;118&quot; filename=&quot;2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;프로젝트명/settings.py의 DATABASES 설정 부분에서 OPTIONS에&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot; style=&quot;border: none; border-collapse: collapse;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt; 'init_command': &quot;SET sql_mode='STRICT_TRANS_TABLES'&quot;,&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;를 추가하면 된다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/25505F4E5829333C02&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F25505F4E5829333C02&quot; width=&quot;618&quot; height=&quot;172&quot; filename=&quot;090-setstrictdb.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;참고 : &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>프로그래밍</category>
      <category>Django</category>
      <category>sql</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/274</guid>
      <comments>https://tibyte.tistory.com/274#entry274comment</comments>
      <pubDate>Mon, 14 Nov 2016 12:53:58 +0900</pubDate>
    </item>
    <item>
      <title>[알고리즘 문제] 0을 만들자 - Large</title>
      <link>https://tibyte.tistory.com/273</link>
      <description>&lt;p&gt;&lt;b&gt;출처&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Koreatech OnlineJudge(&lt;a href=&quot;http://judge.koreatech.ac.kr/problem.php?id=1005&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;링크&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;문제이해&lt;/b&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;수열에서 수를 3개 뽑아서 합이 0이 되는 경우의 수를 구한다. 중복되는 경우는 계산하지 않는다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
문제접근&lt;/b&gt;&lt;/p&gt;&lt;p&gt;단순히 3중 for문으로 반복하여 찾으면 시간복잡도는 O(n^3)으로, 시간초과가 나서 통과하지 못한다.&lt;/p&gt;&lt;p&gt;세 수 i, j, k가 있을 때 i를 처음부터 한 칸씩 증가시키면서 각 i에 대해 &amp;nbsp;j와 k를 찾으면 빠른데,&lt;/p&gt;&lt;p&gt;이 방법을 사용하려면 먼저 &lt;b&gt;수열을 정렬해야 한다.&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 475px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/253E6643582333B72A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F253E6643582333B72A&quot; width=&quot;475&quot; height=&quot;75&quot; filename=&quot;2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;i+j+k &amp;gt;&amp;nbsp;0이면&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;k를 감소시키고,&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;i+j+k &amp;lt;&amp;nbsp;0이면,&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;j를 증가시킨다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;i+j+k = 0이면,&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;경우의 수를 한 번 카운트하고, k를 감소시키고 j를 증가시킨다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그리고 반복문의 종료조건은 j와 k가 서로 교차했을 때이므로 아래 그림과 같은 경우까지 반복하게 된다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;시간복잡도는 O(n^2)이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 472px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2438CE43582333B72F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F2438CE43582333B72F&quot; width=&quot;472&quot; height=&quot;73&quot; filename=&quot;캡처6.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;이 부분을 코드로 보면 아래와 같다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;prv 변수는 중복되는 순서쌍을 제외하기위해 만든 변수이다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;(전체 코드는 맨 아래에 있음.)&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;while(j&amp;lt;k) {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;if(arr[i]+arr[j]+arr[k] &amp;gt; 0)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;--k;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else if(arr[i]+arr[j]+arr[k] &amp;lt; 0)&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;++j;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;else {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;if(prv != arr[j]) {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;++cnt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;prv = arr[j];&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;--k;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;++j;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;}&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;구현&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;수열을 정렬할 때 std::sort()를 사용하면 간단하다.&lt;/p&gt;&lt;p&gt;위에서 중복을 제거하는 부분이 있었는데, 바깥쪽 반복문에서 i, j, k 중 i가 중복되는 경우 또한 제거한다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
실행결과&amp;nbsp;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 258px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/24469844582336B80F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F24469844582336B80F&quot; width=&quot;258&quot; height=&quot;55&quot; filename=&quot;2.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;
코드
&lt;/b&gt;&lt;br /&gt;&lt;a href=&quot;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1005/1005.cpp&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/algorithm-problems/blob/master/koreatech/1005/1005.cpp&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>알고리즘 문제</category>
      <category>알고리즘</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/273</guid>
      <comments>https://tibyte.tistory.com/273#entry273comment</comments>
      <pubDate>Wed, 9 Nov 2016 23:48:18 +0900</pubDate>
    </item>
    <item>
      <title>안드로이드 스튜디오 NDK에서 C++11, STL 사용하기</title>
      <link>https://tibyte.tistory.com/272</link>
      <description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;메모형식으로 작성한 글입니다..&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;안드로이드 스튜디오에서 NDK로 C++11과 STL을 사용한 소스를 빌드하는 법.&lt;/p&gt;&lt;p&gt;C++가 아닌 C를 사용할 때는 makefile과 소스코드에서&amp;nbsp;약간의 차이가 있다. (본문 내에서 설명)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;테스트 환경&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Android Studio : 2.2.2&lt;/p&gt;&lt;p&gt;Gradle : 2.2.2&lt;/p&gt;&lt;p&gt;buildToolsVersion&amp;nbsp;: 24.0.0&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;테스트 소스 코드&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/tibyte/practice-unclassified/tree/master/Android/NDKTest3&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://github.com/tibyte/practice-unclassified/tree/master/Android/NDKTest3&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;NDK 설치&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;File - Settings - Appearance &amp;amp; Behavior - System Settings - Android SDK&lt;/p&gt;&lt;p&gt;에서 SDK Tools로 들어가면 NDK를 설치할 수 있다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 484px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/277826505820988809&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F277826505820988809&quot; width=&quot;484&quot; height=&quot;458&quot; filename=&quot;00.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;javah 추가&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;File - Settings - Tools - External Tools에서 추가를 눌러 javah를 추가한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;하단의 Tool settings에 들어갈 내용은 아래와 같다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Program : jdk에 포함되어 있는 javah의 경로&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Parameters : -v -jni -d $ModuleFileDir$/src/main/jni $FileClass$&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Working directory : $SourcepathEntry$&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 618px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/216CFE505820988816&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F216CFE505820988816&quot; width=&quot;618&quot; height=&quot;405&quot; filename=&quot;10.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;java코드에서 네이티브 함수 사용&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;System.loadLibrary()로 사용할 라이브러리를 로드한다. &amp;nbsp;라이브러리 이름은 임의로 정해도 되는데, 이 글에서는 main.cpp를 만들 것이므로 여기에서는 main으로 정한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그리고 사용할 네이티브 함수명을 native키워드를 통해 선언한다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;pre style=&quot;background-color: rgb(255, 255, 255); font-family: 굴림체; font-size: 9pt;&quot;&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;package &lt;/span&gt;kr.tibyte.ndktest3;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;import &lt;/span&gt;android.app.Activity;&lt;br /&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;import &lt;/span&gt;android.os.Bundle;&lt;br /&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;import &lt;/span&gt;android.widget.TextView;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;public class &lt;/span&gt;MainActivity &lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;extends &lt;/span&gt;Activity {&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;static &lt;/span&gt;{&lt;br /&gt;        System.&lt;span style=&quot;font-style:italic;&quot;&gt;loadLibrary&lt;/span&gt;(&lt;span style=&quot;color:#008000;font-weight:bold;&quot;&gt;&quot;main&quot;&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;    &lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;public native &lt;/span&gt;String getNativeText();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style=&quot;color:#808000;&quot;&gt;@Override&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#808000;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;protected void &lt;/span&gt;onCreate(Bundle savedInstanceState) {&lt;br /&gt;        &lt;span style=&quot;color:#000080;font-weight:bold;&quot;&gt;super&lt;/span&gt;.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.&lt;span style=&quot;color:#660e7a;font-weight:bold;font-style:italic;&quot;&gt;activity_main&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        TextView tv = (TextView)findViewById(R.id.&lt;span style=&quot;color:#660e7a;font-weight:bold;font-style:italic;&quot;&gt;text_view&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        tv.setText(getNativeText());&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;span style=&quot;font-family: 굴림체; font-size: 9pt;&quot;&gt;}&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;JNI용 헤더파일 생성&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;프로젝트 탭에서 보기 설정을 Project로 한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 403px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/25599A50582098892F&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F25599A50582098892F&quot; width=&quot;403&quot; height=&quot;337&quot; filename=&quot;30.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;네이티브 함수를 사용한 Java파일을 우클릭하여 External Tools - javah를 클릭한다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;그러면 src/main/jni 경로에 프로젝트_경로.h파일이 생성된다.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 519px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/217795505820988A0A&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F217795505820988A0A&quot; width=&quot;519&quot; height=&quot;646&quot; filename=&quot;40.PNG&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;C++ 소스코드 작성&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;JNI디렉토리&amp;nbsp;내에 cpp파일을 만들고 소스코드를 작성하는데,&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;함수 이름에 패키지&amp;nbsp;경로가 들어있어야 한다. 이 부분이 실제 패키지&amp;nbsp;경로와&amp;nbsp;다르면 빌드가 되지 않는다. 아래 예제에서는 테스트 목적으로 STL과 C++11 기능을 사용했다.&amp;nbsp;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;#include &amp;lt;jni.h&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;vector&amp;gt;&lt;/p&gt;&lt;p&gt;#include &amp;lt;string&amp;gt;&lt;/p&gt;&lt;p&gt;#include &quot;kr_tibyte_ndktest3_MainActivity.h&quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;using namespace std;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;extern &quot;C&quot; {&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;JNIEXPORT jstring JNICALL Java_kr_tibyte_ndktest3_MainActivity_getNativeText(JNIEnv *env, jobject obj)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; string str = &quot;&quot;;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vector&amp;lt;char&amp;gt; vec;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vec.push_back('a');&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vec.push_back('b');&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; vec.push_back('c');&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for(auto&amp;amp; x : vec) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x ^= 32;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; str += x;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; return env-&amp;gt;NewStringUTF(str.c_str());&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;}&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;clear: none; float: none;&quot;&gt;이 부분에서 C와 C++의 차이는 다음과&amp;nbsp;같다.&lt;/p&gt;&lt;div&gt;- 소스코드 확장자 (.c, .cpp)&lt;/div&gt;&lt;div&gt;- C++문법 사용여부&lt;/div&gt;&lt;div&gt;- C++에서는 함수 형식이&amp;nbsp;JNIEXPORT jstring JNICALL이지만, C에서는 jstring&lt;/div&gt;&lt;div&gt;- JNI함수를 호출할 때&amp;nbsp;C++에서는 env-&amp;gt;NewStringUTF(&quot;string&quot;) 형식을 사용하지만,&lt;/div&gt;&lt;div&gt;&amp;nbsp;C에서는 (*env)-&amp;gt;NewStringUTF(env, &quot;string&quot;); 형식으로 리턴.&lt;/div&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;- C++에서 extern으로 네임 맹글링을 어떤 규칙으로 할 것인지 지정(&lt;a href=&quot;http://develog.tistory.com/entry/JNI%EC%97%90%EC%84%9C-C%EC%99%80-C%EC%9D%98-%EC%B0%A8%EC%9D%B4%EC%A0%90&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;참고링크&lt;/a&gt;)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Makefile 설정&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;jni디렉토리&amp;nbsp;안에 Android.mk와 Application.mk 파일을 생성하고 각각 아래와 같은 내용을 적는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Android.mk&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;LOCAL_PATH := $(call my-dir)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;include $(CLEAR_VARS)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;LOCAL_DEFAULT_CPP_EXTENSION := cpp&lt;/p&gt;&lt;p&gt;LOCAL_MODULE &amp;nbsp; &amp;nbsp;:= main&lt;/p&gt;&lt;p&gt;LOCAL_SRC_FILES := main.cpp&lt;/p&gt;&lt;p&gt;LOCAL_LDLIBS &amp;nbsp; &amp;nbsp;:= -llog -latomic&lt;/p&gt;&lt;p&gt;LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;include $(BUILD_STATIC_LIBRARY)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;C로 빌드할 때에는 LOCAL_DEFAULT_CPP_EXTENSION := cpp가 필요하지 않다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;LOCAL_MODULE과 LOCAL_SRC_FILES는 작성한 C/C++네이티브 소스파일과 관련된 내용을 적는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;Application.mk&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;NDK_TOOLCHAIN_VERSION := 4.9&lt;/p&gt;&lt;p&gt;APP_STL := gnustl_static&lt;/p&gt;&lt;p&gt;APP_MODULED := main&lt;/p&gt;&lt;p&gt;APP_ABI := armeabi-v7a&lt;/p&gt;&lt;p&gt;APP_CPPFLAGS += -std=c++11&lt;/p&gt;&lt;p&gt;LOCAL_C_INCLUDES += ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.9/include&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;NDK_TOOLCHAIN_VERSION :&amp;nbsp;NDK설치경로/sources/cxx-stl/gnu-libstdc++ 에 있는 툴체인 버전을 적는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;APP_STL : 정적 라이브러리를 사용하고 싶을 경우 gnustl_static를, 공유라이브러리를 쓸 대는&amp;nbsp;gnustl_shared를 적을 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;APP_ABI : 빌드할 대상 아키텍쳐를 적는다. all로 적으면 모든 대상으로 빌드할 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;APP_CPPFLAGS : C++11로 빌드하려면 -std=c++11 플래그를 넣는다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;LOCAL_C_INCLUDES : 자신이 가진 버전에 맞는 경로를 적는다. (NDK설치경로 확인)&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;build.gradle ndk 정보 추가&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;src디렉토리 내에 있는&amp;nbsp;defaultConfig안에 다음과 같은 내용을 추가한다.&lt;/p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;582&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:&quot; 맑은=&quot;&quot; 고딕&quot;,=&quot;&quot; sans-serif;font-size:15px&quot;=&quot;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;width:582;height:24;border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;;&quot;&gt;&lt;p&gt;&amp;nbsp;ndk {&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;stl &quot;gnustl_static&quot;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;moduleName &quot;main&quot;&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;stl에서 gnustl_static은 Application.mk에서 설정했던 것과 같은 것이고,&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;moduleName은 Android.mk, Application.mk, java파일에서 썼던 것과 같다.&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;만약 STL을 사용하지 않을 것이면 stl은 작성하지 않아도 된다..&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;실행화면&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;STL vector와 C++11의 auto를 사용한 코드가 정상적으로 빌드된다.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 517px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/216A87505820988B1C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F216A87505820988B1C&quot; width=&quot;517&quot; height=&quot;283&quot; filename=&quot;50.jpg&quot; filemime=&quot;image/jpeg&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Android</category>
      <category>NDK</category>
      <category>안드로이드</category>
      <category>프로그래밍</category>
      <author>티바이트</author>
      <guid isPermaLink="true">https://tibyte.tistory.com/272</guid>
      <comments>https://tibyte.tistory.com/272#entry272comment</comments>
      <pubDate>Tue, 8 Nov 2016 01:16:38 +0900</pubDate>
    </item>
  </channel>
</rss>