Closed Thread Icon

Preserved Topic: A fun little Puzzel V2 (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=20913" title="Pages that link to Preserved Topic: A fun little Puzzel V2 (Page 1 of 1)" rel="nofollow" >Preserved Topic: A fun little Puzzel V2 <span class="small">(Page 1 of 1)</span>\

 
WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-18-2001 06:35

Create a program that takes in a word of any length and finds all of the combinations of words (even the ones that don't work).

For example:

input: ab
output:
ab
ba

example 2:
input: abc
output:
abc
acb
bac
bca
cab
cba

Good luck with it.

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-18-2001 16:02

Combinations of letters? All the unique combinations?

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-18-2001 16:50

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-18-2001 17:17

Yes all the combinations.

say you enter the word

yes

the program would output all the possible letter combinations. A factoral.

yes
yse
eys
esy
sye
sey

If you want to get even fancier, you could link it to a dictionary of known words, and return only the words that are actually in the dictionary.

Or you could just keep it simple like it is above.

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 05-18-2001 21:45

can i do that in turbo pascal?

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-18-2001 22:19

Can you? I can't answer that question for you. I would imagine it to be possible, but you would have to put in the thinking in order to achomplish it.

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-18-2001 22:27

It's fairly hard. Since the solution is in the Perl Cookbook, I don't care to try and outsmart any of the authors.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-19-2001 06:28

They gave the solution... those bastards

Yeah I am still trying to work out the math. I came upon the puzzle a couple of days ago while fooling around, making work for myself, it wasn't anything too hard to stumble across, but I haven't had it broached to me yet so I figured I will give it too all of you.

So my advice now, don't read the perl book and attempt to come up with your own solution.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-19-2001 15:51

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-19-2001 17:33

Well, I would say that you don't need to have the output sorted. I would also say that is up to you how you want the program to work.

I can not tell you if you are going in the correct direction or not, as I am still attempting to work it out myself. I am getting caught on the math, I would really like to be an algorithms guy, but the high level thinking math takes me a while...

I will tell you that I am thinking nested for loops are going to be needed. And I am attempting to do this using a single letter at a time, in each word.

I can't figure out the common pattern yet, once I see the pattern it will all fall into place.

A nice little thing I notice that may or may not help you is that, if you get half the unique solutions.

abc
acb
bac

Then you revese the order you get the other unique solutions.

cba
bca
cab

I might cut the work load in half or it might cause the math to go even screwier.

Good luck with it, I know I need it.




linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-19-2001 22:59

To iterate is human; to recurse, divine.

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-20-2001 00:02

I like that... inspiration...

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-20-2001 20:04

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-20-2001 20:37

Recursive functions.

Here it is in JavaScript, cut and paste it into an HTML file to test, I'm pretty sure it works right:

code:
<script>

function getAllCombinations(alreadyhave, thestring)
{
var a;
if (thestring.length == 0)
{
// store alreadyhave, it's one of the possible combinations that we're looking for
document.write(alreadyhave + "<br>");
return;
}
for (a=0; a < thestring.length; a++)
{
getAllCombinations(alreadyhave + thestring.substr(a,1), thestring.substr(0,a) + thestring.substring(a+1,thestring.length));
}
}

getAllCombinations("", "hello");
</script>



WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-20-2001 20:56

Looks great slime, I will have to try it out!

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 05-20-2001 21:14

Works awsome slime. I like it a lot

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-21-2001 08:38

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 05-21-2001 10:22

recursive and in pascal.
not so easy as in javascript.

code:
uses crt;
const uBound=4;

var data: array[1..uBound,1..uBound-2] of char;
var i,anz:integer;

procedure swapspec(a,b:byte);
var temp:char;
begin
for i:=1 to uBound do
data[i,1]:=data[i,uBound-a-1];
temp:=data[a,1];
data[a,1]:=data[b,1];
data[b,1]:=temp;
end;

procedure swap(a,b:byte);
var temp:char;
begin
temp:=data[a,1];
data[a,1]:=data[b,1];
data[b,1]:=temp;
end;

procedure print;
begin
for i:=1 to uBound-1 do write(data[i,1],' ');
writeln(data[uBound,1],' ');
end;

procedure permutate(pos:byte);
var j:byte;
begin
if pos = uBound-1 then
begin
print;
swap(pos,pos+1);
print;
anz:=anz+2;
swap(pos,pos+1);
end
else
begin
for i:=1 to uBound do data[i,uBound-pos-1]:=data[i,1];
permutate(pos+1);
for j:=pos+1 to uBound do
begin
swapspec(pos,j);
permutate(pos+1);
end;
end;
end;

begin
textmode(-1);
clrscr;
for i:=1 to uBound do data[i,1]:=chr(64+i);
anz:=0;
permutate(1);
write(anz);
repeat until keypressed;
end.




and here is the compiled file...

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-21-2001 21:25

Hmm, InI, what exactly are you referring to with the "game coding thing?" I might like to, in a few weeks when I'm out of school, if you have something specific in mind, perhaps.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-22-2001 10:01

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

« BackwardsOnwards »

Show Forum Drop Down Menu