Ad
Fundamentals
Code
Diff
  • fun main() = print("Hello world")
    • fun main(args: Array<String>) {
    • println("Hello from Kotlin")
    • }
    • fun main() = print("Hello world")
Algorithms
Logic
Code
Diff
  • getDividors = n => [...Array(n).keys()].filter(e => n % e)
    • getDividors = n => Array.from({length: n}, (e, i) => n % ++i ? i : 0).filter(e => e)
    • getDividors = n => [...Array(n).keys()].filter(e => n % e)
Algorithms
Logic
Code
Diff
  • getDividors = n => Array.from({length: n}, (e, i) => n % ++i ? i : 0).filter(e => e)
    • const getDividors = (n, result = []) => {
    • for (let i = 1; i <= Math.floor(Math.sqrt(n)); i++)
    • if (n % i === 0) { result.push(i); if (n / i !== i) result.push(n / i) }
    • return result; // output array won't be sorted
    • }
    • getDividors = n => Array.from({length: n}, (e, i) => n % ++i ? i : 0).filter(e => e)
Code
Diff
  • test = s => s.match(/\[(\w+)].*\[\/\1]/g).join``
    • function test(str) {
    • return (str.match(/\[([a-zA-Z]+)](.*)\[\/\1]/g)).join('');
    • }
    • test = s => s.match(/\[(\w+)].*\[\/\1]/g).join``