Last letter-first letter: Difference between revisions

Added BBC BASIC
(Updated second D entry)
(Added BBC BASIC)
Line 131:
emolga
audino</pre>
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> DIM names$(69)
names$() = "audino", "bagon", "baltoy", "banette", \
\ "bidoof", "braviary", "bronzor", "carracosta", "charmeleon", \
\ "cresselia", "croagunk", "darmanitan", "deino", "emboar", \
\ "emolga", "exeggcute", "gabite", "girafarig", "gulpin", \
\ "haxorus", "heatmor", "heatran", "ivysaur", "jellicent", \
\ "jumpluff", "kangaskhan", "kricketune", "landorus", "ledyba", \
\ "loudred", "lumineon", "lunatone", "machamp", "magnezone", \
\ "mamoswine", "nosepass", "petilil", "pidgeotto", "pikachu", \
\ "pinsir", "poliwrath", "poochyena", "porygon2", "porygonz", \
\ "registeel", "relicanth", "remoraid", "rufflet", "sableye", \
\ "scolipede", "scrafty", "seaking", "sealeo", "silcoon", \
\ "simisear", "snivy", "snorlax", "spoink", "starly", "tirtouga", \
\ "trapinch", "treecko", "tyrogue", "vigoroth", "vulpix", \
\ "wailord", "wartortle", "whismur", "wingull", "yamask"
maxPathLength% = 0
maxPathLengthCount% = 0
maxPathExample$ = ""
FOR i% = 0 TO DIM(names$(),1)
SWAP names$(0), names$(i%)
PROClastfirst(names$(), 1)
SWAP names$(0), names$(i%)
NEXT
PRINT "Maximum length = " ; maxPathLength%
PRINT "Number of solutions with that length = " ; maxPathLengthCount%
PRINT "One such solution: " ' maxPathExample$
END
DEF PROClastfirst(names$(), offset%)
LOCAL i%, l%
IF offset% > maxPathLength% THEN
maxPathLength% = offset%
maxPathLengthCount% = 1
ELSE IF offset% = maxPathLength% THEN;
maxPathLengthCount% += 1
maxPathExample$ = ""
FOR i% = 0 TO offset%-1
maxPathExample$ += names$(i%) + CHR$13 + CHR$10
NEXT
ENDIF
l% = ASCRIGHT$(names$(offset% - 1))
FOR i% = offset% TO DIM(names$(),1)
IF ASCnames$(i%) = l% THEN
SWAP names$(i%), names$(offset%)
PROClastfirst(names$(), offset%+1)
SWAP names$(i%), names$(offset%)
ENDIF
NEXT
ENDPROC</lang>
'''Output:'''
<pre>
Maximum length = 23
Number of solutions with that length = 1248
One such solution:
machamp
pinsir
rufflet
trapinch
heatmor
remoraid
darmanitan
nosepass
starly
yamask
kricketune
exeggcute
emboar
relicanth
haxorus
simisear
registeel
landorus
seaking
girafarig
gabite
emolga
audino
</pre>
 
=={{header|Bracmat}}==
===Naive===
Line 315 ⟶ 398:
petilil
machamp</pre>
 
=={{header|C}}==
From the D version.