All SolutionsAll Solutions
🕵️
The Secret Order
Week 3, 2026
python brute force approach | BMC | Python Solutions
# bmc's ideas below ---
# checking if each word is in ALPHABETICAL ORDER or not.
# since all of the BLUE words are, I decided to do the following:
# ALSO, we see that 'A' is NOT VALID but 'AAA' is valid. Which made me think that maybe the minimum length is 2?
# yeah and I did that and it worked, gamer god
def is_valid(word):
if len(word) < 2: return False
word_lower = word.lower()
sorted_version = ''.join(sorted(word_lower))
return sorted_version == word_lower
with open('words.txt', 'r') as f:
words = [line.strip().lower() for line in f if line.strip()]
valid_words = []
for word in words:
if is_valid(word):
valid_words.append(word)
with open('valid_words.txt', 'w') as f:
for word in valid_words:
f.write(word + '\n')
print(f"Found {len(valid_words)} valid words out of {len(words)}")
Python function & Procedure approach | rud | Python Solutions
def read_file(filename: str) -> list[str]:
try:
with open(filename, "r") as file:
return file.read().strip().split()
except IOError:
raise IOError(f"File {filename} could not be found")
def is_abecedarian(word: str) -> bool:
return list(word) == sorted(list(word))
def save_file(filename: str, words: list[str]) -> None:
with open(filename, 'w', encoding='utf-8') as file:
file.writelines(word + '\n' for word in words)
#Driver Code
words: list[str] = read_file("words.txt")
accepted_words = [word for word in words if is_abecedarian(word) and len(word) > 1]
save_file("answer.txt", accepted_words)
Word by word, rune by rune | greenya | Odin Solutions
// - use "odin run ." to run the code (append " >result.txt" for convenience)
// - words.txt should be nearby with the input data
package main
import "core:fmt"
import "core:strings"
words_txt_bytes := #load("words.txt")
main :: proc () {
words_txt_trimmed := strings.trim(string(words_txt_bytes), "\n\r\t ")
words := strings.split_lines(words_txt_trimmed)
valid: int
next: for w in words {
if len(w) < 2 do continue
for i in 1..<len(w) do if int(w[i-1]) > int(w[i]) do continue next
valid += 1
fmt.println(w)
}
fmt.println("--------------------------")
fmt.println("total words checked:", len(words))
fmt.println("total valid words :", valid)
}
Python function based approach | THOMAS L | Python Solutions
//Paste your solution here if you want to share it publ
def PrintWord(word: str):
prev = ord('a') - 1
for c in word.strip(" ").lower():
binary = ord(c)
if binary < prev:
return
prev = binary
if len(word) > 1:
print(word)
fileName = input()
with open(fileName, "r") as f:
content = f.read()
words = content.splitlines()
for word in words:
PrintWord(word)
loop dit.file thru parsing function - out to file | Draw6 | C++ Solutions
//Paste your solution here if you want to share it publicly
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include <fstream>
#include <errno.h>
#include <stdexcept>
using namespace std;
//-------------------------------------------
static bool isAbecedarian(string s)
{
int index = s.length() - 1;
for (int i = 0; i < index; i++)
{
if (s.at(i) <= s.at(i + 1))
{
return true;
} //Need to check if each letter for the whole word is less than the one before it
else
{
return false;
}
}
return true;
}
//-------------------------------------------
bool isAlphabeticOrderX(string s)
{
// array to store the
// count of each alphabet
int arr[26]={0};
int n = s.length();
if( n > 1)//skips single letter words
{
for(int i=0;i<n;i++)
{
arr[s[i]-'a']++;
}
int ind=0;
// Using the count array we will iterate
// in lexicographic order through each
// alphabet present and check if the
// string has element present in same
// order or not
for(int i=0;i<26;i++)
{
while(arr[i]--)
{
char c= char(97+i);
if(c!=s[ind])
{
return false;
}
else
{
ind++;
}
}
}
return true;
}
return false;
}
// -----------------------------main program
int main()
{
//-----------------------------------------------
cout << "Running program ...\n";
string line;
ifstream infile ("week3_dict.txt");// strings (pre-sorted)
ofstream outfile ("outfile.txt");//Abecedarian extraction (post-sorted)
if (infile.is_open())
{
while ( getline (infile,line) )
{
if(isAlphabeticOrderX(line))
{
if(isAbecedarian(line))
{
cout << line << "\n";
outfile << line << "\n";
}
}
}
outfile.close();
infile.close();
}
else cout << "Unable to open file";
cout << "\nExiting program ...\n";
fprintf(stderr,"GetLastError( &msg ) : %s\n", strerror(errno));
return 0;
}
python | Peiran D | Python Solutions
//Paste your solution here if you want to share it publiclywith open("word_list.txt", "r") as file:
for line in file:
word = line.strip()
if word:
w = word.lower()
is_ascending = True
for i in range(len(w) - 1):
if w[i] > w[i + 1]:
is_ascending = False
break
if is_ascending:
print(word)
The Secret Order PSEUDCODE SOLUTION | MarsKing | Pseudocode Solutions
FUNCTION ISALPHATIBCAL(text:STRING) RETURNS BOOLEAN
DECLARE charchters:ARRAY[1:LENGTH(text)] OF CHAR
DECLARE sorted:BOOLEAN
FOR Count ← 1 TO LENGTH(text)
charchters[Count] ← MID(text,Count,1)
NEXT Count
sorted ← TRUE
FOR Count ← 1 TO (LENGTH(text)-1)
IF ASC(charchters[Count]) > ASC(charchters[Count+1]) THEN
sorted ← FALSE
ENDIF
NEXT Count
IF LENGTH(text)= 1 THEN
sorted ← FALSE
ENDIF
RETURN sorted
ENDFUNCTION
DECLARE line:STRING
OPENFILE "AllWords.txt" FOR READ
WHILE NOT EOF("AllWords.txt")
READFILE "AllWords.txt", line
IF ISALPHATIBCAL(line) = TRUE THEN
OUTPUT line
ENDIF
ENDWHILE
CLOSEFILE "AllWords.txt"
Python easy solution | MushyZ | Python Solutions
# Function to check Abecedarian property
def is_abecedarian(word):
word = word.lower()
return len(word) > 1 and all(word[i] <= word[i+1] for i in range(len(word)-1))
# Read English words
with open("breakfun/english_words.txt", "r") as f:
words = [line.strip() for line in f if line.strip()]
# Filter Abecedarian words
abecedarian_words = [word for word in words if is_abecedarian(word)]
# Save to file, one word per line
with open("breakfun/abecedarian_words.txt", "w") as f:
for word in abecedarian_words:
f.write(word + "\n")
print(f"{len(abecedarian_words)} Abecedarian words found")