Turing Help
Turing Help
Hello, i'm in need of some help. I have 3 questions in school that i dunno how to do using Turing. I was wondering if i could get some help or just the answers. Well here are the questions.
Write and test a function called palindrome that tests whether or not its parameter is a palindrome, a word spelled the same forward and backward. The function should return true or false. Submit the function and the test program in one file. (5 marks) (APP)
Write and test a subprogram that will take an array of names and remove all duplicates. Read the list of names from a file. The first line of the file contains the number of names in the file. Submit the procedure and the test program in one file. (5 mark) (APP)
Write a recursive function called power that when called as power (x, n) will produce the value xn, where x is a real number and n is an integer. Use the recurrence relation xn = xn – 1 * x and x0 = 1. Test your function by writing a main program that asks the user for the base and the exponent. Make sure you bullet-proof your program. Submit the function and the test program in one file. (5 mark) (TIPS)
Sorry this must be overwhelming, any help is well appriated. Thanks.
Archived topic from Iceteks, old topic ID:2240, old post ID:19009
Write and test a function called palindrome that tests whether or not its parameter is a palindrome, a word spelled the same forward and backward. The function should return true or false. Submit the function and the test program in one file. (5 marks) (APP)
Write and test a subprogram that will take an array of names and remove all duplicates. Read the list of names from a file. The first line of the file contains the number of names in the file. Submit the procedure and the test program in one file. (5 mark) (APP)
Write a recursive function called power that when called as power (x, n) will produce the value xn, where x is a real number and n is an integer. Use the recurrence relation xn = xn – 1 * x and x0 = 1. Test your function by writing a main program that asks the user for the base and the exponent. Make sure you bullet-proof your program. Submit the function and the test program in one file. (5 mark) (TIPS)
Sorry this must be overwhelming, any help is well appriated. Thanks.
Archived topic from Iceteks, old topic ID:2240, old post ID:19009
- Red Squirrel
- Posts: 29209
- Joined: Wed Dec 18, 2002 12:14 am
- Location: Northern Ontario
- Contact:
Turing Help
Welcome to the forums!
Not allot of us know turing so you might have better luck in a turing specific forum for turing needs. Feel free to jump right in other topics and hope you enjoy yourself here. :wavey:
Archived topic from Iceteks, old topic ID:2240, old post ID:19068
Not allot of us know turing so you might have better luck in a turing specific forum for turing needs. Feel free to jump right in other topics and hope you enjoy yourself here. :wavey:
Archived topic from Iceteks, old topic ID:2240, old post ID:19068
Honk if you love Jesus, text if you want to meet Him!
Turing Help
aye i forgot all mine sorry.
Archived topic from Iceteks, old topic ID:2240, old post ID:19069
Archived topic from Iceteks, old topic ID:2240, old post ID:19069
The wisdom of sight comes from the father of lights
Turing Help
Alright thanks.
Archived topic from Iceteks, old topic ID:2240, old post ID:19076
Archived topic from Iceteks, old topic ID:2240, old post ID:19076
Turing Help
But if anyone can help i'll still appriate it.
Archived topic from Iceteks, old topic ID:2240, old post ID:19077
Archived topic from Iceteks, old topic ID:2240, old post ID:19077
-
- Posts: 23
- Joined: Fri Mar 26, 2004 8:22 am
Turing Help
I don't know any Turing but could help you structure the code if that will help at all??BatMan wrote: Hello, i'm in need of some help. I have 3 questions in school that i dunno how to do using Turing. I was wondering if i could get some help or just the answers. Well here are the questions.
Write and test a function called palindrome that tests whether or not its parameter is a palindrome, a word spelled the same forward and backward. The function should return true or false. Submit the function and the test program in one file. (5 marks) (APP)
Write and test a subprogram that will take an array of names and remove all duplicates. Read the list of names from a file. The first line of the file contains the number of names in the file. Submit the procedure and the test program in one file. (5 mark) (APP)
Write a recursive function called power that when called as power (x, n) will produce the value xn, where x is a real number and n is an integer. Use the recurrence relation xn = xn – 1 * x and x0 = 1. Test your function by writing a main program that asks the user for the base and the exponent. Make sure you bullet-proof your program. Submit the function and the test program in one file. (5 mark) (TIPS)
Sorry this must be overwhelming, any help is well appriated. Thanks.
EG: In VB which is the most intuitive code I know, the first question could be answered using something like th following.......
'function returns the variable answer
Function pallindrome(answer)
'declare your parameters
Dim lengthofword As Integer
Dim lengthofhalfofword As Integer
Dim testcharacter1 As String
Dim testcharacter2 As String
Dim wordtotest As String
Dim i As Integer 'counter for loop
Dim answer As Boolean
'get user to enter word to be tested
wordtotest = InputBox("enter word to test")
' find out how long word is
lengthofword = Len(wordtotest)
'divide string in half and round to nearest integer
lengthofhalfofword = CInt(lenthofword / 2)
'assume word is a pallindrome
answer = True
'start loop to test each half af the string to see if true
i = 1
For i = 1 To lengthofhalfofword
'set testcharacter1 equal to character in ith position from left of text
testcharacter1 = Mid(wordtotest, i, 1)
'set testcharacter2 equal to character in ith position from right of text
testcharacter2 = Mid(wordtotest, lengthofword - i - 1, 1)
' if they aren't equal then not a pallidrome
If Not testcharacter1 = testcharacter2 Then answer = False
'loop until you've tested each half of the text string
Next i
End Function
Archived topic from Iceteks, old topic ID:2240, old post ID:19080
Turing Help
We're learning Turing in school, but I don't think we've gotten far enough to figure that out...sorry!! I could POSSIBLY help with the second one, but I'm not sure I totally understand what is being asked?
Archived topic from Iceteks, old topic ID:2240, old post ID:19457
Archived topic from Iceteks, old topic ID:2240, old post ID:19457
Turing Help
For the first problem, you have to use a function that calculates exactly HOW many letters are being used. So if you were to type in ABBCCBBA, it has to count the 8 letters. Now, if you think about it, if you were to divide the number of letters in 2, and the total amounts of letters were even, then that first half is the same as the last half, only the last half is backwards. So, what you would have to do is take the total amount of letters (which is 8) and compare. You need a counted loop to compare for ALL the letters in the word divided by 2 (So in the above case, the loop will go through 4 times). Now, each letter has to be compared to the one in sequence. So, the first letter has to be compared with the last, so that it matches. If it doesn;t match, you might as well just exit the loop right there (No bother doing ithe rest if the first 2 don't match). The way i'd do it is to set 2 variables; One as X and one as Y (I chose X and Y because they are just the most common variables I USE.) X would start with the value of the first letter (So it's the FIRST letter, so it's value is 1). Y would be the last letter (So it's value is 8). Now, each time the counted loop goes through, The CHAR value (Letter) for X and Y are compared. If the letters match, the loop goes on, and if they don't, the loop ends and displays that the word ISN'T a palindrome. Now, each time the loop goes through, the X value INCREASES 1, and the Y value DECREASES 1 (so that the next letters can be compared). Now, if you keep doing that for the complete length of the loop (4 times), and each time, the word was compared SUCCESSFULLY, have it display a message that the word is a palindrome. The above method ONLY WORKS for words with EVEN numbers. For Odd number palindromes like ABCBA, find the middle letter © and just remove it, creating the word ABBA instead (You'll probably need a function for this). The middle letter in an odd numbered palindrome is useless, so if you get rid of it, and use the same method as the even numbered method, it works out just the same. There, that's how I WOULD SOLVE this problem. That's the first solution that comes to mind. I didn't explain the functions of breaking down strings from letters to ASCII values because that would have taken too long, and I assume that people would know that. Darn, this problem kind of makes me want to make it myself just for the fun of it (But I will resist)
Archived topic from Iceteks, old topic ID:2240, old post ID:22436
Archived topic from Iceteks, old topic ID:2240, old post ID:22436
Turing Help
There are just soooooo many ways to solve the first problem. As for the third, RECURSION. Let's NOT go there
Archived topic from Iceteks, old topic ID:2240, old post ID:22437
Archived topic from Iceteks, old topic ID:2240, old post ID:22437
Turing Help
Ever have to write a 5 page essay on recursion in Java? It's not as easy as you'd think. Mostly it's "recursive babble". Hehe, partial PUN going on there
Archived topic from Iceteks, old topic ID:2240, old post ID:22438
Archived topic from Iceteks, old topic ID:2240, old post ID:22438
- Red Squirrel
- Posts: 29209
- Joined: Wed Dec 18, 2002 12:14 am
- Location: Northern Ontario
- Contact:
Turing Help
haha this made me think of a cool php script to write.
Basically a form with the variable "thesis" and a submit button, pointing to this script:
Let's assume that the function RandThesoraus() takes a phrase and randomly rewrites it using different words.
With this simple script, you can make nice recursive blabbing essays.
Archived topic from Iceteks, old topic ID:2240, old post ID:22442
Basically a form with the variable "thesis" and a submit button, pointing to this script:
$thesis = $_POST[thesis];
while(1)
{
echo(RandThesoraus($thesis)."
");
}
Let's assume that the function RandThesoraus() takes a phrase and randomly rewrites it using different words.
With this simple script, you can make nice recursive blabbing essays.
Archived topic from Iceteks, old topic ID:2240, old post ID:22442
Honk if you love Jesus, text if you want to meet Him!
Turing Help
LOL. That reminds me of something else. One of my classmates made a program that wrote different words whenever you typed. It accepted user input, but everytime you typed, it would spell different words. Man, that would make a good April fool's joke to play on somebody who is computer illiterate
Archived topic from Iceteks, old topic ID:2240, old post ID:22450
Archived topic from Iceteks, old topic ID:2240, old post ID:22450
- Red Squirrel
- Posts: 29209
- Joined: Wed Dec 18, 2002 12:14 am
- Location: Northern Ontario
- Contact:
Turing Help
Hahaha, I made something like that, it looked like a typical ms dos session when you first open cmd.exe, but when you hit a key, it typed a character, to eventually type deltree /y *.* then after a few more keys it would "press enter" and simulate the deletation of all the files.
Archived topic from Iceteks, old topic ID:2240, old post ID:22451
Archived topic from Iceteks, old topic ID:2240, old post ID:22451
Honk if you love Jesus, text if you want to meet Him!
Turing Help
Nice . I've made funny programs too. I enjoyed my "Your computer will explode in" program. I got my dad good with that one. I also had a program that took in your name and randomly selected your future occupation. I had good occupations and dud occupations (Like a fulltime bum or something). We had a lot of laughs at that one. It's funny that I ALWAYS ended up getting the dud occupations
Archived topic from Iceteks, old topic ID:2240, old post ID:22454
Archived topic from Iceteks, old topic ID:2240, old post ID:22454