1. APL programming

--Now lets see if I got this correct. How many J (or was that APL)
--programmers to write The Encyclopedia Britanica?
--I've probably totally misunderstood the problem entirely.

global sequence s,APLprogram
s="The Encyclopedia Britanica"
APLprogram=s
global integer try,a,b,c,L
L=length(s)
try=0

procedure monkey()
  a=rand(L)
  b=rand(L)
  c=APLprogram[a]
  APLprogram[a]=APLprogram[b]
  APLprogram[b]=c
end procedure

monkey()
try+=1

while not equal(s,APLprogram) do
  monkey()
  try+=1
  position(1,1) printf(1,"%s %d",{APLprogram,try})
  if get_key()!=-1 then abort(1) end if
end while

--Just in fun. Hope nobody takes offense.
--JOHN

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu