That's interesting. I started chipping away at it by finding the years first. From 1800 1 1 a four year block would have 1+4*365 days or an average of 365.25 per year. So That extra wouldn't happen until 4 years had passed. See if you would like it better if you remove the years first. I'll see what I get if I work in your direction.
Linda -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of robert therriault Sent: Sunday, September 21, 2014 1:54 AM To: [email protected] Subject: Re: [Jprogramming] Weekend Puzzle - Age of Groundhog born 2002 2 2 Hi Linda, I share your dream and sometimes the statement 'I have a dream' can change the world. :-) On to the weekend puzzle... The first thing I need to figure out is whether the birthday has happened this year or not. If it has then I can pretty easily get the number of days since the birthday using todayno, but if it hasn't then I need to find the number of days since the previous year's birthday. 'yg mg dg' =: gbday =: 2002 2 2 NB. Groundhog's birthday 'ya ma da'=:afterbday =: 2014 9 20 NB. An example of date after the birthday 'yb mb db'=:beforebday =: 2014 1 31 NB. An example of a date before the birthday bdYet=:(0>-/) &: todayno NB. returns 1 if the current date is in the same calendar year before the birthday ya 2014 ya=. ya- afterbday bdYet ({. afterbday),}.gbday NB.use the current year from example and the birthday ya 2014 yb 2014 yb=. yb- beforebday bdYet ({. beforebday),}.gbday yb 2013 Next thing would be to define a vector that gives the accumulated days in the year if the year were to start on February 1st. The leap year issue means that the first item in the list will be 29 if it is a leap year. since I have already figured out whether I am counting from the previous year, I will use the adjusted year to decide if the year that I am counting from was a leap year. I will just use a simple (and incorrect) version of leap year. leap=: 0= 4&| feb=: 28 + leap ya feb 28 [daysFebFirst=: +/\ (feb), 31 30 31 30 31 31 30 31 30 31 31 28 59 89 120 150 181 212 242 273 303 334 365 Finally, I create the results. [yr=:ya-yg NB. number of years 12 [elapsed=: -/ todayno"_1 afterbday,: ya,}.gbday NB. days since the birthday 230 [mr=: +/ elapsed > daysFebFirst NB. number of months 7 [dr=: (<:mr){ elapsed - daysFebFirst 18 yr,mr,dr 12 7 18 And for the case of a date before the birthday Jan 31st 2014 we get [feb=: 28 + leap yb NB. No change since 2013 is not a leap year 28 [yr=:yb-yg NB. number of years 11 [elapsed=: -/ todayno"_1 beforebday ,: yb ,}.gbday NB. days since the previous birthday 363 [mr=: +/ elapsed > daysFebFirst NB. number of months 11 [dr=: (<:mr){ elapsed - daysFebFirst 29 yr,mr,dr 11 11 29 Cheers, bob On Sep 20, 2014, at 10:58 AM, Linda Alvord <[email protected]> wrote: > The J forum is my elementary school set of sub imjects. What you suggest is > exactly what I would hope would happen in a J classroom. All would have J. > All could experiment and exchange ideas. Hopefully they would have solutions > they believe were correct. Then they could explain their thinking to the > entire class and the teacher. At this point in the process, the teacher > would not be a leader but a follower. > > Possibly I am dreaming.... > > Linda > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of robert > therriault > Sent: Saturday, September 20, 2014 1:20 PM > To: [email protected] > Subject: Re: [Jprogramming] Weekend Puzzle - Age of Groundhog born 2002 2 2 > > Hi Linda, > > If you are looking for a way to get learners to be interested in the > problem, why not use the very model of learning that we are using here? > > You put a problem out to your class (forum) and see how the responses go. > You as the teacher (moderator) are free to choose the rules, knowing that > the students (participants) are able to put their attention elsewhere if > things are not kept interesting. It is a style of learning that we use on > these forums everyday and it seems to work for us. > > What might not work as well is going into the class and showing them how to > solve the problem, as this takes away so much from the experience that we > enjoy when we are learning. The challenge for the teacher is not so much > coming up with a solution, as it is to make sure that they are engaging as > many students as possible. This is especially true at the extremes of the > class' abilities - both the really adept and those that are struggling with > the concepts are where teachers are most valuable. > > Just my two bits, but I would probably just start with the question of 'how > would you measure time in metric?' and use that as a way to explore all the > ways that you would count and group the types of time and how they way we > measure time can be pretty crazy and why it might be good if we could get > computers to do the work of taking care of the crazy systems that we have > set up. Where the class would take this in terms of topic is wide open, as a > teacher you just make sure that as the core concepts arise they are covered > accurately. > > Cheers, bob > > ps. The quickest way to get me to care about the age of your groundhog is to > have one of my classmates start trying to figure it out, but my learning is > usually socially motivated. :-) > > On Sep 20, 2014, at 9:35 AM, Joe Bogner <[email protected]> wrote: > >> Hi Linda >> >> The solution is quite simple and uses one built verb from an addon. I >> posted it with the solution masked so others can try it on their own >> without accidentally seeing mine >> >> The actual solution is the result of this: >> >> |. solution2 >> On Sep 20, 2014 11:54 AM, "Linda Alvord" <[email protected]> wrote: >> >>> We are talking children here. >>> >>> Onyadot. emiTetaDot, ffiDst, onyadot, emiTetaDot, emitetad, sepyt and >>> eriuqer are all denied! >>> >>> How about using +, -, *, ?, %: and that sort of thing. >>> >>> I must admit you did get the right answer! >>> >>> You can also get a second chance. >>> >>> Cheers, Linda >>> >>> >>> >>> -----Original Message----- >>> From: [email protected] >>> [mailto:[email protected]] On Behalf Of Joe > Bogner >>> Sent: Saturday, September 20, 2014 9:10 AM >>> To: [email protected] >>> Subject: Re: [Jprogramming] Weekend Puzzle - Age of Groundhog born 2002 2 > 2 >>> >>> solution... >>> >>> >>> >>> >>> >>> >>> 1 >>> 2 >>> 3 >>> 4 >>> 5 >>> >>> >>> lightly obfuscated for someone who doesn't want the solution >>> >>> >>> solution1=: 0 : 0 >>> >>> )2 2 2002 onyadot emiTetaDot( ffiDst )02 9 4102 onyadot emiTetaDot( >>> >>> 'emitetad/sepyt' eriuqer >>> >>> ) >>> >>> >>> >>> to run: >>> >>> >>> 0!:1 |. solution1 >>> >>> >>> >>> solution2 =: 0 : 0 >>> >>> )2 2 2002( ffiDst )02 9 4102( >>> >>> 'emitetad/sepyt' eriuqer >>> >>> ) >>> >>> >>> 0!:1 |. solution2 >>> >>> >>> >>> note: both take advantage of a addon. solution1 uses todayno just because >>> it was stated in the problem but solution2 is what I'd really use >>> >>> >>> >>> On Sat, Sep 20, 2014 at 4:54 AM, Linda Alvord <[email protected]> >>> wrote: >>> >>>> Using the verb todayno which provides the number of days since the >>>> beginning of 1800, write what you need to find the age today of a >>>> groundhog >>>> born on 2002 2 2. >>>> >>>> >>>> >>>> todayno 2014 9 2014 >>>> >>>> 80418 >>>> >>>> >>>> >>>> 2014 9 20 age 2002 2 2 >>>> >>>> 12 7 18 >>>> >>>> >>>> >>>> His age is 12 years, 7 months and 18 days. Use simple J. Check that >>> your >>>> solution provides a correct answer for you birthday. >>>> >>>> >>>> >>>> Have a pleasant weekend. >>>> >>>> >>>> >>>> Linda >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
