1
- """ Examples adapted from Mecha Munch Management"""
1
+ """ Examples adapted from Mecha Munch Management, Alphametrics, and ChatGPT
2
+
3
+ ChatGPT Prompt: Write a python function that
4
+ reads user settings from a toml file and
5
+ merges them with a dictionary of default
6
+ settings to create a single dictionary.
7
+ If there are any conflicts between the
8
+ two sources of settings, the data from
9
+ the toml file should be used.
10
+ """
11
+
12
+
2
13
def update_recipes_tuple (ideas , recipe_updates ):
3
- """Update the recipe ideas dictionary.
14
+ """Mecha Munch Management Example.
15
+
16
+ Update the recipe ideas dictionary.
4
17
:param ideas: dict - The "recipe ideas" dict.
5
18
:param recipe_updates: tuple - tuple with updates for the ideas section.
6
19
:return: dict - updated "recipe ideas" dict.
@@ -14,7 +27,9 @@ def update_recipes_tuple(ideas, recipe_updates):
14
27
15
28
16
29
def update_recipes_dict (ideas , recipe_updates ):
17
- """Update the recipe ideas dictionary.
30
+ """Second Mecha Munch Management Example.
31
+
32
+ Update the recipe ideas dictionary.
18
33
:param ideas: dict - The "recipe ideas" dict.
19
34
:param recipe_updates: dict - dictionary with updates for the ideas section.
20
35
:return: dict - updated "recipe ideas" dict.
@@ -37,9 +52,9 @@ def update_recipes_dict(ideas, recipe_updates):
37
52
# {'Banana Bread': {'Banana': 4, 'Walnuts': 2, 'Flour': 1, 'Eggs': 3, 'Butter': 1, 'Milk': 2}}
38
53
39
54
40
-
41
- """ Example from `alphametrics` exercise """
42
55
def assign (letters , selections , lefty , righty ):
56
+ """ Example from `alphametrics` exercise """
57
+
43
58
while letters :
44
59
new_selections = []
45
60
@@ -61,19 +76,6 @@ def assign(letters, selections, lefty, righty):
61
76
return [slc for slc , _ in selections ]
62
77
63
78
64
-
65
-
66
-
67
- """
68
- This exmple comes from ChatGPT
69
- Prompt: Write a python function that
70
- reads user settings from a toml file and
71
- merges them with a dictionary of default
72
- settings to create a single dictionary.
73
- If there are any conflicts between the
74
- two sources of settings, the data from
75
- the toml file should be used.
76
- """
77
79
import tomlib
78
80
79
81
def merge_settings (default_settings , toml_file_path ):
@@ -95,4 +97,4 @@ def merge_settings(default_settings, toml_file_path):
95
97
toml_file_path = 'settings.toml' # Path to the TOML file
96
98
97
99
final_settings = merge_settings (default_settings , toml_file_path )
98
- print ("Final Settings:" , final_settings )
100
+ print ("Final Settings:" , final_settings )
0 commit comments