The problem is pretty easy to solve with a little software help to
generate lists of 4-digit squares that match the letter patterns. In
particular, NEUN is quite distinctive and is only matched by 5 different
squares. From there, it is pretty trivial to spot the answer (it took
me a couple of minutes with pen and paper) so much so that the effort of
developing a script to solve the whole problem automatically is probably
quite a bit greater...
Donal.
--
"While this is anecdotal, and thus bound to be ignored by all the pedanticism-
fascists out there, I have owned a fully-loaded copy of Emacs and many other
gnutilities for many years, and have never had a fatality yet."
-- Alistair J. R. Young <avatar...@arkane.demon.co.uk>
It took me but a few seconds using a ouija board improvised from
an old playbill and a telegraph insulator (which I found on the way
to work this morning).
"Donal K. Fellows" wrote:
>
> The problem is pretty easy to solve with a little software help to
> generate lists of 4-digit squares that match the letter patterns. In
> particular, NEUN is quite distinctive and is only matched by 5 different
> squares. From there, it is pretty trivial to spot the answer (it took
> me a couple of minutes with pen and paper) so much so that the effort of
> developing a script to solve the whole problem automatically is probably
> quite a bit greater...
I don't think it's about whether it is quicker to use a computer or do it in your
it in your head. It's about how easy is it to express the problem in a programming
language. Much as I love Tcl this seemed to me to be a natural fit for matrix
arithmetic so I used APL. I've change the syntax a bit because the apl characters
won't display. The idea is to form the outer product of NEUNVIER with itself using
the equal operator (ø.=) which gives a matrix
MB
1 0 0 1 0 0 0 0
0 1 0 0 0 0 1 0
0 0 1 0 0 0 0 0
1 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 1 0 0 0 0 1 0
0 0 0 0 0 0 0 1
I do the same with the candidate squares and if the matrix is the same I've solved
it.
("^/ " reduces along a dimension so that applying it twice reduces the two
dimensions down to a scalar 1 if all components are equal and 0 otherwise. FORMAT
converts the number to a character vector. The rest is APL's aging control
structures)
Z:= L FINDSQ R
n:=32
M:=Rø.=R
MB:=(R,L)ø.=R,L
LOOP:GOTO(0=^/^/M=outerSquareø.=outerSquare:=FORMAT n*2)/NEXT
m:=32
ILOOP:GOTO(^/^/MB=bothø.=both:=outerSquare,FORMAT m*2)/END
GOTO (100>m:=m+1)/ILOOP
NEXT: GOTO (100>n:=n+1)/LOOP
END:Z:=n,m,both
used as,
'VIER' FINDSQ 'NEUN'
gives,
39 66 15214356
Assuming that you mean 39 to be the square root of NEUN and 66 to be the
square root of VIER, your answer is wrong since you can substitute 84
for 66 and still get a solution with 39. There are multiple pairs that
match VIER and NEUN, but only one such that each uniquely determines the
other.
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- With a complex beast like Swing, it's not just a matter of "What button
should I push", but rather "How do I put myself into a nice metamorphosis
so that I am deemed acceptable by the Swing Gods." -- Anonymous
If you mean my earlier life as Tcl-URL! editor, I'm not on duty (looks
like nobody is, this week). But I always though the correct answer was
42...
Me too...what was the question?
Tom
(I waited to post this so as not to spoil the puzzle for others.)
The real puzzle here is, "express the stated problem in Tcl," rather than
"come up with the two target numbers." One solution:
proc solve {} {
# Step 1. List all the squares that have the digit pattern NEUN.
# Group them by the digit E.
for { set i 0 } { $i <= 9 } { incr i } {
set neun_values($i) {}
}
for { set sqrt_neun 32 } { $sqrt_neun <= 99 } { incr sqrt_neun } {
set neun [expr { $sqrt_neun * $sqrt_neun }]
foreach { N E U N2 } [split $neun {}] break
if { [string equal $N $N2] } {
lappend neun_values($E) $neun
}
}
# Step 2. List all the squares that have the pattern VIER for
# some value of NEUN. Cast out any for which there
# are duplicates among the digits V, I, E, R, N and U
for { set sqrt_vier 32 } { $sqrt_vier <= 99 } { incr sqrt_vier } {
set vier [expr { $sqrt_vier * $sqrt_vier }]
foreach { V I E R } [split $vier {}] break
foreach neun $neun_values($E) {
foreach { N E2 U N2 } [split $neun {}] break
foreach letter [list $V $I $E $R $N $U] {
if { [info exists have($letter)] } {
set duplicate {}
break
}
set have($letter) {}
}
unset have
if { ![info exists duplicate] } {
lappend pairs $vier $neun
}
catch { unset duplicate }
}
}
# Step 3. Count up the number of times each number appears in
# a pair
foreach { vier neun } $pairs {
if { [info exists vier_count($vier)] } {
incr vier_count($vier)
} else {
set vier_count($vier) 1
}
if { [info exists neun_count($neun)] } {
incr neun_count($neun)
} else {
set neun_count($neun) 1
}
}
# Step 4. Determine which pairs have each number uniquely determining
# the other
foreach { vier neun } $pairs {
if { $vier_count($vier) == 1 && $neun_count($neun) == 1 } {
lappend answer VIER $vier NEUN $neun
}
}
return $answer
}
array set answer [solve]
parray answer
--
73 de ke9tv/2, Kevin KENNY GE Corporate R&D, Niskayuna, New York, USA
Steve Graham
===
"Kevin Kenny" <ken...@crd.ge.com> wrote in message
news:3AA69D3E...@crd.ge.com...
Is there a *single* unique pair?
I found the following 2 solutions.
(maybe I did not understand the original question, anyway)
n=97 v=79, 9409 6241, N=9 E=4 U=0 V=6 I=2 R=1
n=41 v=87, 1681 7569, N=1 E=6 U=8 V=7 I=5 R=9
My code (sorry, its Perl, but I love Tcl too ;-)
for $n (32..99) {
$nn = $n*$n;
for $v (32..99) {
$vv = $v*$v;
$nnvv = $nn.$vv;
%m = map {($_,'x')} split(//,$nnvv);
print "n=$n v=$v, $nn $vv, N=$1 E=$2 U=$3 V=$4 I=$5 R=$6" if keys %m == 6 && ($nnvv) =~ /(.)(.)(.)\1(.)(.)\2(.)/;
}
}
_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com
This is not a solution because it fails the "each uniquely determines
the other" test, since 7569 can also match 4624. :^)
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- There are worse futures that burning in hell. Imagine aeons filled with
rewriting of your apps as WinN**X API will change through eternity...
-- Alexander Nosenko <n...@titul.ru>
"What do you get when you multiply six by nine?"
54
--
Frédéric BONNET frederi...@free.fr
---------------------------------------------------------------
"Theory may inform, but Practice convinces"
George Bain
>"Donal K. Fellows" wrote:
>>
>> Tom Wilkason wrote:
>> > "Richard.Suchenwirth" <richard.s...@kst.siemens.de> wrote:
>> >| But I always though the correct answer was 42...
>> >
>> > Me too...what was the question?
>>
>> "What do you get when you multiply six by nine?"
>
>54
>
Which is 42 base 13.
--
Dan Smart. C++ Programming and Mentoring.
cpp...@dansmart.com
*sigh*
Ooooooooooooooooh! NICE recovery, Dan! =)
--
.-. .-. .---. .---. .-..-. | Do not mistake my cynicism
| |__ / | \| |-< | |-< > / | for dispair for deep inside
`----'`-^-'`-'`-'`-'`-' `-' | me is an optimist forever
http://www.smith-house.org/ | asking, "Why not?"
Not really, it's Hitch Hikers Guide to the Galaxy Trivia, which is why
Donal "Arthur Dent" Fellows sighed.
Dan "Ford Prefect" Smart
:^) Exactly. I can remember seeing this all blugeoned to death online
back in 1992, and if we are going to insist on retracing those steps
again, I should point out [format %c 42] now.
"IRONY. Made of iron. Suitable for beating people over the head with online."
Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
"I wouldn't just call you wrong. I'd go further and call you an argumentative
net-kook idiot who can't do his own research before opening his mouth and
yammering bullshit." -- Theo de Raadt <der...@zeus.theos.com>