help wit turing project
Author |
Message |
vsharma88
|
Posted: Sat Jan 22, 2005 2:31 pm Post subject: help wit turing project |
|
|
plz help me if u can. thx in advance. here is my problem:
code: | var btoken, wtoken: array 1..5 of int
var bmove, wmove, temp, x:int
function bremaindertoken(btoken:int):int
result btoken rem 3
end bremaindertoken
function bmovetoken(btoken:int):int
result btoken div 3
end bmovetoken
function wremaindertoken(wtoken:int):int
result wtoken rem 3
end wremaindertoken
function wmovetoken(wtoken:int):int
result wtoken div 3
end wmovetoken
btoken(1):=1004
btoken(2):=13
btoken(3):=5
btoken(4):=0
btoken(5):=0
wtoken(1):=100
wtoken(2):=10
wtoken(3):=8
wtoken(4):=0
wtoken(5):=0
x:=0
put " ", btoken(3):5, wtoken(3):5, wtoken(2):5," ",wtoken(1):5,btoken(1):8
loop
x:=x+1
for counter1:1..5
bmove:= bmovetoken(btoken(counter1))
temp:=bremaindertoken(btoken(counter1))
if btoken(counter1) > wtoken(counter1) then
bmove:= abs(bmove-wtoken(counter1))
end if
btoken(counter1):=temp
put " ", btoken(3):5, wtoken(3):5, wtoken(2):5," ",wtoken(1):5,btoken(1):8
end for
exit when x=3
end loop |
plz tell me if im on the right track and any problems i have |
|
|
|
|
|
Sponsor Sponsor
|
|
|
vsharma88
|
Posted: Sat Jan 22, 2005 5:58 pm Post subject: (No subject) |
|
|
common can some1 plzzz help me. |
|
|
|
|
|
basketball4ever
|
Posted: Sat Jan 22, 2005 6:07 pm Post subject: (No subject) |
|
|
Compsci isnt a place where you just tell us to do it for you... and we'll do it for you. Its a place where we can give suggestions. and help you out if you have something that you think can be done, but dont know how in code. |
|
|
|
|
|
vsharma88
|
Posted: Sat Jan 22, 2005 6:55 pm Post subject: (No subject) |
|
|
im asking if im on the rite track |
|
|
|
|
|
Cervantes
|
Posted: Sat Jan 22, 2005 7:04 pm Post subject: (No subject) |
|
|
vsharma88 wrote: plz tell me if im on the right track and any problems i have
Sounds like you're asking us to do steps 1 - 4 for you. Why don't you do them, then get back to us? |
|
|
|
|
|
Dan
|
Posted: Sat Jan 22, 2005 7:42 pm Post subject: (No subject) |
|
|
Also thats looks alot like an ISU asgment there (the big ones that are worth 10%~15%) i don't think your teacher whould be very happy about you scaning it and posting it for peoleop to help u with. There are alot of eftical and moral issues with helping you on this one....... |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Tony
|
Posted: Sat Jan 22, 2005 9:43 pm Post subject: (No subject) |
|
|
so how did those archeologists figured out the rules for such an ancient game?
and you should really start by writing out pseudocode and/or a flowchart. Lets see you finish one of those and we'll give you pointers on putting that into working code. |
|
|
|
|
|
vsharma88
|
Posted: Sat Jan 22, 2005 9:55 pm Post subject: (No subject) |
|
|
1. There are a certain number of tokens on board with 10 spot. On the first pace there is 1004 black tokens on the second one 100 white tokens, there is none on the third, on the fourth pace there are 13 black tokens, on the fifth pace 10 white tokens, on the sixth pace 8 white tokens, on the seventh pace 7 black tokens. The object of the games is to use the tokens to get the least amount of tokens on the tenth pace by following the rules.
2. 1.Start at a position 2. Divide # of tokens by 3 and put that amount in the next spot. 4. If there is white token there for each black cancel each white. 5. Stop when the least amount of tokens have been placed on the 10th spot.
3. Start at a position Divide number of tokens and find reminder. Place the number of tokens of that colour from the divided number to the left and leave the remainder in the box. If the opposite coloured token is on that spot then for each token remove the opposite coloured and the original coloured token. Repeat until the minimum number of tokens has end up on the spot. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Leftover
|
Posted: Sun Jan 23, 2005 1:41 am Post subject: (No subject) |
|
|
Also might want to add, most CS teachers are members / browse these forums regularly, I know mine does, and many others from local schools. If your teacher saw this, I'd imagine it would be treated the same way as plagiarism (a mark of 0).
I, too, am working on my final for programming, and I work my arse off, and merely post my code, what is wrong with it, what I think can be done but I don't know how to do it, and people give suggestions how I can fix / improve it (not the exact code I need), and I play with and impliment it from there.
Rather then posting the assignment sheet, use the code button at the top of posting window, and post what you have and what your problem is. |
|
|
|
|
|
vsharma88
|
Posted: Sun Jan 23, 2005 11:01 am Post subject: (No subject) |
|
|
ok i posted what i have sooo far and have taken away the paper |
|
|
|
|
|
vsharma88
|
Posted: Sun Jan 23, 2005 3:48 pm Post subject: (No subject) |
|
|
i have been working on trying to solve it and here is my new code:
code: | var btoken, wtoken : array 1 .. 5, 1 .. 2 of int
var bmove, wmove, btemp, wtemp, x : int
function remaindertoken (token : int) : int
result token rem 3
end remaindertoken
function movetoken (token : int) : int
result token div 3
end movetoken
btoken (1, 1) := 1004
btoken (2, 1) := 13
btoken (3, 1) := 5
btoken (4, 1) := 0
btoken (5, 1) := 0
btoken (1, 2) := 1004
btoken (2, 2) := 13
btoken (3, 2) := 5
btoken (4, 2) := 0
btoken (5, 2) := 0
wtoken (1, 1) := 100
wtoken (2, 1) := 10
wtoken (3, 1) := 8
wtoken (4, 1) := 0
wtoken (5, 1) := 0
wtoken (1, 2) := 100
wtoken (2, 2) := 10
wtoken (3, 2) := 8
wtoken (4, 2) := 0
wtoken (5, 2) := 0
x := 0
put " ", btoken (3, 1) : 5, wtoken (3, 1) : 5, wtoken (2, 1) : 5, " ", wtoken (1, 1) : 5, btoken (1, 1) : 8
loop
x := x + 1
for counter1 : 1 .. 5
for counter2 : 1 .. 2
bmove := movetoken (btoken (counter1, counter2))
btemp := remaindertoken (btoken (counter1, counter2))
if btoken (counter1, counter2) > wtoken (counter1, counter2) then
bmove := abs (bmove - wtoken (counter1, counter2))
elsif wtoken (counter1, counter2) > btoken (counter1, counter2) then
wmove := abs (wmove - btoken (counter1, counter2))
end if
wmove := movetoken (wtoken (counter1, counter2))
wtemp := remaindertoken (btoken (counter1, counter2))
wtoken (counter1, counter2) := wtemp
btoken (counter1, counter2) := btemp
put " ", btoken (3, 1) : 5, wtoken (3, 1) : 5, wtoken (2, 1) : 5, " ", wtoken (1, 1) : 5, btoken (1, 1) : 8
% put " ", btoken (counter1, counter2) : 5, wtoken (counter1, counter2) : 5, wtoken (counter1, counter2) : 5, " ", wtoken (counter1, counter2) : 5, btoken (counter1, counter2) : 8
end for
end for
exit when x = 3
end loop |
i do not know how to show the pieces moving to the left. plz help |
|
|
|
|
|
vsharma88
|
Posted: Sun Jan 23, 2005 10:20 pm Post subject: (No subject) |
|
|
ok forget about the program is there a way to make a table in turing wit out have to draw it? i tried the turing reference buh there was nothing there |
|
|
|
|
|
Leftover
|
Posted: Sun Jan 23, 2005 10:49 pm Post subject: (No subject) |
|
|
You mean drawing a table in Turing as you would in word or html? I.E. A Draw.Table command?
If so, then no. Just do Draw.Box and copy it, just change the co-ordinates to make it look like a table. Draw.Box will give you a frame in the shape of a box, Draw.FillBox has the same paramaters but fills the box in with whatever color you pick. |
|
|
|
|
|
vsharma88
|
Posted: Sun Jan 23, 2005 10:53 pm Post subject: (No subject) |
|
|
ok thx... btw i think i got it buh it styll needs some working on |
|
|
|
|
|
vsharma88
|
|
|
|
|
|
|