HP Forums

Full Version: HHC 2018 Programming Contests
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
SNEAK PREVIEW...

HHC 2018 attendees: If you think that you might enter the Programming Contest (it will NOT be difficult, so please do toy with the idea), you'll be wise to bring along a pad of paper and some writing implements. Reason: Every contestant will be required to submit a program listing (either hand written or printed), as well as comments (either in the listing or attached to the listing) that explain how the program works, highlighting any features that the contestant deems worthy of note. In other words, you have a real chance to convince me that your program is "elegant". The MOST elegant program wins (in each of the three categories: 41CX RPN, RPL, and PPL).
Rats... things were so hectic here this morning at HHC 2918 that I forgot about posting the contest here! SORRY!

It's in PDF form here: http://hhuc.us/2018/HHC-2018-Programming-Contest.pdf

PLEASE do not post programs here until the contest has been judged at the conference, so that the attendees here are not tempted to submit ideas other than their own. Wink Thanks!
Wow, a post from the future too! :-)
(09-29-2018 07:03 PM)Joe Horn Wrote: [ -> ]Rats... things were so hectic here this morning at HHC 2918 that I forgot about posting the contest here! SORRY!

Can you spoiler a bit? Which calculators did the world produce? I am fine if you can cover the years 2018-2030, although I am not sure that the data survived until 900 years ago (because digital data).
Oops... I forgot to specify that I was referring to HHC 2918 B.C. Big Grin
(09-30-2018 04:42 AM)Joe Horn Wrote: [ -> ]Oops... I forgot to specify that I was referring to HHC 2918 B.C. Big Grin

Ah yes, battery life was incredible on those portable stone slabs back in the day. Modern technology is a real step backwards in that respect Smile
(09-29-2018 07:03 PM)Joe Horn Wrote: [ -> ]Rats... things were so hectic here this morning at HHC 2918 that I forgot about posting the contest here! SORRY!

It's in PDF form here: http://hhuc.us/2018/HHC-2018-Programming-Contest.pdf

PLEASE do not post programs here until the contest has been judged at the conference, so that the attendees here are not tempted to submit ideas other than their own. Wink Thanks!

Is 12C playing?
I have one (not so optimised and not tested) version:

47 steps with closing R/S,
used vars R0, R1, R2, R3.

To run needs

f CLEAR PRGM
input date of today ENTER
birthday R/S
display shows next critical Physical day R/S
shows next critical Emotional day R/S
shows next critical Intellectual day

Csaba
(09-30-2018 11:38 AM)Csaba Tizedes Wrote: [ -> ]display shows next critical Physical day R/S
shows next critical Emotional day R/S
shows next critical Intellectual day
That doesn't sound right ... as far as I understood the challenge, the program shall output a single date on which (at least) two functions are extreme. (If I did my calculations right, there should be a few dates with all three functions at extreme values, but just 8 of these days per 58 or so years. I did not bother calculating the necessary ages for them.) This date shall be accompanied by the values of all three functions on that date.

-----

I have a program for the 50G (should work on most RPL models though) which does what I described above. The presentation post is almost written up. 485 bytes, checksum #7601h. Will post when the judge announces "lunch break is over". Wink
(09-30-2018 05:32 PM)3298 Wrote: [ -> ]That doesn't sound right ... as far as I understood the challenge, the program shall output a single date on which (at least) two functions are extreme.

"Life is too short to read the manual" - Smile
(09-30-2018 05:32 PM)3298 Wrote: [ -> ]I have a program for the 50G (should work on most RPL models though) which does what I described above. The presentation post is almost written up. 485 bytes, checksum #7601h. Will post when the judge announces "lunch break is over". Wink

Mine is 356.5 bytes long, CK = #7210h, but it shows only the date.

1.011905 -> 10.102018

9.282018 -> 11.302018

First and probably the only version (started to look at it only this afternoon). Not fully tested yet.

P.S.: Quoting from the rules:

Quote:YOUR CHALLENGE: Write a program (in HP-41 RPN, and/or RPL, and/or PPL) which inputs the user’s birthdate, then outputs the next Extrema Date (not including today) with all three biorhythm values for that date.

I’ve overlooked the last line. Will take care of it soon.
Your first example yields the same result on my program. P: -100, E: 62, I: 100.
The second one yields "Invalid Date". Kind of understandable 'cause I've yet to see a calendar with 28 or more months in a year. Tongue
Adjusted for my value of system flag 42, the program works and outputs a date that matches after being similarly adjusted. P: -100, E: 100, I: -54.
Actually, that exact date was my first test case too. High-Five!
My PPL version calculates the next Extrema Date in 11 lines (out of EXPORT and BEGIN) and displays the results with another 7 lines before RETURN and the final END;
It returns the same results as Gerson 's program, but the date format is YYYY.MMDD

EXTREMA(1963.0227) returns :

Birthday : 1963.0227
Next Extrema Date: 2018.1114
Physical: −100
Emotional: −100
Intellectual: −75

And for the dates tested by Gerson :

Birthday : 1905.0101
Next Extrema Date: 2018.1010
Physical: −100
Emotional: 62
Intellectual: 100

Birthday : 2018.0928
Next Extrema Date: 2018.1130
Physical: −100
Emotional: 100
Intellectual: −54
(09-30-2018 08:47 PM)3298 Wrote: [ -> ]Your first example yields the same result on my program. P: -100, E: 62, I: 100.
The second one yields "Invalid Date". Kind of understandable 'cause I've yet to see a calendar with 28 or more months in a year. Tongue
Adjusted for my value of system flag 42, the program works and outputs a date that matches after being similarly adjusted. P: -100, E: 100, I: -54.
Actually, that exact date was my first test case too. High-Five!

I’m using mm/dd/yyyy format (but my program doesn’t depend on the date format, only dates should be entered accordingly).

Now 419 bytes, #EF6Eh.

1.011905 -> 10.102018
{-.99766872413 .623489809462 .998867339316 }

9.282018 -> 11.302018
{-.997668769192 1. -.54064081743}

2.271963 -> 9.292018
{-.99768769852 .623489808919 .99886733949}

No awe from the judge though, I fear :-)

Also, my last example doesn’t agree with Didier’s because I may have misinterpreted the concept of “Extrema date”. I have considered only (-1, 1) or (1, -1), but not (1, 1) and (-1, -1) pairs. I am probably wrong.

P.S.: Quoting again from the rules;

Quote:Once in a while, two cycles hit 100 and/or -100 simultaneously, as you can see on Day 63 above. Let’s call this an “Extrema Date”.

It’s clear from above that the pairs (1, 1) abd (-1, -1) should also be considered. My failure for not thoroughly reading the instructions. By fixing that the program should certainly grow larger than 485 bytes. There’s only one hour left, so I’ll let it as is. Anyway, it was fun to try.
(09-30-2018 09:40 PM)Gerson W. Barbosa Wrote: [ -> ]2.271963 -> 9.292018
{-.99768769852 .623489808919 .99886733949}

9.292018 is in the past, it doesn't qualify for the next Extrema considering today is September 30th... at least this is my understanding of "next". Also I understand "Once in a while, two cycles hit 100 and/or -100 simultaneously" as allowing any of the (-100, 100), (100, -100), (100, 100) and (-100, -100) pairs.
(09-30-2018 09:54 PM)Didier Lachieze Wrote: [ -> ]
(09-30-2018 09:40 PM)Gerson W. Barbosa Wrote: [ -> ]2.271963 -> 9.292018
{-.99768769852 .623489808919 .99886733949}

9.292018 is in the past, it doesn't qualify for the next Extrema considering today is September 30th... at least this is my understanding of "next". Also I understand "Once in a while, two cycles hit 100 and/or -100 simultaneously" as allowing any of the (-100, 100), (100, -100), (100, 100) and (-100, -100) pairs.

For some reason my 50g was one day and 7 minutes in the past. Upon setting the date to Sep/30/2018, the new result is

1.232019
{-.979084090955 1. -.998867339471 }

The order is { Ph Em In }

Still wrong per the instructions, but now at least in the future, comme il faut Smile
The winners were just announced:

Best RPN Programmer: Kerry Veenstra
Best RPL Programmer: Bill Butler
Best PPL Programmer: Eddie Shore

All entries (complete listings and comments) will be posted here as soon as I have time to do so. We're currently having the drawing for the Door Prizes...
I did not program this, but my thinking went this way... feel free to tell me where I went wrong. :-)

Approach 1:

I treated a triple positive or triple negative as a LCM problem. The 23 day cycle has a +100 or -100 on days 5.75 or17.25. The 28 day cycle on days 7 and 21. The 33 day cycle on days 8.25 and 24.75.

Assumption: The +100 has to be an exact match. A +100 day did not count if it was a 99.8 and a 100.2 and a 100. This could be wrong, but ...

Since you can't (easily?) do a LCM on a decimal number, I found the LCM of 575, 700 and 825. This value is 531,300. Dividing by 100 again, makes a triple event every 5313 days.

So birth plus 5313 should be a triple, plus another 5313 would be a triple, etc. If not, where did I not think properly?

Alternatively...

Approach 2:

I found a website :-) that would do Maximum and minimum bio-dates. This generated a period of 17003 days between extremums. This does not match approach 1, but ... ?

Thoughts?
Now I get Didier’s example right, but the program is now 537 bytes long, CK #EF9Dh, not to mention far from elegant...

27,021963 -> 14.112018
{-,997668769554 -1 -,755749579168 }
Here is my PPL program. I considered the Extrema Date to be a day during which at least two of the biorhythms would reached +100 or -100.
So first it gets the number of days between the input birthday and today (N).
Then it calculates where we are, as of today, in each cycle (A,B,C)
Then it generates for each biorhythm the list of the next 33 minimum and maximum days. I choosed 33 as it is the maximum number of minimum/maximum occurrences between two common days as I found comparing the lists of maximum/minimums for each biorhythm: there could be 33 physical minimum/maximum between two common physical/Intellectual days.
Then it determines the first common day in two of the three lists (D) and the corresponding date (ED).
The rest of the program is then the display of the results.

Code:
EXPORT EXTREMA(BD)
BEGIN
  LOCAL a:={2*PI,360,400},c,d1,d3,ED;
  c:=a(HAngle+1);
  N:=DDAYS(BD,Date);
  A:=iquo(IP(2*(N-(23/4))),23);
  B:=iquo(IP(2*(N-(28/4))),28);
  C:=iquo(IP(2*(N-(33/4))),33);
  L1:=MAKELIST(23/2*(1/2+I),I,A+1,A+33); L4:=IP(L1);
  L2:=MAKELIST(28/2*(1/2+I),I,B+1,B+33);
  L3:=MAKELIST(33/2*(1/2+I),I,C+1,C+33); L5:=IP(L3);
  D:=MIN(head(INTERSECT(L4,L2)),head(INTERSECT(L2,L5)),head(INTERSECT(L4,L5))​);
  ED:=DATEADD(BD,D);
  PRINT("Birthday : " +BD);
  PRINT("Next Extrema Date: " +STRING(ED,2,4));
  d1:=IFTE(POS(L4,D),L1(POS(L4,D)),D);
  d3:=IFTE(POS(L5,D),L3(POS(L5,D)),D);
  PRINT("Physical: " +IP(100*SIN(c*(d1 MOD 23)/23)));
  PRINT("Emotional: " +IP(100*SIN(c*(D MOD 28)/28)));
  PRINT("Intellectual: " +IP(100*SIN(c*(d3 MOD 33)/33)));
  RETURN ED;
END;
(10-01-2018 02:55 AM)Gene Wrote: [ -> ]Assumption: The +100 has to be an exact match. A +100 day did not count if it was a 99.8 and a 100.2 and a 100. This could be wrong, but ...

“Once in a while, two cycles hit 100 and/or -100 simultaneously, as you can see on Day 63 above”

On Day 63 the results are actually

-99.7668769192 %

100. % and

-54.064081743 %

But for practical purposes the unexact ones can be rounded to -100% and -54% (FIX 0). Next time I shall read the instructions :-)
Pages: 1 2 3 4 5
Reference URL's