{"schemaVersion":1,"contentVersion":"3.4.0","id":"intermediate.19","languages":{"javascript":{"id":"intermediate.19","title":"Optional: numeric changes","moduleName":"Optional extensions","tips":"","concept":"<p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p><strong>Before this lesson:</strong> Counts and recovery.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h3>Example</h3><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p>","teaches":["arithmetic"],"introduces":["<C-a>","<C-x>","count"],"constraints":[],"drills":[{"task":"Card payments that fail get a few more tries. Give them one more attempt.","hint":"Ctrl-a adds one to the first number at or after the cursor on the line, so you don't have to move onto it.","mode":"jsx","start":"import { sql } from \"../db\";\n\n// The payments the retry job picks up every ten minutes.\nexport function paymentsToRetry() {\n  return sql`\n    SELECT id, order_id, amount_cents FROM payments\n    WHERE status = 'failed' AND attempts < 3\n  `;\n}","startCursor":{"line":6,"ch":4},"paths":[{"keys":["<C-a>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic"],"note":"Ctrl-a jumps to the number on the line and adds one."}],"target":"import { sql } from \"../db\";\n\n// The payments the retry job picks up every ten minutes.\nexport function paymentsToRetry() {\n  return sql`\n    SELECT id, order_id, amount_cents FROM payments\n    WHERE status = 'failed' AND attempts < 4\n  `;\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.19#0","canonicalFingerprint":"ujparm"},{"task":"The bag is too small in the new header. Add 16 to its size.","hint":"A count before Ctrl-a adds that much. Ctrl-a finds the number on the line by itself.","mode":"jsx","start":"import { ShoppingBag } from \"lucide-react\";\n\nexport function CartIcon({ count }) {\n  return (\n    <button className=\"cart-icon\" aria-label={`Cart, ${count} items`}>\n      <ShoppingBag size={24} strokeWidth={1.5} />\n      {count > 0 && <span className=\"cart-count\">{count}</span>}\n    </button>\n  );\n}","startCursor":{"line":4,"ch":4},"paths":[{"keys":["j","1","6","<C-a>"],"tier":"idiomatic","technique":"count","core":["count","arithmetic"],"note":"16 Ctrl-a adds 16. You never type the new number."}],"target":"import { ShoppingBag } from \"lucide-react\";\n\nexport function CartIcon({ count }) {\n  return (\n    <button className=\"cart-icon\" aria-label={`Cart, ${count} items`}>\n      <ShoppingBag size={40} strokeWidth={1.5} />\n      {count > 0 && <span className=\"cart-count\">{count}</span>}\n    </button>\n  );\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.19#1","canonicalFingerprint":"1ey32ef"},{"task":"Lower the page size from 50 to 20.","hint":"A count before Ctrl-x takes that much off. Ctrl-x finds the number on the line by itself.","mode":"jsx","start":"import { useQuery } from \"@tanstack/react-query\";\nimport { listOrders } from \"../api/orders\";\n\n// The orders table in the admin. Smaller pages load faster on a phone.\nconst PAGE_SIZE = 50;\n\nexport function useOrders(page) {\n  return useQuery({ queryKey: [\"orders\", page], queryFn: () => listOrders(page, PAGE_SIZE) });\n}","startCursor":{"line":3,"ch":0},"paths":[{"keys":["j","3","0","<C-x>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic","count"],"note":"30 Ctrl-x takes 30 off, wherever the number is on the line."}],"target":"import { useQuery } from \"@tanstack/react-query\";\nimport { listOrders } from \"../api/orders\";\n\n// The orders table in the admin. Smaller pages load faster on a phone.\nconst PAGE_SIZE = 20;\n\nexport function useOrders(page) {\n  return useQuery({ queryKey: [\"orders\", page], queryFn: () => listOrders(page, PAGE_SIZE) });\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.19#2","canonicalFingerprint":"12jmpgi"}]},"python":{"id":"intermediate.19","title":"Optional: numeric changes","moduleName":"Optional extensions","tips":"","concept":"<p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p><strong>Before this lesson:</strong> Counts and recovery.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h3>Example</h3><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p>","teaches":["arithmetic"],"introduces":["<C-a>","<C-x>","count"],"constraints":[],"drills":[{"task":"The shop is slow at lunchtime. Start one more worker.","hint":"Ctrl-a adds one to the first number at or after the cursor on the line, so you don't have to move onto it.","mode":"python","start":"# gunicorn reads this when the web container starts.\nimport multiprocessing\n\nbind = \"0.0.0.0:8000\"\nworkers = multiprocessing.cpu_count() + 1\ntimeout = 30\naccesslog = \"-\"","startCursor":{"line":4,"ch":0},"paths":[{"keys":["<C-a>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic"],"note":"Ctrl-a jumps to the number on the line and adds one."}],"target":"# gunicorn reads this when the web container starts.\nimport multiprocessing\n\nbind = \"0.0.0.0:8000\"\nworkers = multiprocessing.cpu_count() + 2\ntimeout = 30\naccesslog = \"-\"","language":"python","evidence":"guided","canonicalKey":"intermediate.19#0","canonicalFingerprint":"ujparm"},{"task":"The social icons are too small in the new email footer. Add 16 to their size.","hint":"A count before Ctrl-a adds that much. Ctrl-a finds the number on the line by itself.","mode":"python","start":"# The footer under every email we send.\nSOCIAL_LINKS = [\n    (\"Instagram\", \"https://instagram.com/northwind.outdoor\"),\n    (\"YouTube\", \"https://youtube.com/@northwindoutdoor\"),\n]\nICON_SIZE = 24\nLOGO_WIDTH = 120","startCursor":{"line":6,"ch":0},"paths":[{"keys":["k","1","6","<C-a>"],"tier":"idiomatic","technique":"count","core":["count","arithmetic"],"note":"16 Ctrl-a adds 16. You never type the new number."}],"target":"# The footer under every email we send.\nSOCIAL_LINKS = [\n    (\"Instagram\", \"https://instagram.com/northwind.outdoor\"),\n    (\"YouTube\", \"https://youtube.com/@northwindoutdoor\"),\n]\nICON_SIZE = 40\nLOGO_WIDTH = 120","language":"python","evidence":"guided","canonicalKey":"intermediate.19#1","canonicalFingerprint":"1ey32ef"},{"task":"Lower the page size from 50 to 20.","hint":"A count before Ctrl-x takes that much off. Ctrl-x finds the number on the line by itself.","mode":"python","start":"from django.core.paginator import Paginator\n\n# The orders table in the admin. Smaller pages load faster on a phone.\nPAGE_SIZE = 50\n\n\ndef orders_page(queryset, number):\n    return Paginator(queryset.order_by(\"-created\"), PAGE_SIZE).get_page(number)","startCursor":{"line":2,"ch":0},"paths":[{"keys":["j","3","0","<C-x>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic","count"],"note":"30 Ctrl-x takes 30 off, wherever the number is on the line."}],"target":"from django.core.paginator import Paginator\n\n# The orders table in the admin. Smaller pages load faster on a phone.\nPAGE_SIZE = 20\n\n\ndef orders_page(queryset, number):\n    return Paginator(queryset.order_by(\"-created\"), PAGE_SIZE).get_page(number)","language":"python","evidence":"guided","canonicalKey":"intermediate.19#2","canonicalFingerprint":"12jmpgi"}]},"text":{"id":"intermediate.19","title":"Optional: numeric changes","moduleName":"Optional extensions","tips":"","concept":"<p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p><strong>Before this lesson:</strong> Counts and recovery.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h3>Example</h3><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p>","teaches":["arithmetic"],"introduces":["<C-a>","<C-x>","count"],"constraints":[],"drills":[{"task":"The browser tests are slow. Run them on one more worker.","hint":"Ctrl-a adds one to the first number at or after the cursor on the line, so you don't have to move onto it.","mode":"text/plain","start":"name: Browser tests\non: pull_request\njobs:\n  playwright:\n    runs-on: ubuntu-24.04\n    steps:\n      - uses: actions/checkout@v5\n      - run: npm ci\n      - run: npx playwright test --workers=2","startCursor":{"line":8,"ch":8},"paths":[{"keys":["<C-a>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic"],"note":"Ctrl-a jumps to the number on the line and adds one."}],"target":"name: Browser tests\non: pull_request\njobs:\n  playwright:\n    runs-on: ubuntu-24.04\n    steps:\n      - uses: actions/checkout@v5\n      - run: npm ci\n      - run: npx playwright test --workers=3","language":"text","evidence":"guided","canonicalKey":"intermediate.19#0","canonicalFingerprint":"ujparm"},{"task":"The icons are too small next to the new type. Add 16 to the icon size.","hint":"A count before Ctrl-a adds that much. Ctrl-a finds the number on the line by itself.","mode":"text/plain","start":"/* Sizes used across the shop. Components read these, never raw numbers. */\n:root {\n  --space-unit: 4px;\n  --radius: 6px;\n  --icon-size: 24px;\n  --header-height: 64px;\n}","startCursor":{"line":5,"ch":2},"paths":[{"keys":["k","1","6","<C-a>"],"tier":"idiomatic","technique":"count","core":["count","arithmetic"],"note":"16 Ctrl-a adds 16. You never type the new number."}],"target":"/* Sizes used across the shop. Components read these, never raw numbers. */\n:root {\n  --space-unit: 4px;\n  --radius: 6px;\n  --icon-size: 40px;\n  --header-height: 64px;\n}","language":"text","evidence":"guided","canonicalKey":"intermediate.19#1","canonicalFingerprint":"1ey32ef"},{"task":"Lower the page size of the order list from 50 to 20.","hint":"A count before Ctrl-x takes that much off. Ctrl-x finds the number on the line by itself.","mode":"text/plain","start":"# The admin's lists. Smaller pages load faster on a phone.\norders:\n  page_size: 50\n  sort: newest_first\n  show_cancelled: false\nrefunds:\n  page_size: 25","startCursor":{"line":1,"ch":0},"paths":[{"keys":["j","3","0","<C-x>"],"tier":"idiomatic","technique":"arithmetic","core":["arithmetic","count"],"note":"30 Ctrl-x takes 30 off, wherever the number is on the line."}],"target":"# The admin's lists. Smaller pages load faster on a phone.\norders:\n  page_size: 20\n  sort: newest_first\n  show_cancelled: false\nrefunds:\n  page_size: 25","language":"text","evidence":"guided","canonicalKey":"intermediate.19#2","canonicalFingerprint":"12jmpgi"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Counts and recovery.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h2 class=\"prose-subhead\">Example</h2><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Counts and recovery.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h2 class=\"prose-subhead\">Example</h2><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Counts and recovery.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Add to or subtract from a number without changing the numbers near it.</p><p>Ctrl-a adds one to the number at or after the cursor on the line, and Ctrl-x subtracts one. It finds the number by itself, so you don't have to move onto it first. A count changes the amount, so 30 Ctrl-x takes 30 off. These exercises use plain whole numbers, because numbers like 0x1f follow their own rules. Check which number comes first on the line before you press it.</p><h2 class=\"prose-subhead\">Example</h2><p>From 7, Ctrl-a gives 8 and 3Ctrl-a gives 10. You never have to type the new number.</p><p>Use Start over to try again.</p></div></details>"}}}