From fbd4f2129ce8fe106391302896dd86e05b2f331b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Dec 2025 04:08:22 +0900 Subject: add files --- archive/q/base32/a/22/index.html | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 archive/q/base32/a/22/index.html (limited to 'archive/q/base32/a/22') diff --git a/archive/q/base32/a/22/index.html b/archive/q/base32/a/22/index.html new file mode 100644 index 0000000..860de85 --- /dev/null +++ b/archive/q/base32/a/22/index.html @@ -0,0 +1,104 @@ + + + + + 問題 #2 - 回答 #22 | Albatross.PHP + + + + + +
+ +
+
+

問題 #2 - 回答 #22

+ + +

Base32

+

+ RFC 4648 で定義された Base32 エンコーディングを実装してください。 +標準入力から与えられる各行に対し、Base32 エンコードをおこなった文字列を標準出力へ改行区切りで出力してください。 +なお、アルファベットの出力には大文字を用いてください。 +

+

回答 #22

+

+ rinchoku が 2024-03-07 23:28:39 に投稿 +

+

コード

+

+ 505 byte +

+
TABLE=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','2','3','4','5','6','7',];while($line=fgets(STDIN)){$line=rtrim($line);$bits='';for($i=0;$i<strlen($line);$i++){$bits.=str_pad(base_convert(strval(ord($line[$i])),10,2),8,'0',STR_PAD_LEFT);}$base32='';foreach(str_split($bits,5)as$b){$base32.=TABLE[base_convert(str_pad($b,5,'0'),2,10)];}$base32.=match(strlen($bits)%40){8=>'======',16=>'====',24=>'===',32=>'=',default=>'',};echo $base32,"\n";}
+

実行結果

+
+
+
+ ステータス: 失敗 +
+
+

テストケース 1

+
+ ステータス: 実行時エラー +
+

標準出力

+

+Parse error: syntax error, unexpected token "=" in php.wasm code on line 6
+
+
+

標準エラー出力

+

+
+

テストケース 2

+
+ ステータス: 実行時エラー +
+

標準出力

+

+Parse error: syntax error, unexpected token "=" in php.wasm code on line 6
+
+
+

標準エラー出力

+

+
+

テストケース 3

+
+ ステータス: 実行時エラー +
+

標準出力

+

+Parse error: syntax error, unexpected token "=" in php.wasm code on line 6
+
+
+

標準エラー出力

+

+
+

テストケース 4

+
+ ステータス: 実行時エラー +
+

標準出力

+

+Parse error: syntax error, unexpected token "=" in php.wasm code on line 6
+
+
+

標準エラー出力

+

+
+
+ +
+ + + -- cgit v1.2.3-70-g09d2