HP Forums
mental challenge - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: mental challenge (/thread-144559.html)

mental challenge - Don Shepherd - 12-11-2008

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 24-hour 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!

Re: mental challenge - Vladan Dugaric - 12-11-2008

64 seconds.

The reasoning goes like this: "binary" values for any 2-digit group (hour, minute, second) would be 00, 01, 10, 11, and they are all valid values for hours (00-23), minutes (00-59), and seconds (00-59). 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.

Re: mental challenge - hpmpdc - 12-11-2008

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.

Re: mental challenge - Pal G. - 12-11-2008

Nice, it only took you 111 minutes.

Re: mental challenge - Don Shepherd - 12-11-2008

OK all, very good. Now, for something a little harder.

Same 24 hour clock. Of the 86,400 6-digit times displayed in a day (from 000000 to 235959), how many are prime numbers?

Excel VBA took around 10 minutes to determine it.

Re: mental challenge - Paul Dale - 12-11-2008

Might the answer happen to be (in base 3 to confuse matters):


Way less than ten minutes too :-)

- Pauli

Re: mental challenge - Don Shepherd - 12-11-2008

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?

Re: mental challenge - Egan Ford - 12-11-2008

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;
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)
mp_set_int(&a, i * 10000 + j * 100 + k);
mp_prime_is_prime(&a, 1, &ret);
if (ret)
return (0);
I get the same with Sage on my notebook in about 1 second:
for i in range(24):
for j in range(60):
for k in range(60):
if is_prime(i*10000 + j*100 + k):
print c
FYI, if you want a Mathematica-like environment for your Windows/OSX/Linux box checkout sagemath.org.

Re: mental challenge - Don Shepherd - 12-11-2008

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.

Re: mental challenge - Chuck - 12-11-2008

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.


Is this cheeting?

Edited: 12 Dec 2008, 10:45 a.m. after one or more responses were posted

Re: mental challenge - George Bailey (Bedford Falls) - 12-12-2008

It is a 24-hour 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.

Re: mental challenge - V-PN - 12-12-2008

Have you tried setting the clock to 203MHz?

Re: mental challenge - Don Shepherd - 12-12-2008

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.

Re: mental challenge - Thomas Klemm - 12-12-2008

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

Re: mental challenge - Chuck - 12-12-2008

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.

Re: mental challenge - Egan Ford - 12-12-2008

No, just 75MHz.

BTW, I just ran it on an ARM-based 50g emulator in 24 seconds (i.e. not EMU48 (Saturn-based), not HPAPINE (Simulator) :-). That's about 231 MHz (on a 2.4 GHz notebook).

Edited: 12 Dec 2008, 2:50 p.m.

Re: mental challenge - Don Shepherd - 12-12-2008

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.

Re: mental challenge - V-PN - 12-13-2008

Is that really available?
HPGCC works directly on a (mini)notebook using (32-bit) XP?

Re: mental challenge - Egan Ford - 12-14-2008

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 32-bit with VMware. I just tested it and it works just fine.

Re: mental challenge - V-PN - 12-14-2008

when I get my Xmas computer on-line,
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

Re: mental challenge - Paul Dale - 12-14-2008

Oops, must learn to engage brain before responding....


- Pauli