All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Dates data distribution (Posted on 2015-01-05) Difficulty: 3 of 5
Consider all possible dates (formatted DD/MM/YY) within a span of a century , from 01/01/01 to 31/12/00 (20th century!).
In this period there are N k dates that can be expressed by k distinct digits, e.g. N1=1 (11/11/11).

a. Derive the values of N k for all other values of k (2 to 6).
b. What is the average k for the 20st century?
c. How about the 21st century?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer-aided solution | Comment 1 of 3
DefDbl A-Z
Dim crlf$, ct(6), cw(10)

Function mform$(x, t$)
  a$ = Format$(x, t$)
  If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
  mform$ = a$
End Function

Private Sub Form_Load()
 ChDir "C:Program Files (x86)DevStudioVBprojects looble"
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 DoEvents
 
 mo = 1: da = 1: ye = 1900
 GoSub GregToJD
 j0 = jd
 mo = 12: da = 31: ye = 1999
 GoSub GregToJD
 j1 = jd
 For j = j0 To j1
   jd = j
   GoSub JDToGreg
   s$ = Right("0" + LTrim(Str(mo)), 2) + Right("0" + LTrim(Str(da)), 2) + Right(Str(ye), 2)
   diffnums = 0
   For i = 1 To Len(s$)
     If InStr(s$, Mid(s$, i, 1)) = i Then diffnums = diffnums + 1
   Next
   ct(diffnums) = ct(diffnums) + 1
 Next
 
 For i = 0 To 6
  Text1.Text = Text1.Text & i & Str(ct(i)) & crlf
 Next

 Text1.Text = Text1.Text & " done"
 
 Exit Sub
 
GregToJD:
10100 Rem :greg mo/da/ye --> jd at noon
10110 GoSub JulToJD
10120 jd = jd + 2 - Int(cw(1) / 100) + Int(cw(1) / 400)
10130 Return

JulToJD:
10150 Rem :jul mo/da/ye --> jd at noon
10160 cw(0) = mo: cw(1) = ye: If mo < 3 Then cw(0) = mo + 12: cw(1) = ye - 1
10170 jd = Int(365.25 * cw(1)) + Int(30.61 * (cw(0) + 1)) + da + 1720995!
10180 Return

JDToGreg:
10200 Rem:noon jd-->greg mo/da/ye
10210 cw(0) = Int((jd - 1867216.25) / 36524.25)
10220 cw(0) = jd + 1 + cw(0) - Int(cw(0) / 4)
10230 GoTo CommonFromJD
JTToJul:
10240 Rem : noon jd-->jul mo/da/ye
10250 cw(0) = jd
CommonFromJD:
10260 cw(0) = cw(0) + 1524
10265 cw(1) = Int((cw(0) - 122.1) / 365.25)
10270 cw(2) = Int(365.25 * cw(1))
10275 cw(3) = Int((cw(0) - cw(2)) / 30.6001)
10280 da = cw(0) - cw(2) - Int(30.61 * cw(3))
10285 ye = cw(1) - 4716
10290 mo = cw(3) - 1: If mo > 12 Then mo = mo - 12: ye = ye + 1
10295 Return
 
End Sub

finds these counts:

0 0
1 1
2 159
3 3203
4 13791
5 15470
6 3900

adding up to 36524, the number of days between Jan 1, 1900, and Dec 31, 1999 or between Jan 1, 2000, and Dec 31, 2099.

If however we wanted 2000 through 2099, we'd need to count in another Feb 29, 2000 (290200) making the 3 count equal 3204. 

Parts b and c:

Using the counts of occurrences as weights for the counts of digits, the weighted sum is 165842; then dividing by the total of 36524 of the weights, gives an average of  4.540630818092214 different digits for a date, the average k. This is for the years 1900-1999 or for 2100-2199, as 1900 and 2100 are non-leap years.

However, to be exact about it, the 21st century really is from 2001 through 2100, being forced into the precedent set by there being no year zero so the first century began with year 1. So the 21st century actually fits the previous average, while the 20th century (1901-2000) had a full complement of 25 leap years, to be described below.

The new stats:

0 0
1 1
2 159
3 3204
4 13791
5 15470
6 3900

make the average   165845/36525 ~= 4.540588637919234, for the 20th century (1901-2000), or for the popular conception of the 21st century (2000-2099).

Edited on January 5, 2015, 9:18 pm
  Posted by Charlie on 2015-01-05 15:54:59

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information