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
| # This program decides the best option | |
| # when you're uncertain, | |
| # with 100% accuracy | |
| # Requires python3 to be installed and I've only tested it with zsh, but maybe works with bash as well | |
| # drop this in your .zshrc file and run it like: | |
| # oracle thai japanese sandwich | |
| # to decide what to eat | |
| # Takes an arbitrary number of arguments (depends on the maximum for your shell), will pick between them |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| const combineFilters = ([head, ...tail]) => (data) => (head ? (head(data) && combineFilters(tail)(data)) : 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
| let status; | |
| if (winner) { | |
| status = "Winner: " + winner; | |
| } else if(history.length === 10){ <<< | |
| status = 'Draw!'; <<< | |
| } else { | |
| status = "Next player: " + (this.state.xIsNext ? "X" : "O"); | |
| } |
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 Square(props) { | |
| return ( | |
| <button | |
| className="square" | |
| onClick={props.onClick} | |
| style={props.isWinning ? {boxShadow: 'inset 0px 0px 3px #4c768f, 0px 0px 3px #4c768f'} : {}} <<< | |
| > | |
| {props.value} | |
| </button> | |
| ); |
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 Board extends React.Component { | |
| renderSquare(i) { | |
| const winningArr = this.props.winningSquares.filter((sq) => sq === i); <<< | |
| return ( | |
| <Square | |
| value={this.props.squares[i]} | |
| onClick={() => this.props.onClick(i)} | |
| isWinning={winningArr.length ? true : false} <<< | |
| /> |
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
| let status; | |
| let winningSquares = []; | |
| if (winner) { | |
| status = "Winner: " + winner.player; | |
| winningSquares = winner.line; | |
| } else { | |
| status = "Next player: " + (this.state.xIsNext ? "X" : "O"); | |
| } |
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 calculateWinner(squares) { | |
| (...) | |
| for (let i = 0; i < lines.length; i++) { | |
| const [a, b, c] = lines[i]; | |
| if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) { | |
| return { <<< | |
| player: squares[a], <<< | |
| line: [a, b, c], <<< | |
| }; <<< | |
| } |
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
| if(!this.state.historyAscending) { | |
| moves.sort((a, b) => b.key - a.key); | |
| } | |
| let status; | |
| if (winner) { | |
| (...) |
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
| handleToggleOrder(historyAscending) { | |
| this.setState({historyAscending}); | |
| } | |
| jumpTo(step) { | |
| (...) |
NewerOlder