From fedc187770059328ff420bcc92dde39492fdf110 Mon Sep 17 00:00:00 2001 From: uswebk Date: Tue, 11 Aug 2026 22:46:54 +0900 Subject: [PATCH] Add data-017 to data-021 problems for block insert, sort, capture substitution, and increment Co-Authored-By: Claude Opus 5 --- problems/data/017-prefix-column.json | 54 ++++++++++++++++++++++++++ problems/data/018-sort-records.json | 53 +++++++++++++++++++++++++ problems/data/019-swap-columns.json | 54 ++++++++++++++++++++++++++ problems/data/020-increment-count.json | 49 +++++++++++++++++++++++ problems/data/021-append-comma.json | 54 ++++++++++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 problems/data/017-prefix-column.json create mode 100644 problems/data/018-sort-records.json create mode 100644 problems/data/019-swap-columns.json create mode 100644 problems/data/020-increment-count.json create mode 100644 problems/data/021-append-comma.json diff --git a/problems/data/017-prefix-column.json b/problems/data/017-prefix-column.json new file mode 100644 index 0000000..516f6e7 --- /dev/null +++ b/problems/data/017-prefix-column.json @@ -0,0 +1,54 @@ +{ + "id": "data-017", + "category": "data", + "difficulty": 3, + "start": [ + "alice,30", + "bob,25", + "carol,41" + ], + "goal": [ + "#alice,30", + "#bob,25", + "#carol,41" + ], + "solutions": [ + { + "keys": "jjI#", + "optimal": true + }, + { + "keys": ":%s/^/#/" + } + ], + "tags": [ + "", + "visual-block", + "insert", + "csv" + ], + "i18n": { + "ja": { + "title": "全行の先頭に # を付ける", + "description": "3 行すべての行頭に # を挿入してください", + "hints": [ + "矩形選択したまま挿入すると、選択した全行に同じ文字が入る" + ], + "notes": [ + "jj で 3 行分の矩形を選び、I で先頭に挿入して で全行に反映する", + ":%s/^/#/ は各行の行頭にマッチさせて # を挿入する" + ] + }, + "en": { + "title": "Prefix every line with #", + "description": "Insert a # at the beginning of all three lines", + "hints": [ + "Inserting from a blockwise selection applies the same text to every selected line" + ], + "notes": [ + "jj selects a block spanning three lines, I inserts at the start, and applies it to every line", + ":%s/^/#/ matches the start of each line and inserts a #" + ] + } + } +} diff --git a/problems/data/018-sort-records.json b/problems/data/018-sort-records.json new file mode 100644 index 0000000..1359d56 --- /dev/null +++ b/problems/data/018-sort-records.json @@ -0,0 +1,53 @@ +{ + "id": "data-018", + "category": "data", + "difficulty": 2, + "start": [ + "banana,3", + "apple,5", + "cherry,2" + ], + "goal": [ + "apple,5", + "banana,3", + "cherry,2" + ], + "solutions": [ + { + "keys": ":sort", + "optimal": true + }, + { + "keys": ":1,3sort" + } + ], + "tags": [ + ":sort", + "sort", + "csv" + ], + "i18n": { + "ja": { + "title": "レコードを名前順に並べ替える", + "description": "3 行を先頭の名前の昇順に並べ替えてください", + "hints": [ + "並べ替え専用の Ex コマンドがある" + ], + "notes": [ + ":sort は範囲を省略するとバッファ全体を辞書順に並べ替える", + ":1,3sort は 1〜3 行目を明示して並べ替える。範囲指定が必要なときの書き方" + ] + }, + "en": { + "title": "Sort the records by name", + "description": "Reorder the three lines alphabetically by the leading name", + "hints": [ + "There is an Ex command dedicated to sorting" + ], + "notes": [ + ":sort with no range sorts the whole buffer lexicographically", + ":1,3sort sorts lines 1 through 3 explicitly, the form to use when you need a range" + ] + } + } +} diff --git a/problems/data/019-swap-columns.json b/problems/data/019-swap-columns.json new file mode 100644 index 0000000..2042491 --- /dev/null +++ b/problems/data/019-swap-columns.json @@ -0,0 +1,54 @@ +{ + "id": "data-019", + "category": "data", + "difficulty": 3, + "start": [ + "alice,30", + "bob,25", + "carol,41" + ], + "goal": [ + "30,alice", + "25,bob", + "41,carol" + ], + "solutions": [ + { + "keys": ":%s/\\(.*\\),\\(.*\\)/\\2,\\1/", + "optimal": true + }, + { + "keys": ":%s/\\v(\\w+),(\\w+)/\\2,\\1/" + } + ], + "tags": [ + ":s", + "substitute", + "regex", + "csv" + ], + "i18n": { + "ja": { + "title": "2 つの列を入れ替える", + "description": "各行の名前と数値の並びを入れ替えて「数値,名前」にしてください", + "hints": [ + "置換でカンマの前後をそれぞれ取り込んでおくと、置換後に順番を入れ替えられる" + ], + "notes": [ + "\\(...\\) で囲んだ 2 か所を \\1 \\2 で参照し、順番を逆にして書き戻す", + "\\v を付けると括弧のエスケープが不要になる。\\w+ で各列を取り込んで入れ替える" + ] + }, + "en": { + "title": "Swap the two columns", + "description": "Reverse the name and number on each line so it reads number,name", + "hints": [ + "Capture what is on each side of the comma, then write the captures back in the other order" + ], + "notes": [ + "The two \\(...\\) groups are referenced as \\1 and \\2 and written back reversed", + "With \\v the parentheses need no escaping; \\w+ captures each column before swapping them" + ] + } + } +} diff --git a/problems/data/020-increment-count.json b/problems/data/020-increment-count.json new file mode 100644 index 0000000..266a4f3 --- /dev/null +++ b/problems/data/020-increment-count.json @@ -0,0 +1,49 @@ +{ + "id": "data-020", + "category": "data", + "difficulty": 2, + "start": [ + "ERROR retry count=9" + ], + "goal": [ + "ERROR retry count=10" + ], + "solutions": [ + { + "keys": "", + "optimal": true + }, + { + "keys": "$" + } + ], + "tags": [ + "", + "increment", + "log" + ], + "i18n": { + "ja": { + "title": "カウントを 1 増やす", + "description": "行末のカウントを 9 から 10 に増やしてください", + "hints": [ + "数字を書き換えなくても、その場で増やせるコマンドがある" + ], + "notes": [ + " はカーソル位置以降で最初に見つかった数値を 1 増やす。行頭からでもそのまま効く", + "$ で数値の上に移動してから で増やす。狙う数値が複数あるときはこの形が確実" + ] + }, + "en": { + "title": "Increment the count", + "description": "Raise the count at the end of the line from 9 to 10", + "hints": [ + "You can bump a number in place instead of retyping it" + ], + "notes": [ + " increments the first number at or after the cursor, so it works straight from the start of the line", + "$ moves onto the number first, then increments it — the reliable form when a line holds several numbers" + ] + } + } +} diff --git a/problems/data/021-append-comma.json b/problems/data/021-append-comma.json new file mode 100644 index 0000000..f205308 --- /dev/null +++ b/problems/data/021-append-comma.json @@ -0,0 +1,54 @@ +{ + "id": "data-021", + "category": "data", + "difficulty": 2, + "start": [ + "alice", + "bob", + "carol" + ], + "goal": [ + "alice,", + "bob,", + "carol," + ], + "solutions": [ + { + "keys": ":%s/$/,/", + "optimal": true + }, + { + "keys": ":%normal! A," + } + ], + "tags": [ + ":s", + ":normal", + "substitute", + "csv" + ], + "i18n": { + "ja": { + "title": "全行の末尾にカンマを付ける", + "description": "3 行すべての行末にカンマを追加してください", + "hints": [ + "行末そのものにマッチさせれば、1 回の置換で全行に追記できる" + ], + "notes": [ + ":%s/$/,/ は各行の行末にマッチして、そこにカンマを挿入する", + ":%normal! A, は各行で追記モードに入りカンマを打つ。 でコマンドを終えると挿入も確定する" + ] + }, + "en": { + "title": "Append a comma to every line", + "description": "Add a trailing comma to all three lines", + "hints": [ + "Matching the end of the line lets a single substitution append to every line" + ], + "notes": [ + ":%s/$/,/ matches the end of each line and inserts a comma there", + ":%normal! A, appends a comma on each line; ending the command with also ends the insert" + ] + } + } +}