This file contains 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
from os import system | |
from random import randint | |
def display_board(board): | |
system('clear') | |
print(' | | ') | |
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9] +' ') | |
print(' | | ') | |
print('------------') |
This file contains 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
def win_check(board,mark): | |
return ((board[7] == mark and board[8] == mark and board[9] == mark) or # across the top | |
(board[4] == mark and board[5] == mark and board[6] == mark) or # across the middle | |
(board[1] == mark and board[2] == mark and board[3] == mark) or # across the bottom | |
(board[7] == mark and board[4] == mark and board[1] == mark) or # down the middle | |
(board[8] == mark and board[5] == mark and board[2] == mark) or # down the middle | |
(board[9] == mark and board[6] == mark and board[3] == mark) or # down the right side | |
(board[7] == mark and board[5] == mark and board[3] == mark) or # diagonal | |
(board[9] == mark and board[5] == mark and board[1] == mark)) # diagonal |
This file contains 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
// Execute using --use_strict tag "node --use_strict classes.js" | |
class Human { | |
constructor(name, job, skills = []){ | |
this.name = name; | |
this.job = job; | |
this.skills = skills; | |
} | |
getJob(){ |
This file contains 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
var pets = [ | |
{ name: "Max", type: "dog", bornOn: 2018 }, | |
{ name: "Angel", type: "cat", bornOn: 2015 }, | |
{ name: "Jasper", type: "dog", bornOn: 2016 } | |
]; | |
const getAge = pet => { | |
return new Date().getFullYear() - pet.bornOn; | |
} |