Post Reply 
HHC 2018 Programming Contests
10-06-2018, 03:15 PM (This post was last modified: 10-06-2018 03:17 PM by Eddie W. Shore.)
Post: #82
RE: HHC 2018 Programming Contests
(10-05-2018 09:32 PM)Joe Horn Wrote:  Here is Eddie Shore's winning PPL entry:

Code:
sub1(); // elegant background screen

EXPORT BIOXTR()
BEGIN
STARTAPP("Function");
Xmin:=−6*π;Xmax:=6*π;
Ymin:=−1.1;Ymax:=1.1;

sub1();
TEXTOUT("BIORYTHM",−2*π,0,5);
TEXTOUT("by Edward Shore",−2*π,−.5,5);
TEXTOUT("Find your fate.",−2*π,−2,5);
WAIT(1);

// enter birthdate
LOCAL b,b1,b2,b3;
INPUT({b1,b2,b3},
"When were you born?",
{"Month: ","Day: ","Year: "});
b:=b3+b1/100+b2/10000;

// calculation
LOCAL d,L0,L1,t,m,p;
d:=DDAYS(b,Date);
L0:={CEILING((d-5.75)/11.5),
CEILING((d-7)/14),
CEILING((d-8.25)/16.5)};
L1:={ROUND(11.5*L0(1)+5.75,0),
ROUND(14*L0(2)+7,0),
ROUND(16.5*L0(3)+8.25,0)};

// loop
WHILE L1(1)≠L1(2) AND L1(1)≠L1(3)
AND L1(2)≠L1(3) DO
m:=POS(L1,MIN(L1));
L0(m):=L0(m)+1;
L1:={ROUND(11.5*L0(1)+5.75,0),
ROUND(14*L0(2)+7,0),
ROUND(16.5*L0(3)+8.25,0)};
END;

// an elegant way to extract the date
IF L1(2)==L1(3) THEN
t:=L1(2);
ELSE
t:=L1(1);
END;
d:=DATEADD(b,t);

// results screen
LOCAL str1;
LOCAL L2:=
{{"Physical: ",23},
{"Emotional: ",28},
{"Intellectual: ",33}};
sub1();
TEXTOUT("Your next extreme day is on...",−5*π,1,5);
WAIT(0.5);
str1:=STRING(IP(FP(d)*100))+" / "
+STRING(FP(d*100)*100)+" / "
+STRING(IP(d));
TEXTOUT(str1,−5*π,.6,5);
FOR m FROM 1 TO 3 DO
str1:=L2(m,1)+
STRING(ROUND(100*SIN(2*π*t/L2(m,2)),0));
TEXTOUT(str1,−5*π,.6-.2*m,5);
END;
WAIT(0);
STARTVIEW(−1);
END;

// screen subroutine
sub1()
BEGIN
RECT(); 
LOCAL t;
HAngle:=0;
FOR t FROM −6*π TO 6*π STEP 12*π/720 DO
PIXON(t,SIN(2*π*t/23),#008000h);
PIXON(t,SIN(2*π*t/28),#FF0000h);
PIXON(t,SIN(2*π*t/33),#0000FFh);
END;
END;

When run, it shows this splash screen:

[Image: Shore1.png]

The code seems to indicate that Eddie intended this screen to also say "Find your fate", but the position specified for that text is off the screen... a minor cosmetic bug. Eddie, where did you intend those three lines of text to appear?

The program then uses an input form to get the user's birthdate, with proper prompts:

[Image: Shore2.png]

It then outputs the next Extrema Date in elegant fashion:

[Image: Shore3.png]

Congrats to Eddie!

Good catch. I had the "Find Your Fate." on the input screen, and I forgot to change the help text when I changed the input from YYYY.DDMM to entering the year, day, and month separately.

The contest wanting elegance inspired me to do the splash screen and the more user friendly input/output.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HHC 2018 Programming Contests - Joe Horn - 09-13-2018, 02:17 PM
RE: HHC 2018 Programming Contests - pier4r - 09-13-2018, 06:29 PM
RE: HHC 2018 Programming Contests - Zaphod - 09-13-2018, 10:10 PM
RE: HHC 2018 Programming Contests - Gene - 09-13-2018, 10:56 PM
RE: HHC 2018 Programming Contests - Gene - 09-14-2018, 12:06 AM
RE: HHC 2018 Programming Contests - Jlouis - 09-19-2018, 07:00 PM
RE: HHC 2018 Programming Contests - sasa - 09-19-2018, 11:17 AM
RE: HHC 2018 Programming Contests - pier4r - 09-29-2018, 07:41 PM
RE: HHC 2018 Programming Contests - 3298 - 09-30-2018, 05:32 PM
RE: HHC 2018 Programming Contests - 3298 - 09-30-2018, 08:47 PM
RE: HHC 2018 Programming Contests - Gene - 09-29-2018, 07:22 PM
RE: HHC 2018 Programming Contests - Gene - 10-01-2018, 02:55 AM
RE: HHC 2018 Programming Contests - sasa - 10-01-2018, 05:31 AM
RE: HHC 2018 Programming Contests - sasa - 10-01-2018, 09:54 AM
RE: HHC 2018 Programming Contests - 3298 - 10-01-2018, 06:37 AM
RE: HHC 2018 Programming Contests - Werner - 10-01-2018, 01:42 PM
RE: HHC 2018 Programming Contests - Werner - 10-02-2018, 06:10 AM
RE: HHC 2018 Programming Contests - Namir - 10-04-2018, 06:09 PM
RE: HHC 2018 Programming Contests - Werner - 10-03-2018, 02:03 PM
RE: HHC 2018 Programming Contests - Werner - 10-04-2018, 05:55 AM
RE: HHC 2018 Programming Contests - 3298 - 10-04-2018, 02:48 PM
RE: HHC 2018 Programming Contests - 3298 - 10-05-2018, 08:26 PM
RE: HHC 2018 Programming Contests - 3298 - 10-06-2018, 12:07 PM
RE: HHC 2018 Programming Contests - Eddie W. Shore - 10-06-2018 03:15 PM
RE: HHC 2018 Programming Contests - 3298 - 10-06-2018, 04:21 PM



User(s) browsing this thread: 2 Guest(s)