I didn't know the correct age for WHO, but it gave unreasonable
result for a trivial case.
2014 9 22 age&todayno 2002 2 2
12 7 18
2002 2 3 age&todayno 2002 2 2
0 0 18
the day seemed always 18.
Пн, 22 сен 2014, Linda Alvord написал(а):
> I just finished a version and hope you won't find problems....but I'm not
> all that confident.
>
> TD=:todayno 2014 9 22
> BD=:todayno WHO=:2002 2 2
>
> yr=: 13 :'<.365.25 %~ x-y'
> TD yr BD
> tds=: 13 :'(x-y)-365.25*x yr y'
> TD tds BD
> M=:31 28.25 31 30 31 30 31 31 30 31 30 31
> +/(TD tds BD) >+/\(1{WHO)|.M
> ms=: 13 :'+/(x tds y)>+/\(1{WHO)|.M'
> TD ms BD
> ds=: 13 :'(TD tds BD)-+/(i.TD ms BD){(1{WHO)|.M'
> age=: 13 :'(x yr y),(x ms y), <.x ds y'
> TD age BD
>
> These are the results. Once it works, it can probably simplified a lot.
>
> TD=:todayno 2014 9 22
> BD=:todayno WHO=:2002 2 2
>
> yr=: 13 :'<.365.25 %~ x-y'
> TD yr BD
> 12
> tds=: 13 :'(x-y)-365.25*x yr y'
> TD tds BD
> 232
> M=:31 28.25 31 30 31 30 31 31 30 31 30 31
> ms=: 13 :'+/(x tds y)>+/\(1{WHO)|.M'
> TD ms BD
> 7
> ds=: 13 :'(TD tds BD)-+/(i.TD ms BD){(1{WHO)|.M'
> age=: 13 :'(x yr y),(x ms y), <.x ds y'
> TD age BD
> 12 7 18
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of robert
> therriault
> Sent: Monday, September 22, 2014 11:35 PM
> To: [email protected]
> Subject: Re: [Jprogramming] Weekend Puzzle - Age of Groundhog born 2002 2 2
>
> Actually Don the most recent version that uses the difference in todayno
> between Feb 29 and March 1 takes this into account. In 1900 and 2100 it
> returns the same number for both dates. On leap years it returns a one day
> difference.
>
> Looks like we should be good for a few thousand years before we run into the
> next level of year duration adjustments required by our choice of calendars.
>
> Cheers, bob
>
> On Sep 22, 2014, at 7:13 PM, Don Kelly <[email protected]> wrote:
>
> > Fortunately, the use of "leap" is valid as long as one doesn't go back
> past 1901 or ahead past 2099.
> >
> > 1900 and 2100 aren't leap years (Fine tuning of the leap year calculation
> ).
> >
> > Don Kelly
> >
> >
> >
> > On 20/09/2014 10:53 PM, robert therriault wrote:
> >> 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
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm