Skip to content

Commit

Permalink
Feat:Save current number in a file upon abortion
Browse files Browse the repository at this point in the history
  • Loading branch information
Justaus3r authored Jul 31, 2021
1 parent ada5896 commit 14ccc4e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ccube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
ccube - collatz conjucture check by justaus3r
ccube - a very simple collatz conjucture check by justaus3r
Distributed under GPLV3
This program is free software: you can redistribute it and/or modify
Expand All @@ -16,7 +16,7 @@
'''
import sys
from rich import print

from time import sleep

def odd_or_even(number):
if number % 2 == 0:
Expand All @@ -31,15 +31,16 @@ def odd_or_even(number):
num = int(read_iter.read())
except Exception:
num = 1
notstopped = True

notinturrepted = True
no_of_iter = 0

def ccube():
try:
global num
global notstopped
global notinturrepted
global no_of_iter
while notstopped:
while notinturrepted:
try:
numcopy = num
while num != 1:
Expand All @@ -57,16 +58,21 @@ def ccube():
print(f"[green]Current Number[/green][blue]:[/blue][cyan]{numcopy}[/cyan]")
print(f"[green]Number of iterations[/green][blue]:[/blue][cyan]{no_of_iter}[/cyan]")
print("[purple]=================================================================[/purple]")

numcopy += 1
num = numcopy
no_of_iter = 0


except KeyboardInterrupt:
print("[red]Interruped!,Aborting[/red]")
with open("save_curr_no.txt","w") as save_iter:
save_iter.write(str(numcopy))
notstopped = False
sleep(1)
except Exception as ex:
print(f"[red]Oho!.it seems that i could only run this much.\nFollowing error has occured while i was running:\n{ex}[/red]")
sleep(5)

ccube()
sys.exit()

0 comments on commit 14ccc4e

Please sign in to comment.