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
#Implementation of Two Player Tic-Tac-Toe game in Python. | |
''' We will make the board using dictionary | |
in which keys will be the location(i.e : top-left,mid-right,etc.) | |
and initialliy it's values will be empty space and then after every move | |
we will change the value according to player's choice of move. ''' | |
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } |
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
board_keys = [] | |
for key in theBoard: | |
board_keys.append(key) | |
restart = input("Do want to play Again?(y/n)") | |
if restart == "y" or restart == "Y": | |
for key in board_keys: | |
theBoard[key] = " " |
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
# Now we will check if player X or O has won,for every move after 5 moves. | |
if count >= 5: | |
if theBoard['7'] == theBoard['8'] == theBoard['9'] != ' ': # across the top | |
printBoard(theBoard) | |
print("\nGame Over.\n") | |
print(" **** " +turn + " won. ****") | |
break | |
elif theBoard['4'] == theBoard['5'] == theBoard['6'] != ' ': # across the middle | |
printBoard(theBoard) | |
print("\nGame Over.\n") |
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 game(): | |
turn = 'X' | |
count = 0 | |
for i in range(10): | |
printBoard(theBoard) | |
print("It's your turn," + turn + ".Move to which place?") | |
move = input() |
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
theBoard = {'7': ' ' , '8': ' ' , '9': ' ' , | |
'4': ' ' , '5': ' ' , '6': ' ' , | |
'1': ' ' , '2': ' ' , '3': ' ' } | |
def printBoard(board): | |
print(board['7'] + '|' + board['8'] + '|' + board['9']) | |
print('-+-+-') | |
print(board['4'] + '|' + board['5'] + '|' + board['6']) | |
print('-+-+-') | |
print(board['1'] + '|' + board['2'] + '|' + board['3']) |
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
#!/bin/bash | |
#shell script to automate project initialization. | |
function create(){ | |
cd | |
python ./automation1.py $1 | |
cd path/to/your/projects/directory/$1 | |
touch Readme.md | |
git init | |
git add . | |
git commit -m "first commit" |
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
import sys | |
import os | |
from github import Github | |
path = "/path/to/your/desired/projects/directory" | |
def create(): | |
folder_name = str(sys.argv[1]) | |
os.makedirs(path+folder_name) | |
username = #your github username |
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
//Implementing Singly Linked List in Java | |
class LinkedList{ | |
Node head; //Reference to the Node class to create head node of the list. | |
//Node class to create nodes. here we make static class so that main method | |
//can recoginze it. | |
static class Node{ | |
int data; | |
Node next; |
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
//Implementing Matrix Addition | |
class MatrixMultiplication{ | |
public static void main(String[] args) { | |
//Creating two matrices | |
int[][] a = {{1,2,3},{2,3,4}}; | |
int[][] b = {{1,2,3},{2,3,4}}; | |
//Creating empty matrix to store the result | |
int[][] sum = new int[2][3]; |
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
#!/bin/bash | |
#shell script to automate project initialization | |
function create(){ | |
cd | |
python ./automation1.py $1 | |
cd path/to/your/projects/directory/$1 | |
touch Readme.md | |
git init | |
git add . | |
git commit -m "first commit" |