Skip to content

Commit

Permalink
Merge pull request #10 from theoforger/fix/whitespace
Browse files Browse the repository at this point in the history
Fix whitespace issues
  • Loading branch information
theoforger authored Sep 18, 2024
2 parents 47bec81 + 0af7d3e commit d1536e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 54 deletions.
36 changes: 15 additions & 21 deletions examples/avoid.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
lease
tooth
introduce
expect
disclose
sick
dry
merchant
skip
approval
taste
quantity
complete
sulphur
candidate
oh
formation
pier
accessible
angel
ski
captain
bass
boil
casino
star
ground
promise
fish
blind
day
tip
goldilocks
field
file
cotton
scarecrow
37 changes: 9 additions & 28 deletions examples/link.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
sketch
arrow
light
few
torch
haunt
blonde
penalty
skeleton
half
night
restrict
illusion
recommendation
cotton
meal
unanimous
berry
ghost
cereal
observation
teacher
warning
horse
wrap
promote
body
pain
bond
sound
park
penny
bee
tokyo
walrus
hospital
scuba diver
4 changes: 2 additions & 2 deletions src/api/chat_completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ I will give you a list of [agent word], followed by a list of [avoid word].
Try to link [agent word] together.
Tro to avoid [avoid word].
Answer in this format:
[clue word] [number of agent words] [agent word] [agent word] [agent word]
...
[clue word], [number of agent words], [agent word], [agent word], [agent word]
...
Here are the requirements:
- Always answer in lower case.
- No special characters.
Expand Down
9 changes: 6 additions & 3 deletions src/clue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pub struct ClueCollection {
impl Clue {
/// Create a new instance of `Clue` from a single line of clue responses from the API
pub fn new(clue_line: &str) -> Option<Self> {
let chunks: Vec<&str> = clue_line.split_whitespace().collect();
println!("{}", clue_line);
let chunks: Vec<&str> = clue_line.split(", ").collect();

// Discard empty lines as well as clues with only one word linked
if chunks.len() < 4 {
Expand Down Expand Up @@ -82,12 +83,14 @@ impl ClueCollection {
table.add_row(vec![
clue.clue_word.clone(),
clue.count.to_string(),
clue.linked_words.join(" "),
clue.linked_words.join(", "),
]);
}

// Center the second column
let second_column = table.column_mut(1).expect("The table has three columns");
let second_column = table
.column_mut(1)
.expect("The table should have three columns");
second_column.set_cell_alignment(CellAlignment::Center);

table.to_string()
Expand Down

0 comments on commit d1536e4

Please sign in to comment.