RosettaCodeData/Task/Biorhythms/11l/biorhythms.11l
2026-02-01 16:33:20 -08:00

44 lines
1.6 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

F biorhythms(birthdate_str, targetdate_str)
Print out biorhythm data for targetdate assuming you were
born on birthdate.
birthdate and targetdata are strings in this format:
YYYY-MM-DD e.g. 1964-12-26
print(Born: birthdate_str Target: targetdate_str)
V birthdate = time:strptime(birthdate_str, %Y-%m-%d)
V targetdate = time:strptime(targetdate_str, %Y-%m-%d)
V days = (targetdate - birthdate).days()
print(Day: days)
V cycle_labels = [Physical, Emotional, Mental]
V cycle_lengths = [23, 28, 33]
V quadrants = [(up and rising, peak), (up but falling, transition), (down and falling, valley), (down but rising, transition)]
L(i) 0.<3
V label = cycle_labels[i]
V length = cycle_lengths[i]
V position = days % length
V quadrant = Int(floor((4 * position) / length))
V percentage = Int(round(100 * sin(2 * math:pi * position / length), 0))
V transition_date = (targetdate + TimeDelta(days' floor((quadrant + 1) / 4 * length) - position)).strftime(%Y-%m-%d)
V (trend, next) = quadrants[quadrant]
String description
I percentage > 95
description = peak
E I percentage < -95
description = valley
E I abs(percentage) < 5
description = critical transition
E
description = percentage% (trend, next next transition_date)
print(label day position: description)
biorhythms(2043-03-09, 2072-07-11)