Skip to content

Linh Ha (haconglinh1990@gmail.com) — Solutions for Problems 1, 2, 3#274

Open
haconglinh1990 wants to merge 21 commits into
99techteam:mainfrom
haconglinh1990:feat/problem2-swap-form
Open

Linh Ha (haconglinh1990@gmail.com) — Solutions for Problems 1, 2, 3#274
haconglinh1990 wants to merge 21 commits into
99techteam:mainfrom
haconglinh1990:feat/problem2-swap-form

Conversation

@haconglinh1990
Copy link
Copy Markdown

@haconglinh1990 haconglinh1990 commented May 17, 2026

Submission by Linh Ha (@haconglinh1990) — three solved problems.

What's included

  • Problem 1 — src/problem1/sum_to_n.js
    Three implementations of sum_to_n(n): iterative O(n), closed-form Gauss O(1), and a functional reduce O(n)/O(n). Each has complexity notes and handles negative n symmetrically. A small self-check runs when invoked as node sum_to_n.js.

  • Problem 2 — src/problem2/
    A polished currency swap form built with Vite + React + TypeScript + Tailwind + Headless UI + framer-motion + sonner. Dark glassmorphism aesthetic. Live exchange rates from https://interview.switcheo.com/prices.json (fetched once, deduped to latest entry per symbol, tokens without prices dropped). Searchable token picker, two-way amount binding, USD value display, flip-direction button, inline + on-blur validation, disabled submit with tooltip reason, mock 1.5 s submit with a success toast, loading skeleton and error-retry states. 61 unit tests cover the pure logic and the data hook. prefers-reduced-motion respected.

Screenshot 2026-05-17 at 15 47 08
  • Problem 3 — src/problem3/
    Refactor of the buggy WalletPage. Original.tsx preserves the original verbatim for reference; README.md documents six correctness bugs plus a list of TypeScript and performance issues; WalletPage.tsx is the cleaned-up version with a hoisted priority lookup, decorate-sort-undecorate, split filter/format memos with correct dependency arrays, and stable composite keys.

Problems 4 and 5 are not attempted.

How to verify

Problem 1:

node code-challenge/src/problem1/sum_to_n.js

Problem 2:

cd code-challenge/src/problem2
npm install
npm run dev      # open the printed URL
npm test         # 61/61 pure-logic tests
npm run build    # type-check + production build

A smoke-test walkthrough is in src/problem2/README.md.

Problem 3:
The refactor compiles in isolation only if the original project hooks (useWalletBalances, usePrices, WalletRow, BoxProps, classes) are wired in — see the comment block at the top of WalletPage.tsx. README.md walks through the issues one by one.

Notes on the spec/plan trail

Design spec and step-by-step implementation plan for Problem 2 are committed under docs/superpowers/specs/ and docs/superpowers/plans/ so the reasoning behind the architecture and validation rules is auditable.

haconglinh1990 and others added 21 commits May 17, 2026 14:04
Captures the brainstormed design for the fancy currency swap form:
tech stack (Vite + React + TS + Tailwind + Headless UI + sonner +
framer-motion), dark glassmorphism aesthetic, file structure, state
machine with two-way binding rule, validation rules, mock submit flow,
and a narrow unit-test plan.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
14 bite-sized tasks covering bootstrap, Tailwind theme, vitest setup,
shared types and helpers, TDD for swap math/validation/usePrices/
useSwapReducer, then the seven components, and the App shell with
loading + error + toast wiring. Each task ends with a commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds iterative, closed-form (Gauss), and reduce-based implementations
with complexity notes and a small self-check runner.
Preserves the original buggy component in Original.tsx for reference,
documents 6 correctness bugs and TS/perf issues in README.md, and
provides a cleaner WalletPage.tsx with hoisted priority table, decorate-
sort-undecorate, split filter/format memos, and stable composite keys.
@haconglinh1990 haconglinh1990 changed the title Linh Ha — Solutions for Problems 1, 2, 3 Linh Ha (haconglinh1990@gmail.com) — Solutions for Problems 1, 2, 3 May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant