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
53 changes: 53 additions & 0 deletions problems/data/009-replace-all-delimiters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"id": "data-009",
"category": "data",
"difficulty": 2,
"start": [
"1;alice;active",
"2;bob;active",
"3;carol;inactive"
],
"goal": [
"1,alice,active",
"2,bob,active",
"3,carol,inactive"
],
"solutions": [
{
"keys": ":%s/;/,/g<CR>",
"optimal": true
},
{
"keys": ":1,3s/;/,/g<CR>"
}
],
"tags": [
":s",
"substitute",
"csv"
],
"i18n": {
"ja": {
"title": "区切り文字を一括で置換する",
"description": "すべてのセミコロンをカンマに置き換えてください",
"hints": [
":%s/old/new/g は全行のすべての一致を置換する"
],
"notes": [
":%s/;/,/g の % は全行、末尾の g は行内のすべての一致を意味する",
":1,3s/;/,/g のように範囲を数字で指定しても同じ結果になる"
]
},
"en": {
"title": "Replace every delimiter",
"description": "Replace every semicolon with a comma",
"hints": [
":%s/old/new/g substitutes every match on every line"
],
"notes": [
"In :%s/;/,/g the % means all lines and the trailing g means every match in each line",
"An explicit range like :1,3s/;/,/g does the same thing"
]
}
}
}
54 changes: 54 additions & 0 deletions problems/data/010-strip-trailing-comma.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"id": "data-010",
"category": "data",
"difficulty": 2,
"start": [
"id,name,",
"1,alice,",
"2,bob,"
],
"goal": [
"id,name",
"1,alice",
"2,bob"
],
"solutions": [
{
"keys": ":%s/,$//<CR>",
"optimal": true
},
{
"keys": ":%normal $x<CR>"
}
],
"tags": [
":s",
"substitute",
"regex",
"csv"
],
"i18n": {
"ja": {
"title": "行末のカンマを消す",
"description": "各行の末尾のカンマを削除してください",
"hints": [
"置換パターンの $ は行末にマッチする"
],
"notes": [
":%s/,$// は全行の行末カンマだけを空文字に置換する",
":%normal $x で全行に対して $x(行末へ移動して1文字削除)を実行しても同じ"
]
},
"en": {
"title": "Strip the trailing comma",
"description": "Delete the trailing comma on every line",
"hints": [
"$ in a substitute pattern matches the end of the line"
],
"notes": [
":%s/,$// replaces only the end-of-line comma with nothing on every line",
":%normal $x runs $x (jump to end of line, delete one char) on every line for the same result"
]
}
}
}
52 changes: 52 additions & 0 deletions problems/data/011-update-status-values.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"id": "data-011",
"category": "data",
"difficulty": 2,
"start": [
"1,alice,pending",
"2,bob,done",
"3,carol,pending"
],
"goal": [
"1,alice,done",
"2,bob,done",
"3,carol,done"
],
"solutions": [
{
"keys": ":%s/pending/done/<CR>",
"optimal": true
},
{
"keys": ":%s/pending/done/g<CR>"
}
],
"tags": [
":s",
"substitute"
],
"i18n": {
"ja": {
"title": "ステータスをまとめて更新する",
"description": "すべての pending を done に置き換えてください",
"hints": [
"1行に1回しか出てこない語なら g フラグは要らない"
],
"notes": [
":%s/pending/done/ は各行の最初の一致だけを置換する。1行1回なのでこれで十分",
"g フラグを付けても結果は同じだが、この行では不要"
]
},
"en": {
"title": "Update the status values",
"description": "Replace every 'pending' with 'done'",
"hints": [
"The g flag is unnecessary when the word appears once per line"
],
"notes": [
":%s/pending/done/ substitutes the first match on each line, which is enough here",
"Adding the g flag gives the same result but is not needed on these lines"
]
}
}
}
55 changes: 55 additions & 0 deletions problems/data/012-delete-blank-rows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"id": "data-012",
"category": "data",
"difficulty": 3,
"start": [
"1,alice",
"",
"2,bob",
"",
"3,carol"
],
"goal": [
"1,alice",
"2,bob",
"3,carol"
],
"solutions": [
{
"keys": ":g/^$/d<CR>",
"optimal": true
},
{
"keys": "jddjdd"
}
],
"tags": [
":g",
"global",
"dd"
],
"i18n": {
"ja": {
"title": "空行を取り除く",
"description": "データの間にある空行をすべて削除してください",
"hints": [
":g/pattern/d はパターンに一致する行をすべて削除する"
],
"notes": [
":g/^$/d は空行(行頭がすぐ行末の行)だけを対象に d を実行する",
"空行が少なければ j で移動して dd を繰り返してもよい"
]
},
"en": {
"title": "Remove the blank rows",
"description": "Delete every blank line between the data rows",
"hints": [
":g/pattern/d deletes every line matching the pattern"
],
"notes": [
":g/^$/d runs d on every empty line (start of line immediately followed by end of line)",
"With only a couple of blanks you can also just move with j and repeat dd"
]
}
}
}
Loading