Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_codex9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Run Codex9 Tests
run: |
echo "🔍 Running unit tests..."
pytest -q test_codex9.py
pytest -q miniproject-1-codex9-ilysimo/test_codex9.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
🧩 Mini Project: The Data Heist of Codex-9
=========================================================

TEAM: # Your team's name
MEMBERS: # List of team members
TEAM: # C++
MEMBERS: # 24101010, 24071004

STORY:
The AI system Codex-9 has been hacked. Fragments of its digital blueprint
Expand Down Expand Up @@ -54,7 +54,15 @@ def decode_fragment(fragment: str) -> list:
['code', 'python', 'Data', 'structure', 'Algorithms']
"""
# TODO: Implement the decoding logic here
pass
if not fragment:
return []

parts = fragment.split(";")

decoded = [p[::-1] for p in parts if p]

return decoded



# =======================================================
Expand All @@ -77,9 +85,9 @@ def organize_segments(words: list, module_numbers: list) -> list:
Example Output:
[('code', 104), ('python', 215), ('Data', 309), ('structure', 412), ('Algorithms', 518)]
"""
# TODO: Combine words and IDs into tuples
pass

if len(words) != len(module_numbers):
raise ValueError(f"Length mismatch")
return list(zip(words, module_numbers))

# =======================================================
# 🧩 TASK 3 — Verify Module Uniqueness (Sets)
Expand All @@ -100,7 +108,7 @@ def unique_modules(modules: list) -> list:
[('code', 104), ('python', 215)]
"""
# TODO: Convert to set and back to list
pass
return list(set(modules))


# =======================================================
Expand All @@ -123,8 +131,13 @@ def build_restoration_queue(unique_list: list) -> list:
[104, 215, 309]
"""
# TODO: Use deque for queue logic
pass
q = deque()
for _, module_id in unique_list:
q.append(module_id)
return [q.popleft() for _ in range(len(q))]



# =======================================================
# 🧩 TASK 5 — Track Actions with Stack (Stack)
# =======================================================
Expand All @@ -147,7 +160,18 @@ def track_actions(module_ids: list) -> list:
['load_104', 'verify_215']
"""
# TODO: Use list as stack and pop last 3
pass
stack = []
for i, mid in enumerate(module_ids):
if i % 2 == 0:
stack.append(f"load_{mid}")
else:
stack.append(f"verify_{mid}")

if len(stack) > 3:
stack = stack[:-3]
else:
stack = []
return stack


# =======================================================
Expand Down Expand Up @@ -177,7 +201,11 @@ def map_actions_to_metadata(actions: list, metadata: dict) -> dict:
}
"""
# TODO: Extract module IDs from actions and map metadata
pass
result = {}
for a in actions:
mid = int(a.split("_")[1])
result[a] = metadata[mid]
return result


# =======================================================
Expand All @@ -199,7 +227,14 @@ def quick_sort_modules(modules: list) -> list:
[(309, 2.1), (104, 3.4), (215, 5.2)]
"""
# TODO: Implement quick sort
pass
if len(modules) <= 1:
return modules

pivot = modules[0]
left = [x for x in modules[1:] if x[1] <= pivot[1]]
right = [x for x in modules[1:] if x[1] > pivot[1]]

return quick_sort_modules(left) + [pivot] + quick_sort_modules(right)


# =======================================================
Expand Down Expand Up @@ -231,7 +266,13 @@ def insert_bst(root: BSTNode, key: int, value: float) -> BSTNode:
value (float): The module size.
"""
# TODO: Insert node correctly
pass
if root is None:
return BSTNode(key, value)
if value < root.value:
root.left = insert_bst(root.left, key, value)
else:
root.right = insert_bst(root.right, key, value)
return root

def inorder_bst(root: BSTNode) -> list:
"""
Expand All @@ -241,7 +282,9 @@ def inorder_bst(root: BSTNode) -> list:
root (BSTNode): The root of the BST.
"""
# TODO: Implement inorder traversal
pass
if root is None:
return []
return inorder_bst(root.left) + [(root.key, root.value)] + inorder_bst(root.right)



Expand Down Expand Up @@ -269,7 +312,7 @@ def build_dependency_graph(connection_map: dict) -> dict:
Same dictionary (adjacency list)
"""
# TODO: Return adjacency list
pass
return connection_map


# =======================================================
Expand Down Expand Up @@ -301,6 +344,15 @@ def dfs_activation(graph: dict, start: str) -> list:
System Message: Blueprint successfully restored. Codex-9 reboot complete.
"""
# TODO: Implement recursive DFS
pass
visited = []

def dfs(node):
if node in visited:
return
visited.append(node)
for nxt in graph[node]:
dfs(nxt)

dfs(start)
return visited, "Blueprint successfully restored. Codex-9 reboot complete."

210 changes: 210 additions & 0 deletions miniproject-2-protocol-QV-7/INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
### 🧠 Storyline

Deep beneath the abandoned research complex Helion Prime, a classified experimental containment system known as the Quantum Vault has suffered a catastrophic breach.

Inside the Vault lie encrypted algorithmic artifacts — predictive AIs, mathematical models, temporal distortion engines — all stored as quantum shards.
When the breach occurred, these shards were fragmented, scrambled, and scattered across corrupted memory sectors.

The Quantum Recovery Task Unit (you) has been activated.

### 🧠 Project Overview

* Number of tasks: 10
* Recommended team size: 1–4 students
* Topics covered:
Strings, lists, sets, tuples, stacks, queues, dictionaries, searching/sorting algorithms, binary search trees, graphs
* Final goal: Rebuild the Quantum Lattice Map and secure The Vault.

### ⚙️ TASKS

#### Task 1 — Extract Quantum Shards

You are given a corrupted quantum data stream where shards are separated by #.

```
"23noitazimitpO#gnirts_001#eman-tceles"
```

You must:
* Split the string into fragments
* Reverse each fragment
* Remove all characters except letters, digits, and hyphens
* Return the resulting cleaned list

```py
['Optimization32', '100_string', 'select-name']
```


#### Task 2 — Pair Shards with Sequence Codes

You receive a list of decoded shard strings and a list of integer sequence codes.

You must pair them into tuples:

```py
(shard_string, code)
```

```py
shards = ['alpha', 'beta', 'gamma', 'alpha']
codes = [7, 12, 18, 22]
```

```py
[('alpha', 7), ('beta', 12), ('gamma', 18), ('alpha', 22)]
```


#### TASK 3 — Stabilize Shard Registry

Duplicates may exist due to memory corruption.

You must:
* Convert the list of shard tuples to a set
* Convert it back to a list
* Return only unique shard entries

```py
[('alpha', 7), ('beta', 12), ('gamma', 18), ('alpha', 22)]
```

```py
[('alpha', 7), ('beta', 12), ('gamma', 18)]
```

#### Task 4 — Initialize Reconstruction Queue

Processing must occur in the exact order that unique shard pairs appear.

```py
[('alpha', 7), ('beta', 12), ('gamma', 18)]
```

You must:
* Create a FIFO queue (collections.deque)
* Enqueue each (shard, code) tuple
* Dequeue items one by one
* Return a list only of the sequence codes in processed order

```py
[7, 12, 18]
```

#### TASK 5 — Action Log Stack

For each code, generate two actions:
* `decode_<code>`
* `validate_<code>`


```py
[7, 12, 18]
```


```py
['decode_7', 'validate_7', 'decode_12', 'validate_12', 'decode_18', 'validate_18']
# after removing 2:
['decode_7', 'validate_7', 'decode_12', 'validate_12']
```

#### TASK 6 — Annotate Shards

You must:
* Use each action name (e.g., "decode_7")
* Extract the code (e.g., 7)
* Map the action to metadata found in shard_info[code]

```py
actions = ['decode_7']
shard_info = {7: {"energy": 1.2, "state": "stable"},
12: {"energy": 2.5, "state": "unstable"},
18: {"energy": 3.1, "state": "stable"},
22: {"energy": 4.0, "state": "critical"},
2: {"energy": 0.9, "state": "stable"}}
```


```py
{'decode_7': {'energy': 1.2, 'state': 'stable'},
'validate_7': {'energy': 1.2, 'state': 'stable'},
'decode_12': {'energy': 2.5, 'state': 'unstable'},
'validate_12': {'energy': 2.5, 'state': 'unstable'}}
```


#### TASK 7 — Sort Shards by Energy

You will receive a list of tuples:

```
(code, energy)
```

You must:
* Implement a sort algorithm manually(by your choice, e.g., quick sort, merge sort, bubble sort)
* Sort by energy in ascending order
* Return the sorted list

```py
[(18, 3.1), (7, 1.2), (12, 2.5)]
```

```py
[(7, 1.2), (12, 2.5), (18, 3.1)]
```


#### TASK 8 — Rebuild Quantum Integrity Tree

You must implement a Binary Search Tree where:
* The tree is ordered by energy
* Each node stores (code, energy)
* You must implement:
* insert_qv
* inorder_qv

**Inorder traversal must return items sorted by energy.**

```py
[(18, 3.1), (2, 0.9), (22, 4.0), (7, 1.2), (12, 2.5)]
```

```py
[(2, 0.9), (7, 1.2), (12, 2.5), (18, 3.1), (22, 4.0)]
```

#### TASK 9 — Build Shard Dependency Map

You receive a dependency mapping:

```py
{
"7": ["12"],
"12": ["18"],
"18": []
}
```

You must return a clean adjacency list (likely identical to input).
Build a Graph representation using a dictionary of lists.



#### TASK 10 — Activate Vault Sequence

Perform a Depth-First Search starting from a given code.

You must return:
* The activation order (list)
* A final status message

```py
graph = {"7": ["12"], "12": ["18"], "18": []}
start = "7"
```

```py
(['7', '12', '18'], "Quantum Vault fully restored. Protocol QV-7 complete.")
```
Loading