aboutsummaryrefslogtreecommitdiffhomepage
path: root/archive/q/base32/a/142
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-05 04:08:22 +0900
committernsfisis <nsfisis@gmail.com>2025-12-05 04:08:22 +0900
commitfbd4f2129ce8fe106391302896dd86e05b2f331b (patch)
tree3be97d86c89a4a8a497e1b8a2d7d032eb153438e /archive/q/base32/a/142
parentca3f1c4b0bd08ab6e836923601cf699d1fd894fb (diff)
downloadphperkaigi-2024-albatross-archive-fbd4f2129ce8fe106391302896dd86e05b2f331b.tar.gz
phperkaigi-2024-albatross-archive-fbd4f2129ce8fe106391302896dd86e05b2f331b.tar.zst
phperkaigi-2024-albatross-archive-fbd4f2129ce8fe106391302896dd86e05b2f331b.zip
add files
Diffstat (limited to 'archive/q/base32/a/142')
-rw-r--r--archive/q/base32/a/142/index.html139
1 files changed, 139 insertions, 0 deletions
diff --git a/archive/q/base32/a/142/index.html b/archive/q/base32/a/142/index.html
new file mode 100644
index 0000000..1627700
--- /dev/null
+++ b/archive/q/base32/a/142/index.html
@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>問題 #2 - 回答 #142 | Albatross.PHP</title>
+ <link rel="stylesheet" href="../../../../assets/index.css">
+ <link rel="icon" type="image/svg+xml" href="../../../../assets/favicon.svg">
+ <script type="module" src="../../../../assets/index.js"></script>
+ </head>
+ <body>
+ <header class="container">
+ <nav class="navbar">
+ <a class="navbar-brand" href="../../../../index.html">Albatross.PHP</a>
+ </nav>
+ </header>
+ <main class="container mt-5">
+ <h1 class="mb-4">問題 #2 - 回答 #142</h1>
+ <nav>
+ <ol class="breadcrumb">
+ <li class="breadcrumb-item"><a href="../../../../index.html">問題一覧</a></li>
+ <li class="breadcrumb-item"><a href="../../index.html">Base32</a></li>
+ <li class="breadcrumb-item"><a href="../index.html">回答一覧</a></li>
+ <li class="breadcrumb-item active">#142</li>
+ </ol>
+ </nav>
+
+ <h2>Base32</h2>
+ <p>
+ RFC 4648 で定義された Base32 エンコーディングを実装してください。
+標準入力から与えられる各行に対し、Base32 エンコードをおこなった文字列を標準出力へ改行区切りで出力してください。
+なお、アルファベットの出力には大文字を用いてください。
+ </p>
+ <h2>回答 #142</h2>
+ <p>
+ keitamax が 2024-03-09 10:38:24 に投稿
+ </p>
+ <h2>コード</h2>
+ <p>
+ 426 byte
+ </p>
+ <pre><code class="hljs language-php">$t=array_merge(range(&#039;A&#039;,&#039;Z&#039;),range(&#039;2&#039;,&#039;7&#039;));
+while($line=STDIN) {
+$line=rtrim($line);
+$bits=&#039;&#039;;
+for($i=-1;$i++&lt;strlen($line);) {
+$bits.=str_pad(base_convert(strval(ord($line[$i])),10,2),8,&#039;0&#039;,STR_PAD_LEFT);
+}
+$base32=&#039;&#039;;
+foreach(str_split($bits,5)as$b) {
+$base32.=t[base_convert(str_pad($b,5,&#039;0&#039;),2,10)];
+}
+$base32.=match(strlen($bits)%40){
+8=&gt;&#039;======&#039;,
+16=&gt;&#039;====&#039;,
+24=&gt;&#039;===&#039;,
+32=&gt;&#039;=&#039;,
+default=&gt;&#039;&#039;,
+};
+echo$base32,PHP_EOL;
+}</code></pre>
+ <h2>実行結果</h2>
+ <div class="js-phper-token">
+ </div>
+ <div class="mt-3">
+ ステータス: <span class="js-aggregated-execution-status" data-answer-id="445">失敗</span>
+ </div>
+ <div class="mt-3">
+ <h3>テストケース 1</h3>
+ <div>
+ ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="1032">実行時エラー</span>
+ </div>
+ <h4>標準出力</h4>
+ <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="1032">
+Fatal error: Uncaught TypeError: rtrim(): Argument #1 ($string) must be of type string, resource given in php.wasm code:8
+Stack trace:
+#0 php.wasm code(8): rtrim(Resource id #2)
+#1 {main}
+ thrown in php.wasm code on line 8
+
+</code></pre>
+ <h4>標準エラー出力</h4>
+ <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="1032">
+</code></pre>
+ <h3>テストケース 2</h3>
+ <div>
+ ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="1033">実行時エラー</span>
+ </div>
+ <h4>標準出力</h4>
+ <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="1033">
+Fatal error: Uncaught TypeError: rtrim(): Argument #1 ($string) must be of type string, resource given in php.wasm code:8
+Stack trace:
+#0 php.wasm code(8): rtrim(Resource id #2)
+#1 {main}
+ thrown in php.wasm code on line 8
+
+</code></pre>
+ <h4>標準エラー出力</h4>
+ <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="1033">
+</code></pre>
+ <h3>テストケース 3</h3>
+ <div>
+ ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="1034">実行時エラー</span>
+ </div>
+ <h4>標準出力</h4>
+ <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="1034">
+Fatal error: Uncaught TypeError: rtrim(): Argument #1 ($string) must be of type string, resource given in php.wasm code:8
+Stack trace:
+#0 php.wasm code(8): rtrim(Resource id #2)
+#1 {main}
+ thrown in php.wasm code on line 8
+
+</code></pre>
+ <h4>標準エラー出力</h4>
+ <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="1034">
+</code></pre>
+ <h3>テストケース 4</h3>
+ <div>
+ ステータス: <span class="js-testcase-execution-status" data-testcase-execution-id="1035">実行時エラー</span>
+ </div>
+ <h4>標準出力</h4>
+ <pre><code class="js-testcase-execution-stdout hljs language-plaintext" data-testcase-execution-id="1035">
+Fatal error: Uncaught TypeError: rtrim(): Argument #1 ($string) must be of type string, resource given in php.wasm code:8
+Stack trace:
+#0 php.wasm code(8): rtrim(Resource id #2)
+#1 {main}
+ thrown in php.wasm code on line 8
+
+</code></pre>
+ <h4>標準エラー出力</h4>
+ <pre><code class="js-testcase-execution-stderr hljs language-plaintext" data-testcase-execution-id="1035">
+</code></pre>
+ </div>
+ <script type="module" src="../../../../assets/loading.js"></script>
+ </main>
+ <footer class="container text-center mt-5 mb-4">
+ Albatross.PHP - PHPerKaigi 2024
+ </footer>
+ </body>
+</html>