I have given a string and asked to write the code with out using any inbuilt functions.below is the description

dim str as string="~~~This~~is~~~~the~~~~~Test~~~~~"
The tilts are dynamically created and may not be the same everytime, but the output should be as follows
str=This~~is~~~~the~~~~~Test
we need to remove the tilts from the begining to "T" and remove the last tilts from "t"
we can do it by using Remove,Mid functions but the interviewer wants the logic to be used not the inbuilt functions.
Could any body helpme out and give me the logic.
Rememember the output should be like "This~~is~~~~the~~~~~Test"

I am new to this site and also for threads. if there is any mistake in the format please forgive me.

Thanks
Narender

Hmm, sir, no offense or anything, but if you cannot do this test, how do you plan to complete the assignments handed down to you once you get the job?

This should be used with the indexOf method and the LastIndexOf method.

Hmm, sir, no offense or anything, but if you cannot do this test, how do you plan to complete the assignments handed down to you once you get the job?

This should be used with the indexOf method and the LastIndexOf method.

Hi thanks for your reply. I have already done this in my home with index of and lastindeof methods used infact it can directly done using substrings,Mid and replace fuctions, but as i said the interviewer do not want us to use the inbuilt funtions as you have asked me to do.
I tried using those functions and got the result also. but he needs some logic without functions. i didnt cleared the interview just because i used those fuctions and since then i trying out to do this with some logic. please help me out if you can.


Thanks
Narender

Actually, after reading that, what does your interviewer mean not using "inbuilt" functions? You cannot use substring, right, left, indexof, lastindexof, etc?

The way I would do it is:

dim str as string="~asd~~~~This~~is~~~~the~~~~~Test~~~~~skjl~~"
response.write (str.substring(str.indexOf("T") , str.LastindexOf("t")-str.indexOf("T")+1))

however, what does he mean by doing it with logic? Everything with VB.NET is built in functions

Actually, after reading that, what does your interviewer mean not using "inbuilt" functions? You cannot use substring, right, left, indexof, lastindexof, etc?

The way I would do it is:

dim str as string="~asd~~~~This~~is~~~~the~~~~~Test~~~~~skjl~~"
response.write (str.substring(str.indexOf("T") , str.LastindexOf("t")-str.indexOf("T")+1))

however, what does he mean by doing it with logic? Everything with VB.NET is built in functions

I dont know exactly what logic he need i think he need some loops to be used and the fetch the output. anyway thanks for spending time on this.

I dont know exactly what logic he need i think he need some loops to be used and the fetch the output. anyway thanks for spending time on this.

Moreover he wants me to do that in both asp.net and vb.net and the weightage for that was 10marsk out of 40.

if he is checking for loops, then you can do it this way, but it it is really poor programming.

Anyway, that's the thing. Everything you use is using a built-in function. To use a loop, you would be checking for characters, hence the "charAt" function. Any way of checking it would be damn near impossible, or at least completely stupid so no one would think of it.

The only way of checking what the string contains is by using the built-in functions like "substring", "mid", "charAt", etc.

why don't you create your own method that would make use of a regular expression. Do some research on regular express and ASP.NET or .NET and see what comes up.

HINT: you are going to start with something like this -->@"^(~.....) and so on.

oh but see.. you cannot use built in functions, there for using the replace or regex period would call for a built in function.

See what I mean?

Seems impossible to me. If you were going to use loops you'd at least have to know the length of the string, which would require a built-in function. I'd try to get more details of exactly what they're looking for.

sure you have to know the length of the string but, you can built your own function that will return the length of the string. for example, you could have a loop that will do this

int index = 0;
while(string[index] != '\0')
{
      index++;
}

return (index); at the end of the loop and this would be your own method for counting the content of the string.

The problem sounds like to me its a data structure and independent software design. but, as you just mentioned get more information on the problem.

This article has been dead for over six months. Start a new discussion instead.