eval_python/main.py
2024-10-07 10:17:49 +02:00

64 lines
2.1 KiB
Python

"""
This module has no real meaning.
Simply implemented for evaluating students.
"""
def list_filenames_of_log_files(*foldernames) -> list:
"""
List all the `*.log` files stored in the folders specified by foldernames.
This method returns a list containing the corresponding strings. Ordered in alphabetical order.
This method does not print anything.
:param foldernames:
:return: list of filenames
:raises FileNotFoundError: If one of the speficied folders does not exist
"""
return foldernames
def list_ipv4_listed_in_logfiles(*foldernames) -> list :
"""
Parse all the `*.log` files stored in the folders specified by foldernames.
This method returns a list of ip adresses stored in those files.
This method does not print anything.
Only IPv4 format are listed
No duplicates are returned.
:param foldernames:
:return: list of ips
:raises FileNotFoundError: If one of the speficied folders does not exist
"""
return foldernames
def cryptarithme(message:str = "SEND + MORE = MONEY") -> list:
"""
The `message` is a formatted mathematical operation.
Each letter represents a number between 0 and 9.
Find the value for each letter so that the full sentence is true.
Knowing that the first letter of each word cannot be a 0 if the word is longer than 1 letter.
It can occur that several results are possible. If so, all solutions must be returned in differents dictionnairies.
The order is not relevant.
Example : A + A = C returns [{"A" : 1, "C" : 2}, {"A" : 2, "C" : 4}, {"A" : 3, "C" : 6}, {"A" : 4, "C" : 8}]
:param message: The string to analyse
:return: List of dictionnaries with the following format : {
'letter1': value1,
'letter2': value2
}
:raises ValueError: If the string cannot be parsed properly.
:raises CryptarithmeError : If the string is not a possible Cryptarithme
"""
return message
if __name__ == '__main__':
list_filenames_of_log_files('data')
list_ipv4_listed_in_logfiles('data')
cryptarithme("")