From 5e202ccf668935f5aecab98856f430ff2a83598d Mon Sep 17 00:00:00 2001 From: theoforger Date: Wed, 18 Sep 2024 11:41:34 -0400 Subject: [PATCH 1/2] Change delimiter to `,` --- examples/avoid.txt | 36 +++++++++++++++--------------------- examples/link.txt | 37 +++++++++---------------------------- src/api/chat_completions.rs | 4 ++-- src/clue.rs | 3 ++- 4 files changed, 28 insertions(+), 52 deletions(-) diff --git a/examples/avoid.txt b/examples/avoid.txt index 94f5904..24b4ec2 100644 --- a/examples/avoid.txt +++ b/examples/avoid.txt @@ -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 \ No newline at end of file +fish +blind +day +tip +goldilocks +field +file +cotton +scarecrow \ No newline at end of file diff --git a/examples/link.txt b/examples/link.txt index 36cbaaf..f164e81 100644 --- a/examples/link.txt +++ b/examples/link.txt @@ -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 \ No newline at end of file +bond +sound +park +penny +bee +tokyo +walrus +hospital +scuba diver \ No newline at end of file diff --git a/src/api/chat_completions.rs b/src/api/chat_completions.rs index 1737f32..c11f40f 100644 --- a/src/api/chat_completions.rs +++ b/src/api/chat_completions.rs @@ -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. diff --git a/src/clue.rs b/src/clue.rs index 6d4f08e..1c090ee 100644 --- a/src/clue.rs +++ b/src/clue.rs @@ -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 { - 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 { From 0af7d3eb8f0a03a0621632c98336a696c1b2ca41 Mon Sep 17 00:00:00 2001 From: theoforger Date: Wed, 18 Sep 2024 11:43:55 -0400 Subject: [PATCH 2/2] Add delimiter to output --- src/clue.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clue.rs b/src/clue.rs index 1c090ee..aafd3ae 100644 --- a/src/clue.rs +++ b/src/clue.rs @@ -83,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()