Wordle comparison: Difference between revisions
Content added Content deleted
(Created Nim solution.) |
|||
Line 355: | Line 355: | ||
BBAABBB: Expected 5 character target.</pre> |
BBAABBB: Expected 5 character target.</pre> |
||
=={{header|FutureBasic}}== |
|||
This compact FutureBasic function fills an array of color objects which can be applied directly to whatever output is chosen, as demonstrated in the 'show' function. |
|||
<syntaxhighlight lang="futurebasic"> |
|||
short x, y = -29 |
|||
clear local fn wordleCompare( wordle as str15, guess as str15, cArray(15) as colorRef ) |
|||
/* 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 guess[0] |
|||
if cArray(r) == fn colorGreen then continue |
|||
if count(guess[r]) then count(guess[r])-- : cArray(r) = fn colorYellow |
|||
next |
|||
end fn |
|||
local fn show( wordle as str15, guess as str15 ) |
|||
colorref color(15) |
|||
short r |
|||
x = 130 : y += 32 |
|||
fn wordleCompare( wordle, guess, color(0) ) //get color array |
|||
text @"menlo", 27, fn colorgray : print %( 20, y ) wordle |
|||
text ,,fn colorBlack |
|||
for r = 1 to guess[0] |
|||
rect fill ( x, y + 8, 28, 28 ), color(r) //apply color from array to square |
|||
print %( x + 5, y ) chr$(guess[r]); : x += 29 |
|||
next |
|||
end fn |
|||
window 1, @"Wordle Compare in FutureBasic",(0,0,310,350) |
|||
fn show( "ALLOW", "LOLLY" ) |
|||
fn show( "CHANT", "LATTE" ) |
|||
fn show( "ROBIN", "SONIC" ) |
|||
fn show( "ROBIN", "ROBIN" ) |
|||
fn show( "ROBIN", "ALERT" ) |
|||
fn show( "BULLY", "LOLLY" ) |
|||
fn show( "STEAL", "LEAST" ) |
|||
fn show( "CHOIR", "LEAST" ) |
|||
fn show( "SILLY", "LABEL" ) |
|||
fn show( "Swiss", "sissy" ) |
|||
handleevents |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
[[File:FutureBasic Output for Wordle Comparison.png]] |
|||
=={{header|Go}}== |
=={{header|Go}}== |