aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html')
-rw-r--r--public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html18
1 files changed, 9 insertions, 9 deletions
diff --git a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
index 851f76c..1e124bf 100644
--- a/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
+++ b/public/posts/2022-08-27/php-conference-okinawa-code-golf/index.html
@@ -10,7 +10,7 @@
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>PHP カンファレンス沖縄で出題されたコードゴルフの問題を解いてみた | REPL: Rest-Eat-Program Loop</title>
<link rel="stylesheet" href="/style.css?h=17cf97a767ec5fb6e64967729f40f30a">
- <link rel="stylesheet" href="/hl.css?h=208c52e3b7c9db1cad782c5d30b4698f">
+ <link rel="stylesheet" href="/hl.css?h=340e65ffd5c17713efc9107c06304f7b">
</head>
<body class="single">
<header class="header">
@@ -121,7 +121,7 @@
書いたものがこちら:
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>[&lt;?php $n=$argv[1];foreach([1e4,5e3,2e3,1e3,500,100,50,10,5,1]as$x)for(;$n&gt;=$x;$n-=$x)$r[]=$x;echo implode(&apos;, &apos;,$r??[]);?&gt;]</code></pre>
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">[<span class="hljs-meta">&lt;?php</span> <span class="hljs-variable">$n</span>=<span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>];<span class="hljs-keyword">foreach</span>([<span class="hljs-number">1e4</span>,<span class="hljs-number">5e3</span>,<span class="hljs-number">2e3</span>,<span class="hljs-number">1e3</span>,<span class="hljs-number">500</span>,<span class="hljs-number">100</span>,<span class="hljs-number">50</span>,<span class="hljs-number">10</span>,<span class="hljs-number">5</span>,<span class="hljs-number">1</span>]<span class="hljs-keyword">as</span><span class="hljs-variable">$x</span>)<span class="hljs-keyword">for</span>(;<span class="hljs-variable">$n</span>&gt;=<span class="hljs-variable">$x</span>;<span class="hljs-variable">$n</span>-=<span class="hljs-variable">$x</span>)<span class="hljs-variable">$r</span>[]=<span class="hljs-variable">$x</span>;<span class="hljs-keyword">echo</span> <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;, &#x27;</span>,<span class="hljs-variable">$r</span>??[]);<span class="hljs-meta">?&gt;</span>]</code></pre>
<p>
しめて 123 バイトとなった (末尾改行を含めずにカウント)。
@@ -131,15 +131,15 @@
こちらは改行とスペースを追加したバージョン:
</p>
- <pre class="highlight" language="php" linenumbering="unnumbered"><code>[&lt;?php
+ <pre class="highlight" language="php" linenumbering="unnumbered"><code class="highlight">[<span class="hljs-meta">&lt;?php</span>
- $n = $argv[1];
- foreach ([1e4, 5e3, 2e3, 1e3, 500, 100, 50, 10, 5, 1] as $x)
- for (; $n &gt;= $x; $n -= $x)
- $r[] = $x;
- echo implode(&apos;, &apos;, $r ?? []);
+ <span class="hljs-variable">$n</span> = <span class="hljs-variable">$argv</span>[<span class="hljs-number">1</span>];
+ <span class="hljs-keyword">foreach</span> ([<span class="hljs-number">1e4</span>, <span class="hljs-number">5e3</span>, <span class="hljs-number">2e3</span>, <span class="hljs-number">1e3</span>, <span class="hljs-number">500</span>, <span class="hljs-number">100</span>, <span class="hljs-number">50</span>, <span class="hljs-number">10</span>, <span class="hljs-number">5</span>, <span class="hljs-number">1</span>] <span class="hljs-keyword">as</span> <span class="hljs-variable">$x</span>)
+ <span class="hljs-keyword">for</span> (; <span class="hljs-variable">$n</span> &gt;= <span class="hljs-variable">$x</span>; <span class="hljs-variable">$n</span> -= <span class="hljs-variable">$x</span>)
+ <span class="hljs-variable">$r</span>[] = <span class="hljs-variable">$x</span>;
+ <span class="hljs-keyword">echo</span> <span class="hljs-title function_ invoke__">implode</span>(<span class="hljs-string">&#x27;, &#x27;</span>, <span class="hljs-variable">$r</span> ?? []);
- ?&gt;]</code></pre>
+ <span class="hljs-meta">?&gt;</span>]</code></pre>
</section>
<section id="section--_使用したテクニック">