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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/problem2/index.html

This file was deleted.

Empty file removed src/problem2/script.js
Empty file.
8 changes: 0 additions & 8 deletions src/problem2/style.css

This file was deleted.

Empty file removed src/problem3/.keep
Empty file.
39 changes: 39 additions & 0 deletions src/problem4/sum-to-n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Iterative approach
* @param n number
* @returns number
*/
export const sum_to_n_a = (n: number): number => {
let sum = 0;
const step = n >= 1 ? 1 : -1;

for (let i = 1; i !== n + step; i += step) {
sum += i;
}

return sum;
};

/**
* Mathematical formula approach
* @param n number
* @returns number
*/
export const sum_to_n_b = (n: number): number => {
if (n <= 0) return 0;

return (n * (n + 1)) / 2;
};

/**
* Recursive approach
* @param n number
* @returns number
*/
export const sum_to_n_c = (n: number): number => {
if (n === 0) return 0;

return n > 0
? n + sum_to_n_c(n - 1)
: n + sum_to_n_c(n + 1);
};
11 changes: 11 additions & 0 deletions src/problem5/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
APP_MODE = "local"
APP_KEY = "AUNGKYAWHTWE1234567890"

RUNNING_PORT = 3000
API_CORS_ORIGIN = "*"

MONGO_URL = ""
MONGO_DBNAME = "users-api"

AUTH_USERNAME = "Admin"
AUTH_PASSWORD = "PASSWORD123"
1 change: 1 addition & 0 deletions src/problem5/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
37 changes: 37 additions & 0 deletions src/problem5/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"no-console": "error",
"no-namespace": "off",
"no-invalid-regexp": "error",
"no-case-declarations": "off",
"no-unused-vars": "off",
"no-var-requires": "off",
"semi": ["error", "always"],
"security/detect-object-injection": "off",
"indent": ['error', 2, { FunctionDeclaration: { parameters: 'first' } }],
"no-trailing-spaces": 'error',
"eol-last": ['error', 'always']
},
};
2 changes: 2 additions & 0 deletions src/problem5/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
127 changes: 127 additions & 0 deletions src/problem5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
1 change: 1 addition & 0 deletions src/problem5/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions src/problem5/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"printWidth": 125
}
19 changes: 19 additions & 0 deletions src/problem5/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"search.exclude": {
"**/node_modules": true
},
"prettier.useTabs": true,
"prettier.tabWidth": 2,
"prettier.singleQuote": true,
"editor.snippetSuggestions": "top"
}
Loading