HHC 2018 Programming Contests
10-05-2018, 02:25 PM
Post: #73
 David Hayden Senior Member Posts: 460 Joined: Dec 2013
RE: HHC 2018 Programming Contests
After the conference and before checking the forum, I worked on an RPL solution using the MOD tricks that others have also found. Recognizing that the maximum days of the E cycle (days 7 and 14) are the same as a 14 days cycle with maximum on day 7 and using the ICHINREM command on the 50g, I found that the extreme days occur on:
[ 91 371 ] MOD 462
[ 190 305 454 569 ] MOD 759
[ 63 259 ] MOD 322

My contribution to the thread is in how, given a number that's less than the modulus, I find the first value in the array after the number. For example, given 100, I want to find 371 in the first list, or 190 in the second, or 259 in the third. You can almost find the next value in the array with:
Code:
@ Level 2 is array @ Level 1 is search number « \-> X   « 1 DO GETI UNTIL X > END     @ level 1 now points one past the value you want. Level 2 is the array     1 - GET   » »

There are two problems with this code. First, if you find the last value then GETI will go back to 1, so the final "1 - GET" won't work. I solve this by adding an extra dummy number at the end of the list.

Second, what if the value you're looking for is larger than the largest value? For example, with [ 91 371 ] MOD 462, what if you're looking for 400? In that case, you need to find the value that's 91 MOD 462 in the next cycle (553).

So the trick is to feed this code with an array that contains (1) the first number in the next cycle, and (2) an extra dummy entry at the end:
For modulus 462, search [ 91 371 553 0]
For modulus 759, search [ 190 305 454 569 949 0]
For modulus 322, search [ 63 259 385 0]

My code (again, not my conference entry, but developed before looking at the forum) runs in about .87 seconds on a 50g, including pretty tagging of the results. I can probably shorten that using some of the list processing techniques that others have used. I'll post the full code when I'm done.

Dave
 « Next Oldest | Next Newest »

 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 - Valentin Albillo - 09-13-2018, 10:05 PM RE: HHC 2018 Programming Contests - Zaphod - 09-13-2018, 10:10 PM RE: HHC 2018 Programming Contests - Joe Horn - 09-14-2018, 04:42 AM RE: HHC 2018 Programming Contests - Valentin Albillo - 09-14-2018, 10:28 PM RE: HHC 2018 Programming Contests - toml_12953 - 09-19-2018, 09:57 AM RE: HHC 2018 Programming Contests - Gene - 09-13-2018, 10:56 PM RE: HHC 2018 Programming Contests - rprosperi - 09-13-2018, 11:34 PM RE: HHC 2018 Programming Contests - Gene - 09-14-2018, 12:06 AM RE: HHC 2018 Programming Contests - cyrille de brébisson - 09-14-2018, 05:28 AM RE: HHC 2018 Programming Contests - Joe Horn - 09-14-2018, 06:18 PM RE: HHC 2018 Programming Contests - RMollov - 09-19-2018, 09:42 AM RE: HHC 2018 Programming Contests - Jlouis - 09-19-2018, 07:00 PM RE: HHC 2018 Programming Contests - Thomas Klemm - 09-19-2018, 10:25 AM RE: HHC 2018 Programming Contests - sasa - 09-19-2018, 11:17 AM RE: HHC 2018 Programming Contests - Joe Horn - 09-19-2018, 12:12 PM RE: HHC 2018 Programming Contests - Eddie W. Shore - 09-19-2018, 12:15 PM RE: HHC 2018 Programming Contests - Eddie W. Shore - 09-21-2018, 12:25 PM RE: HHC 2018 Programming Contests - rprosperi - 09-21-2018, 12:53 PM RE: HHC 2018 Programming Contests - Joe Horn - 09-22-2018, 06:59 PM RE: HHC 2018 Programming Contests - Joe Horn - 09-29-2018, 07:03 PM RE: HHC 2018 Programming Contests - pier4r - 09-29-2018, 07:41 PM RE: HHC 2018 Programming Contests - Csaba Tizedes - 09-30-2018, 11:38 AM RE: HHC 2018 Programming Contests - 3298 - 09-30-2018, 05:32 PM RE: HHC 2018 Programming Contests - Csaba Tizedes - 09-30-2018, 07:16 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 09-30-2018, 08:32 PM RE: HHC 2018 Programming Contests - 3298 - 09-30-2018, 08:47 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 09-30-2018, 09:40 PM RE: HHC 2018 Programming Contests - Didier Lachieze - 09-30-2018, 09:54 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 09-30-2018, 10:22 PM RE: HHC 2018 Programming Contests - Gene - 09-29-2018, 07:22 PM RE: HHC 2018 Programming Contests - Joe Horn - 09-30-2018, 04:42 AM RE: HHC 2018 Programming Contests - grsbanks - 09-30-2018, 04:58 AM RE: HHC 2018 Programming Contests - Didier Lachieze - 09-30-2018, 08:49 PM RE: HHC 2018 Programming Contests - Joe Horn - 09-30-2018, 11:24 PM RE: HHC 2018 Programming Contests - Gene - 10-01-2018, 02:55 AM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-01-2018, 05:15 AM RE: HHC 2018 Programming Contests - sasa - 10-01-2018, 05:31 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-01-2018, 06:09 AM RE: HHC 2018 Programming Contests - sasa - 10-01-2018, 09:54 AM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-01-2018, 04:57 AM RE: HHC 2018 Programming Contests - Didier Lachieze - 10-01-2018, 04:59 AM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-01-2018, 06:21 AM RE: HHC 2018 Programming Contests - 3298 - 10-01-2018, 06:37 AM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-03-2018, 04:20 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-01-2018, 06:38 AM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-01-2018, 06:40 AM RE: HHC 2018 Programming Contests - Werner - 10-01-2018, 01:42 PM RE: HHC 2018 Programming Contests - jjohnson873 - 10-01-2018, 08:38 PM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-01-2018, 09:47 PM RE: HHC 2018 Programming Contests - Didier Lachieze - 10-01-2018, 10:46 AM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-01-2018, 09:33 PM RE: HHC 2018 Programming Contests - Werner - 10-02-2018, 06:10 AM RE: HHC 2018 Programming Contests - Fred Lusk - 10-02-2018, 04:15 AM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-02-2018, 08:11 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-02-2018, 04:33 PM RE: HHC 2018 Programming Contests - Eddie W. Shore - 10-03-2018, 12:39 PM RE: HHC 2018 Programming Contests - Namir - 10-04-2018, 06:09 PM RE: HHC 2018 Programming Contests - Joe Horn - 10-02-2018, 08:47 PM RE: HHC 2018 Programming Contests - Werner - 10-03-2018, 02:03 PM RE: HHC 2018 Programming Contests - Didier Lachieze - 10-03-2018, 03:46 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 - Gerson W. Barbosa - 10-04-2018, 03:47 PM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 12:00 AM RE: HHC 2018 Programming Contests - Didier Lachieze - 10-05-2018, 05:07 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 06:22 AM RE: HHC 2018 Programming Contests - Craig Bladow - 06-25-2019, 01:27 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 12:11 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 12:36 AM RE: HHC 2018 Programming Contests - Didier Lachieze - 10-05-2018, 07:45 AM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 12:26 PM RE: HHC 2018 Programming Contests - David Hayden - 10-05-2018 02:25 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-05-2018, 07:23 PM RE: HHC 2018 Programming Contests - 3298 - 10-05-2018, 08:26 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-05-2018, 09:51 PM RE: HHC 2018 Programming Contests - 3298 - 10-06-2018, 12:07 PM RE: HHC 2018 Programming Contests - Joe Horn - 10-05-2018, 09:32 PM RE: HHC 2018 Programming Contests - Eddie W. Shore - 10-06-2018, 03:15 PM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-06-2018, 10:14 AM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-06-2018, 11:42 AM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-06-2018, 12:48 PM RE: HHC 2018 Programming Contests - Gerson W. Barbosa - 10-06-2018, 03:57 PM RE: HHC 2018 Programming Contests - 3298 - 10-06-2018, 04:21 PM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-06-2018, 06:38 PM RE: HHC 2018 Programming Contests - David Hayden - 10-07-2018, 01:46 PM RE: HHC 2018 Programming Contests - Thomas Klemm - 10-09-2018, 04:48 AM

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