skyfffire 2 anos atrás
commit
854853a454
3 arquivos alterados com 45 adições e 0 exclusões
  1. 2 0
      .gitignore
  2. 16 0
      main.py
  3. 27 0
      re_loop.py

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+venv
+.idea

+ 16 - 0
main.py

@@ -0,0 +1,16 @@
+# This is a sample Python script.
+
+# Press Shift+F10 to execute it or replace it with your code.
+# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
+
+
+def print_hi(name):
+    # Use a breakpoint in the code line below to debug your script.
+    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.
+
+
+# Press the green button in the gutter to run the script.
+if __name__ == '__main__':
+    print_hi('PyCharm')
+
+# See PyCharm help at https://www.jetbrains.com/help/pycharm/

+ 27 - 0
re_loop.py

@@ -0,0 +1,27 @@
+def generate_combinations(n, max_number):
+    # Initialize the combination
+    combination = [0] * n
+
+    # Generate all combinations
+    while True:
+        # Print the current combination
+        print(combination)
+
+        # Increment the combination
+        i = n - 1
+        while i >= 0:
+            if combination[i] < max_number:
+                combination[i] += 1
+                break
+            else:
+                combination[i] = 0
+                i -= 1
+
+        # If i < 0, we've exhausted all combinations
+        if i < 0:
+            break
+
+
+if __name__ == '__main__':
+    # Generate all 8-digit combinations
+    generate_combinations(4, 4)