commit 30f70662569611c7d77a1576929046b76bded137 Author: max Date: Sat Nov 5 12:20:10 2022 +0100 premier commit diff --git a/calcu.html b/calcu.html new file mode 100644 index 0000000..894652f --- /dev/null +++ b/calcu.html @@ -0,0 +1,399 @@ + + + + + Max la menace + + + + + + + + +
+ + +
+
+ + + + + + + + + + + +
+
+ + + + +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/triche/autre_code/a_casse.html b/triche/autre_code/a_casse.html new file mode 100644 index 0000000..336a714 --- /dev/null +++ b/triche/autre_code/a_casse.html @@ -0,0 +1,218 @@ + + + + + max desxieme du nom + + + + + + + A casser +
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+ + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/triche/calculatrie_val_entiere.html b/triche/calculatrie_val_entiere.html new file mode 100644 index 0000000..561e52d --- /dev/null +++ b/triche/calculatrie_val_entiere.html @@ -0,0 +1,254 @@ + + + + + max premier du nom + + + + + +
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/triche/trouche b/triche/trouche new file mode 100644 index 0000000..a74375f --- /dev/null +++ b/triche/trouche @@ -0,0 +1,204 @@ +class Livre { + Titre: string + Date: Time + Nb_pages: uint + + constr = func (titre: string, nb: uint) Livre { + ret = { + Titre: titre, + Date: time.Now(), + Nb_pages: nb, + } + + return ret + } + + func joli_titre():string { + return "Voici le " + this.Titre +" fabulueux qui fait: " + this.Nb_pages.as_string() + } + func mix(autre: Livre){ + this.Nb_pages = this.Nb_pages + autre.Nb_pages + } +} + +lg = new Livre("1er", 1010) +lg2 = new Livre("2er", 10) + +list = [lg, lg2] + +lg.Date = "20-12-1995" + +log(lg.joli_titre()) + +log(list) +// [Livre, Livre] +num_1 = list[0] +log(num_1) +// {"1er", "20-12-1995", 1010} + +num_1.mix(list[1]) +// lg.mix(lg2) + +log(lg.Nb_pages) +// + + + + + + +// nouveau test goo !! + +package main + +import ( + "fmt" +) + +type TestObject struct { + Numbers []int + Symbols []string + Res int +} + +func Handle_multiplications(symbols []string, numbers []int) int { + ret := 0 + + for i, s := range symbols { + n1 := numbers[i] + n2 := numbers[i+1] + if s == "*" { + ret = n1 * n2 + } else { + ret = n1 / n2 + } + } + return ret +} + +func Calculate1(symbols []string, numbers []int) int { + next_iter_symb_list := []string{} + next_iter_numbers_list := []int{} + + fmt.Printf("init %v %v\n", symbols, numbers) + + for i := 0; i < len(symbols); i++ { + s := symbols[i] + + // } + // for i, s := range symbols { + n1 := numbers[i] + n2 := numbers[i+1] + + if s == "-" || s == "+" { + next_iter_numbers_list = append(next_iter_numbers_list, n1) + next_iter_symb_list = append(next_iter_symb_list, s) + // fmt.Println("will add n SUM", n1) + continue + } + + newN := 0 + if s == "*" { + newN = n1 * n2 + } else if s == "/" { + newN = n1 / n2 + } + + j := i + for { + if j == len(symbols) { + next_iter_numbers_list = append(next_iter_numbers_list, newN) + break + } + + if symbols[j+1] == "-" || symbols[j+1] == "+" { + i = j + next_iter_numbers_list = append(next_iter_numbers_list, newN) + break + } else { + n2 := numbers[j+1] + if symbols[j+1] == "/" { + newN = newN / n2 + } else { + newN = newN * n2 + } + } + j += 1 + } + + // fmt.Println("new v:", newN) + + // if i == len(symbols)-1 || symbols[i+1] == "+" || symbols[i+1] == "-" { + // if i == len(symbols)-1 { + // // fmt.Println("1st loop last") + // } + // // fmt.Println("will add n or Next LAST or SUM", newN) + // next_iter_numbers_list = append(next_iter_numbers_list, newN) + // } else { + // numbers[i+1] = newN + // } + } + + fmt.Printf("inter %v %v\n", next_iter_symb_list, next_iter_numbers_list) + + res := 0 + for i, s := range next_iter_symb_list { + n1 := next_iter_numbers_list[i] + n2 := next_iter_numbers_list[i+1] + + if s == "-" { + res = n1 - n2 + } else if s == "+" { + res = n1 + n2 + } + + // fmt.Println("1", res) + + next_iter_numbers_list[i+1] = res + } + + return res +} + +// func Calculate(symbols []string, numbers []int) int { +// res := 0 + +// nxt_symb := []string{} +// nxt_numb := []int{} + +// for i := 0; i < len(symbols); i++ { +// s := symbols[i] +// n1 := numbers[i] +// n2 := numbers[i+1] + +// if s == "" { + +// } +// } + +// return res +// } + +// TestCalculate calls greetings.Hello with a name, checking +// for a valid return value. +func TestCalculate() { + tests := []*TestObject{ + {Numbers: []int{-4, 14, 2, 5}, Symbols: []string{"-", "+", "*"}, Res: -8}, // -4-14+2*5 + {Numbers: []int{4, 4, 2, 2}, Symbols: []string{"*", "+", "/"}, Res: 17}, // 4*4+2/2 + {Numbers: []int{2, 5, 2, 5}, Symbols: []string{"*", "*", "-"}, Res: 15}, // 2*5*2-5 + {Numbers: []int{-4, 14, 2}, Symbols: []string{"-", "+"}, Res: -16}, // -4-14+2 + } + + for _, test := range tests { + res := Calculate1(test.Symbols, test.Numbers) + if test.Res != res { + fmt.Println("FAILED: the expected result was supposed to be", test.Res, "but we got", res, test.Numbers) + } else { + fmt.Println("GOOD:", res, test.Numbers) + } + } +} + +func main() { + TestCalculate() +} \ No newline at end of file