diff --git a/nohup.out b/nohup.out new file mode 100644 index 00000000..eb62c05a --- /dev/null +++ b/nohup.out @@ -0,0 +1,8 @@ +ℹ️ cluster id is 9e68173f-9c23-4acc-ba81-4f079b639964 +ℹ️ using 256 bit prime +ℹ️ storing state in /tmp/.tmpxw189i (77.97Gbs available) +🏃 starting nilchain node in: /tmp/.tmpxw189i/nillion-chain +Error: launching nilchain proxy + +Caused by: + Address in use (os error 98) diff --git a/quickstart/client_code/run_my_first_program.py b/quickstart/client_code/run_my_first_program.py index e69de29b..f8b258f4 100644 --- a/quickstart/client_code/run_my_first_program.py +++ b/quickstart/client_code/run_my_first_program.py @@ -0,0 +1,137 @@ +from datetime import datetime + +def display_tasks(tasks): + if not tasks: + print("Your to-do list is empty.") + return + + print("Your To-Do List:") + for index, task in enumerate(tasks, start=1): + status = "Done" if task['done'] else "Not done" + priority = task['priority'] + due_date = task['due_date'] if task['due_date'] else "No due date" + print(f"{index}. {task['task']} - [{status}] (Priority: {priority}) (Due: {due_date})") + +def add_task(tasks): + task = input("Enter a new task: ") + priority = input("Enter priority (low, medium, high): ").lower() + if priority not in ["low", "medium", "high"]: + priority = "low" + due_date = input("Enter due date (YYYY-MM-DD) or leave blank: ") + try: + due_date = datetime.strptime(due_date, "%Y-%m-%d").date() if due_date else None + except ValueError: + print("Invalid date format. No due date set.") + due_date = None + tasks.append({"task": task, "done": False, "priority": priority, "due_date": due_date}) + print(f"Task '{task}' added with priority '{priority}' and due date '{due_date}'.") + +def remove_task(tasks): + task_number = int(input("Enter the number of the task to remove: ")) + if 0 < task_number <= len(tasks): + removed_task = tasks.pop(task_number - 1) + print(f"Task '{removed_task['task']}' removed.") + else: + print("Invalid task number.") + +def mark_task_done(tasks): + task_number = int(input("Enter the number of the task to mark as done: ")) + if 0 < task_number <= len(tasks): + tasks[task_number - 1]['done'] = True + print(f"Task '{tasks[task_number - 1]['task']}' marked as done.") + else: + print("Invalid task number.") + +def edit_task(tasks): + task_number = int(input("Enter the number of the task to edit: ")) + if 0 < task_number <= len(tasks): + task = tasks[task_number - 1] + new_task = input(f"Enter new task description (current: '{task['task']}') or press Enter to keep it: ") + new_priority = input(f"Enter new priority (low, medium, high) (current: '{task['priority']}') or press Enter to keep it: ").lower() + new_due_date = input(f"Enter new due date (YYYY-MM-DD) (current: '{task['due_date']}') or press Enter to keep it: ") + + if new_task: + task['task'] = new_task + if new_priority in ["low", "medium", "high"]: + task['priority'] = new_priority + if new_due_date: + try: + task['due_date'] = datetime.strptime(new_due_date, "%Y-%m-%d").date() + except ValueError: + print("Invalid date format. Due date not changed.") + print("Task updated.") + else: + print("Invalid task number.") + +def sort_tasks(tasks, by): + if by == 'priority': + tasks.sort(key=lambda x: ['low', 'medium', 'high'].index(x['priority'])) + elif by == 'status': + tasks.sort(key=lambda x: x['done']) + elif by == 'due_date': + tasks.sort(key=lambda x: (x['due_date'] is None, x['due_date'])) + print(f"Tasks sorted by {by}.") + +def save_tasks(tasks, filename="tasks.txt"): + with open(filename, "w") as file: + for task in tasks: + file.write(f"{task['task']}|{task['done']}|{task['priority']}|{task['due_date']}\n") + print("Tasks saved to file.") + +def load_tasks(filename="tasks.txt"): + tasks = [] + try: + with open(filename, "r") as file: + for line in file: + task, done, priority, due_date = line.strip().split("|") + due_date = datetime.strptime(due_date, "%Y-%m-%d").date() if due_date != 'None' else None + tasks.append({"task": task, "done": done == "True", "priority": priority, "due_date": due_date}) + except FileNotFoundError: + print("No saved tasks found.") + return tasks + +def main(): + tasks = load_tasks() + while True: + print("\nOptions:") + print("1. View tasks") + print("2. Add task") + print("3. Remove task") + print("4. Mark task as done") + print("5. Edit task") + print("6. Sort tasks by priority") + print("7. Sort tasks by status") + print("8. Sort tasks by due date") + print("9. Save tasks") + print("10. Quit") + + choice = input("Select an option (1-10): ") + + if choice == '1': + display_tasks(tasks) + elif choice == '2': + add_task(tasks) + elif choice == '3': + remove_task(tasks) + elif choice == '4': + mark_task_done(tasks) + elif choice == '5': + edit_task(tasks) + elif choice == '6': + sort_tasks(tasks, 'priority') + elif choice == '7': + sort_tasks(tasks, 'status') + elif choice == '8': + sort_tasks(tasks, 'due_date') + elif choice == '9': + save_tasks(tasks) + elif choice == '10': + save_tasks(tasks) + break + else: + print("Invalid choice. Try again.") + +if __name__ == "__main__": + main() + + diff --git a/quickstart/nada_quickstart_programs/nada-project.toml b/quickstart/nada_quickstart_programs/nada-project.toml new file mode 100644 index 00000000..da166dde --- /dev/null +++ b/quickstart/nada_quickstart_programs/nada-project.toml @@ -0,0 +1,7 @@ +name = "nada_quickstart_programs" +version = "0.1.0" +authors = [""] + +[[programs]] +path = "src/main.py" +prime_size = 128 diff --git a/quickstart/nada_quickstart_programs/src/main.py b/quickstart/nada_quickstart_programs/src/main.py new file mode 100644 index 00000000..49e9e7e6 --- /dev/null +++ b/quickstart/nada_quickstart_programs/src/main.py @@ -0,0 +1,12 @@ +from nada_dsl import * + +def nada_main(): + party1 = Party(name="Party1") + party2 = Party(name="Party2") + party3 = Party(name="Party3") + a = SecretInteger(Input(name="A", party=party1)) + b = SecretInteger(Input(name="B", party=party2)) + + result = a + b + + return [Output(result, "my_output", party3)] \ No newline at end of file diff --git a/quickstart/nada_quickstart_programs/target/main.nada.bin b/quickstart/nada_quickstart_programs/target/main.nada.bin new file mode 100644 index 00000000..23366cf5 Binary files /dev/null and b/quickstart/nada_quickstart_programs/target/main.nada.bin differ diff --git a/quickstart_complete/nada_quickstart_programs/src/main.py b/quickstart_complete/nada_quickstart_programs/src/main.py new file mode 100644 index 00000000..f1aabf02 --- /dev/null +++ b/quickstart_complete/nada_quickstart_programs/src/main.py @@ -0,0 +1,137 @@ +from datetime import datetime + +def display_tasks(tasks): + if not tasks: + print("Your to-do list is empty.") + return + + print("Your To-Do List:") + for index, task in enumerate(tasks, start=1): + status = "Done" if task['done'] else "Not done" + priority = task['priority'] + due_date = task['due_date'] if task['due_date'] else "No due date" + print(f"{index}. {task['task']} - [{status}] (Priority: {priority}) (Due: {due_date})") + +def add_task(tasks): + task = input("Enter a new task: ") + priority = input("Enter priority (low, medium, high): ").lower() + if priority not in ["low", "medium", "high"]: + priority = "low" + due_date = input("Enter due date (YYYY-MM-DD) or leave blank: ") + try: + due_date = datetime.strptime(due_date, "%Y-%m-%d").date() if due_date else None + except ValueError: + print("Invalid date format. No due date set.") + due_date = None + tasks.append({"task": task, "done": False, "priority": priority, "due_date": due_date}) + print(f"Task '{task}' added with priority '{priority}' and due date '{due_date}'.") + +def remove_task(tasks): + task_number = int(input("Enter the number of the task to remove: ")) + if 0 < task_number <= len(tasks): + removed_task = tasks.pop(task_number - 1) + print(f"Task '{removed_task['task']}' removed.") + else: + print("Invalid task number.") + +def mark_task_done(tasks): + task_number = int(input("Enter the number of the task to mark as done: ")) + if 0 < task_number <= len(tasks): + tasks[task_number - 1]['done'] = True + print(f"Task '{tasks[task_number - 1]['task']}' marked as done.") + else: + print("Invalid task number.") + +def edit_task(tasks): + task_number = int(input("Enter the number of the task to edit: ")) + if 0 < task_number <= len(tasks): + task = tasks[task_number - 1] + new_task = input(f"Enter new task description (current: '{task['task']}') or press Enter to keep it: ") + new_priority = input(f"Enter new priority (low, medium, high) (current: '{task['priority']}') or press Enter to keep it: ").lower() + new_due_date = input(f"Enter new due date (YYYY-MM-DD) (current: '{task['due_date']}') or press Enter to keep it: ") + + if new_task: + task['task'] = new_task + if new_priority in ["low", "medium", "high"]: + task['priority'] = new_priority + if new_due_date: + try: + task['due_date'] = datetime.strptime(new_due_date, "%Y-%m-%d").date() + except ValueError: + print("Invalid date format. Due date not changed.") + print("Task updated.") + else: + print("Invalid task number.") + +def sort_tasks(tasks, by): + if by == 'priority': + tasks.sort(key=lambda x: ['low', 'medium', 'high'].index(x['priority'])) + elif by == 'status': + tasks.sort(key=lambda x: x['done']) + elif by == 'due_date': + tasks.sort(key=lambda x: (x['due_date'] is None, x['due_date'])) + print(f"Tasks sorted by {by}.") + +def save_tasks(tasks, filename="tasks.txt"): + with open(filename, "w") as file: + for task in tasks: + file.write(f"{task['task']}|{task['done']}|{task['priority']}|{task['due_date']}\n") + print("Tasks saved to file.") + +def load_tasks(filename="tasks.txt"): + tasks = [] + try: + with open(filename, "r") as file: + for line in file: + task, done, priority, due_date = line.strip().split("|") + due_date = datetime.strptime(due_date, "%Y-%m-%d").date() if due_date != 'None' else None + tasks.append({"task": task, "done": done == "True", "priority": priority, "due_date": due_date}) + except FileNotFoundError: + print("No saved tasks found.") + return tasks + +def main(): + tasks = load_tasks() + while True: + print("\nOptions:") + print("1. View tasks") + print("2. Add task") + print("3. Remove task") + print("4. Mark task as done") + print("5. Edit task") + print("6. Sort tasks by priority") + print("7. Sort tasks by status") + print("8. Sort tasks by due date") + print("9. Save tasks") + print("10. Quit") + + choice = input("Select an option (1-10): ") + + if choice == '1': + display_tasks(tasks) + elif choice == '2': + add_task(tasks) + elif choice == '3': + remove_task(tasks) + elif choice == '4': + mark_task_done(tasks) + elif choice == '5': + edit_task(tasks) + elif choice == '6': + sort_tasks(tasks, 'priority') + elif choice == '7': + sort_tasks(tasks, 'status') + elif choice == '8': + sort_tasks(tasks, 'due_date') + elif choice == '9': + save_tasks(tasks) + elif choice == '10': + save_tasks(tasks) + break + else: + print("Invalid choice. Try again.") + +if __name__ == "__main__": + main() + + diff --git a/quickstart_complete/nada_quickstart_programs/src/secret_addition_complete.py b/quickstart_complete/nada_quickstart_programs/src/secret_addition_complete.py deleted file mode 100644 index be9daa13..00000000 --- a/quickstart_complete/nada_quickstart_programs/src/secret_addition_complete.py +++ /dev/null @@ -1,12 +0,0 @@ -from nada_dsl import * -def nada_main(): - - party1 = Party(name="Party1") - - my_int1 = SecretInteger(Input(name="my_int1", party=party1)) - - my_int2 = SecretInteger(Input(name="my_int2", party=party1)) - - new_int = my_int1 + my_int2 - - return [Output(new_int, "my_output", party1)] \ No newline at end of file diff --git a/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin b/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin index 4351b211..8a7ddc40 100644 Binary files a/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin and b/quickstart_complete/nada_quickstart_programs/target/secret_addition_complete.nada.bin differ