Did anyone write the 6mark algorithm?? (1 Viewer)

PoP 'n' Fresh

Poke me! I giggle!
Joined
Aug 23, 2004
Messages
193
Location
Manly
Gender
Male
HSC
2005
that algorithm was easy!
it was basically copying their code, fixing the logic error, then for the if statement was:
IF array(row,seat) = "unsold" AND array(row,seat +1) = "unsold"
print array(row,seat), array(row,seat + 1)
End if

note: u had to change the while condition to <= 9, otherwise it would be an error trying to access out of bouns
 

kyliej

rOcKiN PuMpKiN
Joined
Aug 26, 2003
Messages
48
Location
in a room in my house =P
Gender
Undisclosed
HSC
N/A
yeh.. well i tried.. i pretty much copied their code.. and then tried to fix the logical error... and tried to add my code in... but im pretty sure i still left errors in it... but hopefully ill get half marks.... :eek:
 

zeal

New Member
Joined
Feb 8, 2004
Messages
8
Gender
Male
HSC
2004
PoP 'n' Fresh said:
that algorithm was easy!
it was basically copying their code, fixing the logic error, then for the if statement was:
IF array(row,seat) = "unsold" AND array(row,seat +1) = "unsold"
print array(row,seat), array(row,seat + 1)
End if

note: u had to change the while condition to <= 9, otherwise it would be an error trying to access out of bouns
That only checks for two seats in a row. The questions asks for two or more, so a different algorithm would be needed if you went for more than two.
 

smallcattle

Member
Joined
Jul 6, 2004
Messages
443
Location
blacktown
Gender
Undisclosed
HSC
2010
PoP 'n' Fresh said:
that algorithm was easy!
it was basically copying their code, fixing the logic error, then for the if statement was:
IF array(row,seat) = "unsold" AND array(row,seat +1) = "unsold"
print array(row,seat), array(row,seat + 1)
End if

note: u had to change the while condition to <= 9, otherwise it would be an error trying to access out of bouns
i dont think that code will work as required

however nobody is perfect, therefore to write a perfect code in less than 30min is impossible
 

Rabz_17

New Member
Joined
Oct 13, 2004
Messages
21
Location
Central Coast
I wrote a bit over half a page, but i made it a subprogram close to the end of the original code. It basically did wat Pop 'n Fresh said tho.

I thought that was the hardest part of the whole thing so if i kinda did it half right, i'm pretty happy.
 

Premus

Member
Joined
May 21, 2004
Messages
216
i did something like.....

IF array(row,seat) = "unsold" AND array(row,seat +1) = "unsold" THEN
WHILE array(row,seat ) = "unsold"
Print array (row, seat)
seat = seat + 1
END WHILE

END IF
 

dritz2003

Member
Joined
Feb 16, 2004
Messages
146
Location
Hornsby
Gender
Male
HSC
N/A
I just did the 2 adjoining as well... I hope the markers don't have too high hopes!
 

disco_dave

is the disco_king!
Joined
Oct 14, 2003
Messages
465
Location
South Side lil old G-town
Gender
Male
HSC
2004
i tried to create a loop until seat whatever = "sold" whilst seat <=10, not sure how it worked in the end. 3/4's of a page but never proof read cause i thought i was going to slow. should have gone back cause i did finish early!
 

acmilan

I'll stab ya
Joined
May 24, 2004
Messages
3,989
Location
Jumanji
Gender
Male
HSC
N/A
I wrote about a page, it worked fine, it was very similar to the one they gave except the errors were corrected and i added an extra while loop to check if the seats next to it were empty
 

Purp|e

miesynth
Joined
Jun 15, 2004
Messages
664
Location
sellin drugs in a school zone
Gender
Undisclosed
HSC
2004
yeah mine was like neely same as urs pop'n'fresh ...but it aint perfect. im sure we'll get ok mark for it though ... :D

ooh, i forgot, but i did ( number of seats required + index of seat ) - 1 ... wait i really cant remember, im confusing myself now, but yeah something along the lines of urs (i think)
 
Last edited:

Archman

Member
Joined
Jul 29, 2003
Messages
337
Gender
Undisclosed
HSC
N/A
heres what i did, whenever u find an unsold seat, u check ones after it, until u reach the next sold one. now if more than 1 were unsold, u print them together, otherwise its just normal.
 

Archman

Member
Joined
Jul 29, 2003
Messages
337
Gender
Undisclosed
HSC
N/A
oh ye, and stop checking for adjoins when the end of row is reached.
 

BrentMcKendrick

New Member
Joined
Apr 7, 2004
Messages
12
Hey everyone, i finished the exam about an hour early and left this till last because i couldnt do it first time round. took me a spare book of about 5 pages of crossing out and 50 mins of exam time to finally get it. I think this is right, tell me if it aint, but heres wot i put in the exam.

BEGIN Show_Available
Row = 1
WHILE row <= 8
Seat = 1
WHILE seat <= 10
Start = Seat
WHILE array(row,seat) = “Unsold”
Seat = seat + 1
If seat = 11 then Exit Loop
ENDWHILE
If seat > start then
Print Start & “ To “ & (Seat-1) & “ Is available for purchase “
End if
ENDWHILE
Increment Row
ENDWHILE
END
 

ZzJasonzZ

Member
Joined
Mar 25, 2004
Messages
36
Location
Sydney
i did:
Begin print_adjacent unsold
--Input "How many adject seats" ; amtadj
--IF amtadj > 0 AND amtadj < 11
----row = 1
----WHILE row <= 8
------Seat = 1
------WHILE seat <= 10
--------available = 1
--------IF array(row,seat) = "unsold" THEN
----------FOR i = seat to (seat + amtadj)
------------IF array(row,seat) = "unsold" THEN
--------------increment available
------------END IF
----------NEXT i
----------IF available = amtadj THEN
------------PRINT amtavailable "seats available to the right of"; seat; row
----------END IF
--------END IF
--------Increment seat
------ENDWHILE
------Increment row
----ENDWHILE
--END IF
END print_adjacent unsold



This is not an exact replica of what i did, but i desk-checked mine and it worked and i think this is pretty close (i also had a loop asking if wanting to do it again but i cbf putting it in here)
 

Wild Dan Hibiki

teh sex0r
Joined
Feb 28, 2004
Messages
649
Gender
Undisclosed
HSC
2004
WTF!!!!!! did u have to modify their algorithm? i made up one from scratch (although it was probly wrong)
 

ZzJasonzZ

Member
Joined
Mar 25, 2004
Messages
36
Location
Sydney
Wild Dan Hibiki said:
WTF!!!!!! did u have to modify their algorithm? i made up one from scratch (although it was probly wrong)
you were supposed to write one from scratch but it was easier to take parts of their algorithm.. because it did most of the job

if it works, it works, regardless of whether you used parts of the code in the earlier question or not
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top