▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
OK, this isn't really a calculator challenge, it's just a mental challenge, and admittedly it isn't much of a challenge. The forum has been dull lately.
Assume you have a digital clock that shows time as HH:MM:SS. It is a 24hour clock, so HH goes from 00 to 23.
How many seconds each day is the clock showing only "binary" time, that is, only ones and zeroes?
The first poster with the correct answer has the satisfaction of being first!
▼
Posts: 34
Threads: 0
Joined: Jul 2008
64 seconds.
The reasoning goes like this: "binary" values for any 2digit group (hour, minute, second) would be 00, 01, 10, 11, and they are all valid values for hours (0023), minutes (0059), and seconds (0059). Therefore, each of these digit groups can have 4 different "binary" values, so we have 4 ENTER^ 3 Y^X possible values, each lasting one second.
Edited: 11 Dec 2008, 3:43 p.m.
▼
Posts: 260
Threads: 21
Joined: Nov 2006
Nice, it only took you 111 minutes.
Posts: 1
Threads: 0
Joined: Jan 1970
6 positions each with a possible value of 0 or 1... = 2^6 = 64.
'Would have answered sooner, but I had to create an account.
▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
OK all, very good. Now, for something a little harder.
Same 24 hour clock. Of the 86,400 6digit times displayed in a day (from 000000 to 235959), how many are prime numbers?
Excel VBA took around 10 minutes to determine it.
▼
Posts: 3,229
Threads: 42
Joined: Jul 2006
Might the answer happen to be (in base 3 to confuse matters):
1001200012
Way less than ten minutes too :)
 Pauli
▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
Hmmm, that's not what I got (after converting your base 3 number to base 10). I could be wrong, of course. You did not include impossible time numbers like 220673 did you?
▼
Posts: 3,229
Threads: 42
Joined: Jul 2006
Oops, must learn to engage brain before responding....
:(
 Pauli
Posts: 1,619
Threads: 147
Joined: May 2006
I get 7669 in 74 seconds with HPGCC2 on my 50g:
#include <hpgcc49.h>
#include <tommath.h>
int main()
{
mp_int a;
mp_err ret;
int c = 1, i, j, k;
sys_slowOff();
mp_init(&a);
for (i = 0; i < 24; i++)
for (j = 0; j < 60; j++)
for (k = 0; k < 60; k++) {
if (k % 2 == 0  k % 5 == 0)
continue;
mp_set_int(&a, i * 10000 + j * 100 + k);
mp_prime_is_prime(&a, 1, &ret);
if (ret)
c++;
}
sat_push_zint_llong(c);
return (0);
}
I get the same with Sage on my notebook in about 1 second:
c=0
for i in range(24):
for j in range(60):
for k in range(60):
if is_prime(i*10000 + j*100 + k):
c=c+1
print c
FYI, if you want a Mathematicalike environment for your Windows/OSX/Linux box checkout sagemath.org.
▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
Yeah, I got 7669 also, using VBA in Excel. It took about 3 minutes after I realized I didn't need to check the even seconds! That Sage code looks interesting, I'll have to check that out. Thanks, and thanks to Pauli too.
Posts: 785
Threads: 13
Joined: Jan 2005
Have you tried setting the clock to 203MHz?
▼
Posts: 1,619
Threads: 147
Joined: May 2006
No, just 75MHz.
BTW, I just ran it on an ARMbased 50g emulator in 24 seconds (i.e. not EMU48 (Saturnbased), not HPAPINE (Simulator) :). That's about 231 MHz (on a 2.4 GHz notebook).
Edited: 12 Dec 2008, 2:50 p.m.
▼
Posts: 785
Threads: 13
Joined: Jan 2005
What?
Is that really available?
HPGCC works directly on a (mini)notebook using (32bit) XP?
▼
Posts: 1,619
Threads: 147
Joined: May 2006
Sadly OS/X and Linux only. I think I can get it working with Cygwin or you can try yourself:
svn co https://x49gp.svn.sourceforge.net/svnroot/x49gp x49gp
I'll have a quick start guide checked in this weekend sometime.
Worse case use Ubuntu 32bit with VMware. I just tested it and it works just fine.
▼
Posts: 785
Threads: 13
Joined: Jan 2005
when I get my Xmas computer online,
I give it a try  although installing software may take weeks
I need 32&64:XP,Vista,Win7,Ubuntu,etc
then add to that some software...
wait 
it will take months, since I have also other things to do
Posts: 735
Threads: 34
Joined: May 2007
You can do that in pure python as well:
max = 240000
is_prime = [True for i in range(max)]
is_prime[0] = is_prime[1] = False
for p in range(2, max):
if is_prime[p]:
for i in range(p, max/p):
is_prime[i*p] = False
c = 0
for i in range(24):
for j in range(60):
for k in range(60):
if is_prime[i*10000 + j*100 + k]:
c = c + 1
print c
Posts: 320
Threads: 59
Joined: Dec 2006
0.171 seconds with Mathematica. However, this is still checking the evens, so it should be almost half that for an efficient line of code.
Count[Flatten[PrimeQ[Table[10000h+100m+s,{h,0,23},{m,0,59},{s,0,59}]]],True]
=7669
Is this cheeting?
Edited: 12 Dec 2008, 10:45 a.m. after one or more responses were posted
▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
Chuck, I pasted your code in Mathematica and it said you are missing a right bracket.
I thought about trying this problem in Mathematica, but I use it so seldom that I can never remember the syntax rules and commands. I also tried to do it on the TI NSpire (because I knew it had an IsPrime function), but that was an exercise in frustration. The program development editor on the NSpire is horrible.
▼
Posts: 320
Threads: 59
Joined: Dec 2006
Oops. you're right Don, thanks (I fixed the missing bracket.) I have several students that have purchased the NSpire, and I agree, it has to be one of the most frustrating machines ever.
▼
Posts: 1,392
Threads: 142
Joined: Jun 2007
Chuck, I just downloaded a new NSpire CAS operating system, and this version contains a program editor the fixes many of the problems inherent in the old system. Interestingly, under the I/O menu there is still only Disp (for display). Still no provision for user input.
Link to learning module for the NSpire.
Posts: 335
Threads: 12
Joined: Dec 2007
Quote:
It is a 24hour clock, so HH goes from 00 to 23.
The odd thing about it is, that the clock on my micro wave shows 24:00:00 to 23:59:59... ;) Going on with 24:00:01  there is no 00 hour.
Edited: 12 Dec 2008, 6:51 a.m.
