[Github] 깃허브 페이지에 카테고리 만들기
카테고리 만들기
1. posts 폴더에 있는 파일에 카테고리 변수 선언
포스팅 파일의 YAML Front Matter에 categories 변수를 선언합니다.
---
layout: single
comments: ...
title: ...
subtitle: ...
description: ...
date: ...
background: ...
...
categories: ['programming', 'python']
---
다른 파일들에도 모두 추가합니다.
---
...
categories: ['programming', 'java']
---
---
...
categories: ['programming', 'ruby']
---
2. 카테고리 변수 가져오기
우리는 카테고리를 블로그의 홈(초기화면)에 띄울 것이다.
위치는 사용자 임의로 지정할 수 있는데, 여기서는 화면의 왼쪽 수직 중앙에 배치해보도록 한다.
layout 폴더에서 홈 화면을 나타내는 home.html에 코드를 작성한다.
가장 바깥 위치의 태그로 < div > 를 추가해준다. 그리고 그 안에 카테고리를 생성한다.
---
layout: archive
---
<div id="main" role="main">
<div class="sidebar sticky">
<div itemscope itemtype="https://schema.org/Person">
<div class="author__avatar">
<img src="/assets/images/avatar_01.jpg" alt="wowo0709" itemprop="image">
</div>
<div class="author__content">
<h3 class="author__name" itemprop="name">wowo0709</h3>
<div class="author__bio" itemprop="description">
<p>큰 사람이 되려면 큰 물에서 놀아라</p>
</div>
</div>
<div class="author__urls-wrapper">
<button class="btn btn--inverse">Follow</button>
<ul class="author__urls social-icons">
<li itemprop="homeLocation" itemscope itemtype="https://schema.org/Place">
<i class="fas fa-fw fa-map-marker-alt" aria-hidden="true"></i> <span itemprop="name">Ilsan, South Korea</span>
</li>
<li><a href="https://github.com/wowo0709" rel="nofollow noopener noreferrer"><i class="fab fa-fw fa-github" aria-hidden="true"></i><span class="label">GitHub</span></a></li>
<li>
<a href="mailto:wjsduddn0709@naver.com">
<meta itemprop="email" content="wjsduddn0709@naver.com" />
<i class="fas fa-fw fa-envelope-square" aria-hidden="true"></i><span class="label">Email</span>
</a>
</li>
<!--
<li>
<a href="http://link-to-whatever-social-network.com/user/" itemprop="sameAs" rel="nofollow noopener noreferrer">
<i class="fas fa-fw" aria-hidden="true"></i> Custom Social Profile Link
</a>
</li>
-->
</ul>
</div>
</div>
<!--전체 글 수를 세기 위한 연산. sum 변수에 전체 글 수 저장-->
<nav class="nav__list">
<input id="ac-toc" name="accordion-toc" type="checkbox" />
<label for="ac-toc">Toggle menu</label>
<ul class="nav__items" id="category_tag_menu">
<!--전체 글 수-->
<li>
📂 <span style="font-family:'Cafe24Oneprettynight';">전체 글 수</style> <span style="font-family:'Coming Soon';">(586)</style> <span style="font-family:'Cafe24Oneprettynight';"></style>
</li>
<li>
<!--span 태그로 카테고리들을 크게 분류 ex) C/C++/C#-->
<span class="nav__sub-title">💪 KPT</span>
<!--ul 태그로 같은 카테고리들 모아둔 페이지들 나열-->
<ul>
<li><a href="/categories/kpt" class="">Keep-Problem-Try (3)</a></li>
</ul>
<span class="nav__sub-title">📖 Language</span>
<!--ul 태그로 같은 카테고리들 모아둔 페이지들 나열-->
<ul>
<!--Python 카테고리 글들을 모아둔 페이지인 /categories/python 주소의 글로 링크 연결-->
<!--category[1].size 로 해당 카테고리를 가진 글의 개수 표시-->
<li><a href="/categories/python" class="">Python (11)</a></li>
</ul>
<ul>
<li><a href="/categories/kotlin" class="">Kotlin (11)</a></li>
</ul>
<span class="nav__sub-title">🧮 Algorithm</span>
<ul>
<li><a href="/categories/math" class="">Math (32)</a></li>
</ul>
<ul>
<li><a href="/categories/string" class="">String (11)</a></li>
</ul>
<ul>
<li><a href="/categories/implementation" class="">Implementation (43)</a></li>
</ul>
<ul>
<li><a href="/categories/bruteforce" class="">Bruteforce (19)</a></li>
</ul>
<ul>
<li><a href="/categories/sorting" class="">Sorting (4)</a></li>
</ul>
<ul>
<li><a href="/categories/backtracking" class="">Backtracking (7)</a></li>
</ul>
<ul>
<li><a href="/categories/greedy" class="">Greedy (7)</a></li>
</ul>
<ul>
<li><a href="/categories/dfsbfs" class="">DFS/BFS (20)</a></li>
</ul>
<ul>
<li><a href="/categories/graph" class="">Graph (21)</a></li>
</ul>
<ul>
<li><a href="/categories/sequentialsearch" class="">SequentialSearch (11)</a></li>
</ul>
<ul>
<li><a href="/categories/stack" class="">Stack (13)</a></li>
</ul>
<ul>
<li><a href="/categories/queue" class="">Queue (8)</a></li>
</ul>
<ul>
<li><a href="/categories/divideconquer" class="">Divide&Conquer (12)</a></li>
</ul>
<ul>
<li><a href="/categories/binarysearch" class="">BinarySearch (4)</a></li>
</ul>
<ul>
<li><a href="/categories/heap" class="">Heap (6)</a></li>
</ul>
<ul>
<li><a href="/categories/shortestpath" class="">ShortestPath (10)</a></li>
</ul>
<ul>
<li><a href="/categories/twopointer" class="">TwoPointer (3)</a></li>
</ul>
<ul>
<li><a href="/categories/hashmap" class="">HashMap (10)</a></li>
</ul>
<ul>
<li><a href="/categories/dynamicprogramming" class="">DynamicProgramming (27)</a></li>
</ul>
<ul>
<li><a href="/categories/tree" class="">Tree (8)</a></li>
</ul>
<ul>
<li><a href="/categories/unionfind" class="">UnionFind (5)</a></li>
</ul>
<span class="nav__sub-title">💡 AI</span>
<ul>
<li><a href="/categories/ai-papers" class="">Papers (6)</a></li>
</ul>
<ul>
<li><a href="/categories/aitech" class="">AI Tech (162)</a></li>
</ul>
<ul>
<li><a href="/categories/computervision" class="">Computer Vision (24)</a></li>
</ul>
<ul>
<li><a href="/categories/machinelearning" class="">Machine Learning (28)</a></li>
</ul>
<ul>
<li><a href="/categories/deeplearning" class="">Deep Learning (14)</a></li>
</ul>
<ul>
<li><a href="/categories/recommendationsystem" class="">Recommendation System (1)</a></li>
</ul>
<ul>
<li><a href="/categories/tflite" class="">TFLite (20)</a></li>
</ul>
<ul>
<li><a href="/categories/search" class="">Search (4)</a></li>
</ul>
<ul>
<li><a href="/categories/optimization" class="">Optimization (2)</a></li>
</ul>
<ul>
<li><a href="/categories/knowledgeexpression" class="">Knowledge Expression (6)</a></li>
</ul>
<ul>
<li><a href="/categories/tensorflowkeras" class="">Tensorflow&Keras (9)</a></li>
</ul>
<span class="nav__sub-title">👨💻 HCI</span>
<ul>
<li><a href="/categories/hci-papers" class="">Papers (3)</a></li>
</ul>
<ul>
<li><a href="/categories/ux" class="">UX (12)</a></li>
</ul>
<ul>
</ul>
<span class="nav__sub-title">📱 Android</span>
<ul>
<li><a href="/categories/android" class="">Android(Kotlin) (47)</a></li>
</ul>
<span class="nav__sub-title">💻 Web</span>
<ul>
<li><a href="/categories/html" class="">HTML (9)</a></li>
</ul>
<ul>
<li><a href="/categories/css" class="">CSS (7)</a></li>
</ul>
<span class="nav__sub-title">🖊 Mathematics</span>
<ul>
<li><a href="/categories/numericalanalysis" class="">NumericalAnalysis (16)</a></li>
</ul>
<span class="nav__sub-title">📝 Git&Github</span>
<ul>
<li><a href="/categories/git" class="">Git (2)</a></li>
</ul>
<ul>
<li><a href="/categories/github" class="">Github (3)</a></li>
</ul>
</li>
</ul>
</nav>
</div>
<article class="page" itemscope itemtype="https://schema.org/CreativeWork">
<meta itemprop="headline" content="[Programmers] 거리두기 확인하기">
<meta itemprop="description" content="거리두기 확인하기">
<meta itemprop="datePublished" content="2021-09-05T00:00:00+00:00">
<div class="page__inner-wrap">
<header>
<h1 id="page-title" class="page__title" itemprop="headline">[Programmers] 거리두기 확인하기
</h1>
<p class="page__meta">
<span class="page__meta-readtime">
<i class="far fa-clock" aria-hidden="true"></i>
3 minute read
</span>
</p>
</header>
<section class="page__content" itemprop="text">
<h1 id="거리두기-확인하기">거리두기 확인하기</h1>
<h3 id="문제-설명">문제 설명</h3>
<hr />
<h5 id="문제-설명-1">문제 설명</h5>
<p>개발자를 희망하는 죠르디가 카카오에 면접을 보러 왔습니다.</p>
<p>코로나 바이러스 감염 예방을 위해 응시자들은 거리를 둬서 대기를 해야하는데 개발 직군 면접인 만큼
아래와 같은 규칙으로 대기실에 거리를 두고 앉도록 안내하고 있습니다.</p>
<blockquote>
<ol>
<li>대기실은 5개이며, 각 대기실은 5x5 크기입니다.</li>
<li>거리두기를 위하여 응시자들 끼리는 맨해튼 거리<a href="https://programmers.co.kr/learn/courses/30/lessons/81302#fn1">1</a>가 2 이하로 앉지 말아 주세요.</li>
<li>단 응시자가 앉아있는 자리 사이가 파티션으로 막혀 있을 경우에는 허용합니다.</li>
</ol>
</blockquote>
<p>예를 들어,</p>
<table>
<thead>
<tr>
<th style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/8c056cac-ec8f-435c-a49a-8125df055c5e/PXP.png" alt="PXP.png" /></th>
<th style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/d611f66e-f9c4-4433-91ce-02887657fe7f/PX_XP.png" alt="PX_XP.png" /></th>
<th style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/ed707158-0511-457b-9e1a-7dbf34a776a5/PX_OP.png" alt="PX_OP.png" /></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center">위 그림처럼 자리 사이에 파티션이 존재한다면 맨해튼 거리가 2여도 거리두기를 <strong>지킨 것입니다.</strong></td>
<td style="text-align: center">위 그림처럼 파티션을 사이에 두고 앉은 경우도 거리두기를 <strong>지킨 것입니다.</strong></td>
<td style="text-align: center">위 그림처럼 자리 사이가 맨해튼 거리 2이고 사이에 빈 테이블이 있는 경우는 거리두기를 <strong>지키지 않은 것입니다.</strong></td>
</tr>
<tr>
<td style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/4c548421-1c32-4947-af9e-a45c61501bc4/P.png" alt="P.png" /></td>
<td style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/ce799a38-668a-4038-b32f-c515b8701262/O.png" alt="O.png" /></td>
<td style="text-align: center"><img src="https://grepp-programmers.s3.ap-northeast-2.amazonaws.com/files/production/91e8f98b-baeb-4f81-8cb6-5bafebebdcc7/X.png" alt="X.png" /></td>
</tr>
<tr>
<td style="text-align: center">응시자가 앉아있는 자리(<code class="language-plaintext highlighter-rouge">P</code>)를 의미합니다.</td>
<td style="text-align: center">빈 테이블(<code class="language-plaintext highlighter-rouge">O</code>)을 의미합니다.</td>
<td style="text-align: center">파티션(<code class="language-plaintext highlighter-rouge">X</code>)을 의미합니다.</td>
</tr>
</tbody>
</table>
<p>5개의 대기실을 본 죠르디는 각 대기실에서 응시자들이 거리두기를 잘 기키고 있는지 알고 싶어졌습니다. 자리에 앉아있는 응시자들의 정보와 대기실 구조를 대기실별로 담은 2차원 문자열 배열 <code class="language-plaintext highlighter-rouge">places</code>가 매개변수로 주어집니다. 각 대기실별로 거리두기를 지키고 있으면 1을, 한 명이라도 지키지 않고 있으면 0을 배열에 담아 return 하도록 solution 함수를 완성해 주세요.</p>
<hr />
<h5 id="제한사항">제한사항</h5>
<ul>
<li><code class="language-plaintext highlighter-rouge">places</code>의 행 길이(대기실 개수) = 5
<ul>
<li><code class="language-plaintext highlighter-rouge">places</code>의 각 행은 하나의 대기실 구조를 나타냅니다.</li>
</ul>
</li>
<li><code class="language-plaintext highlighter-rouge">places</code>의 열 길이(대기실 세로 길이) = 5</li>
<li><code class="language-plaintext highlighter-rouge">places</code>의 원소는 <code class="language-plaintext highlighter-rouge">P</code>, <code class="language-plaintext highlighter-rouge">O</code>, <code class="language-plaintext highlighter-rouge">X</code> 로 이루어진 문자열입니다.
<ul>
<li><code class="language-plaintext highlighter-rouge">places</code> 원소의 길이(대기실 가로 길이) = 5</li>
<li><code class="language-plaintext highlighter-rouge">P</code>는 응시자가 앉아있는 자리를 의미합니다.</li>
<li><code class="language-plaintext highlighter-rouge">O</code>는 빈 테이블을 의미합니다.</li>
<li><code class="language-plaintext highlighter-rouge">X</code>는 파티션을 의미합니다.</li>
</ul>
</li>
<li>입력으로 주어지는 5개 대기실의 크기는 모두 5x5 입니다.</li>
<li>return 값 형식
<ul>
<li>1차원 정수 배열에 5개의 원소를 담아서 return 합니다.</li>
<li><code class="language-plaintext highlighter-rouge">places</code>에 담겨 있는 5개 대기실의 순서대로, 거리두기 준수 여부를 차례대로 배열에 담습니다.</li>
<li>각 대기실 별로 모든 응시자가 거리두기를 지키고 있으면 1을, 한 명이라도 지키지 않고 있으면 0을 담습니다.</li>
</ul>
</li>
</ul>
<hr />
<h5 id="입출력-예">입출력 예</h5>
<table>
<thead>
<tr>
<th>places</th>
<th>result</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">[["POOOP", "OXXOX", "OPXPX", "OOXOX", "POXXP"], ["POOPX", "OXPXP", "PXXXO", "OXXXO", "OOOPP"], ["PXOPX", "OXOXP", "OXPOX", "OXXOP", "PXPOX"], ["OOOXX", "XOOOX", "OOOXX", "OXOOX", "OOOOO"], ["PXPXP", "XPXPX", "PXPXP", "XPXPX", "PXPXP"]]</code></td>
<td>[1, 0, 1, 1, 1]</td>
</tr>
</tbody>
</table>
<hr />
<h5 id="입출력-예-설명">입출력 예 설명</h5>
<p><strong>입출력 예 #1</strong></p>
<p>첫 번째 대기실</p>
<table>
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>No.</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>0</td>
<td>P</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>P</td>
</tr>
<tr>
<td>1</td>
<td>O</td>
<td>X</td>
<td>X</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td>2</td>
<td>O</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
</tr>
<tr>
<td>3</td>
<td>O</td>
<td>O</td>
<td>X</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td>4</td>
<td>P</td>
<td>O</td>
<td>X</td>
<td>X</td>
<td>P</td>
</tr>
</tbody>
</table>
<ul>
<li>모든 응시자가 거리두기를 지키고 있습니다.</li>
</ul>
<p>두 번째 대기실</p>
<table>
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>No.</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>0</td>
<td><strong>P</strong></td>
<td>O</td>
<td>O</td>
<td><strong>P</strong></td>
<td>X</td>
</tr>
<tr>
<td>1</td>
<td>O</td>
<td>X</td>
<td><strong>P</strong></td>
<td>X</td>
<td>P</td>
</tr>
<tr>
<td>2</td>
<td><strong>P</strong></td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>O</td>
</tr>
<tr>
<td>3</td>
<td>O</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>O</td>
</tr>
<tr>
<td>4</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td><strong>P</strong></td>
<td><strong>P</strong></td>
</tr>
</tbody>
</table>
<ul>
<li>(0, 0) 자리의 응시자와 (2, 0) 자리의 응시자가 거리두기를 지키고 있지 않습니다.</li>
<li>(1, 2) 자리의 응시자와 (0, 3) 자리의 응시자가 거리두기를 지키고 있지 않습니다.</li>
<li>(4, 3) 자리의 응시자와 (4, 4) 자리의 응시자가 거리두기를 지키고 있지 않습니다.</li>
</ul>
<p>세 번째 대기실</p>
<table>
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>No.</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>0</td>
<td>P</td>
<td>X</td>
<td>O</td>
<td>P</td>
<td>X</td>
</tr>
<tr>
<td>1</td>
<td>O</td>
<td>X</td>
<td>O</td>
<td>X</td>
<td>P</td>
</tr>
<tr>
<td>2</td>
<td>O</td>
<td>X</td>
<td>P</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td>3</td>
<td>O</td>
<td>X</td>
<td>X</td>
<td>O</td>
<td>P</td>
</tr>
<tr>
<td>4</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>O</td>
<td>X</td>
</tr>
</tbody>
</table>
<ul>
<li>모든 응시자가 거리두기를 지키고 있습니다.</li>
</ul>
<p>네 번째 대기실</p>
<table>
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>No.</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>0</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td>1</td>
<td>X</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td>2</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td>3</td>
<td>O</td>
<td>X</td>
<td>O</td>
<td>O</td>
<td>X</td>
</tr>
<tr>
<td>4</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>O</td>
<td>O</td>
</tr>
</tbody>
</table>
<ul>
<li>대기실에 응시자가 없으므로 거리두기를 지키고 있습니다.</li>
</ul>
<p>다섯 번째 대기실</p>
<table>
<thead>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
<tr>
<td>No.</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>0</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
<td>P</td>
</tr>
<tr>
<td>1</td>
<td>X</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
</tr>
<tr>
<td>2</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
<td>P</td>
</tr>
<tr>
<td>3</td>
<td>X</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
</tr>
<tr>
<td>4</td>
<td>P</td>
<td>X</td>
<td>P</td>
<td>X</td>
<td>P</td>
</tr>
</tbody>
</table>
<ul>
<li>모든 응시자가 거리두기를 지키고 있습니다.</li>
</ul>
<p>두 번째 대기실을 제외한 모든 대기실에서 거리두기가 지켜지고 있으므로, 배열 [1, 0, 1, 1, 1]을 return 합니다.</p>
<hr />
<h5 id="제한시간-안내">제한시간 안내</h5>
<ul>
<li>정확성 테스트 : 10초</li>
</ul>
<hr />
<ol>
<li>
<table>
<tbody>
<tr>
<td>두 테이블 T1, T2가 행렬 (r1, c1), (r2, c2)에 각각 위치하고 있다면, T1, T2 사이의 맨해튼 거리는</td>
<td>r1 - r2</td>
<td>+</td>
<td>c1 - c2</td>
<td>입니다. <a href="https://programmers.co.kr/learn/courses/30/lessons/81302#fnref1">↩</a></td>
</tr>
</tbody>
</table>
</li>
</ol>
<p><br /></p>
<h3 id="문제-풀이">문제 풀이</h3>
<hr />
<h4 id="-coo-행렬--맨해튼-거리"># COO 행렬 # 맨해튼 거리</h4>
<p><br /></p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">is_distancing</span><span class="p">(</span><span class="n">Ps</span><span class="p">,</span><span class="n">Xs</span><span class="p">):</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">Ps</span><span class="p">)):</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">Ps</span><span class="p">)):</span>
<span class="n">h_dist</span><span class="p">,</span> <span class="n">v_dist</span> <span class="o">=</span> <span class="nb">abs</span><span class="p">(</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">-</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]),</span> <span class="nb">abs</span><span class="p">(</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">-</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
<span class="c1"># 3칸 이상 거리두기
</span> <span class="k">if</span> <span class="n">h_dist</span><span class="o">+</span><span class="n">v_dist</span> <span class="o">></span> <span class="mi">2</span><span class="p">:</span> <span class="k">continue</span>
<span class="c1"># 1칸 거리두기
</span> <span class="k">if</span> <span class="n">h_dist</span><span class="o">+</span><span class="n">v_dist</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> <span class="k">return</span> <span class="mi">0</span>
<span class="c1"># 2칸 거리두기
</span> <span class="c1"># 세로/가로로 위치한 경우
</span> <span class="k">if</span> <span class="p">(</span><span class="n">h_dist</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">v_dist</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="ow">and</span> <span class="p">((</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span><span class="o">//</span><span class="mi">2</span><span class="p">,(</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">+</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span><span class="o">//</span><span class="mi">2</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Xs</span><span class="p">:</span> <span class="k">return</span> <span class="mi">0</span>
<span class="c1"># \ 또는 / 로 위치한 경우
</span> <span class="k">if</span> <span class="n">h_dist</span> <span class="o">==</span> <span class="n">v_dist</span> <span class="o">==</span> <span class="mi">1</span> <span class="ow">and</span> <span class="p">((</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Xs</span> <span class="ow">or</span> <span class="p">(</span><span class="n">Ps</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span><span class="n">Ps</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Xs</span><span class="p">):</span> <span class="k">return</span> <span class="mi">0</span>
<span class="k">return</span> <span class="mi">1</span>
<span class="k">def</span> <span class="nf">solution</span><span class="p">(</span><span class="n">places</span><span class="p">):</span>
<span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
<span class="n">coo_mat_P</span><span class="p">,</span> <span class="n">coo_mat_X</span> <span class="o">=</span> <span class="p">{},</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
<span class="k">if</span> <span class="n">places</span><span class="p">[</span><span class="n">n</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">==</span> <span class="s">'P'</span><span class="p">:</span> <span class="n">coo_mat_P</span><span class="p">[(</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">)]</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">elif</span> <span class="n">places</span><span class="p">[</span><span class="n">n</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">==</span> <span class="s">'X'</span><span class="p">:</span> <span class="n">coo_mat_X</span><span class="p">[(</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">)]</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">places</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_distancing</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">coo_mat_P</span><span class="p">.</span><span class="n">keys</span><span class="p">()),</span> <span class="n">coo_mat_X</span><span class="p">)</span>
<span class="k">return</span> <span class="n">places</span>
</code></pre></div></div>
<p><br /></p>
</section>
<footer class="page__meta">
<p class="page__taxonomy">
<strong><i class="fas fa-fw fa-folder-open" aria-hidden="true"></i> Categories: </strong>
<span itemprop="keywords">
<a href="/categories/#algorithm" class="page__taxonomy-item" rel="tag">Algorithm</a><span class="sep">, </span>
<a href="/categories/#bruteforce" class="page__taxonomy-item" rel="tag">Bruteforce</a><span class="sep">, </span>
<a href="/categories/#implementation" class="page__taxonomy-item" rel="tag">Implementation</a>
</span>
</p>
<p class="page__date"><strong><i class="fas fa-fw fa-calendar-alt" aria-hidden="true"></i> Updated:</strong> <time datetime="2021-09-05T00:00:00+00:00">September 5, 2021</time></p>
</footer>
<section class="page__share">
<h4 class="page__share-title">Share on</h4>
<a href="https://twitter.com/intent/tweet?text=%5BProgrammers%5D+%EA%B1%B0%EB%A6%AC%EB%91%90%EA%B8%B0+%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0%20https%3A%2F%2Fwowo0709.github.io%2Falgorithm%2Fimplementation%2Fbruteforce%2FProgrammers-%25EA%25B1%25B0%25EB%25A6%25AC%25EB%2591%2590%25EA%25B8%25B0-%25ED%2599%2595%25EC%259D%25B8%25ED%2595%2598%25EA%25B8%25B0%2F" class="btn btn--twitter" onclick="window.open(this.href, 'window', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" title="Share on Twitter"><i class="fab fa-fw fa-twitter" aria-hidden="true"></i><span> Twitter</span></a>
<a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwowo0709.github.io%2Falgorithm%2Fimplementation%2Fbruteforce%2FProgrammers-%25EA%25B1%25B0%25EB%25A6%25AC%25EB%2591%2590%25EA%25B8%25B0-%25ED%2599%2595%25EC%259D%25B8%25ED%2595%2598%25EA%25B8%25B0%2F" class="btn btn--facebook" onclick="window.open(this.href, 'window', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" title="Share on Facebook"><i class="fab fa-fw fa-facebook" aria-hidden="true"></i><span> Facebook</span></a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwowo0709.github.io%2Falgorithm%2Fimplementation%2Fbruteforce%2FProgrammers-%25EA%25B1%25B0%25EB%25A6%25AC%25EB%2591%2590%25EA%25B8%25B0-%25ED%2599%2595%25EC%259D%25B8%25ED%2595%2598%25EA%25B8%25B0%2F" class="btn btn--linkedin" onclick="window.open(this.href, 'window', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;" title="Share on LinkedIn"><i class="fab fa-fw fa-linkedin" aria-hidden="true"></i><span> LinkedIn</span></a>
</section>
<nav class="pagination">
<a href="/algorithm/dynamicprogramming/Baekjoon-2565.-%EC%A0%84%EA%B9%83%EC%A4%84/" class="pagination--pager" title="[Baekjoon] 10844. 쉬운 계단 수
">Previous</a>
<a href="/gitgithub/github/Github-%EA%B9%83%ED%97%88%EB%B8%8C-%ED%8E%98%EC%9D%B4%EC%A7%80%EC%97%90-%EC%B9%B4%ED%85%8C%EA%B3%A0%EB%A6%AC-%EB%A7%8C%EB%93%A4%EA%B8%B0/" class="pagination--pager" title="[Github] 깃허브 페이지에 카테고리 만들기
">Next</a>
</nav>
</div>
<div class="page__comments">
<h4 class="page__comments-title">Leave a comment</h4>
<section id="disqus_thread"></section>
</div>
</article>
<div class="page__related">
<h4 class="page__related-title">You may also enjoy</h4>
<div class="grid__wrapper">
<div class="grid__item">
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
<h2 class="archive__item-title no_toc" itemprop="headline">
<a href="/language/python/Python-Effective-Python-CH-2-1/" rel="permalink">[Python] Effective Python CH 2. 리스트와 딕셔너리 - 1
</a>
</h2>
<!-- 날짜&카테고리 출력 -->
<p class="archive__item-excerpt"><i class="far fa-calendar-alt"></i> 06/20/2022
<i class="far fa-folder-open"></i>
↪Language <!--☑-->
↪Python <!--☑-->
</p>
<!-- 태그 출력 -->
<p class="page__meta">
<span class="page__meta-readtime">
<i class="far fa-clock" aria-hidden="true"></i>
8 minute read
</span>
</p>
<p class="archive__item-excerpt" itemprop="description">CH 2. 리스트와 딕셔너리 - 1
</p>
</article>
</div>
<div class="grid__item">
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
<h2 class="archive__item-title no_toc" itemprop="headline">
<a href="/language/python/Python-Effective-Python-CH-1-2/" rel="permalink">[Python] Effective Python CH 1. 파이썬답게 생각하기 - 2
</a>
</h2>
<!-- 날짜&카테고리 출력 -->
<p class="archive__item-excerpt"><i class="far fa-calendar-alt"></i> 06/19/2022
<i class="far fa-folder-open"></i>
↪Language <!--☑-->
↪Python <!--☑-->
</p>
<!-- 태그 출력 -->
<p class="page__meta">
<span class="page__meta-readtime">
<i class="far fa-clock" aria-hidden="true"></i>
7 minute read
</span>
</p>
<p class="archive__item-excerpt" itemprop="description">CH 1. 파이썬답게 생각하기 - 2
</p>
</article>
</div>
<div class="grid__item">
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
<h2 class="archive__item-title no_toc" itemprop="headline">
<a href="/language/python/Python-Effective-Python-CH-1-1/" rel="permalink">[Python] Effective Python CH 1. 파이썬답게 생각하기 - 1
</a>
</h2>
<!-- 날짜&카테고리 출력 -->
<p class="archive__item-excerpt"><i class="far fa-calendar-alt"></i> 06/19/2022
<i class="far fa-folder-open"></i>
↪Language <!--☑-->
↪Python <!--☑-->
</p>
<!-- 태그 출력 -->
<p class="page__meta">
<span class="page__meta-readtime">
<i class="far fa-clock" aria-hidden="true"></i>
6 minute read
</span>
</p>
<p class="archive__item-excerpt" itemprop="description">CH 1. 파이썬답게 생각하기 - 1
</p>
</article>
</div>
<div class="grid__item">
<article class="archive__item" itemscope itemtype="https://schema.org/CreativeWork">
<h2 class="archive__item-title no_toc" itemprop="headline">
<a href="/language/python/Python-Effective-Python-%EC%A0%84%EC%B2%B4-%EB%AA%A9%EC%B0%A8/" rel="permalink">[Python] Effective Python 전체 목차
</a>
</h2>
<!-- 날짜&카테고리 출력 -->
<p class="archive__item-excerpt"><i class="far fa-calendar-alt"></i> 06/18/2022
<i class="far fa-folder-open"></i>
↪Language <!--☑-->
↪Python <!--☑-->
</p>
<!-- 태그 출력 -->
<p class="page__meta">
<span class="page__meta-readtime">
<i class="far fa-clock" aria-hidden="true"></i>
5 minute read
</span>
</p>
<p class="archive__item-excerpt" itemprop="description">
</p>
</article>
</div>
</div>
</div>
</div>
...
<div class="col-lg-4 col-md-2">
...
</div>
여기서 알아야할 것이 있는데, 바로 지킬 블로그에서 사용하는 리퀴드 문법이다.
여기서는 카테고리를 만드는데 꼭 필요한 부분만 알아보도록 하자.
카테고리를 어떻게 불러오느냐?
카테고리는 지킬의 site.categories
라는 변수에 리스트들이 들어있다.
우리는 이 리스트들을 순회하면서 필요한 리스트들을 출력한다.
<div class="col-lg-4 col-md-2">
</div>
site.categories에 있는 리스트를 차례로 category에 담으면서 순회를 진행합니다.
category라는 변수를 출력해봅시다.
Leave a comment