[FE] - submission: Problems 1, 2 and 3 (with tests and docs) - #296
Open
hieuctfe wants to merge 9 commits into
Open
[FE] - submission: Problems 1, 2 and 3 (with tests and docs)#296hieuctfe wants to merge 9 commits into
hieuctfe wants to merge 9 commits into
Conversation
Searchable token selectors with Switcheo icons, live prices.json rates, input validation, swap-direction flip, and a mocked loading->success submit.
Unit tests for swap/format utils and usePrices; component tests for SwapForm validation/flip/submit and TokenSelect search.
MAX rounded the balance to 8 decimals with toFixed (round-to-nearest), which could produce an amount just above the real balance and fail the insufficient-balance check. Floor to 8 decimals instead, and add a magnitude-scaled epsilon to the balance comparison. Adds a regression test.
P1: collapse to a single sum_to_n.mjs with an inline self-test; drop the separate test file and package.json. P2: add i18n (en/vi JSON catalogs) with a language switcher, a wallet hook, and prices/swap services, each with tests; wire into App and form components. P3: move refactored.tsx under src/ and update tsconfig.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frontend role submission for the 99Tech Code Challenge, covering Problems 1, 2 and 3. Each problem ships with clean code, documentation, and unit tests.
Problem 1: Three ways to sum to n (
src/problem1/)Three distinct implementations of
sum_to_n:sum_to_n_a: iterative loop, O(n) time / O(1) spacesum_to_n_b: closed-form Gauss, O(1), sign-aware to match the negative-n conventionsum_to_n_c: recursion, O(n) time / O(n) stackProblem 2: Fancy Form (
src/problem2/)A currency swap form built with Vite, React, TypeScript and Tailwind CSS.
interview.switcheo.com/prices.json(deduped, priced tokens only) with an offline fallback53 tests with Vitest and React Testing Library (utils, price hook, SwapForm, TokenSelect).
npm run buildpasses.Problem 3: Messy React (
src/problem3/)README.mddocuments the computational inefficiencies and anti-patterns (bugs, performance, type-safety, React smells) with fixes. Business logic is extracted into a pure, testedwalletLogic.tsconsumed by a thinrefactored.tsx. 18 unit tests (Vitest) and a cleantsc --noEmit, including regression tests for the original bugs.Running
cd src/problem1 && node --testcd src/problem2 && npm install && npm test && npm run buildcd src/problem3 && npm install && npm test && npm run typecheck