A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation 100000 and has no binary gaps.
Write a function:
function solution(N);
that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.
For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5. Given N = 32 the function should return 0, because N has binary representation '100000' and thus no binary gaps.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [1..2,147,483,647].
10000010001
1111
100000
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = (N).toString(2);
let amountOf0 = 0;
binary.forEach(bit => )
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = (N).toString(2);
let amountOf0 = 0;
binary.forEach(bit => {
console.log(bit)
})
console.log((N).toString(2))
return N;
}
example test n=1041=10000010001_2
tested program terminated with exit code 1
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2)).toString();
let amountOf0 = 0;
binary.forEach(bit => {
console.log(bit)
})
console.log((N).toString(2))
return N;
}
example test n=1041=10000010001_2
tested program terminated with exit code 1
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
TypeError: binary.forEach is not a function at solution (solution.js:8:12) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2)));
let amountOf0 = 0;
binary.forEach(bit => {
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
console.log(bit)
})
console.log((N).toString(2))
return N;
}
1 0 0 0 0 0 1 0 0 0 1 10000010001
1 1 1 1 1111
1 0 0 0 0 0 100000
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
if()
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
if(bit == 0)
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
if(bit == 1) {
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
f[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; )[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i)[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++)[...binary].forEach(bit => {
if(bit == 1) {
}
}
console.log(bit)
})
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
bin
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
binary.indexOf(0);
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
binary.indexOf(0);
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
binary.indexOf(0);
binary.slice()
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
if(bit == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
if(binary[0] == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
if(binary[0] == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
let startCounting = false;
if(binary[0] == 1) {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
for(let i = 0; i < binary.length; i++) {
let startCounting = false;
if() {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 0; i < binary.length; i++) {
if() {
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting && binary[i] == 0) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting && binary[i] == 0) {
amount ++;
}
console.log(bit)
}
console.log((N).toString(2))
return N;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting && binary[i] == 0) {
amount ++;
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
}
if(binary[i] == 0) {
amount ++;
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(!startCounting) {
}
{
if(binary[i] == 0) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
} else if() {
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const isOne = value => value == 1
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = binary[0] == 1;
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(binary[i] == 0) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(is0(binary[i]) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if()
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0]))
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let maxAmount =
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let maxAmount = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
maxAmount = maxAmount >
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let maxAmount = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
maxAmount = maxAmount < amountOf0 : amountOf0;
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let maxAmount = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
maxAmount = maxAmount < amountOf0? : amountOf0;
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let amountOf0 = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < amountOf0? amountOf0 : max;
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
startCounting = true;
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
startCounting = true;
} else {
}
if(startCounting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
startCounting = true;
} else {
if(start)
}
if(counting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
if(counting) {
if(is0(binary[i])) {
amount ++;
}
} else {
if()
}
console.log(bit)
}
console.log((N).toString(2))
return amountOf0;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = maxAmount < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return max;
}
example test n=1041=10000010001_2
tested program terminated with exit code 1
ReferenceError: maxAmount is not defined at solution (solution.js:14:13) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
ReferenceError: maxAmount is not defined at solution (solution.js:14:13) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
ReferenceError: maxAmount is not defined at solution (solution.js:14:13) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(bit)
}
console.log((N).toString(2))
return max;
}
example test n=1041=10000010001_2
tested program terminated with exit code 1
ReferenceError: bit is not defined at solution (solution.js:22:21) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
ReferenceError: bit is not defined at solution (solution.js:22:21) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
ReferenceError: bit is not defined at solution (solution.js:22:21) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
0 0 0 0 0 1 0 0 0 1 10000010001
1 1 1 1111
0 0 0 0 0 100000
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
01
00
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
010
000
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
01
00
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
counting =
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = false;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
amount ++;
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
amount ++;
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i])
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1{}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1{binary[]}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
counting = is1{binary[]}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1(binary[i])
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1(binary[i]) ||
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1(binary[i]) || is()
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1(binary[i]) || is0()
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
counting = is1(binary[i]) || is0()
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
counting = is1{binary[]}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
counting = is1{binary[]}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[0])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
amount ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
example test n=1041=10000010001_2
tested program terminated with exit code 1
ReferenceError: amount is not defined at solution (solution.js:20:17) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
1 true 1 true 1 true 1111
ReferenceError: amount is not defined at solution (solution.js:20:17) at solutionWrapper (/tmp/exec.js:394:28) at Promise.resolve.then (/tmp/exec.js:420:24) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
0 true 0 true 0 true 0 true 0 true 1 true 0 true 0 true 0 true 1 true 10000010001
1 true 1 true 1 true 1111
0 true 0 true 0 true 0 true 0 true 100000
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
0 true 0 true 0 true 0 true 0 true 1 true 0 true 0 true 0 true 1 true 10000010001
1 true 1 true 1 true 1111
0 true 0 true 0 true 0 true 0 true 100000
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = binaris1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let shouldCount = binary.indexOf(1) > 0;
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(shouldCount) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let shouldCount = binary.indexOf(1) > 0;
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
} else {
if(shouldCount) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = binary.indexOf(1)is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let counting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
counting = true;
} else {
if(counting) {
count ++;
}
}
console.log(binary[i], counting)
}
console.log((N).toString(2))
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1);
solution(6);
solution(50);
solution(99);
solution(100);
solution(451);
solution(483);
solution(500);
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution('1');
solution('6');
solution('50');
solution('99');
solution('100');
solution('451');
solution('483');
solution('500');
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1);
solution(6);
solution(50);
solution(99);
solution(100);
solution(451);
solution(483);
solution(500);
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1)
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(parseInt(1))
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(parseInt("1"))
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1)
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution("1")
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1)
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(int N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(int N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1)
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
example test n=1041=10000010001_2
tested program terminated with exit code 1
solution.js:6 function solution(int N) { ^ SyntaxError: Unexpected identifier at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:384:29) at Promise.resolve.then (/tmp/exec.js:418:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
solution.js:6 function solution(int N) { ^ SyntaxError: Unexpected identifier at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:384:29) at Promise.resolve.then (/tmp/exec.js:418:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
solution.js:6 function solution(int N) { ^ SyntaxError: Unexpected identifier at createScript (vm.js:80:10) at Object.runInNewContext (vm.js:135:10) at getSolution (/tmp/exec.js:384:29) at Promise.resolve.then (/tmp/exec.js:418:34) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7) at Function.Module.runMain (module.js:686:11) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
solution(1)
solution(6)
solution(50)
solution(99)
solution(100)
solution(451)
solution(483)
solution(500)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
[1]
[6]
[50]
[99]
[100]
[451]
[483]
[500]
function result: 0
function result: 0
function result: 2
function result: 3
function result: 2
function result: 4
function result: 3
function result: 1
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
c
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
console.log(binary)
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
[1]
[6]
[50]
[99]
[100]
[451]
[483]
[500]
10000010001
1111
100000
function result: 0
1
function result: 0
110
function result: 2
110010
function result: 3
1100011
function result: 2
1100100
function result: 4
111000011
function result: 3
111100011
function result: 1
111110100
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
[1]
[6]
[50]
[99]
[100]
[451]
[483]
[500]
function result: 0
function result: 0
function result: 2
function result: 3
function result: 2
function result: 4
function result: 3
function result: 1
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
[1]
[6]
[50]
[99]
[100]
[451]
[483]
[500]
function result: 0
function result: 0
function result: 2
function result: 3
function result: 2
function result: 4
function result: 3
function result: 1
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
const is1 = value => value == 1;
const is0 = value => value == 0;
function solution(N) {
// write your code in JavaScript (Node.js 8.9.4)
const binary = ((N).toString(2));
let count = 0;
let max = 0;
let startCounting = is1(binary[0]);
for(let i = 1; i < binary.length; i++) {
if(is1(binary[i])) {
max = max < count ? count : max;
count = 0;
startCounting = true;
} else {
if(startCounting) {
count ++;
}
}
}
return max;
}
The solution obtained perfect score.