Permalink
Browse files

Code reformatting and fixes

  • Loading branch information...
metopa committed May 3, 2018
1 parent f7bef7d commit 7fada56de6f11f1d696c2d8b60131e4e04ca9d19
Showing with 802 additions and 1,047 deletions.
  1. +2 −0 .gitignore
  2. +6 −9 epi_judge_cpp/test_framework/any.h
  3. +6 −7 epi_judge_cpp/test_framework/binary_tree_utils.h
  4. +5 −7 epi_judge_cpp/test_framework/console_color.h
  5. +2 −4 epi_judge_cpp/test_framework/fmt_print.h
  6. +2 −3 epi_judge_cpp/test_framework/fmt_print_fwd.h
  7. +9 −12 epi_judge_cpp/test_framework/generic_test.h
  8. +6 −9 epi_judge_cpp/test_framework/generic_test_handler.h
  9. +10 −19 epi_judge_cpp/test_framework/json_parser.h
  10. +9 −12 epi_judge_cpp/test_framework/platform.h
  11. +5 −8 epi_judge_cpp/test_framework/random_sequence_checker.h
  12. +45 −74 epi_judge_cpp/test_framework/serialization_traits.h
  13. +5 −8 epi_judge_cpp/test_framework/test_config.h
  14. +3 −6 epi_judge_cpp/test_framework/test_failure.h
  15. +2 −3 epi_judge_cpp/test_framework/test_output.h
  16. +1 −1 epi_judge_cpp/test_framework/test_result.h
  17. +3 −5 epi_judge_cpp/test_framework/test_timer.h
  18. +5 −8 epi_judge_cpp/test_framework/test_utils.h
  19. +13 −15 epi_judge_cpp/test_framework/test_utils_console.h
  20. +10 −15 epi_judge_cpp/test_framework/test_utils_meta.h
  21. +4 −8 epi_judge_cpp/test_framework/timed_executor.h
  22. +3 −6 epi_judge_cpp/test_framework/timeout_exception.h
  23. +1 −1 epi_judge_cpp/test_framework/tri_bool.h
  24. +6 −9 epi_judge_cpp_solutions/test_framework/any.h
  25. +6 −7 epi_judge_cpp_solutions/test_framework/binary_tree_utils.h
  26. +5 −7 epi_judge_cpp_solutions/test_framework/console_color.h
  27. +2 −4 epi_judge_cpp_solutions/test_framework/fmt_print.h
  28. +2 −3 epi_judge_cpp_solutions/test_framework/fmt_print_fwd.h
  29. +9 −12 epi_judge_cpp_solutions/test_framework/generic_test.h
  30. +6 −9 epi_judge_cpp_solutions/test_framework/generic_test_handler.h
  31. +10 −19 epi_judge_cpp_solutions/test_framework/json_parser.h
  32. +9 −12 epi_judge_cpp_solutions/test_framework/platform.h
  33. +5 −8 epi_judge_cpp_solutions/test_framework/random_sequence_checker.h
  34. +45 −74 epi_judge_cpp_solutions/test_framework/serialization_traits.h
  35. +5 −8 epi_judge_cpp_solutions/test_framework/test_config.h
  36. +3 −6 epi_judge_cpp_solutions/test_framework/test_failure.h
  37. +2 −3 epi_judge_cpp_solutions/test_framework/test_output.h
  38. +1 −1 epi_judge_cpp_solutions/test_framework/test_result.h
  39. +3 −5 epi_judge_cpp_solutions/test_framework/test_timer.h
  40. +5 −8 epi_judge_cpp_solutions/test_framework/test_utils.h
  41. +13 −15 epi_judge_cpp_solutions/test_framework/test_utils_console.h
  42. +10 −15 epi_judge_cpp_solutions/test_framework/test_utils_meta.h
  43. +4 −8 epi_judge_cpp_solutions/test_framework/timed_executor.h
  44. +3 −6 epi_judge_cpp_solutions/test_framework/timeout_exception.h
  45. +1 −1 epi_judge_cpp_solutions/test_framework/tri_bool.h
  46. +1 −1 epi_judge_java/epi/test_framework/BinaryTreeUtils.java
  47. +23 −23 epi_judge_java/epi/test_framework/ConsoleColor.java
  48. +1 −1 epi_judge_java/epi/test_framework/EpiTest.java
  49. +1 −1 epi_judge_java/epi/test_framework/EpiTestComparator.java
  50. +1 −1 epi_judge_java/epi/test_framework/EpiTestExpectedType.java
  51. +1 −1 epi_judge_java/epi/test_framework/EpiUserType.java
  52. +8 −8 epi_judge_java/epi/test_framework/GenericTest.java
  53. +1 −1 epi_judge_java/epi/test_framework/GenericTestHandler.java
  54. +1 −1 epi_judge_java/epi/test_framework/LexicographicalListComparator.java
  55. +11 −11 epi_judge_java/epi/test_framework/Platform.java
  56. +10 −8 epi_judge_java/epi/test_framework/RandomSequenceChecker.java
  57. +29 −30 epi_judge_java/epi/test_framework/TestConfig.java
  58. +19 −19 epi_judge_java/epi/test_framework/TestFailure.java
  59. +1 −0 epi_judge_java/epi/test_framework/TestOutput.java
  60. +1 −1 epi_judge_java/epi/test_framework/TestResult.java
  61. +1 −1 epi_judge_java/epi/test_framework/TestTimer.java
  62. +1 −1 epi_judge_java/epi/test_framework/TestUtils.java
  63. +20 −20 epi_judge_java/epi/test_framework/TestUtilsConsole.java
  64. +1 −1 epi_judge_java/epi/test_framework/TimedExecutor.java
  65. +1 −1 epi_judge_java/epi/test_framework/TimeoutException.java
  66. +8 −8 epi_judge_java/epi/test_framework/TriBool.java
  67. +1 −1 epi_judge_java_solutions/epi/test_framework/BinaryTreeUtils.java
  68. +23 −23 epi_judge_java_solutions/epi/test_framework/ConsoleColor.java
  69. +1 −1 epi_judge_java_solutions/epi/test_framework/EpiTest.java
  70. +1 −1 epi_judge_java_solutions/epi/test_framework/EpiTestComparator.java
  71. +1 −1 epi_judge_java_solutions/epi/test_framework/EpiTestExpectedType.java
  72. +1 −1 epi_judge_java_solutions/epi/test_framework/EpiUserType.java
  73. +8 −8 epi_judge_java_solutions/epi/test_framework/GenericTest.java
  74. +1 −1 epi_judge_java_solutions/epi/test_framework/GenericTestHandler.java
  75. +1 −1 epi_judge_java_solutions/epi/test_framework/LexicographicalListComparator.java
  76. +11 −11 epi_judge_java_solutions/epi/test_framework/Platform.java
  77. +10 −8 epi_judge_java_solutions/epi/test_framework/RandomSequenceChecker.java
  78. +29 −30 epi_judge_java_solutions/epi/test_framework/TestConfig.java
  79. +19 −19 epi_judge_java_solutions/epi/test_framework/TestFailure.java
  80. +1 −0 epi_judge_java_solutions/epi/test_framework/TestOutput.java
  81. +1 −1 epi_judge_java_solutions/epi/test_framework/TestResult.java
  82. +1 −1 epi_judge_java_solutions/epi/test_framework/TestTimer.java
  83. +1 −1 epi_judge_java_solutions/epi/test_framework/TestUtils.java
  84. +20 −20 epi_judge_java_solutions/epi/test_framework/TestUtilsConsole.java
  85. +1 −1 epi_judge_java_solutions/epi/test_framework/TimedExecutor.java
  86. +1 −1 epi_judge_java_solutions/epi/test_framework/TimeoutException.java
  87. +8 −8 epi_judge_java_solutions/epi/test_framework/TriBool.java
  88. +4 −4 epi_judge_python/circular_queue.py
  89. +2 −2 epi_judge_python/hanoi.py
  90. +2 −2 epi_judge_python/lowest_common_ancestor.py
  91. +2 −2 epi_judge_python/lowest_common_ancestor_close_ancestor.py
  92. +2 −2 epi_judge_python/lowest_common_ancestor_in_bst.py
  93. +2 −2 epi_judge_python/lowest_common_ancestor_with_parent.py
  94. +4 −4 epi_judge_python/lru_cache.py
  95. +2 −2 epi_judge_python/queue_with_max.py
  96. +0 −64 epi_judge_python/queue_with_max_using_deque.py
  97. +2 −2 epi_judge_python/random_permutation.py
  98. +2 −0 epi_judge_python/range_lookup_in_bst.py
  99. +2 −2 epi_judge_python/road_network.py
  100. +2 −2 epi_judge_python/sorted_list_to_bst.py
  101. +6 −6 epi_judge_python/stack_with_max.py
  102. +2 −2 epi_judge_python/sudoku_solve.py
  103. +1 −1 epi_judge_python/test_framework/__init__.py
  104. +0 −1 epi_judge_python/test_framework/binary_tree_utils.py
  105. +8 −5 epi_judge_python/test_framework/console_color.py
  106. +6 −6 epi_judge_python/test_framework/generic_test.py
  107. +6 −4 epi_judge_python/test_framework/generic_test_handler.py
  108. +2 −3 epi_judge_python/test_framework/platform.py
  109. +0 −1 epi_judge_python/test_framework/random_sequence_checker.py
  110. +0 −1 epi_judge_python/test_framework/test_config.py
  111. +0 −1 epi_judge_python/test_framework/test_failure.py
  112. +0 −1 epi_judge_python/test_framework/test_result.py
  113. +0 −1 epi_judge_python/test_framework/test_timer.py
  114. +0 −1 epi_judge_python/test_framework/test_utils.py
  115. +7 −8 epi_judge_python/test_framework/test_utils_console.py
  116. +0 −1 epi_judge_python/test_framework/test_utils_deserialization.py
  117. +0 −1 epi_judge_python/test_framework/timed_executor.py
  118. +0 −1 epi_judge_python/test_framework/timeout_exception.py
  119. +0 −1 epi_judge_python/test_framework/tri_bool.py
  120. +1 −0 epi_judge_python_solutions/a_b_sqrt2.py
  121. +2 −2 epi_judge_python_solutions/absent_value_array.py
  122. +1 −0 epi_judge_python_solutions/adding_credits.py
  123. +2 −2 epi_judge_python_solutions/bonus.py
  124. +2 −3 epi_judge_python_solutions/calendar_rendering.py
  125. +4 −4 epi_judge_python_solutions/circular_queue.py
  126. +2 −2 epi_judge_python_solutions/count_inversions.py
  127. +3 −6 epi_judge_python_solutions/enumerate_balanced_parentheses.py
  128. +2 −1 epi_judge_python_solutions/enumerate_palindromic_decompositions.py
  129. +2 −2 epi_judge_python_solutions/enumerate_trees.py
  130. +4 −4 epi_judge_python_solutions/hanoi.py
  131. +2 −2 epi_judge_python_solutions/int_as_array_multiply.py
  132. +3 −4 epi_judge_python_solutions/is_string_palindromic_punctuation.py
  133. +4 −6 epi_judge_python_solutions/is_valid_sudoku.py
  134. +4 −4 epi_judge_python_solutions/k_largest_in_heap.py
  135. +4 −2 epi_judge_python_solutions/line_through_most_points.py
  136. +2 −2 epi_judge_python_solutions/lowest_common_ancestor.py
  137. +2 −2 epi_judge_python_solutions/lowest_common_ancestor_close_ancestor.py
  138. +2 −2 epi_judge_python_solutions/lowest_common_ancestor_in_bst.py
  139. +2 −2 epi_judge_python_solutions/lowest_common_ancestor_with_parent.py
  140. +4 −4 epi_judge_python_solutions/lru_cache.py
  141. +4 −3 epi_judge_python_solutions/matrix_enclosed_regions.py
  142. +2 −1 epi_judge_python_solutions/max_of_sliding_window.py
  143. +2 −2 epi_judge_python_solutions/maximum_subarray_in_circular_array.py
  144. +1 −0 epi_judge_python_solutions/minimum_distance_3_sorted_arrays.py
  145. +4 −3 epi_judge_python_solutions/minimum_weight_path_in_a_triangle.py
  146. +2 −1 epi_judge_python_solutions/number_of_traversals_staircase.py
  147. +3 −5 epi_judge_python_solutions/phone_number_mnemonic.py
  148. +6 −7 epi_judge_python_solutions/picking_up_coins.py
  149. +2 −2 epi_judge_python_solutions/queue_with_max.py
  150. +2 −2 epi_judge_python_solutions/queue_with_max_using_deque.py
  151. +2 −2 epi_judge_python_solutions/random_permutation.py
  152. +1 −2 epi_judge_python_solutions/rectangle_intersection.py
  153. +2 −2 epi_judge_python_solutions/road_network.py
  154. +2 −2 epi_judge_python_solutions/search_for_missing_element.py
  155. +2 −2 epi_judge_python_solutions/search_maze.py
  156. +2 −2 epi_judge_python_solutions/smallest_nonconstructible_value.py
  157. +2 −2 epi_judge_python_solutions/sorted_list_to_bst.py
  158. +8 −8 epi_judge_python_solutions/stack_with_max.py
  159. +2 −2 epi_judge_python_solutions/string_transformability.py
  160. +2 −2 epi_judge_python_solutions/sudoku_solve.py
  161. +2 −2 epi_judge_python_solutions/sum_root_to_leaf.py
  162. +1 −1 epi_judge_python_solutions/test_framework/__init__.py
  163. +0 −1 epi_judge_python_solutions/test_framework/binary_tree_utils.py
  164. +8 −5 epi_judge_python_solutions/test_framework/console_color.py
  165. +6 −6 epi_judge_python_solutions/test_framework/generic_test.py
  166. +6 −4 epi_judge_python_solutions/test_framework/generic_test_handler.py
  167. +2 −3 epi_judge_python_solutions/test_framework/platform.py
  168. +0 −1 epi_judge_python_solutions/test_framework/random_sequence_checker.py
  169. +0 −1 epi_judge_python_solutions/test_framework/test_config.py
  170. +0 −1 epi_judge_python_solutions/test_framework/test_failure.py
  171. +0 −1 epi_judge_python_solutions/test_framework/test_result.py
  172. +0 −1 epi_judge_python_solutions/test_framework/test_timer.py
  173. +0 −1 epi_judge_python_solutions/test_framework/test_utils.py
  174. +7 −8 epi_judge_python_solutions/test_framework/test_utils_console.py
  175. +0 −1 epi_judge_python_solutions/test_framework/test_utils_deserialization.py
  176. +0 −1 epi_judge_python_solutions/test_framework/timed_executor.py
  177. +0 −1 epi_judge_python_solutions/test_framework/timeout_exception.py
  178. +0 −1 epi_judge_python_solutions/test_framework/tri_bool.py
  179. +1 −2 epi_judge_python_solutions/tree_from_preorder_inorder.py
  180. +2 −3 epi_judge_python_solutions/tree_level_order.py
@@ -20,3 +20,5 @@ __pycache__/
# Generated by make
cpp_build
epi_judge_java/java_build/
@@ -1,13 +1,11 @@
// @library
#pragma once
#include <memory>
#include <typeindex>
#include <utility>
#include "fmt_print.h"
#include "test_utils_meta.h"
#include "serialization_traits.h"
#include "test_utils_meta.h"
#pragma once
namespace any {
class AnyBase {
@@ -31,7 +29,8 @@ class AnyBase {
const T& Cast() const {
const T* ptr = TryCast<T>();
if (!ptr) {
throw std::runtime_error(FmtStr("Any: expected type {}, got {}", TypeName(), typeid(T).name()));
throw std::runtime_error(FmtStr("Any: expected type {}, got {}",
TypeName(), typeid(T).name()));
}
return *ptr;
}
@@ -47,9 +46,7 @@ class AnySpecialization : public AnyBase {
explicit AnySpecialization(FwdT&& value)
: value_(std::forward<FwdT>(value)) {}
std::type_index Typeid() const override {
return std::type_index(typeid(T));
}
std::type_index Typeid() const override { return std::type_index(typeid(T)); }
std::string TypeName() const override { return typeid(T).name(); }
@@ -1,15 +1,14 @@
// @library
#pragma once
#include <algorithm>
#include <memory>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <string>
#include <unordered_set>
#include <vector>
#include "fmt_print_fwd.h"
#include "serialization_traits.h"
#pragma once
template <typename Node, typename T>
void TreeGenerateHelper(const Node& tree, std::vector<T>* result, int order) {
@@ -144,8 +143,8 @@ int BinaryTreeHeight(const Node& tree) {
if (!tree) {
return -1;
}
return 1 + std::max(BinaryTreeHeight(tree->left),
BinaryTreeHeight(tree->right));
return 1 +
std::max(BinaryTreeHeight(tree->left), BinaryTreeHeight(tree->right));
}
template <typename Node>
@@ -1,16 +1,14 @@
// @library
#pragma once
#include <functional>
#include <iostream>
#ifdef PLATFORM_WIN
#define NOMINMAX
#include <Windows.h>
#endif
#include "platform.h"
#pragma once
#ifdef PLATFORM_WIN
#endif
namespace console_color {
enum class ConsoleColor { FG_RED, FG_GREEN, FG_BLUE, FG_YELLOW, FG_DEFAULT };
@@ -1,13 +1,11 @@
// @library
#pragma once
#include <ostream>
#include <string>
#include <tuple>
#include "fmt_print_fwd.h"
#include "serialization_traits.h"
#pragma once
namespace detail {
template <typename T>
void PrintToImpl(std::ostream& out, const T& x, HasOStreamOpTag) {
@@ -1,8 +1,7 @@
// @library
#pragma once
#include <iosfwd>
#pragma once
template <typename T>
std::ostream& PrintTo(std::ostream& out, const T& x);
@@ -1,14 +1,10 @@
// @library
#pragma once
#include <chrono>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
#include "fmt_print.h"
#include "generic_test_handler.h"
#include "json_parser.h"
@@ -17,6 +13,8 @@
#include "test_timer.h"
#include "test_utils.h"
#pragma once
template <typename Function, typename Comparator>
TestResult RunTests(GenericTestHandler<Function, Comparator>& handler,
const TestConfig& config);
@@ -50,8 +48,8 @@ TestResult GenericTestMain(const std::vector<std::string>& commandline_args,
platform::SetOutputOpts(config.tty_mode, config.color_mode);
GenericTestHandler<Function, Comparator> test_handler(
test_func, comparator, param_names);
GenericTestHandler<Function, Comparator> test_handler(test_func, comparator,
param_names);
return RunTests(test_handler, config);
} catch (std::runtime_error& e) {
std::cerr << std::endl << "Critical error: " << e.what() << std::endl;
@@ -68,8 +66,8 @@ void UpdateTestPassed(std::string test_file, int tests_passed) {
std::string err;
std::string js_file_str = buffer.str();
const std::string kJsBeginPattern = "run(";
js_file_str.replace(js_file_str.find(kJsBeginPattern),
kJsBeginPattern.size(), "");
js_file_str.replace(js_file_str.find(kJsBeginPattern), kJsBeginPattern.size(),
"");
const std::string kJsEndPattern = ");";
js_file_str.replace(js_file_str.find(kJsEndPattern), kJsEndPattern.size(),
"");
@@ -85,16 +83,15 @@ void UpdateTestPassed(std::string test_file, int tests_passed) {
for (const auto& language : problem.second.object_items()) {
if (test_file == language.first) {
const std::string format = "\"{}\": {{\"passed\": {},";
const std::string pattern = FmtStr(
format, test_file, language.second["passed"].int_value());
const std::string pattern =
FmtStr(format, test_file, language.second["passed"].int_value());
const std::string replacement =
FmtStr(format, test_file, tests_passed);
serialized_problem_mapping.replace(
serialized_problem_mapping.find(pattern), pattern.size(),
replacement);
std::ofstream ofs(problem_mapping_file_path);
ofs << kJsBeginPattern << serialized_problem_mapping
<< kJsEndPattern;
ofs << kJsBeginPattern << serialized_problem_mapping << kJsEndPattern;
ofs.close();
return;
}
@@ -1,19 +1,17 @@
// @library
#pragma once
#include <iterator>
#include <numeric>
#include <regex>
#include <string>
#include <tuple>
#include <vector>
#include "serialization_traits.h"
#include "test_output.h"
#include "test_utils.h"
#include "test_utils_meta.h"
#include "serialization_traits.h"
#include "timed_executor.h"
#pragma once
/**
* The central class in generic test runner framework.
* It is responsible for asserting that the function signature matches
@@ -66,8 +64,7 @@ class GenericTestHandler {
const std::vector<std::string>& param_names)
: func_(func), comp_(comp), param_names_(param_names) {
if (func_traits::HasExecutorHook()) {
param_names_.erase(
param_names_.begin()); // Remove "executor" parameter
param_names_.erase(param_names_.begin()); // Remove "executor" parameter
}
}
@@ -202,8 +199,8 @@ class GenericTestHandler {
template <typename ArgTuple, std::size_t... I>
decltype(auto) Invoke(TimedExecutor& executor, ArgTuple& args,
std::index_sequence<I...> /*unused*/) const {
return InvokeWithExecutor(typename func_traits::executor_hook_tag(),
func_, executor, std::get<I>(args)...);
return InvokeWithExecutor(typename func_traits::executor_hook_tag(), func_,
executor, std::get<I>(args)...);
};
template <typename T, typename U>
@@ -1,6 +1,3 @@
// @library
#pragma once
#include <cassert>
#include <cinttypes>
#include <cmath>
@@ -13,15 +10,17 @@
#include <memory>
#include <string>
#include <vector>
#define noexcept throw()
#define snprintf _snprintf_s
#pragma once
#ifdef _MSC_VER
#if _MSC_VER <= 1800 // VS 2013
#ifndef noexcept
#define noexcept throw()
#endif
#ifndef snprintf
#define snprintf _snprintf_s
#endif
#endif
#endif
@@ -426,8 +425,7 @@ Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {}
Json::Json(const string &value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(string &&value) : m_ptr(make_shared<JsonString>(move(value))) {}
Json::Json(const char *value) : m_ptr(make_shared<JsonString>(value)) {}
Json::Json(const Json::array &values)
: m_ptr(make_shared<JsonArray>(values)) {}
Json::Json(const Json::array &values) : m_ptr(make_shared<JsonArray>(values)) {}
Json::Json(Json::array &&values)
: m_ptr(make_shared<JsonArray>(move(values))) {}
Json::Json(const Json::object &values)
@@ -449,16 +447,12 @@ const map<string, Json> &Json::object_items() const {
return m_ptr->object_items();
}
const Json &Json::operator[](size_t i) const { return (*m_ptr)[i]; }
const Json &Json::operator[](const string &key) const {
return (*m_ptr)[key];
}
const Json &Json::operator[](const string &key) const { return (*m_ptr)[key]; }
double JsonValue::number_value() const { return 0; }
int64_t JsonValue::int_value() const { return 0; }
bool JsonValue::bool_value() const { return false; }
const string &JsonValue::string_value() const {
return statics().empty_string;
}
const string &JsonValue::string_value() const { return statics().empty_string; }
const vector<Json> &JsonValue::array_items() const {
return statics().empty_vector;
}
@@ -553,8 +547,7 @@ struct JsonParser final {
* Advance until the current character is non-whitespace.
*/
void consume_whitespace() {
while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' ||
str[i] == '\t')
while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t')
i++;
}
@@ -657,8 +650,7 @@ struct JsonParser final {
string out;
long last_escaped_codepoint = -1;
while (true) {
if (i == str.size())
return fail("unexpected end of input in string", "");
if (i == str.size()) return fail("unexpected end of input in string", "");
char ch = str[i++];
@@ -679,8 +671,7 @@ struct JsonParser final {
}
// Handle escapes
if (i == str.size())
return fail("unexpected end of input in string", "");
if (i == str.size()) return fail("unexpected end of input in string", "");
ch = str[i++];
@@ -1,4 +1,12 @@
// @library
#define PLATFORM_WIN
#include <io.h>
#include <sys/stat.h>
#include <sys/types.h> //must precede sys/stat.h
#include <unistd.h>
#include <cstdio>
#include <iostream>
#include "tri_bool.h"
#pragma once
/**
@@ -7,23 +15,12 @@
*/
#if _WINDOWS || __MINGW__ || __CYGWIN__
#define PLATFORM_WIN
#endif
#include <iostream>
#ifdef PLATFORM_WIN
#include <io.h>
#include <sys/stat.h>
#include <sys/types.h> //must precede sys/stat.h
#include <cstdio>
#else // UNIX
#include <sys/stat.h>
#include <unistd.h>
#endif
#include "tri_bool.h"
namespace platform {
bool ENABLE_TTY_OUTPUT = false;
@@ -1,6 +1,3 @@
// @library
#pragma once
#include <algorithm>
#include <array>
#include <cmath>
@@ -11,9 +8,10 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "test_failure.h"
#pragma once
int ComputeDeviationMultiplier(double allowed_false_negative, int num_rvs) {
const double individual_rv_error = allowed_false_negative / num_rvs;
std::array<double, 7> kErrorBounds = {
@@ -53,8 +51,7 @@ bool CheckFrequencies(const std::vector<int>& seq, int n,
// roughly we mean the difference is less than k_sigma.
return std::all_of(std::begin(indiv_freqs), std::end(indiv_freqs),
[avg, k_sigma_indiv](const auto& key_freq) {
return std::abs(avg - key_freq.second) <=
k_sigma_indiv;
return std::abs(avg - key_freq.second) <= k_sigma_indiv;
});
}
@@ -127,8 +124,8 @@ int BinomialCoefficient(int n, int k) {
// Get the mth combination in lexicographical order from A (n elements) chosen
// k at a time.
std::vector<int> ComputeCombinationIdx(const std::vector<int>& A, int n,
int k, int m) {
std::vector<int> ComputeCombinationIdx(const std::vector<int>& A, int n, int k,
int m) {
std::vector<int> comb;
int a = n, b = k, x = (BinomialCoefficient(n, k) - 1) - m;
for (int i = 0; i < k; ++i) {
Oops, something went wrong.

0 comments on commit 7fada56

Please sign in to comment.