Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4c758d8
First commit
Sep 15, 2020
3187c20
Average OK
Sep 15, 2020
1a4ad52
First commit
Sep 15, 2020
0708443
Algo_2
Sep 15, 2020
0ecda22
Algo_3
Sep 15, 2020
3838cfc
roi_bbox in progress
Sep 15, 2020
dc447cf
Algo_4
Sep 16, 2020
58ade86
Algo_3 optimisation
Sep 16, 2020
9fea65e
Algo_5
Sep 16, 2020
f18e382
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
Sep 16, 2020
cb4c4e3
Algo_6
Sep 16, 2020
1bd72e5
indentation
Sep 16, 2020
0ae5e8e
first test
Sep 16, 2020
9b2545e
test average
Sep 16, 2020
d3e99c6
test Algo 1,2,3,4,5
Sep 16, 2020
7b25410
Update README.md
BadTripHD Sep 16, 2020
912f0fe
correctif
Sep 29, 2020
baf4f0f
s3 invert function
Sep 29, 2020
d261757
test unitaire invert image
Sep 29, 2020
f2f564b
Update README.md
BadTripHD Sep 29, 2020
107181b
Update README.md
BadTripHD Sep 29, 2020
bbc6128
requirements maj
Sep 29, 2020
bce8701
Merge branch 'master' of https://github.com/BadTripHD/BachelorDIM-Lec…
Sep 29, 2020
2132843
thresholding image in progress
Sep 29, 2020
e4173b8
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
Oct 13, 2020
c82108f
gitignore commit
Oct 13, 2020
b34f30e
create file S4 and connecte to cloudamqp
Oct 13, 2020
3fb7e3f
read cloudamqp data OK
Oct 13, 2020
e875565
new file for type of execution (default=send, or enter -read)
Oct 13, 2020
2f6f2d7
correctif
Oct 13, 2020
73dd77f
compteur ;)
BadTripHD Oct 20, 2020
2cfb338
comment function and add argument for durable channel pika
BadTripHD Oct 20, 2020
2b64b72
queue Name in parameter
BadTripHD Oct 20, 2020
dab6937
correctif queueName and queue channel persistent
BadTripHD Oct 20, 2020
5b19d47
sleep argument
BadTripHD Oct 20, 2020
98f14d0
add fanout publish/read in progress
BadTripHD Oct 20, 2020
5593ec9
Dice game
BadTripHD Oct 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.sqlite3

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Environnements #
##################

.env
venv
.idea
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ addons:
organization: albenoit-github
# command to run tests
script:
- pwd
- ls
- pytest -v --cov .
#- sonar-scanner
- coveralls
Expand Down
Binary file added Code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added CodeInvert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Coverage Status](https://coveralls.io/repos/github/albenoit/BachelorDIM-Lectures-Algorithms-2020/badge.svg?branch=master)](https://coveralls.io/github/albenoit/BachelorDIM-Lectures-Algorithms-2020?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/BadTripHD/BachelorDIM-Lectures-Algorithms-2020/badge.svg?branch=master)](https://coveralls.io/github/BadTripHD/BachelorDIM-Lectures-Algorithms-2020?branch=master)

# BachelorDIM-Lectures-Algorithms-2020
Algorithms, code writing and continuous integration @ DIM Bachelor, Université Savoie Mont Blanc, France
Expand All @@ -23,3 +23,6 @@ Evaluation will consist in continuous control and a mid term test.
Evaluation will take into account your code quality and assignements coverage but also github pull request and commits naming conventions and code comments...

Prefer better quality code, ready to be shared and enhanced by others, instead of too rapidly written code, unreadable, un-commented that people will throw to trash and completely rewrite !


Hello world !!
172 changes: 172 additions & 0 deletions S1_algotools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 14:45:46 2020

@author: polletb
"""
import math
import numpy as np
import random

def average_above_zero(marks:list):
'''
Get average from list
Parameters:
marks: list float
Returns :
average of list
'''
average = 0
for i in marks:
average += i

if len(marks) > 0:
average = math.floor(average / len(marks))
else:
raise Exception("Sorry marks is null, empty or equal 0")

return average

#Question 1 : la variable sum n'existe pas donc erreur
#Question 2 : erreur pas divisible par 0

#print(average_above_zero([]))


def max_value(marks:list):
'''
Get max value of list
Parameters:
marks: list float
Returns :
max of list
'''
try:
max_value = max(marks)
max_value_index = marks.index(max(marks))
except:
raise Exception("Sorry marks is null, empty")

return max_value, max_value_index

#print(max_value([10.0, 20.0, 30.0]))


def reverse_table(table:list):
'''
Reverse an list
Parameters:
table: list
Returns :
list reverse
'''
try:
#reverse_table = table[::-1]
#or
lenght = len(table)
for i in range(lenght//2):
tmp = table[i]
endindex = lenght-i-1
table[i] = table[endindex]
table[endindex] = tmp
except:
raise Exception("Sorry table is null or empty")

return table

#print(reverse_table([]))

def roi_bbox(input_image:np):
'''
Get bouding box of numpy array with value equal 1
Parameters:
input_image: numpy
Returns :
input_image as numpy
tuples with coords of min and max bounding box
'''
try:
input_image[2:5, 2:5] = np.ones((3,3), dtype=float)

row = np.any(input_image, axis=1)
column = np.any(input_image, axis=0)

rmin, rmax = np.where(row)[0][[0, -1]]
cmin, cmax = np.where(column)[0][[0, -1]]
except:
raise Exception("Sorry numpy is null or empty")

return input_image, ([rmin, cmin], [rmax, cmax])

#print(roi_bbox(np.zeros((10,10), dtype=float)))


def alea(min:int, max:int):
'''
Get random number
Parameters:
min: int
max: int
Returns :
alea_value as int
'''
try:
alea_value = random.randint(min, max)
except:
raise Exception("alea_value is null or empty")
return alea_value


def random_fill_sparse(table:np, K:int):
'''
Get random numpy with random X in
Parameters:
table: numpy
K: int
Returns :
table as numpy
'''
try:
for i in range(K):
row = table[alea(0,len(table)-1)]
row[alea(0,len(row)-1)] = 'X'
except:
raise Exception("table or K is null or empty")
return table

#print(random_fill_sparse(np.empty((alea(1,10),alea(1,10)), dtype=str), 5))


def remove_whitespace(string_value:str):
'''
Remove whitespace in string
Parameters:
string_value: str
Returns :
string_value as str
'''
try:
string_value.replace(" ","")
except:
raise Exception("string_value is null")

return string_value

#print(remove_whitespace("Je suis une patate"))


def function_shuffle(list_in:list):
'''
Shuffle list
Parameters:
list_in: list
Returns :
list_in as list
'''
try:
random.shuffle(list_in)
except:
raise Exception("list_in is null or empty")
return list_in

#print(function_shuffle([10,20,30,40,50]))
68 changes: 68 additions & 0 deletions S1_dice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 31 15:26:46 2020

@author: polletb
"""
import S1_algotools as s1

dice = [1, 2, 3, 4, 5, 6]

while True:

playerScore = 0
computerScore = 0
turn = 0
numberTmp = 0

print("---------------------------------------------------")
print("-------------------- Dice game --------------------")
print("---------------------------------------------------")
print("\n")
print("------> Are you ready? Please enter 'start' <------")

start = input()

if start == 'start':
while True:

if (playerScore or computerScore) >= 100:
break

print("Score player : " + str(playerScore))
print("Score computer : " + str(computerScore))
print("---------------------------------------------------")
turnOf = "Turn of player" if turn % 2 == 0 else "Turn of computer"
print(turnOf)

while True:

randomNumber = s1.function_shuffle(dice)[0]
numberTmp = numberTmp + randomNumber
print("You have done : " + str(randomNumber))

if randomNumber == 1:
print("nice try you have get 1 no points add")
numberTmp = 0
turn += 1
break

reroll = input("Please enter 'go' to continue or 'stop'")

if reroll == "stop":
if turn % 2 == 0:
playerScore += numberTmp
else:
computerScore += numberTmp
numberTmp = 0
turn += 1
break

print("Game is over")
winner = "player" if playerScore <= 100 else "computer"
print("Winner is : " + winner)
print("---------------------------------------------------")
print("You want to retry ? Y/N")
retry = input()
if retry == 'N':
break
Loading