Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -3,3 +3,4 @@ gcc -o cbio cbio.c -lm
Age: 10717 days
Physical cycle: -27%
Emotional cycle: -100%
Intellectual cycle: -100%

View file

@ -1,24 +1,21 @@
Module Biorhythms {
form 80
enum bio {Physical=23, Emotional=28,Mental=33}
quadrants=(("up and rising", "peak"), ("up but falling", "transition"), ("down and falling", "valley"), ("down but rising", "transition"))
date birth="1943-03-09"
date bioDay="1972-07-11", transition
for k=1 to 1
Module Biorhythms (birth, bioDay, N as long = 1) {
date birth, bioDay, transition
enum bio {Physical=23, Emotional=28, Mental=33}
dim quadrants(4)
quadrants(0):=("up and rising", "peak"), ("up but falling", "transition"), ("down and falling", "valley"), ("down but rising", "transition")
if N<1 then N=1
for k=1 to N
long Days=bioDay-birth
Print "Day "+(bioDay)+":"
Print "Day "+bioDay+" | Age in days: "+Days
string frm="{0:-20} : {1}", pword, dfmt="YYYY-MM-DD"
long position, percentage, length, targetday
long position, percentage, length
k=each(bio)
while k
length=eval(k)
length=eval(k)
position=days mod length
quadrant=int(4*position/length)
targetday=bioDay // get the long value of day from date type
percentage=100*sin(360*position/length)
transition=bioDay+floor((quadrant+1)/4*23)-position
transition=bioDay+floor((quadrant+1)/4*length)-position
select case percentage
case >95
pword="peak"
@ -27,14 +24,15 @@ Module Biorhythms {
case -5 to 5
pword="critical "
case else
{
pword=percentage+"% ("+quadrants#val(quadrant)#val$(0)+", next "
pword+=quadrants#val(quadrant)#val$(1)+" "+str$(transition,dfmt)+")"
}
{
pword=percentage+"% ("+quadrants(quadrant)#val$(0)+", next "
pword+=quadrants(quadrant)#val$(1)+" "+str$(transition, dfmt)+")"
}
end select
print format$(frm, eval$(k)+" day "+(days mod length), pword)
End while
bioDay++
next k
}
Biorhythms
form 80
Biorhythms "1943-03-09", "1972-07-11"

View file

@ -0,0 +1,94 @@
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import scala.jdk.CollectionConverters._
object Biorhythms extends App {
private val datePairs = List(
("1943-03-09", "1972-07-11"),
("1809-01-12", "1863-11-19"),
("1809-02-12", "1863-11-19")
)
datePairs.foreach(calculateBiorhythms)
private def calculateBiorhythms(dates: (String, String)): Unit = {
val formatter = DateTimeFormatter.ISO_LOCAL_DATE
val birthDate = LocalDate.parse(dates._1, formatter)
val targetDate = LocalDate.parse(dates._2, formatter)
val daysBetween = ChronoUnit.DAYS.between(birthDate, targetDate).toInt
println(s"Birth Date: $birthDate, Target Date: $targetDate")
println(s"Days Between: $daysBetween")
Cycle.values.foreach(processCycle(daysBetween, targetDate, _))
println()
}
private def processCycle(daysBetween: Int, targetDate: LocalDate, cycle: Cycle): Unit = {
val position = daysBetween % cycle.length
val angle = 2 * Math.PI * position / cycle.length
val percentage = Math.round(100 * Math.sin(angle)).toInt
val description = percentage match {
case p if p > 95 => "peak"
case p if p < -95 => "valley"
case p if Math.abs(p) < 5 => "critical transition"
case _ =>
val quadrant = Quadrant.fromPosition(position, cycle.length)
val daysToTransition = quadrant.daysToTransition(position, cycle.length)
val transitionDate = targetDate.plusDays(daysToTransition)
val (trend, nextTransition) = quadrant.getDescriptions
s"$percentage% ($trend, $nextTransition on $transitionDate)"
}
println(s"${cycle} day $position: $description")
}
private enum Cycle(val length: Int) {
private case PHYSICAL extends Cycle(23)
private case EMOTIONAL extends Cycle(28)
private case MENTAL extends Cycle(33)
override def toString: String = this match {
case PHYSICAL => "Physical"
case EMOTIONAL => "Emotional"
case MENTAL => "Mental"
}
}
enum Quadrant {
case UpAndRising
case UpButFalling
case DownAndFalling
case DownButRising
def getDescriptions: (String, String) = this match {
case UpAndRising => ("up and rising", "next peak")
case UpButFalling => ("up but falling", "next transition")
case DownAndFalling => ("down and falling", "next valley")
case DownButRising => ("down but rising", "next transition")
}
def daysToTransition(position: Int, cycleLength: Int): Int = {
val quarter = cycleLength / 4
val positionInQuadrant = position % quarter
quarter - positionInQuadrant
}
}
private object Quadrant {
def fromPosition(position: Int, cycleLength: Int): Quadrant = {
val relativePosition = position.toDouble / cycleLength
relativePosition match {
case p if p >= 0.0 && p < 0.25 => Quadrant.UpAndRising
case p if p >= 0.25 && p < 0.5 => Quadrant.UpButFalling
case p if p >= 0.5 && p < 0.75 => Quadrant.DownAndFalling
case p if p >= 0.75 && p < 1.0 => Quadrant.DownButRising
case _ => throw new IllegalArgumentException("Position out of bounds")
}
}
}
}