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
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
47 changes: 29 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
function moveZeros(arr = '') {
function twistIt(str = '') {
return str.split('').map((a, i, arr) => arr[arr.length - i - 1]).join('')
}
return arr.split(' ').map(item => twistIt(item)).join(' ')
}

console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps")
console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps")
console.log(moveZeros("double spaces"), "double spaces", '==>', "elbuod secaps")

function manhattanDistance(arr0, arr1) {
function fn(params) {
// ? Write the function bigToSmall, which will take one argument arr (two-dimensional array).
// ? Bring the two-dimensional array to one-dimensional. Sort the array in descending order.
// ? Use the '>' character as a separator when converting an array to a string. For example:
// ? bigToSmall([[1,2],[3,4],[5,6]]) "6>5>4>3>2>1"
// ? bigToSmall([[1,3,5],[2,4,6]]) "6>5>4>3>2>1"
// ? bigToSmall([[1,1],[1],[1,1]]) "1>1>1>1>1"

return Math.abs(params)
function bigToSmall(arr) {
var arr2 = []
for (var i = arr.length - 1; i >= 0; i--) {
for (var j = arr[i].length - 1; j >= 0; j--) {
arr2.push(arr[i][j])
}
}
return (fn(arr0[0] - arr1[0]) + fn(arr0[1] - arr1[1]))
return arr2.join('>')
}

console.log(manhattanDistance([1, 1], [1, 1]), '=> returns 0')
console.log(manhattanDistance([5, 4], [3, 2]), '=> returns 4')
console.log(manhattanDistance([1, 1], [0, 3]), '=> returns 3')
console.log(
bigToSmall([
[1, 3, 5],
[2, 4, 6],
]),
'6>5>4>3>2>1',
)
console.log(bigToSmall([[1, 1], [1], [1, 1]]), '1>1>1>1>1')
console.log(
bigToSmall([
[1, 2],
[3, 4],
[5, 6],
]),
'6>5>4>3>2>1',
)
159 changes: 133 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-promise": "^6.1.1",
"prettier": "^2.8.1"
"prettier": "^2.8.1",
"eslint-plugin-node": "^11.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
6 changes: 2 additions & 4 deletions registration-form/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "interviewtask",
"name": "interviewask",
"version": "1.0.0",
"main": "index.js",
"scripts": {
Expand All @@ -8,9 +8,7 @@
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {

},
"devDependencies": {},
"dependencies": {
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
Expand Down