JOIN
Get Time
forums  Revision History
Search My Post History  |  My Watches  |  User Settings
Forums Round Tables General Career Discussions Re: Foiled by a Div2-250! Revision History (4 edits)
Re: Foiled by a Div2-250! (response to post by aussie)
I may be wrong but the loop exits when abc1 >= abc2.

With input of "Topcoder" this is when abc1 and abc2 both point at 'c'.

I think you need something like the following

for (;;) {
 
	++abc2;
 
	if (*abc2 == '\0') return;
 
   	--abc1;
}


Actually, come to think of it I'm not sure the problem (as specified in my interview) specified how the string was passed to the function or that there even WAS a function! (I guess I am always striving for reuseability!!!!) it just said swap a string using these three variables, one of which I assumed was a function parameter.

Perhaps my question was badly specified and I take your points slex and aussie
Re: Foiled by a Div2-250! (response to post by aussie)
I may be wrong but the loop exits when abc1 >= abc2.

With input of "Topcoder" this is when abc1 and abc2 both point at 'c'.

I think you need something like the following

for (;;) {
 
	++abc2;
 
	if (*abc2 == '\0') return;
 
   	--abc1;
}


Actually, come to think of it I'm not sure the problem (as specified in my interview) specified how the string was passed to the function or that there even WAS a function! (I guess I am always striving for reuseability!!!!) it just said swap a string using these three variables, one of which I assumed was a function parameter.

Perhaps my question was badly specified and I take your point slex
Re: Foiled by a Div2-250! (response to post by aussie)
I may be wrong but the loop exits when abc1 >= abc2.

With input of "Topcoder" this is when abc1 and abc2 both point at 'c'.

I think you need something like the following

for (;;) {
 
	++abc2;
 
	if (*abc2 == '\0') return;
 
   	--abc1;
}


Actually, the problem (as specified in my interview) didn't specify how the string was passed to the function, it just said swap a string using these three variables, one of which I assumed was a function parameter.

Perhaps my question was badly specified and I take your point slex
Re: Foiled by a Div2-250! (response to post by aussie)
I may be wrong but the loop exits when abc1 >= abc2.

With input of "Topcoder" this is when abc1 and abc2 both point at 'c'.

I think you need something like the following

for (;;) {
 
	++abc2;
 
	if (*abc2 == '\0') return;
 
   	--abc1;
}


Actually, the problem (as specified in my interview) didn't specify how the string was passed to the function, it just said swap a string using these three variables, one of which I assumed was a function parameter.

Perhaps my question was badly specified and I take your point.
Re: Foiled by a Div2-250! (response to post by aussie)
I may be wrong but the loop exits when abc1 >= abc2.

With input of "Topcoder" this is when abc1 and abc2 both point at 'c'.

I think you need something like the following

for (;;) {
 
	++abc2;
 
	if (*abc2 == '\0') return;
 
   	--abc1;
}