Friday the 13th Challenge, "Make 13 on the 13th" « Next Oldest | Next Newest »

 ▼ Egan Ford Unregistered Posts: 1,619 Threads: 147 Joined: May 2006 03-13-2009, 03:20 PM Using your favorite calculator find a future Friday the 13th where the sum of the digits that make up the date equals 13. E.g. if the date were MM/DD/YYYY (or DD.MM.YYYY) then M+M+D+D+Y+Y+Y+Y = 13. E.g. today is 13.03.2009, 1 + 3 + 3 + 2 + 9 <> 13. Can you find the next one after that? Hint: DD = 13 :-) ▼ Monte Dalrymple Unregistered Posts: 297 Threads: 25 Joined: Nov 2006 03-13-2009, 04:23 PM Using my trusty 41cv with time module: 5-13-2011 4-13-2012 are the next two ▼ hugh steers Unregistered Posts: 536 Threads: 56 Joined: Jul 2005 03-13-2009, 04:40 PM only 4 digit years! 07/13/10001 ;-) ▼ Egan Ford Unregistered Posts: 1,619 Threads: 147 Joined: May 2006 03-20-2009, 12:24 AM Perhaps a future challenge, "Find the next 13 Friday the 13ths with digit sums of 13 with binary years, i.e. years with only 0s and 1s." hugh steers Unregistered Posts: 536 Threads: 56 Joined: Jul 2005 03-13-2009, 04:45 PM but more seriously, does anyone have a better way to screen the digit sum. i'm doing (y + m) == 0 mod 9, as a first approx, then summing the year and month digits for 9? Gerson W. Barbosa Unregistered Posts: 2,761 Threads: 100 Joined: Jul 2005 03-14-2009, 10:38 PM A straightforward approach on the HP 50g: ```FR13: << { } RCLF -42 CF UNROT SWAP 130000 + 132009 SWAP FOR i i 1000000 / 1 12 FOR j 1 + DUP 0 TSTR 1 1 SUB "F" == IF THEN DUP 1000000 * SOD 13 == IF THEN DUP ROT + SWAP END END NEXT DROP NEXT REVLIST SWAP STOF >> SOD: << 0 SWAP 1 8 START 10 / DUP FP 10 * ROT + SWAP IP NEXT DROP >> ``` 2040 FR13 returns {5.132011 4.132012 12.132013 2.132032} Hopefully no typo (no connectivity kit installed on this computer). Regards, Gerson. ▼ Gerson W. Barbosa Unregistered Posts: 2,761 Threads: 100 Joined: Jul 2005 03-14-2009, 11:33 PM It's better to replace FOR j with START in the program above since the local variable j is never used. Alternative SOD (sum of digits) routine: ```SOD2: << DUP LN pi sqrt * SWAP 10 MOD + IP >> ``` It works for the following random examples: 7221961, 12345678, 41179453, 79, 9612 ;-) It would be great if such a formula existed... ```--------------------- ``` Just a curiosity. These are all ocurrences of those Fridays the 13th in the period from 1583 to 9999: { 1.132006 10.132006 5.132011 4.132012 12.132013 2.132032 1.132051 10.132051 5.132101 2.132122 11.132122 1.132141 10.132141 1.132204 4.13221 12.132211 11.132212 4.1323 12.132301 2.13232 6.133 3.133012 1.133032 11.13304 2.133103 11.133103 1.133122 10.133122 1.133212 11.13322 1.133302 10.133302 4.134001 12.134002 3.13402 1.13404 2.134111 11.134111 1.13413 10.13413 2.134201 11.134201 10.13422 10.1344 3.135001 1.135111 10.135111 10.138 } Edited: 15 Mar 2009, 7:14 p.m. ▼ Egan Ford Unregistered Posts: 1,619 Threads: 147 Joined: May 2006 03-20-2009, 12:33 AM Quote: It would be great if such a formula existed... http://mathworld.wolfram.com/DigitSum.html Clearly there is a pattern, but nothing to simply return a digit sum. Nigel Bamber Unregistered Posts: 47 Threads: 16 Joined: Feb 2009 03-18-2009, 01:56 PM Thanks for the interesting and enjoyable challenge Egan, which I solved by writing my first proper 'program' for 25 years on my I41cx+ ! I am not sure it was the most elegant or efficient but it worked in the end , once I had worked out the differences in the effects of a XEQ and a GOTO jump. Great fun. Nigel ▼ Egan Ford Unregistered Posts: 1,619 Threads: 147 Joined: May 2006 03-19-2009, 11:25 PM You are very welcome. Nigel Bamber Unregistered Posts: 47 Threads: 16 Joined: Feb 2009 03-18-2009, 01:57 PM Thanks for the interesting and enjoyable challenge Egan, which I solved by writing my first proper 'program' for 25 years on my I41cx+ ! I am not sure it was the most elegant or efficient but it worked in the end , once I had worked out the differences in the effects of a XEQ and a GOTO jump. Great fun. Nigel Egan Ford Unregistered Posts: 1,619 Threads: 147 Joined: May 2006 03-20-2009, 12:18 AM Quote: Using your favorite calculator find a future Friday the 13th where the sum of the digits that make up the date equals 13. E.g. if the date were MM/DD/YYYY (or DD.MM.YYYY) then M+M+D+D+Y+Y+Y+Y = 13. E.g. today is 13.03.2009, 1 + 3 + 3 + 2 + 9 <> 13. Can you find the next one after that? Thanks to all that participated and provided solutions. As Monte quickly pointed out the first two are: 5-13-2011 and 4-13-2012 I created 3 solutions for the 12C. The 12C has two date functions: DATE. Put a date in Y and a number in X and DATE will compute the future (or past) date and will also display the day-of-week, however the day-of-week is not stored, so it cannot be used in a program. Delta Days. Put two dates on the stack and DDYS will return the difference in days. My first program uses brute force to find the next and future Friday the 13ths with a digit sum of 13. To use, set the 12C in D.MY mode (cannot be programmed) and input any Friday date on the stack in D.MY format (e.g. 13.032009) and then press R/S. This program will test each Friday until another 13th is found, then a digit sum is used to check. After discovered you can press R/S again to get the next date. NOTE: The DATE function includes a built-in PSE. Yup, its slow. Time to first solution: 7 min 26 sec Code: ```01 f6 14 Rv 27 x=0 02 ENTER 15 STO 1 28 GTO 30 03 7 16 0 29 GTO 20 04 DATE 17 STO 0 30 RCL 0 05 ENTER 18 RCL 1 31 9 06 INTG 19 FRAC 32 - 07 1 20 1 33 x=0 08 3 21 0 34 GTO 37 09 - 22 x 35 RCL 1 10 x=0 23 INTG 36 GTO 02 11 GTO 14 24 STO+ 0 37 RCL 1 12 Rv 25 LSTx 13 GTO 02 26 FRAC ``` My 2nd program works like the first, but skips by month. To use, set the 12C in M.DY mode and input in any 2009 or later 13th (e.g. 3.132009) and press R/S. After discovered you can press R/S again to get the next date. Clearly skipping by month instead of week should be ~4x faster. However, this code is a bit more complicated because there is no easy way to check that each 13th of each month is on a Friday. The constant 12.282008 is a Sunday and is used to calculate day-of-week. Time to first solution: 2 min 5 sec Code: ```01 STO 1 22 - 43 x 64 0 02 f6 23 1 44 - 65 STO 0 03 1 24 EEX 45 5 66 x<>y 04 2 25 6 46 - 67 1 05 . 26 CHS 47 x=0 68 0 06 2 27 + 48 GTO 51 69 x 07 8 28 GTO 33 49 RCL 1 70 INTG 08 2 29 Rv 50 GTO 14 71 STO+ 0 09 0 30 Rv 51 RCL 1 72 LSTx 10 0 31 1 52 FRAC 73 FRAC 11 8 32 + 53 LSTx 74 x=0 12 STO 2 33 STO 1 54 INTG 75 GTO 77 13 Rv 34 RCL 2 55 EEX 76 GTO 67 14 ENTER 35 RCL 1 56 2 77 RCL 0 15 INTG 36 DELTA DAYS 57 / 78 9 16 1 37 ENTER 58 x<>y 79 - 17 1 38 ENTER 59 . 80 x=0 18 x<>y 39 7 60 1 81 GTO 84 19 x<=y 40 / 61 3 82 RCL 1 20 GTO 29 41 INTG 62 - 83 GTO 14 21 Rv 42 7 63 + 84 RCL 1 ``` My final program takes a 4 digit year as the input and returns a "magic" number that represents all the months with Friday the 13ths. Unfortunately I ran out of steps (and time) and was unable to generalize this to produce exact solutions without a bit of aid. Magic Number Table: ```Magic Number Months with Friday the 13ths ------------ ---------------------------- 1 May 2 August 2 February, August (leap year) 3 February, March, November 3 March, November (leap year) 4 June 5 September, December 6 April, July 7 January, October 7 January, April, July (leap year) ``` E.g. 2011 will return 1, so 05-13-2011 is a Friday the 13th. Do the digit sum manually. E.g. 2012 will return 6, so 04-13-2012 and 06-13-2012 are both Friday the 13ths. Again do the digit sum manually. E.g. 2020 will return 3, but 2020 is a leap year, so only 03-13-2020 and 11-13-2020 are Friday the 13ths. 4046 is the largest year supported by the 12C. Code: ```01 STO 1 17 1 33 4 49 0 02 1 18 . 34 / 50 0 03 2 19 0 35 FRAC 51 / 04 . 20 1 36 x=0 52 FRAC 05 2 21 + 37 GTO 39 53 x=0 06 8 22 DELTA DAYS 38 GTO 56 54 GTO 56 07 2 23 ENTER 39 RCL 1 55 GTO 58 08 0 24 ENTER 40 4 56 1 09 0 25 7 41 0 57 STO- 2 10 8 26 / 42 0 58 ENTER 11 STO 0 27 INTG 43 / 59 5 12 RCL 1 28 7 44 FRAC 60 RCL 2 13 1 29 x 45 x=0 61 1 14 EEX 30 - 46 GTO 58 62 - 15 6 31 STO 2 47 RCL 1 63 - 16 / 32 RCL 1 48 1 ``` Edited: 20 Mar 2009, 12:39 a.m.

 Possibly Related Threads… Thread Author Replies Views Last Post HP Prime 2013 8 13. Rev:5106 bluesun08 2 1,338 09-28-2013, 11:05 AM Last Post: debrouxl Fibonacci Friday Dave Shaffer (Arizona) 2 1,186 06-10-2013, 03:19 AM Last Post: Paul Dale happy fibonacci day 5/8/13 Allen 8 2,817 05-09-2013, 01:48 AM Last Post: Gerson W. Barbosa [43S]Top row poll (until Monday, 4.2.13, 13:13 UTC) Walter B 175 38,193 02-04-2013, 09:38 AM Last Post: Andrés C. Rodríguez (Argentina) Still a new colour calc ! When you'll make it HP ? Mic 10 2,944 01-13-2013, 09:17 AM Last Post: Marcus von Cube, Germany OT: Apollo 13 checklist/artifacts law Ethan Conner 0 789 09-27-2012, 04:35 PM Last Post: Ethan Conner Make PIL-Box ILPer program run on OS X Juergen Keller 6 2,165 09-07-2012, 04:38 PM Last Post: Hans Holzach Friday Potluck (orbits, back to school, baseball) (OT) Eddie W. Shore 0 882 07-06-2012, 01:18 PM Last Post: Eddie W. Shore Never make a dime of profit... Kees Bouw 19 4,700 01-04-2012, 05:29 PM Last Post: bill platt OT: The Math That Saved Apollo 13 Just Sold for \$388,375 Egan Ford 4 1,584 12-01-2011, 08:02 PM Last Post: Egan Ford

Forum Jump: