Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions src/problem1/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const sum_to_n_a = function (n: number) {
if (n <= 0) return 0;
n = Math.floor(n);
let sum = 0;
for (let i = 1; i <= n; i++) {
sum += i;
}
return sum;
};

const sum_to_n_b = function (n: number) {
if (n <= 0) return 0;
n = Math.floor(n);
return (n * (n + 1)) / 2;
};

const sum_to_n_c = function (n: number) {
if (n <= 0) return 0;
n = Math.floor(n);
return Array.from({ length: n }, (_, i) => i + 1).reduce((acc, v) => acc + v, 0);
};
21 changes: 21 additions & 0 deletions src/problem2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node_modules/
dist/
coverage/
.vscode/
.idea/
.eslintcache
*.tsbuildinfo
.DS_Store
Thumbs.db
*.log
npm-debug.log*
yarn-debug.log*
pnpm-debug.log*
lerna-debug.log*
.env
.env.local
.env.development.local
.env.production.local
.env.test.local
*.swp
*.swo
38 changes: 12 additions & 26 deletions src/problem2/index.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fancy Form</title>

<!-- You may add more stuff here -->
<link href="style.css" rel="stylesheet" />
</head>

<body>

<!-- You may reorganise the whole HTML, as long as your form achieves the same effect. -->
<form onsubmit="return !1">
<h5>Swap</h5>
<label for="input-amount">Amount to send</label>
<input id="input-amount" />

<label for="output-amount">Amount to receive</label>
<input id="output-amount" />

<button>CONFIRM SWAP</button>
</form>
<script src="script.js"></script>
</body>

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Coin Swap</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading