X-Git-Url: https://git.llucax.com/z.facultad/75.29/susanita.git/blobdiff_plain/1670f4becf3b3f643d02235972937562c86b9a74..2b522532565096bddb79d9cdc34bb958e0c90797:/src/parser.cpp diff --git a/src/parser.cpp b/src/parser.cpp index 4bd29f1..b5fccb4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -115,3 +115,27 @@ output() const } } +/// Hack medio feo para obtener el N del problema +Susanita::size_type +Parser:: +get_n(const std::string& filename) +{ + std::ifstream f(filename.c_str()); + if (!f) + return 0; + std::string l; + if (!std::getline(f, l)) + return 0; + std::istringstream ss(strip(l)); + // descartamos el nombre + get_hasta(ss, ':'); + // contamos personas en la lista + Susanita::size_type count = 0; + while (ss) + { + if (!strip(get_hasta(ss, ',')).empty()) + ++count; + } + return count; +} +