aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/posts/2022-08-27/php-conference-okinawa-code-golf
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2022-08-31 23:30:53 +0900
committernsfisis <nsfisis@gmail.com>2022-08-31 23:32:02 +0900
commit5d5367ed00c22cc194b8a2411b2b4b828751003b (patch)
tree02392cbb201091853c58ffccea81dbc8f9102854 /docs/posts/2022-08-27/php-conference-okinawa-code-golf
parent8c071f04a749d2cf7ca7a23bff49d94738aa6b6d (diff)
downloadnsfisis.github.io-5d5367ed00c22cc194b8a2411b2b4b828751003b.tar.gz
nsfisis.github.io-5d5367ed00c22cc194b8a2411b2b4b828751003b.tar.zst
nsfisis.github.io-5d5367ed00c22cc194b8a2411b2b4b828751003b.zip
update hugo
Diffstat (limited to 'docs/posts/2022-08-27/php-conference-okinawa-code-golf')
-rw-r--r--docs/posts/2022-08-27/php-conference-okinawa-code-golf/index.html28
1 files changed, 14 insertions, 14 deletions
diff --git a/docs/posts/2022-08-27/php-conference-okinawa-code-golf/index.html b/docs/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
index 113d7e0..b9c337e 100644
--- a/docs/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
+++ b/docs/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
@@ -15,7 +15,7 @@
<link href="https://blog.nsfisis.dev/custom.css" rel="stylesheet">
<link rel="icon" href="https://blog.nsfisis.dev/favicon.svg">
- <meta name="generator" content="Hugo 0.88.1" />
+ <meta name="generator" content="Hugo 0.102.1" />
</head>
@@ -47,7 +47,7 @@
<h1 id="はじめに">はじめに</h1>
<p>本日 <a href="https://phpcon.okinawa.jp/">PHP カンファレンス沖縄 2022</a> が開催された (らしい)。</p>
<p>カンファレンスには参加できなかったものの、懇親会の LT で出題されたコードゴルフの問題が Twitter に流れてきたので、解いてみた。</p>
-<p>ツイート: <a href="https://twitter.com/m3m0r7/status/1563397620231712772">https://twitter.com/m3m0r7/status/1563397620231712772</a><br>
+<p>ツイート: <a href="https://twitter.com/m3m0r7/status/1563397620231712772">https://twitter.com/m3m0r7/status/1563397620231712772</a> <br>
スライド: <a href="https://speakerdeck.com/memory1994/php-conference-okinawa-2022-extra?slide=3">https://speakerdeck.com/memory1994/php-conference-okinawa-2022-extra?slide=3</a></p>
<h1 id="解">解</h1>
<p>細かいレギュレーションは不明だったので、勝手に定めた。</p>
@@ -60,19 +60,19 @@
<li>負数は入ってこないものとする</li>
</ul>
<p>書いたものがこちら:</p>
-<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-php" data-lang="php">[<span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span> $n<span style="color:#f92672">=</span>$argv[<span style="color:#ae81ff">1</span>];<span style="color:#66d9ef">foreach</span>([<span style="color:#ae81ff">1e4</span>,<span style="color:#ae81ff">5e3</span>,<span style="color:#ae81ff">2e3</span>,<span style="color:#ae81ff">1e3</span>,<span style="color:#ae81ff">500</span>,<span style="color:#ae81ff">100</span>,<span style="color:#ae81ff">50</span>,<span style="color:#ae81ff">10</span>,<span style="color:#ae81ff">5</span>,<span style="color:#ae81ff">1</span>]<span style="color:#66d9ef">as</span>$x)<span style="color:#66d9ef">for</span>(;$n<span style="color:#f92672">&gt;=</span>$x;$n<span style="color:#f92672">-=</span>$x)$r[]<span style="color:#f92672">=</span>$x;<span style="color:#66d9ef">echo</span> <span style="color:#a6e22e">implode</span>(<span style="color:#e6db74">&#39;, &#39;</span>,$r<span style="color:#f92672">??</span>[]);<span style="color:#75715e">?&gt;</span><span style="color:#960050;background-color:#1e0010">]
-</span></code></pre></div><p>しめて 123 バイトとなった (末尾改行を含めずにカウント)。</p>
+<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span>[<span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span> $n<span style="color:#f92672">=</span>$argv[<span style="color:#ae81ff">1</span>];<span style="color:#66d9ef">foreach</span>([<span style="color:#ae81ff">1e4</span>,<span style="color:#ae81ff">5e3</span>,<span style="color:#ae81ff">2e3</span>,<span style="color:#ae81ff">1e3</span>,<span style="color:#ae81ff">500</span>,<span style="color:#ae81ff">100</span>,<span style="color:#ae81ff">50</span>,<span style="color:#ae81ff">10</span>,<span style="color:#ae81ff">5</span>,<span style="color:#ae81ff">1</span>]<span style="color:#66d9ef">as</span>$x)<span style="color:#66d9ef">for</span>(;$n<span style="color:#f92672">&gt;=</span>$x;$n<span style="color:#f92672">-=</span>$x)$r[]<span style="color:#f92672">=</span>$x;<span style="color:#66d9ef">echo</span> <span style="color:#a6e22e">implode</span>(<span style="color:#e6db74">&#39;, &#39;</span>,$r<span style="color:#f92672">??</span>[]);<span style="color:#75715e">?&gt;</span><span style="color:#960050;background-color:#1e0010">]
+</span></span></span></code></pre></div><p>しめて 123 バイトとなった (末尾改行を含めずにカウント)。</p>
<p>こちらは改行とスペースを追加したバージョン:</p>
-<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-php" data-lang="php">[<span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span>
-
-$n <span style="color:#f92672">=</span> $argv[<span style="color:#ae81ff">1</span>];
-<span style="color:#66d9ef">foreach</span> ([<span style="color:#ae81ff">1e4</span>, <span style="color:#ae81ff">5e3</span>, <span style="color:#ae81ff">2e3</span>, <span style="color:#ae81ff">1e3</span>, <span style="color:#ae81ff">500</span>, <span style="color:#ae81ff">100</span>, <span style="color:#ae81ff">50</span>, <span style="color:#ae81ff">10</span>, <span style="color:#ae81ff">5</span>, <span style="color:#ae81ff">1</span>] <span style="color:#66d9ef">as</span> $x)
- <span style="color:#66d9ef">for</span> (; $n <span style="color:#f92672">&gt;=</span> $x; $n <span style="color:#f92672">-=</span> $x)
- $r[] <span style="color:#f92672">=</span> $x;
-<span style="color:#66d9ef">echo</span> <span style="color:#a6e22e">implode</span>(<span style="color:#e6db74">&#39;, &#39;</span>, $r <span style="color:#f92672">??</span> []);
-
-<span style="color:#75715e">?&gt;</span><span style="color:#960050;background-color:#1e0010">]
-</span></code></pre></div><h1 id="使用したテクニック">使用したテクニック</h1>
+<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span>[<span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span>
+</span></span><span style="display:flex;"><span>
+</span></span><span style="display:flex;"><span>$n <span style="color:#f92672">=</span> $argv[<span style="color:#ae81ff">1</span>];
+</span></span><span style="display:flex;"><span><span style="color:#66d9ef">foreach</span> ([<span style="color:#ae81ff">1e4</span>, <span style="color:#ae81ff">5e3</span>, <span style="color:#ae81ff">2e3</span>, <span style="color:#ae81ff">1e3</span>, <span style="color:#ae81ff">500</span>, <span style="color:#ae81ff">100</span>, <span style="color:#ae81ff">50</span>, <span style="color:#ae81ff">10</span>, <span style="color:#ae81ff">5</span>, <span style="color:#ae81ff">1</span>] <span style="color:#66d9ef">as</span> $x)
+</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">for</span> (; $n <span style="color:#f92672">&gt;=</span> $x; $n <span style="color:#f92672">-=</span> $x)
+</span></span><span style="display:flex;"><span> $r[] <span style="color:#f92672">=</span> $x;
+</span></span><span style="display:flex;"><span><span style="color:#66d9ef">echo</span> <span style="color:#a6e22e">implode</span>(<span style="color:#e6db74">&#39;, &#39;</span>, $r <span style="color:#f92672">??</span> []);
+</span></span><span style="display:flex;"><span>
+</span></span><span style="display:flex;"><span><span style="color:#75715e">?&gt;</span><span style="color:#960050;background-color:#1e0010">]
+</span></span></span></code></pre></div><h1 id="使用したテクニック">使用したテクニック</h1>
<h2 id="指数表記">指数表記</h2>
<p>割と多くの言語のゴルフで使えるテクニック。<code>e</code> を用いた指数表記で、大きな数を短く表す。このコードでは <code>10000</code>、<code>5000</code>、<code>2000</code>、<code>1000</code> を指数表記している。</p>
<h2 id="foreach-や-for-の中身を1つの文に">foreach や for の中身を1つの文に</h2>