Dinesman's multiple-dwelling problem: Difference between revisions

Content added Content deleted
No edit summary
Line 1,431: Line 1,431:
<lang IS-BASIC>100 PROGRAM "Dinesman.bas"
<lang IS-BASIC>100 PROGRAM "Dinesman.bas"
110 PRINT "Floors are numbered 0 (ground) to 4 (top).":PRINT "Baker, Cooper, Fletcher, Miller, and Smith live on different floors."
110 PRINT "Floors are numbered 0 (ground) to 4 (top).":PRINT "Baker, Cooper, Fletcher, Miller, and Smith live on different floors."
130 PRINT "- Baker does not live on the top floor.":PRINT "- Cooper does not live on the bottom floor."
120 PRINT "- Baker does not live on the top floor.":PRINT "- Cooper does not live on the bottom floor."
150 PRINT "- Fletcher does not live on either the top or the bottom floor.":PRINT "- Miller lives on a higher floor than does Cooper."
130 PRINT "- Fletcher does not live on either the top or the bottom floor.":PRINT "- Miller lives on a higher floor than does Cooper."
170 PRINT "- Smith does not live on a floor adjacent to Fletcher's.":PRINT "- Fletcher does not live on a floor adjacent to Cooper's.":PRINT :LET S$=" lives on floor"
140 PRINT "- Smith does not live on a floor adjacent to Fletcher's.":PRINT "- Fletcher does not live on a floor adjacent to Cooper's.":PRINT :LET S$=" lives on floor"
190 FOR B=0 TO 3
150 FOR B=0 TO 3
200 FOR C=1 TO 4
150 FOR C=1 TO 4
210 FOR F=1 TO 3
170 FOR F=1 TO 3
220 FOR M=0 TO 4
180 FOR M=0 TO 4
230 FOR S=0 TO 4
190 FOR S=0 TO 4
240 IF B<>C AND B<>F AND B<>M AND B<>S AND C<>F AND C<>M AND C<>S AND F<>M AND F<>S AND M<>S AND M>C AND ABS(S-F)<>1 AND ABS(F-C)<>1 THEN
200 IF B<>C AND B<>F AND B<>M AND B<>S AND C<>F AND C<>M AND C<>S AND F<>M AND F<>S AND M<>S AND M>C AND ABS(S-F)<>1 AND ABS(F-C)<>1 THEN
250 PRINT "Baker",S$;B:PRINT "Cooper",S$;C:PRINT "Fletcher";S$;F:PRINT "Miller",S$;M:PRINT "Smith",S$;S
210 PRINT "Baker",S$;B:PRINT "Cooper",S$;C:PRINT "Fletcher";S$;F:PRINT "Miller",S$;M:PRINT "Smith",S$;S
260 END
220 END
270 END IF
230 END IF
280 NEXT
240 NEXT
290 NEXT
250 NEXT
300 NEXT
260 NEXT
310 NEXT
270 NEXT
320 NEXT</lang>
280 NEXT</lang>


=={{header|J}}==
=={{header|J}}==