(April 10, 2010 at 5:52 pm)Disinter Wrote:(April 10, 2010 at 4:37 pm)Darwinian Wrote: I'm pleased you indent your code properly, so many people don't and just produce a clumsy mess. Nothing to do with the topic but I thought I'd give you a bit of praise anyway
You certainly wouldn't want to see my code
@ Adrian: Nice job!
What about me

Anyway..
Code:
var
target, output, tmp: string; a: word; cnt: longint;
Const
hold: boolean = False;
begin
target:='Hello';
cnt:=0;
repeat
output:=''; a:=0;
while a<=length(target)-1 do begin
tmp:=chr(32+Random(94)); inc(cnt);
if (Copy(target,a+1,1)=tmp) or (not hold) then begin
output:=output+tmp; inc(a);
end;
end;
until (hold) or (output=target);
Label1.Caption:='Target string '+target+' found after '+IntToStr(cnt)+' attempts..';
end;
It's still working on 'Hello' without the hold option and it's really surprising how long it takes using the whole alphabet rather than just the capitals :S
Edit: It found 'Hell' in 216813840 attempts!!! I dare you to do it with the full alphabet and look for 'How long will this take?'
![[Image: cinjin_banner_border.jpg]](https://images.weserv.nl/?url=oggtheclever.com%2Fcinjin_banner_border.jpg)