Skip to content
Permalink
Browse files

Sync with working copy

  • Loading branch information
metopa committed Dec 4, 2019
1 parent 7ebd807 commit 6867c6f520eac905df0e3a8200d4ba37ae8fb206
Showing with 229 additions and 2,293 deletions.
  1. +0 −3 CHANGELOG.md
  2. +1 −4 epi_judge_cpp/adding_credits.cc
  3. +10 −14 epi_judge_cpp/circular_queue.cc
  4. +4 −4 epi_judge_cpp/dutch_national_flag.cc
  5. +1 −4 epi_judge_cpp/lru_cache.cc
  6. +7 −7 epi_judge_cpp/pivot_list.cc
  7. +8 −12 epi_judge_cpp/queue_from_stacks.cc
  8. +10 −14 epi_judge_cpp/queue_with_max.cc
  9. +1 −4 epi_judge_cpp/run_length_compression.cc
  10. +2 −2 epi_judge_cpp/search_maze.cc
  11. +1 −5 epi_judge_cpp/stack_with_max.cc
  12. +6 −6 epi_judge_cpp/test_framework/fmt_print.h
  13. +10 −10 epi_judge_cpp/test_framework/generic_test.h
  14. +0 −365 epi_judge_cpp/test_framework/test_complexity.h
  15. +6 −6 epi_judge_cpp/test_framework/test_result.h
  16. +4 −4 epi_judge_cpp/test_framework/test_utils_console.h
  17. +1 −4 epi_judge_cpp_solutions/adding_credits.cc
  18. +1 −1 epi_judge_cpp_solutions/buy_and_sell_stock_twice.cc
  19. +10 −13 epi_judge_cpp_solutions/circular_queue.cc
  20. +7 −6 epi_judge_cpp_solutions/deadlock_detection.cc
  21. +4 −4 epi_judge_cpp_solutions/dutch_national_flag.cc
  22. +2 −2 epi_judge_cpp_solutions/kth_largest_element_in_long_array.cc
  23. +1 −4 epi_judge_cpp_solutions/lru_cache.cc
  24. +7 −7 epi_judge_cpp_solutions/pivot_list.cc
  25. +8 −11 epi_judge_cpp_solutions/queue_from_stacks.cc
  26. +10 −13 epi_judge_cpp_solutions/queue_with_max.cc
  27. +10 −13 epi_judge_cpp_solutions/queue_with_max_using_deque.cc
  28. +7 −5 epi_judge_cpp_solutions/real_square_root.cc
  29. +1 −4 epi_judge_cpp_solutions/run_length_compression.cc
  30. +4 −4 epi_judge_cpp_solutions/search_maze.cc
  31. +10 −6 epi_judge_cpp_solutions/sort_increasing_decreasing_array.cc
  32. +1 −4 epi_judge_cpp_solutions/stack_with_max.cc
  33. +6 −6 epi_judge_cpp_solutions/test_framework/fmt_print.h
  34. +10 −13 epi_judge_cpp_solutions/test_framework/generic_test.h
  35. +0 −365 epi_judge_cpp_solutions/test_framework/test_complexity.h
  36. +6 −6 epi_judge_cpp_solutions/test_framework/test_result.h
  37. +4 −4 epi_judge_cpp_solutions/test_framework/test_utils_console.h
  38. +0 −4 epi_judge_java/Makefile
  39. +0 −7 epi_judge_java/epi/AddingCredits.java
  40. +0 −7 epi_judge_java/epi/CircularQueue.java
  41. +0 −7 epi_judge_java/epi/LruCache.java
  42. +0 −6 epi_judge_java/epi/QueueFromStacks.java
  43. +0 −6 epi_judge_java/epi/RunLengthCompression.java
  44. +0 −6 epi_judge_java/epi/StackWithMax.java
  45. +0 −2 epi_judge_java/epi/test_framework/GenericTest.java
  46. +0 −348 epi_judge_java/epi/test_framework/TestComplexity.java
  47. +0 −4 epi_judge_java_solutions/Makefile
  48. +0 −7 epi_judge_java_solutions/epi/AddingCredits.java
  49. +2 −3 epi_judge_java_solutions/epi/BuyAndSellStockTwice.java
  50. +0 −7 epi_judge_java_solutions/epi/CircularQueue.java
  51. +3 −4 epi_judge_java_solutions/epi/KthLargestElementInLongArray.java
  52. +0 −7 epi_judge_java_solutions/epi/LruCache.java
  53. +0 −6 epi_judge_java_solutions/epi/QueueFromStacks.java
  54. +0 −7 epi_judge_java_solutions/epi/QueueWithMaxUsingDeque.java
  55. +0 −6 epi_judge_java_solutions/epi/RunLengthCompression.java
  56. +0 −6 epi_judge_java_solutions/epi/StackWithMax.java
  57. +0 −2 epi_judge_java_solutions/epi/test_framework/GenericTest.java
  58. +0 −348 epi_judge_java_solutions/epi/test_framework/TestComplexity.java
  59. +1 −6 epi_judge_python/adding_credits.py
  60. +1 −7 epi_judge_python/circular_queue.py
  61. +2 −8 epi_judge_python/lru_cache.py
  62. +1 −7 epi_judge_python/queue_from_stacks.py
  63. +1 −7 epi_judge_python/queue_with_max.py
  64. +1 −6 epi_judge_python/run_length_compression.py
  65. +1 −7 epi_judge_python/stack_with_max.py
  66. +0 −3 epi_judge_python/test_framework/generic_test.py
  67. +0 −205 epi_judge_python/test_framework/test_complexity.py
  68. +1 −6 epi_judge_python_solutions/adding_credits.py
  69. +1 −1 epi_judge_python_solutions/buy_and_sell_stock_twice.py
  70. +1 −7 epi_judge_python_solutions/circular_queue.py
  71. +1 −2 epi_judge_python_solutions/kth_largest_element_in_long_array.py
  72. +2 −8 epi_judge_python_solutions/lru_cache.py
  73. +1 −1 epi_judge_python_solutions/phone_number_mnemonic.py
  74. +1 −7 epi_judge_python_solutions/queue_from_stacks.py
  75. +1 −7 epi_judge_python_solutions/queue_with_max.py
  76. +1 −7 epi_judge_python_solutions/queue_with_max_using_deque.py
  77. +1 −6 epi_judge_python_solutions/run_length_compression.py
  78. +5 −3 epi_judge_python_solutions/smallest_subarray_covering_set.py
  79. +1 −7 epi_judge_python_solutions/stack_with_max.py
  80. +0 −3 epi_judge_python_solutions/test_framework/generic_test.py
  81. +0 −205 epi_judge_python_solutions/test_framework/test_complexity.py
  82. +18 −8 epijudge_ci_test_tool.py
@@ -9,9 +9,6 @@
## [Beta 5] - 2018-??-??

### Added
- Automatically determine solution asymptotic complexity
- Please, let us know if complexity analyzer produces strange results
- Some types of problems (like graph problems) are not yet supported
- Namespace for C++ test framework
- Python type hints

@@ -2,7 +2,6 @@

#include "test_framework/fmt_print.h"
#include "test_framework/generic_test.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
using std::string;

@@ -84,12 +83,10 @@ void ClientsCreditsInfoTester(const std::vector<Operation>& ops) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "adding_credits.cc", "adding_credits.tsv",
&ClientsCreditsInfoTester, DefaultComparator{},
param_names, &ProgramConfig);
param_names);
}
@@ -1,6 +1,5 @@
#include "test_framework/generic_test.h"
#include "test_framework/serialization_traits.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
class Queue {
public:
@@ -19,41 +18,41 @@ class Queue {
}
};
struct QueueOp {
enum { kConstruct, kDequeue, kEnqueue, kSize } op;
enum class Operation { kConstruct, kDequeue, kEnqueue, kSize } op;
int argument;

QueueOp(const std::string& op_string, int arg) : argument(arg) {
if (op_string == "Queue") {
op = kConstruct;
op = Operation::kConstruct;
} else if (op_string == "dequeue") {
op = kDequeue;
op = Operation::kDequeue;
} else if (op_string == "enqueue") {
op = kEnqueue;
op = Operation::kEnqueue;
} else if (op_string == "size") {
op = kSize;
op = Operation::kSize;
} else {
throw std::runtime_error("Unsupported queue operation: " + op_string);
}
}

void execute(Queue& q) const {
switch (op) {
case kConstruct:
case Operation::kConstruct:
// Hack to bypass deleted assign operator
q.~Queue();
new (&q) Queue(argument);
break;
case kDequeue: {
case Operation::kDequeue: {
int result = q.Dequeue();
if (result != argument) {
throw TestFailure("Dequeue: expected " + std::to_string(argument) +
", got " + std::to_string(result));
}
} break;
case kEnqueue:
case Operation::kEnqueue:
q.Enqueue(argument);
break;
case kSize: {
case Operation::kSize: {
int s = q.Size();
if (s != argument) {
throw TestFailure("Size: expected " + std::to_string(argument) +
@@ -76,12 +75,9 @@ void QueueTester(const std::vector<QueueOp>& ops) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "circular_queue.cc", "circular_queue.tsv",
&QueueTester, DefaultComparator{}, param_names,
&ProgramConfig);
&QueueTester, DefaultComparator{}, param_names);
}
@@ -5,7 +5,7 @@
#include "test_framework/test_failure.h"
#include "test_framework/timed_executor.h"
using std::vector;
using Color = enum { kRed, kWhite, kBlue };
enum class Color { kRed, kWhite, kBlue };

void DutchFlagPartition(int pivot_index, vector<Color>* A_ptr) {
// TODO - you fill in here.
@@ -26,17 +26,17 @@ void DutchFlagPartitionWrapper(TimedExecutor& executor, const vector<int>& A,

int i = 0;
while (i < colors.size() && colors[i] < pivot) {
count[colors[i]]--;
count[static_cast<int>(colors[i])]--;
++i;
}

while (i < colors.size() && colors[i] == pivot) {
count[colors[i]]--;
count[static_cast<int>(colors[i])]--;
++i;
}

while (i < colors.size() && colors[i] > pivot) {
count[colors[i]]--;
count[static_cast<int>(colors[i])]--;
++i;
}

@@ -2,7 +2,6 @@

#include "test_framework/generic_test.h"
#include "test_framework/serialization_traits.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"

class LruCache {
@@ -60,11 +59,9 @@ void LruCacheTester(const std::vector<Op>& commands) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"commands"};
return GenericTestMain(args, "lru_cache.cc", "lru_cache.tsv", &LruCacheTester,
DefaultComparator{}, param_names, &ProgramConfig);
DefaultComparator{}, param_names);
}
@@ -31,24 +31,24 @@ void ListPivotingWrapper(TimedExecutor& executor,
executor.Run([&] { return ListPivoting(l, x); });

std::vector<int> pivoted = ListToVector(pivoted_list);
enum { kLess, kEq, kGreater } mode = kLess;
enum class Mode { kLess, kEq, kGreater } mode = Mode::kLess;
for (auto& i : pivoted) {
switch (mode) {
case kLess:
case Mode::kLess:
if (i == x) {
mode = kEq;
mode = Mode::kEq;
} else if (i > x) {
mode = kGreater;
mode = Mode::kGreater;
}
break;
case kEq:
case Mode::kEq:
if (i < x) {
throw TestFailure("List is not pivoted");
} else if (i > x) {
mode = kGreater;
mode = Mode::kGreater;
}
break;
case kGreater:
case Mode::kGreater:
if (i <= x) {
throw TestFailure("List is not pivoted");
}
@@ -4,7 +4,6 @@

#include "test_framework/generic_test.h"
#include "test_framework/serialization_traits.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
using std::length_error;
class Queue {
@@ -19,16 +18,16 @@ class Queue {
}
};
struct QueueOp {
enum { kConstruct, kDequeue, kEnqueue } op;
enum class Operation { kConstruct, kDequeue, kEnqueue } op;
int argument;

QueueOp(const std::string& op_string, int arg) : argument(arg) {
if (op_string == "Queue") {
op = kConstruct;
op = Operation::kConstruct;
} else if (op_string == "dequeue") {
op = kDequeue;
op = Operation::kDequeue;
} else if (op_string == "enqueue") {
op = kEnqueue;
op = Operation::kEnqueue;
} else {
throw std::runtime_error("Unsupported queue operation: " + op_string);
}
@@ -45,17 +44,17 @@ void QueueTester(const std::vector<QueueOp>& ops) {
Queue q;
for (auto& x : ops) {
switch (x.op) {
case QueueOp::kConstruct:
case QueueOp::Operation::kConstruct:
break;
case QueueOp::kDequeue: {
case QueueOp::Operation::kDequeue: {
int result = q.Dequeue();
if (result != x.argument) {
throw TestFailure("Dequeue: expected " +
std::to_string(x.argument) + ", got " +
std::to_string(result));
}
} break;
case QueueOp::kEnqueue:
case QueueOp::Operation::kEnqueue:
q.Enqueue(x.argument);
break;
}
@@ -65,12 +64,9 @@ void QueueTester(const std::vector<QueueOp>& ops) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "queue_from_stacks.cc", "queue_from_stacks.tsv",
&QueueTester, DefaultComparator{}, param_names,
&ProgramConfig);
&QueueTester, DefaultComparator{}, param_names);
}
@@ -2,7 +2,6 @@

#include "test_framework/generic_test.h"
#include "test_framework/serialization_traits.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
using std::length_error;

@@ -22,18 +21,18 @@ class QueueWithMax {
}
};
struct QueueOp {
enum { kConstruct, kDequeue, kEnqueue, kMax } op;
enum class Operation { kConstruct, kDequeue, kEnqueue, kMax } op;
int argument;

QueueOp(const std::string& op_string, int arg) : argument(arg) {
if (op_string == "QueueWithMax") {
op = kConstruct;
op = Operation::kConstruct;
} else if (op_string == "dequeue") {
op = kDequeue;
op = Operation::kDequeue;
} else if (op_string == "enqueue") {
op = kEnqueue;
op = Operation::kEnqueue;
} else if (op_string == "max") {
op = kMax;
op = Operation::kMax;
} else {
throw std::runtime_error("Unsupported queue operation: " + op_string);
}
@@ -50,20 +49,20 @@ void QueueTester(const std::vector<QueueOp>& ops) {
QueueWithMax q;
for (auto& x : ops) {
switch (x.op) {
case QueueOp::kConstruct:
case QueueOp::Operation::kConstruct:
break;
case QueueOp::kDequeue: {
case QueueOp::Operation::kDequeue: {
int result = q.Dequeue();
if (result != x.argument) {
throw TestFailure("Dequeue: expected " +
std::to_string(x.argument) + ", got " +
std::to_string(result));
}
} break;
case QueueOp::kEnqueue:
case QueueOp::Operation::kEnqueue:
q.Enqueue(x.argument);
break;
case QueueOp::kMax: {
case QueueOp::Operation::kMax: {
int s = q.Max();
if (s != x.argument) {
throw TestFailure("Max: expected " + std::to_string(x.argument) +
@@ -77,12 +76,9 @@ void QueueTester(const std::vector<QueueOp>& ops) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "queue_with_max.cc", "queue_with_max.tsv",
&QueueTester, DefaultComparator{}, param_names,
&ProgramConfig);
&QueueTester, DefaultComparator{}, param_names);
}
@@ -1,7 +1,6 @@
#include <string>

#include "test_framework/generic_test.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
using std::string;
string Decoding(const string &s) {
@@ -21,12 +20,10 @@ void RleTester(const string &encoded, const string &decoded) {
}
}

void ProgramConfig(TestConfig &config) { config.analyze_complexity = false; }

int main(int argc, char *argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"encoded", "decoded"};
return GenericTestMain(args, "run_length_compression.cc",
"run_length_compression.tsv", &RleTester,
DefaultComparator{}, param_names, &ProgramConfig);
DefaultComparator{}, param_names);
}
@@ -7,7 +7,7 @@
#include "test_framework/test_failure.h"
#include "test_framework/timed_executor.h"
using std::vector;
using Color = enum { kWhite, kBlack };
enum class Color { kWhite, kBlack };
struct Coordinate {
bool operator==(const Coordinate& that) const {
return x == that.x && y == that.y;
@@ -47,7 +47,7 @@ struct SerializationTrait<Coordinate> : UserSerTrait<Coordinate, int, int> {
bool PathElementIsFeasible(const vector<vector<Color>>& maze,
const Coordinate& prev, const Coordinate& cur) {
if (!(0 <= cur.x && cur.x < maze.size() && 0 <= cur.y &&
cur.y < maze[cur.x].size() && maze[cur.x][cur.y] == kWhite)) {
cur.y < maze[cur.x].size() && maze[cur.x][cur.y] == Color::kWhite)) {
return false;
}
return cur == Coordinate{prev.x + 1, prev.y} ||
@@ -2,7 +2,6 @@

#include "test_framework/generic_test.h"
#include "test_framework/serialization_traits.h"
#include "test_framework/test_config.h"
#include "test_framework/test_failure.h"
using std::length_error;

@@ -70,12 +69,9 @@ void StackTester(const std::vector<StackOp>& ops) {
}
}

void ProgramConfig(TestConfig& config) { config.analyze_complexity = false; }

int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "stack_with_max.cc", "stack_with_max.tsv",
&StackTester, DefaultComparator{}, param_names,
&ProgramConfig);
&StackTester, DefaultComparator{}, param_names);
}

0 comments on commit 6867c6f

Please sign in to comment.
You can’t perform that action at this time.