diff --git a/livres/ex_cpp/Makefile b/livres/ex_cpp/Makefile new file mode 100644 index 0000000..21bcd90 --- /dev/null +++ b/livres/ex_cpp/Makefile @@ -0,0 +1,16 @@ +CXX = c++ +CXXFLAGS = -Wall -g +LDFLAGS= -lm + +SOURCE_POINTS= points.cpp main.cpp + +all: points + +points: $(SOURCE_POINTS) + $(CXX) $(CXXFLAGS) -o $@ $(SOURCE_POINTS) $(LDFLAGS) + +run: points + ./points + +clean: + rm -f *.o ./points diff --git a/livres/ex_cpp/main.cpp b/livres/ex_cpp/main.cpp new file mode 100644 index 0000000..93da3ca --- /dev/null +++ b/livres/ex_cpp/main.cpp @@ -0,0 +1,16 @@ +#include "points.h" +#include + +int main(int argc, char *argv[]) +{ + Points p(5,5); + std::cout << p.abscisse() << ' ' << p.ordonnee() << std::endl; + + std::cout << p.rho() << ' ' << p.theta() << std::endl; + + p.deplace(3.1, 2); + std::cout << p.abscisse() << ' ' << p.ordonnee() << std::endl; + + + return 0; +} diff --git a/livres/ex_cpp/points b/livres/ex_cpp/points new file mode 100755 index 0000000..69db7c4 Binary files /dev/null and b/livres/ex_cpp/points differ diff --git a/livres/ex_cpp/points.cpp b/livres/ex_cpp/points.cpp new file mode 100644 index 0000000..027a898 --- /dev/null +++ b/livres/ex_cpp/points.cpp @@ -0,0 +1,39 @@ +#include "points.h" +#include "math.h" + +Points::Points(float m_x, float m_y) +: x(m_x), y(m_y){} + +// SETTERS + +void Points::deplace(float m_dx, float m_dy){ + x += m_dx; + y += m_dy; +} + +void Points::homothetie(float k){ + x *= k; + y *= k; +} + +void Points::rotation(float angle){ + +} + +// GETTERS + +float Points::abscisse(){ + return x; +} + +float Points::ordonnee(){ + return y; +} + +float Points::rho(){ + return sqrt(x*x + y*y); +} + +float Points::theta(){ + return atan(y/x); +} diff --git a/livres/ex_cpp/points.h b/livres/ex_cpp/points.h new file mode 100644 index 0000000..6bfcf42 --- /dev/null +++ b/livres/ex_cpp/points.h @@ -0,0 +1,24 @@ +#ifndef POINTS_H +#define POINTS_H + +class Points +{ +private: + float x, y; + + +public: + Points(float x, float y); + + void deplace(float, float); + void homothetie(float); + void rotation(float); + + float abscisse(); + float ordonnee(); + float rho(); + float theta(); + +}; + +#endif /* POINTS_H */ diff --git a/renforcement/entrainement_0311/entrainement0311.pdf b/renforcement/entrainement_0311/entrainement0311.pdf new file mode 100644 index 0000000..0f4578a Binary files /dev/null and b/renforcement/entrainement_0311/entrainement0311.pdf differ diff --git a/renforcement/entrainement_0311/ex1.py b/renforcement/entrainement_0311/ex1.py new file mode 100644 index 0000000..9b32df0 --- /dev/null +++ b/renforcement/entrainement_0311/ex1.py @@ -0,0 +1,27 @@ + +def find(chambre, etiquette): + """Find all occurence of etiquette in chambre and return a list of all his position + + :chambre: matrice of item in chambre + :etiquette: Element to find in chambre as string + :returns: list of positions + + """ + ret = list() + for x in range(len(chambre)): + for y in range(len(chambre[x])): + if etiquette == chambre[x][y]: + ret.append((x,y)) + return ret + +# Tests +if __name__ == "__main__": + chambre = [ + [ "A" , "A" , "B" , "D" ], + [ "C" , "P" , "U" , "A" ], + [ "M" , "O" , "N" , "S " ], + [ "A" , "B" , "D" , "A" ] + ] + print(find(chambre, 'A'), "should print 5 elemets") + print(find(chambre, 'C'), "Should print 1 element") + print(find(chambre, 'Elephant'), "Should print nothing") diff --git a/renforcement/entrainement_0311/ex2.py b/renforcement/entrainement_0311/ex2.py new file mode 100644 index 0000000..c294d9a --- /dev/null +++ b/renforcement/entrainement_0311/ex2.py @@ -0,0 +1,32 @@ +def champ(): + """Create a field, ask for size, amount of orni and position of said orni + :returns: number of plan + """ + (N, M) = tuple(input("Size Quantity:").split()[:2]) + field = [['🌱' for y in range(int(N))] for x in range(int(N))] + for i in range(int(M)): + (_X, _Y) = tuple(input(f"(orni {i}) X Y:").split()[:2]) + field[int(_Y)][int(_X)] = '🦝' + + for x in range(int(N)): + for y in range(int(N)): + if field[y][x] == '🦝': + for i in range(x-1, x+2): + for j in range(y-1, y+2): + if field[j][i] == '🥕': + field[j][i] = '💀' + if field[j][i] == '🌱': + field[j][i] = '🥕' + return field + +def draw_field(field): + """draw a field """ + for x in range(len(field)): + for y in range(len(field[x])): + print(field[x][y], end=' ') + print() + + + +if __name__ == "__main__": + draw_field(champ()) diff --git a/renforcement/entrainement_0311/ex3.py b/renforcement/entrainement_0311/ex3.py new file mode 100644 index 0000000..587f10f --- /dev/null +++ b/renforcement/entrainement_0311/ex3.py @@ -0,0 +1,7 @@ +def check_ticket(ticket): + while(:) + tosumuup = [int(i)for i in list(ticket)] + return sum(tosumuup) + +if __name__ == "__main__": + print(check_ticket('999999')) diff --git a/renforcement/entrainement_0311/ex4.py b/renforcement/entrainement_0311/ex4.py new file mode 100644 index 0000000..c22971a --- /dev/null +++ b/renforcement/entrainement_0311/ex4.py @@ -0,0 +1,24 @@ + +def permutation(mot): + """find all permutation of a word + + :mot: TODO + :returns: list of all permutations + + """ + return permutation_rec('' , mot) + +def permutation_rec(pre, post): + print(pre, post) + if (post == ''): + return pre + ret = list() + for i in list(post): + _post = list(post) + _post.remove(i) + ret.append(permutation_rec(pre + i, str(_post))) + return ret + +if __name__ == "__main__": + permutation('abc') + diff --git a/renforcement/ex1.py b/renforcement/renforcement_2510/ex1.py similarity index 100% rename from renforcement/ex1.py rename to renforcement/renforcement_2510/ex1.py diff --git a/renforcement/ex2.py b/renforcement/renforcement_2510/ex2.py similarity index 100% rename from renforcement/ex2.py rename to renforcement/renforcement_2510/ex2.py diff --git a/renforcement/ex3.py b/renforcement/renforcement_2510/ex3.py similarity index 100% rename from renforcement/ex3.py rename to renforcement/renforcement_2510/ex3.py diff --git a/renforcement/renforcement.pdf b/renforcement/renforcement_2510/renforcement.pdf similarity index 100% rename from renforcement/renforcement.pdf rename to renforcement/renforcement_2510/renforcement.pdf diff --git a/renforcement/renforcement.txt b/renforcement/renforcement_2510/renforcement.txt similarity index 99% rename from renforcement/renforcement.txt rename to renforcement/renforcement_2510/renforcement.txt index e8bbd22..91ea0ed 100644 --- a/renforcement/renforcement.txt +++ b/renforcement/renforcement_2510/renforcement.txt @@ -146,4 +146,4 @@ nom). 5 - \ No newline at end of file +