• ###### LetTheComputerDecidecommented on "Is Integer Array?" javascript solution

Same here. And I have been writing JS for more than half a decade now..
Thanks! :)

• ###### sajadtorkamanicommented on "Is Integer Array ?" javascript solution

This comment is hidden because it contains spoiler information about the solution

• ###### smolencommented on "Cancer cells" javascript solution

Thats just awesome, great way to learn programming.
If only my teacher would implement this kind of teaching when i was in school i wouldnt have problems to pass to the next year.

Props for you!

• ###### Logancommented on "Cancer cells" javascript solution

Certainly not coincidence, he is one of my students ;)

• ###### smolencommented on "Cancer cells" javascript solution

Huh thats interesting,im curious if its coincidente or what?

Yours

``````function cutCancerCells (organism) {
let types = {
advance:   (c) => (c == 'C'),
initial:   (c) => (c == 'c'),
normal:    (c) => (c == c.toLowerCase()),
important: (c) => (c == c.toUpperCase()),
unknown:   (c) => (true)
}
let classify = (c) => Object.keys(types).find(key => types[key](c))
let cells = [...organism].map(c => ({ cell: c, type: classify(c) }))

let mark_resect = (cell) => { if (cell) cell.resect = true }
let clear_resect = (cell) => { if (cell) cell.resect = false }
let rules = {
mark_resect(cells[idx-1]),
mark_resect(cells[idx+1]) },
initial:   (idx) => { mark_resect(cells[idx]) },
important: (idx) => { clear_resect(cells[idx]) }
}

for (let rule in rules)
cells.forEach((cell, idx) => {if (cell.type == rule) rules[rule](idx)})
let remaining = cells.filter(cell => !cell.resect)
return remaining.map(cell => cell.cell).join('')
}
``````

@cerbin

``````function cutCancerCells(organism){
let types = {
advance:   (c) => (c == 'C'),
initial:   (c) => (c == 'c'),
normal:    (c) => (c == c.toLowerCase()),
important: (c) => (c == c.toUpperCase()),
unkown:    (c) => true
}

let classify = (c) => Object.keys(types).find((key) => types[key](c))
let cells = [...organism].map(c => ({ cell: c, type: classify(c) }))

let mark_resect = (cell) => { if(cell) cell.resect = true }
let clear_resect = (cell) => { if(cell) cell.resect = false }

let rules = {
mark_resect(cells[index - 1]), mark_resect(cells[index + 1])
},
initial: (index) => { mark_resect(cells[index])},
important: (index) => { clear_resect(cells[index])}
}

for (let rule in rules)
cells.forEach((cell, index) => {if(cell.type == rule) rules[rule](index)})

let remaining = cells.filter(cell => !cell.resect)
console.log(organism)
console.log(cells)
console.log(remaining)
return remaining.map(cell => cell.cell).join('')
}
``````
• ###### Logancommented on "k-Primes" cpp solution

Try comparing this solution with https://www.codewars.com/kata/reviews/57a3503a7cfe50ebcb00014e/groups/58d061753f25db3d9600003f which is about 30% faster, although it still requires some attention to integer type choices.

• ###### thegardscommented on "Complete The Pattern #2" cpp solution

And I thought I was the one going for the overkill with a recursive approach...

Nice usage of C++ though :)