Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions problems/data/017-prefix-column.json
Original file line number Diff line number Diff line change
@@ -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": "<C-v>jjI#<Esc>",
"optimal": true
},
{
"keys": ":%s/^/#/<CR>"
}
],
"tags": [
"<C-v>",
"visual-block",
"insert",
"csv"
],
"i18n": {
"ja": {
"title": "全行の先頭に # を付ける",
"description": "3 行すべての行頭に # を挿入してください",
"hints": [
"矩形選択したまま挿入すると、選択した全行に同じ文字が入る"
],
"notes": [
"<C-v>jj で 3 行分の矩形を選び、I で先頭に挿入して <Esc> で全行に反映する",
":%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": [
"<C-v>jj selects a block spanning three lines, I inserts at the start, and <Esc> applies it to every line",
":%s/^/#/ matches the start of each line and inserts a #"
]
}
}
}
53 changes: 53 additions & 0 deletions problems/data/018-sort-records.json
Original file line number Diff line number Diff line change
@@ -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<CR>",
"optimal": true
},
{
"keys": ":1,3sort<CR>"
}
],
"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"
]
}
}
}
54 changes: 54 additions & 0 deletions problems/data/019-swap-columns.json
Original file line number Diff line number Diff line change
@@ -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/<CR>",
"optimal": true
},
{
"keys": ":%s/\\v(\\w+),(\\w+)/\\2,\\1/<CR>"
}
],
"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"
]
}
}
}
49 changes: 49 additions & 0 deletions problems/data/020-increment-count.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"id": "data-020",
"category": "data",
"difficulty": 2,
"start": [
"ERROR retry count=9"
],
"goal": [
"ERROR retry count=10"
],
"solutions": [
{
"keys": "<C-a>",
"optimal": true
},
{
"keys": "$<C-a>"
}
],
"tags": [
"<C-a>",
"increment",
"log"
],
"i18n": {
"ja": {
"title": "カウントを 1 増やす",
"description": "行末のカウントを 9 から 10 に増やしてください",
"hints": [
"数字を書き換えなくても、その場で増やせるコマンドがある"
],
"notes": [
"<C-a> はカーソル位置以降で最初に見つかった数値を 1 増やす。行頭からでもそのまま効く",
"$ で数値の上に移動してから <C-a> で増やす。狙う数値が複数あるときはこの形が確実"
]
},
"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": [
"<C-a> 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 <C-a> increments it — the reliable form when a line holds several numbers"
]
}
}
}
54 changes: 54 additions & 0 deletions problems/data/021-append-comma.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"id": "data-021",
"category": "data",
"difficulty": 2,
"start": [
"alice",
"bob",
"carol"
],
"goal": [
"alice,",
"bob,",
"carol,"
],
"solutions": [
{
"keys": ":%s/$/,/<CR>",
"optimal": true
},
{
"keys": ":%normal! A,<CR>"
}
],
"tags": [
":s",
":normal",
"substitute",
"csv"
],
"i18n": {
"ja": {
"title": "全行の末尾にカンマを付ける",
"description": "3 行すべての行末にカンマを追加してください",
"hints": [
"行末そのものにマッチさせれば、1 回の置換で全行に追記できる"
],
"notes": [
":%s/$/,/ は各行の行末にマッチして、そこにカンマを挿入する",
":%normal! A, は各行で追記モードに入りカンマを打つ。<CR> でコマンドを終えると挿入も確定する"
]
},
"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 <CR> also ends the insert"
]
}
}
}
Loading