From 7eee5a78005a9a569186d2c8b4b645a818ab9bf1 Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev Date: Sun, 6 Oct 2024 07:04:44 -0400 Subject: Cleanup --- Seminar13/task02.cpp | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 Seminar13/task02.cpp (limited to 'Seminar13/task02.cpp') diff --git a/Seminar13/task02.cpp b/Seminar13/task02.cpp deleted file mode 100644 index 8d47b45..0000000 --- a/Seminar13/task02.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include -#include - -bool canRead(const std::multimap& graph, const std::string& word, size_t at) { - if(at == word.length() - 1) - return true; - - auto successors = graph.find(word[at]); // Може ли да си спестим това търсене? - - if(successors == graph.end()) - return false; - - while(successors != graph.end() && (*successors).first == word[at]) { - if((*successors).second == word[at + 1]) { - return canRead(graph, word, at + 1); - } - - ++successors; - } - - return false; -} - -int main() { - std::multimap graph; - - graph.insert({'a', 'c'}); - graph.insert({'a', 'd'}); - graph.insert({'c', 'b'}); - graph.insert({'b', 'd'}); - graph.insert({'d', 'k'}); - graph.insert({'d', 'c'}); - graph.insert({'d', 'a'}); - - std::map visited; - std::string word = "adaz"; - - std::cout << canRead(graph, word, 0); -} \ No newline at end of file -- cgit v1.3.1-26-gb76a