J
jimgardener
what is the reason for using 31 in the calculation of hashcode for
String?can anyone give a precise answer?
thanks
jim
String?can anyone give a precise answer?
thanks
jim
what is the reason for using 31 in the calculation of hashcode for
String?can anyone give a precise answer?
The prime hint makes it trivial.
Well, I can easily and compactly tell you all the 2 digit ones:Kenneth said:Try this one..
Write a program to find all the numbers where their value is equal to the
sum of the digits each raised to the power of the number of significant
digits.
Examples:
1, 2, 3, .... 153, 370, 371,
I've always heard this called the Armstrong set, but apparently there are
different definitions for this set in common use.
It has a finite number of members. I wrote a program a few years ago to
enumerate them all in common lisp. Brute force won't do it.
Good luck.
How would you go about writing a computer program to solves such
problems? People have no problem seeing new patterns.
In general, the same way Victorians evaluated polynomials with their
steam computers - the method of successive differences.
Calculate the differences between successive terms of a series, then the
differences between successive differences, and pretty soon a "subtle"
pattern will throw up an "obvious" pattern in its diffs.
Of course this fails dismally for primes! In that case, you'd compare
the differences to a set of "well known sequences", primes being an
obvious candidate, along with the birthdates of US Presidents, run
lengths of Startrek movies, etc. according to the relevant fandom of the
cryptographer setting the puzzle.
Several! Not usually English or American though, so they tended to fall
out of the histories.
If you visit the Science Museum, they have a working reconstruction of a
Babbage Difference Engine. In the case opposite, is a period difference
engine, almost a contemporary and a working machine that was used in its
day. Of course its maker (a Swede, AFAIR) just made a difference engine
and got on with it, he didn't spend most of his time trying to either
re-design and improve it, or else dreaming of an Analytical Engine
instead.
Oh, and the harmonic analyser, too, which is very clever.
The sphere and disk machine?
I spent a whole day in there recently, the first time I'd ever been to
the Science Museum and not had a deadline or timescale to keep up with.
I only left when I ran out of camera batteries. The wikipedia writing
backlog (including the sphere and disk) is slowly getting worked
through...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.