Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Generating all possible combinations
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Thu Aug 03, 2006 1:15 pm   Post subject: (No 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
Tony




PostPosted: Thu Aug 03, 2006 3:20 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
bugzpodder




PostPosted: Thu Sep 07, 2006 8:15 pm   Post subject: (No 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));
}
Decadence666




PostPosted: Tue Oct 24, 2006 9:40 pm   Post subject: (No 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.
Craige




PostPosted: Tue Oct 24, 2006 10:01 pm   Post subject: (No 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?
rdrake




PostPosted: Tue Oct 24, 2006 10:34 pm   Post subject: (No 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.
md




PostPosted: Tue Oct 24, 2006 10:42 pm   Post subject: (No 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.
Sponsor
Sponsor
Sponsor
sponsor
Craige




PostPosted: Wed Oct 25, 2006 7:19 am   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: