Wordle comparison: Difference between revisions

→‎{{header|FutureBasic}}: Replaced with more compact revised code
(→‎{{header|FutureBasic}}: Replaced with more compact revised code)
Line 357:
 
=={{header|FutureBasic}}==
This compact FutureBasic function fillsreturns ana byte array of(as colora objectspstring) whichwith can2, be1, applied0, directlyfor tomatched, whatever output is chosenmismatched, as demonstrated in the 'show' functionunmatched. It is useful for games up to 15 chars wide, and is case sensitive as specified.
<syntaxhighlight lang="futurebasic">
short x = 80, y = -2920
 
clear local fn wordleComparecolorString( wordlew1 as str15, guessw2 as str15, cArray(15) as colorRef )str15
short x, y = -29
str255 n : str15 c : c[0] = w2[0] : short r
 
for r = 1 to guessw1[0]
clear local fn wordleCompare( wordle as str15, guess as str15, cArray(15) as colorRef )
if w2[r] = w1[r] then c[r] = 2 else n[w1[r]]++
/* Returns colors in passed array "cArray()". */
byte count(255)
short r
for r = 1 to wordle[0]
if guess[r] == wordle[r] then cArray(r) = fn colorGreen : continue
count(wordle[r])++ : cArray(r) = fn colorGray
next
for r = 1 to wordlew2[0]
if c[r] == 0 then if n[w2[r]] then n[w2[r]]-- : c[r] = 1
for r = 1 to guess[0]
if cArray(r) == fn colorGreen then continue
if count(guess[r]) then count(guess[r])-- : cArray(r) = fn colorYellow
next
end fn = c
</syntaxhighlight>
end fn
This function uses the array to display output mimicking the appearance of WORDLE.
 
<syntaxhighlight lang="futurebasic">
local fn show( wordle as str15, guess as str15 )
mda(0) = {fn ColorDarkGray,fn ColorWithRGB(.7,.6,.3,1),fn ColorWithRGB(.3,.6,.3,1)}
colorref color(15)
void local fn showwordleCompare( wordle as str15, guess as str15 )
short r
xstr15 = 130color : y +=short 32r
color = fn wordleComparecolorString( wordle, guess, color(0) ) //get color array
text @"menlo bold", 2714, fn colorgray : print %( 20, y ) wordlecolorLightGray
print %( 20, y ) wordle : text ,,fn colorBlackcolorWhite
for r = 1 to guess[0]
rect fill ( x, y + 8, 2824, 2824 ), colormda_object(r) //apply color[r] from array to square)
print %( x + 7.5, y + 1 ) chr$( guess[r] ); : x += 2928
next
x = 80 : y += 28
end fn
 
window 1, @"FB Wordle Compare in FutureBasic", ( 0, 0,310 265,350 290 )
WindowSetBackgroundColor( 1, fn Colorblack )
fn show( "ALLOW", "LOLLY" )
fn showwordleCompare( "CHANTALLOW", "LATTELOLLY" )
fn showwordleCompare( "ROBINCHANT", "SONICLATTE" )
fn showwordleCompare( "ROBIN", "ROBINSONIC" )
fn showwordleCompare( "ROBINPROUD", "ALERTLEAST" )
fn showwordleCompare( "BULLYSTEAL", "LOLLYLEAST" )
fn showwordleCompare( "STEALLEAST", "LEAST" )
fn showwordleCompare( "CHOIRFULLY", "LEASTLABEL" )
fn showwordleCompare( "SILLYWe're", "LABELShe's" )
fn showwordleCompare( "SwissLONGER", "sissySTRING" )
 
handleevents
</syntaxhighlight>
{{out}}
[[File:FutureBasicWordle OutputComparison forin Wordle ComparisonFutureBasic.png]]
 
=={{header|Go}}==
68

edits