Skip to content

Instantly share code, notes, and snippets.

View jamesshah's full-sized avatar

james shah jamesshah

View GitHub Profile
@jamesshah
jamesshah / tictactoe.py
Last active March 28, 2022 07:06
TicTacToe Game implemented in python3
#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': ' ' }
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] = " "
# 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")
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()
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'])
#!/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"
@jamesshah
jamesshah / automation.py
Last active November 11, 2019 11:12
Automation Of Project Initialization Using (Python + Shell Script)
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
@jamesshah
jamesshah / LinkedList.java
Last active October 21, 2019 19:04
Linked List Implementation in Java
//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;
@jamesshah
jamesshah / MatrixAddition.java
Last active October 21, 2019 19:06
Implementing Arrays in Java.
//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];
@jamesshah
jamesshah / automation.sh
Created October 5, 2019 08:44
Project Initialization Automation using Python And Shell Script
#!/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"