This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.function.Function; | |
import java.util.stream.Collectors; | |
import static java.lang.System.out; | |
import static java.util.stream.Collectors.summingInt; | |
public class Main { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import groupby | |
from collections import Counter | |
def frequencies_map_with_for_from(elements): | |
frequencies_map = {} | |
for element in elements: | |
if element in frequencies_map.keys(): | |
frequencies_map[element] = frequencies_map[element] + 1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@startmindmap kata-mindmap | |
* Ressources pour pratiquer les Katas | |
** Catalogues de Katas | |
*** Kata-Log : https://kata-log.rocks/ | |
*** CodingDojo : https://codingdojo.org/ | |
**** https://codingdojo.org/kata/ | |
*** Code Kata : http://codekata.com/ | |
** Katas spécialisés | |
*** Refactoring Katas | |
**** Tennis : https://github.com/emilybache/Tennis-Refactoring-Kata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] | |
print('letters {}'.format(letters)) | |
print('\n##########\n') | |
print('In Python, the for is a foreach : ') | |
for letter in letters: | |
print(letter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
print('liste de nombres :', numbers) | |
numbers.reverse() | |
print('liste de nombres après reverse() :', numbers) | |
print('\n##############\n') | |
numbers = list(range(10)) | |
print('liste de nombres :', numbers) | |
reversed(numbers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
print('Compréhension de liste') | |
list_of_powers_of_2_for_first_numbers = [x**2 for x in range(1, 10)] | |
print(list_of_powers_of_2_for_first_numbers) | |
print('\n##############\n') | |
print("Compréhension d'ensemble") | |
set_of_powers_of_2_for_first_numbers = {x**2 for x in range(1, 10)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
houses = ["Stark", "Lannister", "Baratheon", "Greyjoy"] | |
seats = ["Winterfell", "Casterly Rock", "Storm's End", "Pyke"] | |
sigils = ["A Gray Direwolf", "A Golden Lion", "A Crowned Black Stag", "A Golden Kraken"] | |
words = ["Winter is coming", "Hear me roar !", "Our is the fury !", "We do not sow"] | |
print(f"houses : {houses}") | |
print(f"seats : {seats}") | |
print(f"sigils : {sigils}") | |
print(f"words : {words}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
houses = ["tyrell", "stark", "lannister", "tarly", "baratheon", "targaryen"] | |
print("Houses :", houses) | |
print("\n##############\n") | |
houses_starting_with_t = filter(lambda s: s.startswith("t"), houses) | |
print("La fonction filter retourne un objet iterator :", houses_starting_with_t) | |
print("C'est bien un objet iterator avec les méthodes __iter__ et __next__") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("L'équivalent avec une boucle for : ", end="") | |
powers_of_2 = [] | |
for number in range(1, 10): | |
powers_of_2.append(number**2) | |
print(powers_of_2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import functools | |
import operator | |
columns = ("a", "b", "c", "d", "e", "f", "g", "h") | |
rows = (1, 2, 3, 4, 5, 6, 7, 8) | |
# Approche naïve | |
print( | |
"Approche naïve (1) : ", list(map(lambda x: map(lambda y: (x, y), rows), columns)) |
OlderNewer