From 668937e3a195ae14d338352a496ec627bee0bf80 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 16 Mar 2025 01:29:40 +0900
Subject: commit admin queries

---
 q2.sql | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)
 create mode 100644 q2.sql

(limited to 'q2.sql')

diff --git a/q2.sql b/q2.sql
new file mode 100644
index 0000000..81be736
--- /dev/null
+++ b/q2.sql
@@ -0,0 +1,187 @@
+UPDATE problems
+SET
+sample_code = $EOF$list($player1_name, $player2_name) = fgetcsv(STDIN, 1024, ',', '"', '');
+while ($row = fgetcsv(STDIN, 1024, ',', '"', '')) {
+    if (count($row) === 0) {
+        break;
+    }
+    $player1_hand = $row[0];
+    $player2_hand = $row[1];
+    switch ($player1_hand) {
+        case "グー":
+            printf("%sさん %s", $player1_name, match ($player1_hand) {
+                "グー" => "\u{270A}",
+                "チョキ" => "\u{270C}",
+                "パー" => "\u{270B}",
+            });
+            echo " vs ";
+            switch ($player2_hand) {
+                case "グー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => あいこ\n";
+                    break;
+                case "チョキ":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player1_name}の勝ち\n";
+                    break;
+                case "パー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player2_name}の勝ち\n";
+                    break;
+
+            }
+        break;
+        case "チョキ":
+            printf("%sさん %s", $player1_name, match ($player1_hand) {
+                "グー" => "\u{270A}",
+                "チョキ" => "\u{270C}",
+                "パー" => "\u{270B}",
+            });
+            echo " vs ";
+            switch ($player2_hand) {
+                case "グー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player2_name}の勝ち\n";
+                    break;
+                case "チョキ":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => あいこ\n";
+                    break;
+                case "パー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player1_name}の勝ち\n";
+                    break;
+
+            }
+        break;
+        case "パー":
+            printf("%sさん %s", $player1_name, match ($player1_hand) {
+                "グー" => "\u{270A}",
+                "チョキ" => "\u{270C}",
+                "パー" => "\u{270B}",
+            });
+            echo " vs ";
+            switch ($player2_hand) {
+                case "グー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player1_name}の勝ち\n";
+                    break;
+                case "チョキ":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => {$player2_name}の勝ち\n";
+                    break;
+                case "パー":
+                    printf("%sさん %s", $player2_name, match ($player2_hand) {
+                        "グー" => "\u{270A}",
+                        "チョキ" => "\u{270C}",
+                        "パー" => "\u{270B}",
+                    });
+                    echo " => あいこ\n";
+                    break;
+            }
+        break;
+    }
+}
+$EOF$
+WHERE title = 'じゃんけん';
+
+UPDATE problems
+SET
+sample_code = $EOF$$aa = array_map(fn($s) => explode("\n", $s), [
+  <<<'AA'
+┌┐
+││
+└┘
+AA,
+  <<<'AA'
+ ┐
+ │
+ ╵
+AA,
+  <<<'AA'
+╶┐
+┌┘
+└╴
+AA,
+  <<<'AA'
+┌┐
+ ┤
+└┘
+AA,
+  <<<'AA'
+╷╷
+└┤
+ ╵
+AA,
+  <<<'AA'
+┌╴
+└┐
+╶┘
+AA,
+  <<<'AA'
+┌┐
+├┐
+└┘
+AA,
+  <<<'AA'
+┌┐
+ │
+ ╵
+AA,
+  <<<'AA'
+┌┐
+├┤
+└┘
+AA,
+  <<<'AA'
+┌┐
+└┤
+└┘
+AA,
+]);
+
+while ($line = fgets(STDIN)) {
+    $digits = str_split(rtrim($line, "\n"));
+    $output = '';
+    foreach (range(0, 2) as $i) {
+        foreach ($digits as $digit) {
+            $output = $output . $aa[$digit][$i];
+        }
+        $output = $output . "\n";
+    }
+    echo $output;
+}
+$EOF$
+WHERE title = 'でっかい数字';
-- 
cgit v1.2.3-70-g09d2

