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
| CanMakePalindrome = (s, b, o, t) => { | |
| t = s.length % 2; | |
| o = [...s].filter(l => { | |
| b = s.split(l); | |
| s = b.join``; | |
| return (b.length - 1)%2; | |
| }); | |
| return t ? (o.length === 1) : (o.length === 0); | |
| } |
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
| TicTacToe = (board) => { | |
| let winbits = [7,56,73,84,146,273,292,448]; | |
| board = Array.prototype.concat.apply([], board); | |
| query = player => { | |
| num = 0; | |
| board.forEach((cell, i) => { | |
| var i = (board.length-i)-1; | |
| num += (cell === player)<<i; | |
| }); |
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 ClosedBracketWord(w='w') { | |
| return !w[19] && w.split('').every((l, i) => 122-(l.charCodeAt()-97) === w.charCodeAt(w.length-1-i)); | |
| } | |
| ClosedBracketWord('abiryz'); // true | |
| ClosedBracketWord('abixyz'); // false | |
| ClosedBracketWord('ABCXYZ'); // false | |
| ClosedBracketWord(''); // true |
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
| class Openable { | |
| constructor(isOpen = false) { | |
| this._isOpen = isOpen; | |
| } | |
| get isOpen() { | |
| return this._isOpen + ' is stupid.'; | |
| } |
NewerOlder