Skip to content

Commit

Permalink
performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Kelley committed Jun 5, 2022
2 parents 1ef448e + 637b62e commit 51ace4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 1 addition & 5 deletions WordleArchive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ cmake_minimum_required (VERSION 3.8)
# Set the project name and version
project (WordleArchive VERSION 1.0)

if (CMAKE_VERSION VERSION_GREATER 3.12)
set (CMAKE_CXX_STANDARD 20)
else()
set (CMAKE_CXX_STANDARD 17)
endif()
set (CMAKE_CXX_STANDARD 17)

set (CMAKE_CXX_STANDARD_REQUIRED True)

Expand Down
6 changes: 3 additions & 3 deletions WordleArchive/WordleArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class WordlePlayer {
cout << " by Alex Kelley" << "\n\n";

cout << "This archive contains all Wordles, both past, present, and\n";
cout << "future. It goes from Day 0, June 19, 2021, to Day 2306,\n";
cout << "future. It goes from Day 0, June 19, 2021, to Day " << word_list.size() - 1 << ",\n";
cout << "October 12, 2027." << "\n\n";

cout << "If you'd like, you can create a custom word list by adding\n";
Expand Down Expand Up @@ -200,7 +200,7 @@ class WordlePlayer {
current_operation = quit;
return -1;
}
else if (word_number < 0 || word_number > 2306 || !cin.good()) {
else if (word_number < 0 || word_number > word_list.size() - 1 || !cin.good()) {
cout << "Invalid number, please try again." << endl;
if (!cin.good()) {
cin.clear();
Expand Down Expand Up @@ -753,7 +753,7 @@ class WordlePlayer {
playWordle();
break;
}
else if (current_word.number == 2306) {
else if (current_word.number == word_list.size() - 1) {
// there is no next word
cout << "You've just played the last Wordle. Go play outside!" << endl;
current_operation = home;
Expand Down
2 changes: 2 additions & 0 deletions WordleArchive/word_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class WordList {
return word_list_by_number.at(rand() % word_list_by_number.size());
}

inline size_t size() const { return word_list_by_number.size(); }

auto begin() { return word_list_by_number.begin(); }

auto end() { return word_list_by_number.end(); }
Expand Down

0 comments on commit 51ace4f

Please sign in to comment.