Computer Science Canada

Generating all possible combinations

Author:  Amailer [ Thu Aug 03, 2006 11:03 am ]
Post subject:  Generating all possible combinations

Hey,
Can anyone explain to me a way to create a function that allows me to get every single combination of case and numbers represneting letters of a word?

Example, I enter the word 'hello' (all lower case) into the function, it should output:
Hello
HEllo
HELlo
HELLo
HELLO
Hell0
HEll0
HELl0
HELL0
hEllo
heLlo
helLo
hellO

and so on xD

Author:  [Gandalf] [ Thu Aug 03, 2006 1:15 pm ]
Post subject: 

I don't know... But I can't think of any reason for doing this that can't be solved by using a changeToUpperCase(word) function. If not, I'd like to hear what your reason is. Smile

Author:  Tony [ Thu Aug 03, 2006 3:20 pm ]
Post subject: 

have a function that takes in a character, and returns an array of alternatives

code:

fnc leet(char a)
{
     if (a == 'o')
         return ['o', 'O', 0];
}

Then run though the length of the string recursivly

Author:  bugzpodder [ Thu Sep 07, 2006 8:15 pm ]
Post subject: 

this is a terrible mix of C,C++, and PHP, and pseudocode

function f(string x) {
for each variation of x[0]
echo x[0].f(x.substr(1));
}

Author:  Decadence666 [ Tue Oct 24, 2006 9:40 pm ]
Post subject: 

ok, heres a tip to help you.

$var = "Hello"

$var{1} is equal to 'H'

I belive, i don't have access to my files right now but i think thats how you access a single char in a string.

Author:  Craige [ Tue Oct 24, 2006 10:01 pm ]
Post subject: 

I'm sure if I thought about it for a while, I could write a function to do it, but if I may ask: why would you want something to do this?

Author:  rdrake [ Tue Oct 24, 2006 10:34 pm ]
Post subject: 

Craige wrote:
I'm sure if I thought about it for a while, I could write a function to do it, but if I may ask: why would you want something to do this?
A thought would be something like an offensive words filter.

Author:  md [ Tue Oct 24, 2006 10:42 pm ]
Post subject: 

rdrake wrote:
Craige wrote:
I'm sure if I thought about it for a while, I could write a function to do it, but if I may ask: why would you want something to do this?
A thought would be something like an offensive words filter.

There are easier solutions to that; such as making each word lowercase and comparing to a loercase lsit of offensive words. This sounds like either homework or just fooling around learning the language.

Author:  Craige [ Wed Oct 25, 2006 7:19 am ]
Post subject: 

[quote="md"]
rdrake wrote:
There are easier solutions to that; such as making each word lowercase and comparing to a loercase lsit of offensive words. This sounds like either homework or just fooling around learning the language.


Indeed, but it would be something interesting to code.


: