r/learnprogramming•
[deleted]

Arrays in Applesoft BASIC?

Hi r/learnprogramming! I asked this yest and got no help. :( This may seem like a random question because it's Applesoft basic, but I have no programming experience. I have to find and print all the possible seating arrangements for a group of 5 people (A,B,C,D & E) and C&D can't sit next to each other.

My plan was to make an array of the peoples names, then assign values to each name. A, B, & E would equal 0 and C & D would equal 1. Then I was thinking of having the program add 2 places at a time and if it is less than 2, then print. How having the people switch places and the computer check all 120 possibilities?

This is what I currently have. 5 DIM G$(20): REM an array of maximum 20 guests 10 N=N+1 20 INPUT "Name of Guest, or blank line to stop"; G$(N) 30 if LEN(G$(N)) <>0 THEN GOTO 10

100 DIM A$(20) : DIM B$(20) :REM you can replace 20 with a larger number 110 M=0 120 M=M+1 130 PRINT "Input a pair, separated by a comma, who cannot sit together. Type DONE,DONE if you are done" 140 INPUT A$(M),B$(M) 159 IF a$(M) <>"DONE" then GOTO 120

Thanks!

Posted Dec 2, 2012, 7:40 PM UTC

61
Loading comments…