From adaf874859a1d40e94064e1ecc34b7fefeb8c1ac Mon Sep 17 00:00:00 2001 From: Jatinderjit Singh Date: Sun, 19 Apr 2026 00:37:40 +0530 Subject: [PATCH 1/3] Fix invisible wordle messages --- modules/fun/wordle.nu | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/fun/wordle.nu b/modules/fun/wordle.nu index 46c7036a0..ea8bd563d 100644 --- a/modules/fun/wordle.nu +++ b/modules/fun/wordle.nu @@ -8,9 +8,9 @@ export def main [ --alternative_source(-a) : string = "https://raw.githubusercontent.com/charlesreid1/five-letter-words/master/sgb-words.txt" # Alternative link to provide as a word source ] { let words = (if ($alternative_source | str substring 0..4 | str contains "http") {http get $alternative_source} else {open $alternative_source} | from ssv -n) - let word = ($words | get (random int 0..($words | length)) | get column1) - if ((($words | each {|it| ($it.column1 | str length)}) | where $it != 5 | length) != 0 ) { - echo $"(ansi rb)Warning:(ansi reset) The words list contains words that are not length 5" + let word = ($words | get (random int 0..($words | length)) | get column0) + if ((($words | each {|it| ($it.column0 | str length)}) | where $it != 5 | length) != 0 ) { + print $"(ansi rb)Warning:(ansi reset) The words list contains words that are not length 5" } mut end = false mut guess_count = 0 @@ -18,9 +18,9 @@ export def main [ while (not ($end)) { $guess_count += 1 if ($guess_count <= $max_count or $unlimited) { - echo $"(ansi xterm_aquamarine1a)Enter your guess (ansi reset)\((ansi green)($guess_count)(ansi reset)/(ansi yellow)(if ($unlimited) {inf} else {$max_count})(ansi reset)\)" + print $"(ansi xterm_aquamarine1a)Enter your guess (ansi reset)\((ansi green)($guess_count)(ansi reset)/(ansi yellow)(if ($unlimited) {inf} else {$max_count})(ansi reset)\)" mut guess = (input | str downcase ) - if (((($words | where column1 =~ $guess) | length) >= 1) and ($guess | str length) == 5) { + if (((($words | where column0 =~ $guess) | length) >= 1) and ($guess | str length) == 5) { mut out = "" mut checked = $word for i in ($guess | split chars | enumerate) { @@ -38,17 +38,17 @@ export def main [ } } $avail = $"(ansi white_reverse)($avail)(ansi reset)" - echo $"($out) possible -> ($avail)" + print $"($out) possible -> ($avail)" if ($guess == $word) { $end = true - echo $"(ansi xterm_green1 )You guessed right!(ansi reset)" + print $"(ansi xterm_green1 )You guessed right!(ansi reset)" } } else { - echo "please enter a valid [5 letter] word!" + print "please enter a valid [5 letter] word!" $guess_count -= 1 } } else { - echo $"(ansi yellow )You loose, the word was: (ansi red)($word)(ansi reset)" + print $"(ansi yellow )You loose, the word was: (ansi red)($word)(ansi reset)" $end = true } } From 0869983183e260cddf1bf2f4c46ffab692627781 Mon Sep 17 00:00:00 2001 From: Jatinderjit Singh Date: Sun, 19 Apr 2026 01:19:16 +0530 Subject: [PATCH 2/3] Simplify $words to list --- modules/fun/wordle.nu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/fun/wordle.nu b/modules/fun/wordle.nu index ea8bd563d..ab0bed277 100644 --- a/modules/fun/wordle.nu +++ b/modules/fun/wordle.nu @@ -7,9 +7,9 @@ export def main [ --max_count(-M) : int = 6 # Give yourself more chances than default --alternative_source(-a) : string = "https://raw.githubusercontent.com/charlesreid1/five-letter-words/master/sgb-words.txt" # Alternative link to provide as a word source ] { - let words = (if ($alternative_source | str substring 0..4 | str contains "http") {http get $alternative_source} else {open $alternative_source} | from ssv -n) - let word = ($words | get (random int 0..($words | length)) | get column0) - if ((($words | each {|it| ($it.column0 | str length)}) | where $it != 5 | length) != 0 ) { + let words = (if ($alternative_source | str starts-with "http") {http get $alternative_source} else {open $alternative_source} | lines) + let word = ($words | get (random int 0..($words | length))) + if ((($words | each {|it| $it | str length}) | where $it != 5 | length) != 0 ) { print $"(ansi rb)Warning:(ansi reset) The words list contains words that are not length 5" } mut end = false @@ -19,8 +19,8 @@ export def main [ $guess_count += 1 if ($guess_count <= $max_count or $unlimited) { print $"(ansi xterm_aquamarine1a)Enter your guess (ansi reset)\((ansi green)($guess_count)(ansi reset)/(ansi yellow)(if ($unlimited) {inf} else {$max_count})(ansi reset)\)" - mut guess = (input | str downcase ) - if (((($words | where column0 =~ $guess) | length) >= 1) and ($guess | str length) == 5) { + let guess = (input | str downcase) + if ($guess | str length) == 5 and ($words | any {|w| $w == $guess}) { mut out = "" mut checked = $word for i in ($guess | split chars | enumerate) { @@ -44,8 +44,8 @@ export def main [ print $"(ansi xterm_green1 )You guessed right!(ansi reset)" } } else { - print "please enter a valid [5 letter] word!" - $guess_count -= 1 + print "please enter a valid [5 letter] word!" + $guess_count -= 1 } } else { print $"(ansi yellow )You loose, the word was: (ansi red)($word)(ansi reset)" From 016c066ba6da858facaded43708c647e1dd54f11 Mon Sep 17 00:00:00 2001 From: Jatinderjit Singh Date: Sun, 19 Apr 2026 01:33:52 +0530 Subject: [PATCH 3/3] Fix color for chars at correct position --- modules/fun/wordle.nu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fun/wordle.nu b/modules/fun/wordle.nu index ab0bed277..b924187b4 100644 --- a/modules/fun/wordle.nu +++ b/modules/fun/wordle.nu @@ -14,7 +14,7 @@ export def main [ } mut end = false mut guess_count = 0 - mut avail = "abcdefghijklmnopqrstuvyxwz" + mut avail = "abcdefghijklmnopqrstuvwxyz" while (not ($end)) { $guess_count += 1 if ($guess_count <= $max_count or $unlimited) { @@ -24,7 +24,7 @@ export def main [ mut out = "" mut checked = $word for i in ($guess | split chars | enumerate) { - if ($i.item == ($word | str substring ($i.index)..($i.index + 1)) ) { + if ($i.item == ($word | str substring ($i.index)..($i.index)) ) { $out += $"(ansi green_reverse)($i.item)(ansi reset)" $avail = ($avail | str replace $i.item $"(ansi green_reverse)($i.item)(ansi white_reverse)") $checked = ($checked | str replace $i.item "")