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
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let leftSum =0 | |
let rightSum= A.reduce((acc, el)=>acc+el) | |
let result =null | |
for (let i=0;i<A.length-1;i++){ | |
leftSum+=A[i] | |
rightSum-=A[i] | |
let diff = Math.abs(rightSum-leftSum) | |
if (result ===null ||result >diff){ |
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
function sumTo(n) { | |
return n * (n + 1) / 2; | |
} | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let arraySum = A.reduce(function(acc, el) { return acc + el; }, 0); | |
let sum =sumTo(A.length+1) | |
return sum - arraySum | |
} |
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
function solution(X, Y, D) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
return Math.ceil((Y-X)/D) | |
} |
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
function solution(N) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
if (N === parseInt(N, 10) && N >= 1 && N <= 2147483647) { | |
const binaryArray = N.toString(2).split(''); | |
let res = 0; | |
let acc = 0; | |
binaryArray.forEach((el, i, arr) => { | |
if (el === '0' && arr[i - 1] === '1') { | |
acc++; | |
} |
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
const express = require('express'); | |
const path = require('path'); | |
const port = process.env.PORT || 7096; | |
const app = express(); | |
app.use(express.static(`${__dirname}/build`)); | |
app.get('*', (request, response) => { | |
response.sendFile(path.resolve(__dirname, 'build/index.html')); | |
}); |
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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |