Size: a a a

2020 June 18

t

th.witness in pro.js
Lupusregina[beta]
у тебя до скольки рандом тестов доходило?
Биг рандом тестс?
источник

В

Виктория in pro.js
Катитесь уже
источник

L

Lupusregina[beta] in pro.js
th.witness
Биг рандом тестс?
да
источник

t

th.witness in pro.js
Сейчас чекну.
источник

DE

Denis Efremov in pro.js
Lupusregina[beta]
хотя s может быть очень большой длинны
Да понял уже. Надо порезать по 10
источник

p

persona x grata in pro.js
Construct a function union that takes an input array of arrays, compares each array, and returns a new flat array that contains all elements. If there are duplicate elements, only add it once to the new array. Preserve the order of the elements starting from the first element of the first input array.

const union = arr => {
 let flatArr = [].concat(...arr);
 return [...new Set(flatArr)]
}

const arr1 = [5, 10, 15];
const arr2 = [15, 88, 1, 5, 7];
const arr3 = [100, 15, 10, 1, 5];

console.log(union([arr1, arr2, arr3])); // should log: [5, 10, 15, 88, 1, 7, 100]
источник

t

th.witness in pro.js
1-2.
источник

p

persona x grata in pro.js
как еще сделать лучше?
источник

t

th.witness in pro.js
У меня форич :)
источник

L

Lupusregina[beta] in pro.js
у меня
источник

t

th.witness in pro.js
Круто.
источник

L

Lupusregina[beta] in pro.js
th.witness
Круто.
та, может там этих тестов пара тысяч
источник

L

Lupusregina[beta] in pro.js
неа
источник

L

Lupusregina[beta] in pro.js
ну я по 32 бита сделал
источник

L

Lupusregina[beta] in pro.js
все равно не проходит по скорости
источник

L

Lupusregina[beta] in pro.js
function binarySimulation(s, q) {
 const a = new Int32Array((s.length >> 5) + 1)
 for(let i = 0, k = 0; i < s.length; ) {
   let i32 = 0
   for(let j = 0; j < 32; j++) {
     i32 |= ( s[i++]|0 ) << j
   }
   a[k++] = i32
 }
 
 const r = []
 for(const v of q) {
   switch(v[0]) {
     case "I":
       const start = v[1] - 1, end = v[2] - 1
       let j = start;
       const startFl = Math.min( end, ((start >> 5) + 1) << 5 )
       
       //const mask = ( (1 << (startFl - j)) - 1 ) << (j & 31)
       //a[j >> 5] ^= mask
       
       while( j < startFl ) {
         const byte = j >> 5
         const bit = j & 31
         const val = 1 << bit
         //if ( !bit )
         //  break
         a[byte] ^= val
         
         j++
       }
       
       const endFl = (end >> 5) << 5
       
       
       /// ~250
       if ( j < endFl ) {
         for(let i = j >> 5; i < end >> 5; i++)
           a[i] ^= -1
         j = endFl
       }
       
       /*
       /// ~115
       while( j < endFl ) {
         const byte = j >> 5
         a[byte] ^= -1
         j += 32
       }
       */

       for(; j <= end; j++) {
         const byte = j >> 5
         const bit = j & 31
         const val = 1 << bit
         a[byte] ^= val
       }
       break
     
     case "Q":
       const i = v[1] - 1
       const byte = i >> 5
       const bit = i & 31
       r.push( '' + ( (a[byte] >> bit) & 1) )
   }
 }
 return r
}
источник

t

th.witness in pro.js
Время.
источник

t

th.witness in pro.js
По времени не проходит.
источник

t

th.witness in pro.js
Или потому что код недостаточно оптимизирован для задачи.
источник

t

th.witness in pro.js
Всë это одно и то же.
источник