|
No it will not. It converts char to its ascii value and sum them.
Zen and the art of software maintenance : rm -rf *
Maths is like love : a simple idea but it can get complicated.
|
|
|
|
|
Last time I checked, 97 + 98 + 99 = 98 + 98 + 98
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
And sir you won the argument !
Hanging my head in shame !
Zen and the art of software maintenance : rm -rf *
Maths is like love : a simple idea but it can get complicated.
|
|
|
|
|
string str1 = "aac";
string str2 = "caa";
bool match = false;
try
{
foreach (char c in str1) str2 = str2.RemoveAt(str2.FirstIndexOf(c));
match = (str2 == "");
}
catch
{
}
COnsole.WriteLine(match.ToString());
|
|
|
|
|
string str1 = "aac";
string str2 = "caa";
array[char] chars1 = str1.ToCharArray();
array[char] chars2 = str2.ToCharArray();
int length1=0; int length2=0;
foreach (char c in chars1) length1++;
foreach (char c in chars2) length2++;
bool match = true;
for (int i = 0; i < length1; i++) {
bool match2 = false;
for (int i2 = 0; i2 < length2; i2++)
{
if (chars1[i] == chars2[i2]) match2 = true; }
match = match && match2;
}
Console.WriteLine(match.ToString());
|
|
|
|
|
virang_21 wrote: Any better real solution ?
What makes this a non-programming question?
Peter Wasser
"The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell
|
|
|
|
|
pwasser wrote: What makes this a non-programming question? If you are intelligent enough to know this is not a programming question, then why did you respond as if it were, thus encouraging the OP ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
pwasser wrote: What makes this a non-programming question? Since you recognize this is a programming question, and since you've been a member of CodeProject for many years ... why did you respond to the OP's question multiple times, thus reinforcing his abuse of the Lounge ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
What are you smoking today Bill?
Peter Wasser
"The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell
|
|
|
|
|
Bill gets the good stuff, he lives in Thailand.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How can you be a member of CodeProject for six years and post a programming question in the Lounge ?
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
How can you be a member of CodeProject for 14 years and 6 months and not report it?
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
How can you two be members for approximately a century and still have no other problems?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
How can you be a member for over eight years and still have such bad arithmetic skills?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Which finally leads me to asking a programming question here:
How do I get a computer to add days, months and years accurately?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
Threats.
Eddie: I'm waiting. I can wait all day if necessary.
Zaphod Beeblebrox: Computer, if you don't open that exit hatch pretty damn pronto, I shall go straight to your major data banks with a very large axe and give you a reprogramming you will never forget. Capisco?
Works for me!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
And what if that thing is threat safe?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
Escalate to "Promises"
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
You assume I did not report it.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
I know you didn't report it, because I checked the OP's message log, and only one person had downvoted the post (and that was me)...
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Are you thinking about performance? If so, use the fastest but more inaccurate checks first. If they fail, return false. If they pass, then do the slower but more accurate checks. That way, the false results would be really fast. The true results would be a touch slower.
|
|
|
|
|
Should have waited until Friday, then post a Friday Programming Challenge (haven't had one for a while).
If you care about only ASCII characters, use an array of ints
If you want to support Unicode, use a Dictionary of ints
Iterate the strings
For each character in the first string, increment its respective value
For each character in the second string, decrement its respective value
At the end, all values should be zero
|
|
|
|
|
|
It could be a misunderstanding that 1 == best.
|
|
|
|
|
I see nothing there indicating that this is the person who voted.
This space for rent
|
|
|
|