Skip to content

Instantly share code, notes, and snippets.

@vipranarayan14
Created November 29, 2020 17:35
Show Gist options
  • Save vipranarayan14/dac873c576a1ad2d7f616d93e5f3637c to your computer and use it in GitHub Desktop.
Save vipranarayan14/dac873c576a1ad2d7f616d93e5f3637c to your computer and use it in GitHub Desktop.
def evaluate(
nakshatram: int,
udayadi_naligai: int,
mundaya_naligai: int,
nakshatra_iruppu: int,
should_reeval: bool,
padam: int = 1,
):
if nakshatram == 0:
return "NaksError"
if udayadi_naligai == nakshatra_iruppu or mundaya_naligai == udayadi_naligai:
return "TimeError"
if udayadi_naligai > nakshatra_iruppu & udayadi_naligai < mundaya_naligai:
return "TimeError"
f = 0
s = udayadi_naligai - mundaya_naligai
# 950 - 350 = 600
i = 0
if s < 0:
s += 3600
# x
f = nakshatra_iruppu - mundaya_naligai + 3600
# 3600 - 350 + 3600 = 6850
if f > 4000 and not should_reeval:
return "SameError"
# MsgBox(f.ToString)
if udayadi_naligai > mundaya_naligai and udayadi_naligai < nakshatra_iruppu:
if not reEval:
return "PathError"
else:
if patham == 4:
s += 3600
if f > 4000:
f -= 3600
i = f - s
selluvalue = s * nakshatram / f
irupuvalue = i * nakshatram / f
return {"sellu": selluvalue, "iruppu": irupuvalue}
def timer_value(naligai: [int, int], vinaligai: [int, int]):
return ((naligai[0] * 10) + naligai[1]) * 60 + ((vinaligai[0] * 10) + vinaligai[1])
def format_result(result):
year = int(result)
_result = (result - year) * 12
month = int(_result)
_result = (_result - month) * 30
day = int(_result)
_result = (_result - day) * 60
naligai = int(_result)
_result = (_result - naligai) * 60
vinaligai = int(_result)
return {
"year": year,
"month": month,
"day": day,
"naligai": naligai,
"vinaligai": vinaligai,
}
nakshatram = 7
udayadi_naligai = timer_value(naligai=[5, 0], vinaligai=[0, 0])
mundaya_naligai = timer_value(naligai=[0, 0], vinaligai=[0, 0])
nakshatra_iruppu = timer_value(naligai=[0, 0], vinaligai=[0, 0])
result = evaluate(
nakshatram, udayadi_naligai, mundaya_naligai, nakshatra_iruppu, should_reeval=True
)
if type(result) == dict:
print(format_result(result["sellu"]))
else:
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment