Skip to content

Commit

Permalink
Reformat Code by PyCharm-Community
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Krell <[email protected]>
  • Loading branch information
JeromeK13 committed Oct 10, 2019
1 parent f538edd commit 45897fa
Show file tree
Hide file tree
Showing 185 changed files with 128,830 additions and 86,755 deletions.
476 changes: 233 additions & 243 deletions Assembler/assembler.py

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions Binary Coefficients.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
def pascal_triangle( lineNumber ) :
def pascal_triangle(lineNumber):
list1 = list()
list1.append([1])
i=1
while(i<=lineNumber):
j=1
l=[]
i = 1
while (i <= lineNumber):
j = 1
l = []
l.append(1)
while(j<i):

l.append(list1[i-1][j]+list1[i-1][j-1])
j=j+1
while (j < i):
l.append(list1[i - 1][j] + list1[i - 1][j - 1])
j = j + 1
l.append(1)
list1.append(l)
i=i+1
i = i + 1
return list1

def binomial_coef(n,k):
pascalTriangle=pascal_triangle(n)
return(pascalTriangle[n][k-1])

def binomial_coef(n, k):
pascalTriangle = pascal_triangle(n)
return (pascalTriangle[n][k - 1])
54 changes: 27 additions & 27 deletions Binary_search.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# It returns location of x in given array arr
# if present, else returns -1
def binarySearch(arr, l, r, x):

while l <= r:

mid = l + (r - l)/2;

def binarySearch(arr, l, r, x):
while l <= r:

mid = l + (r - l) / 2;

# Check if x is present at mid
if arr[mid] == x:
return mid
# If x is greater, ignore left half
elif arr[mid] < x:
if arr[mid] == x:
return mid

# If x is greater, ignore left half
elif arr[mid] < x:
l = mid + 1

# If x is smaller, ignore right half
else:
else:
r = mid - 1

# If we reach here, then the element was not present
return -1



# Main Function
if __name__ == "__main__":
# User input array
print("Enter the array with comma separated in which element will be searched")
arr = map(int,input().split(","))
x = int(input("Enter the element you want to search in given array"))

# Function call
result = binarySearch(arr, 0, len(arr)-1, x)

if result != -1:
print("Element is present at index {}".format(result))
else:
print("Element is not present in array")
# User input array
print("Enter the array with comma separated in which element will be searched")
arr = map(int, input().split(","))
x = int(input("Enter the element you want to search in given array"))

# Function call
result = binarySearch(arr, 0, len(arr) - 1, x)

if result != -1:
print("Element is present at index {}".format(result))
else:
print("Element is not present in array")
140 changes: 66 additions & 74 deletions BlackJack_game/blackjack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,86 @@

import random

deck=[1,2,3,4,5,6,7,8,9,10,10,10,10,11]*4
deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] * 4

random.shuffle(deck)

print(
" ********************************************************** ")
print(
" Welcome to the game Casino - BLACK JACK ! ")
print(
" ********************************************************** ")

print(" ********************************************************** ")
print(" Welcome to the game Casino - BLACK JACK ! ")
print(" ********************************************************** ")


d_cards = [] #Initialising dealer's cards
p_cards = [] #Initialising player's cards
d_cards = [] # Initialising dealer's cards
p_cards = [] # Initialising player's cards

while len(d_cards) != 2:
random.shuffle(deck)
d_cards.append(deck.pop())
if len(d_cards) == 2:
print('The cards dealer has are X ',d_cards[1])


random.shuffle(deck)
d_cards.append(deck.pop())
if len(d_cards) == 2:
print('The cards dealer has are X ', d_cards[1])

# Displaying the Player's cards
while len(p_cards) != 2:
random.shuffle(deck)
p_cards.append(deck.pop())
if len(p_cards) == 2:
print("The total of player is ",sum(p_cards))
print("The cards Player has are ",p_cards)

random.shuffle(deck)
p_cards.append(deck.pop())
if len(p_cards) == 2:
print("The total of player is ", sum(p_cards))
print("The cards Player has are ", p_cards)

if sum(p_cards) > 21:
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
exit()
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
exit()

if sum(d_cards) > 21:
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
exit()
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
exit()

if sum(d_cards) == 21:
print("***********************Dealer is the Winner !!******************")
exit()
print("***********************Dealer is the Winner !!******************")
exit()

if sum(d_cards) == 21 and sum(p_cards) == 21:
print("*****************The match is tie !!*************************")
exit()
print("*****************The match is tie !!*************************")
exit()


def dealer_choice():
if sum(d_cards) < 17:
while sum(d_cards) < 17:
random.shuffle(deck)
d_cards.append(deck.pop())


print("Dealer has total "+ str(sum(d_cards))+"with the cards ",d_cards)

if sum(p_cards) == sum(d_cards):
print("***************The match is tie !!****************")
exit()


if sum(d_cards) == 21:
if sum(p_cards) < 21:
print("***********************Dealer is the Winner !!******************")
elif sum(p_cards) == 21:
print("********************There is tie !!**************************")
else:
print("***********************Dealer is the Winner !!******************")

elif sum(d_cards) <21:
if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards):
print("***********************Dealer is the Winner !!******************")
if sum(p_cards) == 21:
print("**********************Player is winner !!**********************")
if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards):
print("**********************Player is winner !!**********************")

else:
if sum(p_cards) < 21:
print("**********************Player is winner !!**********************")
elif sum(p_cards) == 21:
print("**********************Player is winner !!**********************")
else:
print("***********************Dealer is the Winner !!******************")

if sum(d_cards) < 17:
while sum(d_cards) < 17:
random.shuffle(deck)
d_cards.append(deck.pop())

print("Dealer has total " + str(sum(d_cards)) + "with the cards ", d_cards)

if sum(p_cards) == sum(d_cards):
print("***************The match is tie !!****************")
exit()

if sum(d_cards) == 21:
if sum(p_cards) < 21:
print("***********************Dealer is the Winner !!******************")
elif sum(p_cards) == 21:
print("********************There is tie !!**************************")
else:
print("***********************Dealer is the Winner !!******************")

elif sum(d_cards) < 21:
if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards):
print("***********************Dealer is the Winner !!******************")
if sum(p_cards) == 21:
print("**********************Player is winner !!**********************")
if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards):
print("**********************Player is winner !!**********************")

else:
if sum(p_cards) < 21:
print("**********************Player is winner !!**********************")
elif sum(p_cards) == 21:
print("**********************Player is winner !!**********************")
else:
print("***********************Dealer is the Winner !!******************")


while sum(p_cards) < 21:
Expand All @@ -96,16 +90,14 @@ def dealer_choice():
if k == 1:
random.shuffle(deck)
p_cards.append(deck.pop())
print ('You have a total of ' + str(sum(p_cards))
+ ' with the cards ', p_cards)
print('You have a total of ' + str(sum(p_cards))
+ ' with the cards ', p_cards)
if sum(p_cards) > 21:
print ('*************You are BUSTED !*************\n Dealer Wins !!')
print('*************You are BUSTED !*************\n Dealer Wins !!')
if sum(p_cards) == 21:
print ('*******************You are the Winner !!*****************************')
print('*******************You are the Winner !!*****************************')


else:
dealer_choice()
break


else:
dealer_choice()
break
Loading

0 comments on commit 45897fa

Please sign in to comment.