Git Product home page Git Product logo

epijudge's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epijudge's Issues

Plans for relaunch of EPI Online Judge ?

Hi,

This book, repo are amazing and helpful. Many Thanks for it. I recently stumbled across your website and found out that you earlier had an online judge and closed it due to issues. Are there any plans to rebuild and relaunch it ? I am interested to contribute and be a part of that team.

Incorrect solution for sort_almost_sorted_array.py

In the solution for sort_almost_sorted_array.py, we see this:

    result = []
    # For every new element, add it to min_heap and extract the smallest.
    for x in sequence:
        smallest = heapq.heappushpop(min_heap, x)
        result.append(smallest)

However, the first k elements were already added in the first for loop, and they are being inserted again. This means the output will actually duplicate the first k elements.

Running the given solution on input array [2,1,3,4,5] with k=2 confirms the bug, and gives output:
[1, 1, 2, 2, 3, 4, 5]

If I'm not mistaken, the second for loop should actually be:
for x in itertools.islice(sequence, k, None):

StopIteration leads to Critical error(RuntimeError): generator raised StopIteration [Python 3.7]

Hi !
As per PEP 0479 (https://www.python.org/dev/peps/pep-0479/) , there is a change in StopIteration handling inside generators.
Due to this, when we run tree_right_sibling.py (I haven't yet checked which other files are affected by this too, but it should be anywhere StopIteration is being used), it leads to a RunTime Error.
A quick solution is to just replace

raise StopIteration

with

return

The above solution is also mentioned on the PEP:

Here are some illustrations from the standard library.

Lib/ipaddress.py:

if other == self:
raise StopIteration
Becomes:

if other == self:
return

about one case of DoListsOverlab.java

Book P101 (7.5 DoListsOverlab.java ): need more explanation on why "if one list is cyclic, and the other one is not, they cannot overlap.". They can still overlap when the cyclic part appears earlier in one list and they can share the following part without the circle.

Question on 14.9

Q14.9 (DescendantAndAncestorInBst) asks us to determine if two given nodes are a proper ancestor and a proper descendant of the middle node. According to the explanation, if one of the two is equal to the middle, then it should return false because one of them is not a proper ancestor/descendant. One of the test cases is as follows:

Test FAILED (441/959) 
Arguments
	arg1:     ["18", "9", "29", "5", "14", "21", "34", "1", "null", "null", "17", "null", "25", "null", "35"]
	arg2:     17
	arg3:     9
	arg4:     9

Failure info
	expected: true
	result:   false

If I am not mistaken, the expected result should be false, because the third argument equal to the middle node (the forth argument). Did I misunderstand the question?

Suggestions from the author of another EPIJudge

Tsung-Hsien reached out to me over LinkedIn to ask for my comments on this repository after he learned that I had written this EPI judge for java. Here is some general feedback that I have for the current iteration of this project.

Pros

  • One less thing to install; I required maven to use my repo.
  • An abundance of test cases. Literally thousands of times as many as my repository contained and you have barely put a dent into the list of problems in the book.
  • Your tests run so much faster than mine did.
  • All the languages are supported using the same test cases. This is awesome for polyglots that know that cool array manipulation technique from Python3, but prefer working with the Collections library inside of Java for anything related to maps or hashes.
  • Works well and is easily navigable inside my IDE.

Cons

  • Let all the tests run and show failures at the end, or at least give the user the option to do so. A failing implementation will hard stop on the first failure, which isn't the best user experience especially if the test case is wrong.
  • I think it would be cleaner to have each chapter in its own folder. I went as far as using maven to make this a reality, because it makes the user experience for my repository inside of Intellij (or any IDE) very organized:
    maven-project
  • I attempted to debug using Intellij inside of your repo and couldn't get it to work. Maybe it's better if they can't debug, but I don't think thats a decision you should make for the user.
  • It's hard to debug your code when the only output is from a single failing test; perhaps it would be better to only have the tests fail after some user configurable value k tests failed. For example, if I find that I need to look at 5 test cases failing to get a grip on what I'm doing wrong it might be nice for me to be able to look at five failing tests for my implementation, but instead this repo locks you into only being able to see a single test at a time (and they are not even randomized!).
  • Adding to the above point: writing the test cases was very helpful for me to understand some of these problems, but since you've taken that away from people here they should have a nice UI to be able to look at the test cases rather than opening a .tsv file (and bonus points for seeing their implementation's incorrect answer).

Nice-to-Haves

  • A nice little touch I added to my repo was having each chapter in its own folder with a README.md that included checkboxes for all the tests that the user had completed. I think a nice touch for your repo would be an output file (probably markdown) that would dynamically change when users ran a test. Here is an example of what it would look like:
  • Strings []
    • BaseConversion [] [500/3456]
    • ReplaceAndRemove[x] [6001/6001]
  • Arrays [x]
    • BuySellStockOnce [x] [4003/4003]
    • BuySellStockTwice [x] [6700/6700]

This output can be saved inside of the /out folder that you already use and stored on the user's machine so they can always refer back to their current solved problems. If a user runs a single test it should add that result to the running list, but not wipe away any of their other stored data. This would help users get a better sense of where they stood overall. It could come with helpful metrics like the percentage of overall problems solved.

I talked in the pros section about polyglot programmers and you could even make the summary include which languages a user has solved problems in like so:

  • Strings []

    • BaseConversion [700/3456]
      • Java: [500/3456]
      • Python: [200/3456]
      • C++: [0/3456]
    • ReplaceAndRemove[x] [6001/6001]
      • Java: [5900/6001]
      • Python: [6001/6001]
      • C++: [0/6001]
  • Arrays [x]

    • BuySellStockOnce [x] [4003/4003]
      • Java: [0/4003]
      • Python: [0/4003]
      • C++: [4003/4003]
    • BuySellStockTwice [x] [6700/6700]
      • Java: [0/6700]
      • Python: [0/6700]
      • C++: [6700/6700]
  • Is it possible to pull the main function that is repeated over and over into an abstract class that then each test extends from? I attempted this, but the current implementation relies on using a java annotation—something I have only used and not implemented before. I'm imagining something like this:

/* AbstractTest.java */
public abstract class AbstractTest {
    abstract String getFile();
    abstract Class getImplementation();

    public static void main(String[] args) {
        GenericTestHandler.runTests(getFile(), getImplementation())
    }
}

/* SwapBits.java */
public class SwapBits extends AbstractTest {

  @Override
  public String getFile() {
    return "swap_bits.tsv";
  }

  @Override
  public Class getImplementation() {
    return this.getClass();
  }

  public static long swapBits(long x, int i, int j) {
    // Implement this placeholder.
    return 0;
  }
}

Next time I feel the need to study up on algorithms I will definitely prefer this repository over using my own!

two_sum test data (two_sum.tsv) incorrect expected values?

It looks like few of the test cases have incorrect expected bool values.

For example the 1st test case :
[6, -7, -3, 3, -3, 4, -5] 3 false TODO

There are two entries (of values 6 and -3) in the array which add upto the target 3. Still the expected value is false.

Apologies if my interpretation of the question was incorrect.

Adding question number prefix to file names?

Hello,
First of all I would like to say that this judge / practice system is great and really helpful! Thanks for that.
Just one suggestion. I am working with the book, and for every question I need to go to the mapping in the README in order to check which file is used for that question. I think it would be great to add a short prefix such as "q6_1_" for Question 6.1 in the book.
That way it will also be sorted nicely in the IDE and the mapping won't really be necessary.

Thanks!

Naming Mismatch: Problem 10.1

In the text problem 10.1 is called "Merge Sorted Files".
The testfile is called sorted_arrays_merge.cc.

The only way I found the file name was by peeking at the solution.

Guideline for submitting better solutions

Since the book is becoming more popular, I was wondering if there is a guideline for submitting simpler and cleaner solutions with better comments and explanations?
Also is there a to-do list of backlogs that we can contribute to?

is_list_cyclic solution explanation

According to the Tortoise and Hare's explanation, the tortoise should be moved to the beginning of linked list while keeping the hare at meeting place.
As a sample code, this can also be found here:

// If loop exists. Start slow from 
    // head and fast from meeting point. 
    slow = head; 
    while (slow != fast) { 
        slow = slow->next; 
        fast = fast->next; 
    } 

But looking at the solutions the approach seems to be different. Can anybody explain why it was solved this way?
I also found this link with no definite conclusion.

    fast = slow = head
    while fast and fast.next and fast.next.next:
        slow, fast = slow.next, fast.next.next
        if slow is fast:
            # Finds the start of the cycle.
            cycle_len_advanced_iter = head
            for _ in range(cycle_len(slow)):
                cycle_len_advanced_iter = cycle_len_advanced_iter.next

            it = head
            # Both iterators advance in tandem.
            while it is not cycle_len_advanced_iter:
                it = it.next
                cycle_len_advanced_iter = cycle_len_advanced_iter.next
            return it  # iter is the start of cycle.
    return None  # No cycle.

Can't Build C++ Tests From Command Line

I'm receiving errors when trying to build any of the test cases within a Windows environment that has the MinGW compiler. Running 'make' from command line and within code runner within VS Code both produce the same errors. The errors are below:

g++ -std=c++14 -pthread -Werror -Wno-unused-variable -Wno-sign-compare -g -O0 -o cpp_build/anagrams anagrams.cc
In file included from test_framework/test_utils.h:19,
                 from test_framework/generic_test_handler.h:12,
                 from test_framework/generic_test.h:13,
                 from anagrams.cc:3:
test_framework/platform.h: In function 'int platform::StdOutFd()':
test_framework/platform.h:35:10: error: '_fileno' was not declared in this scope
   return _fileno(stdout);
          ^~~~~~~
test_framework/platform.h:35:10: note: suggested alternative: '_filbuf'
   return _fileno(stdout);
          ^~~~~~~
          _filbuf
In file included from test_framework/generic_test_handler.h:15,
                 from test_framework/generic_test.h:13,
                 from anagrams.cc:3:
test_framework/timed_executor.h: In instantiation of 'decltype(auto) TimedExecutor::Run(Func) [with Func = InvokeWithExecutor(HasNoExecutorHookTag, Func&, TimedExecutor&, ArgsFwd&& ...) [with Func = std::vector<std::vector<std::__cxx11::basic_string<char> > > (* const)(const std::vector<std::__cxx11::basic_string<char> >&); ArgsFwd = {std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&}]::<lambda()>]':
test_framework/timed_executor.h:59:72:   required from 'decltype(auto) InvokeWithExecutor(HasNoExecutorHookTag, Func&, TimedExecutor&, ArgsFwd&& ...) [with Func = std::vector<std::vector<std::__cxx11::basic_string<char> > > (* const)(const std::vector<std::__cxx11::basic_string<char> >&); ArgsFwd = {std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&}]'
test_framework/generic_test_handler.h:205:30:   required from 'decltype(auto) GenericTestHandler<Function, Comparator>::Invoke(TimedExecutor&, ArgTuple&, std::index_sequence<I ...>) const [with ArgTuple = std::tuple<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >; unsigned int ...I = {0}; Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >); std::index_sequence<I ...> = std::integer_sequence<unsigned int, 0>]'
test_framework/generic_test_handler.h:177:10:   required from 'TestTimer GenericTestHandler<Function, Comparator>::ParseExpectedAndInvokeImpl(GenericTestHandler<Function, Comparator>::ExpectedIsValueTag, TimedExecutor&, const string&, ArgTuple&) const [with ArgTuple = std::tuple<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >; Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >); std::__cxx11::string = std::__cxx11::basic_string<char>]'
test_framework/generic_test_handler.h:163:64:   required from 'TestTimer GenericTestHandler<Function, Comparator>::ParseExpectedAndInvoke(TimedExecutor&, const string&, ArgTuple&) const [with ArgTuple = std::tuple<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >; Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >); std::__cxx11::string = std::__cxx11::basic_string<char>]'
test_framework/generic_test_handler.h:113:10:   required from 'TestOutput GenericTestHandler<Function, Comparator>::RunTest(const seconds&, const std::vector<std::__cxx11::basic_string<char> >&) const [with Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >); std::chrono::seconds = std::chrono::duration<long long int>]'
test_framework/generic_test.h:133:19:   required from 'TestResult RunTests(GenericTestHandler<Function, Comparator>&, const TestConfig&) [with Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >)]'
test_framework/generic_test.h:55:20:   required from 'TestResult GenericTestMain(const std::vector<std::__cxx11::basic_string<char> >&, const string&, const string&, Function, Comparator, const std::vector<std::__cxx11::basic_string<char> >&) [with Function = std::vector<std::vector<std::__cxx11::basic_string<char> > > (*)(const std::vector<std::__cxx11::basic_string<char> >&); Comparator = bool (*)(std::vector<std::vector<std::__cxx11::basic_string<char> > >, std::vector<std::vector<std::__cxx11::basic_string<char> > >); std::__cxx11::string = std::__cxx11::basic_string<char>]'
anagrams.cc:17:79:   required from here
test_framework/timed_executor.h:31:21: error: invalid use of incomplete type 'class std::future<std::vector<std::vector<std::__cxx11::basic_string<char> > > >'
           std::async(std::launch::async, [&] { return TimedCall(func); });
           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from test_framework/test_utils.h:7,
                 from test_framework/generic_test_handler.h:12,
                 from test_framework/generic_test.h:13,
                 from anagrams.cc:3:
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\future:125:11: note: declaration of 'class std::future<std::vector<std::vector<std::__cxx11::basic_string<char> > > >'
     class future;
           ^~~~~~
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\future: At global scope:
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\future:189:5: error: 'std::future<typename std::result_of<typename std::decay<_Tp>::type(typename std::decay<_Args>::type ...)>::type> std::async(std::launch, _Fn&&, _Args&& ...) [with _Fn = TimedExecutor::Run(Func) [with Func = InvokeWithExecutor(HasNoExecutorHookTag, Func&, TimedExecutor&, ArgsFwd&& ...) [with Func = std::vector<std::vector<std::__cxx11::basic_string<char> > > (* const)(const std::vector<std::__cxx11::basic_string<char> >&); ArgsFwd = {std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&}]::<lambda()>]::<lambda()>; _Args = {}; typename std::result_of<typename std::decay<_Tp>::type(typename std::decay<_Args>::type ...)>::type = std::vector<std::vector<std::__cxx11::basic_string<char> > >]', declared using local type 'TimedExecutor::Run(Func) [with Func = InvokeWithExecutor(HasNoExecutorHookTag, Func&, TimedExecutor&, ArgsFwd&& ...) [with Func = std::vector<std::vector<std::__cxx11::basic_string<char> > > (* const)(const std::vector<std::__cxx11::basic_string<char> >&); ArgsFwd = {std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&}]::<lambda()>]::<lambda()>', is used but never defined [-fpermissive]
     async(launch __policy, _Fn&& __fn, _Args&&... __args);
     ^~~~~
make: *** [cpp_build/anagrams] Error 1

As you can see it is very long. I tried to checkout the _fileno method and saw that it was a Windows specific method for C++. The function signature is logged in my intellisense however it registers as undefined. I tried the solution given in #47 , however when I removed the || CYWIN portion, I was given the following error instead:

platform.h:2:9: warning: #pragma once in main file
 #pragma once
         ^~~~
Program 'platform.exe' failed to run: The specified executable is not a valid application for this OS platform.At line:1 char:131
+ ... k\" ; if ($?) { g++ platform.h -o platform } ; if ($?) { .\platform }
+                                                              ~~~~~~~~~~.
At line:1 char:131
+ ... k\" ; if ($?) { g++ platform.h -o platform } ; if ($?) { .\platform }
+                                                              ~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

Any suggestions? Just bought this book and am getting started and am setting up my testing environment. Would love to get all of this up and running so I can dive into the book. Thanks!

Buy and sell stock once C++

My bad, you can close this issue, its the nature of Sublime text, in order to change context of which file you want to build you have to explicitly save that file. and the hit build.

Visual Studio 2017 release version no longer contains compilation bug

README.md states under What compilers are supported for judge? that

Visual Studio 2017 15.7.0 Preview 6
Release version of VS2017 contains a bug that makes it impossible to compile judge programs

Under 15.9.2 and 15.9.3 on my machine everything compiled just fine. It appears that a user can simply download the latest version of Visual Studio Community.

Perhaps README.md could be amended to simply warn users not to install 15.7.0 because of said bug.

Cannot run any test cases in IntelliJ

Hi,
I cannot run any test cases due to 3 errors in epi/test_framework.

  1. In ~/EPIJudge/epi_judge_java/epi/test_framework/GenericTestHandler.java the error is:
    Error:(67, 22) java: cannot find symbol
    symbol: method of(java.lang.reflect.Type[])
    location: interface java.util.List

  2. In ~/EPIJudge/epi_judge_java/epi/test_framework/TestUtils.java
    Error:(30, 22) java: cannot find symbol
    symbol: method of(java.lang.String[])
    location: interface java.util.List

  3. In ~/EPIJudge/epi_judge_java/epi/test_framework/serialization_traits/TraitsFactory.java
    Error:(21, 42) java: cannot infer type arguments for java.util.HashMap<K,V>
    reason: cannot use '<>' with anonymous inner classes

Please help me. Thanks.

Errors when using "make" command or the manual command line options to compile c++ solutions. Visual Studio can compile them just fine

Here are the errors I get for "make search_maze" for example:

mkdir -p cpp_build
g++ -std=c++17 -pthread -Werror -g -O0 -o cpp_build/search_maze search_maze.cc
In file included from test_framework/test_utils.h:19:0,
from test_framework/generic_test_handler.h:11,
from test_framework/generic_test.h:12,
from search_maze.cc:6:
test_framework/platform.h: In function ‘int platform::StdOutFd()’:
test_framework/platform.h:34:10: error: ‘_fileno’ was not declared in this scope
return _fileno(stdout);
^~~~~~~
test_framework/platform.h:34:10: note: suggested alternative: ‘__sfileno’
return _fileno(stdout);
^~~~~~~
__sfileno
test_framework/platform.h: In function ‘int platform::IsATty(int)’:
test_framework/platform.h:42:10: error: ‘_isatty’ was not declared in this scope
return _isatty(fd);
^~~~~~~
test_framework/platform.h: In function ‘bool platform::IsDir(const char*)’:
test_framework/platform.h:62:16: error: variable ‘platform::IsDir(const char*)::_stat buf’ has initializer but incomplete type
struct _stat buf {};
^~~
test_framework/platform.h:63:19: error: invalid use of incomplete type ‘struct platform::IsDir(const char*)::_stat’
_stat(path, &buf);
^
test_framework/platform.h:62:10: note: forward declaration of ‘struct platform::IsDir(const char*)::_stat’
struct stat buf {};
^~~~~
In file included from test_framework/test_failure.h:7:0,
from test_framework/test_utils.h:20,
from test_framework/generic_test_handler.h:11,
from test_framework/generic_test.h:12,
from search_maze.cc:6:
test_framework/any.h: At global scope:
test_framework/any.h:67:7: error: ‘Any’ has a field ‘Any::ptr
’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
class Any {
^~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:1707: cpp_build/search_maze] Error 1

Exception in thread "main" java.lang.RuntimeException: config.json file not found

After cloning the EpiJudge I'm getting the following error when running any of the java files:

Exception in thread "main" java.lang.RuntimeException: config.json file not found
at epi.test_framework.GenericTest.genericTestMain(GenericTest.java:36)
at epi.test_framework.GenericTest.runFromAnnotations(GenericTest.java:156)
at epi.BinomialCoefficients.main(BinomialCoefficients.java:16)

I'm using Eclipse and I followed the import process. I tried with Java 9.04 and 8.152. This is on the latest release of EpiJudge from 2018-03-27. The previous version from 2018-01-30 doesn't have this problem
clipboard01

Unclear data format to return in Hanoi problem

The 16.1 problem (The Tower of Hanoi)

In the book It is asked to print out all the moves. But in the java source code you expect to return List<List<Integer>>, which is misleading. I had to dig into computeTowerHanoiWrapper function to understand the data format.

Should there be a clarification that each list is a state of three pegs?

absent_value_array.cc, test 21/100 - wrong test?

The error output is as follows:

Test FAILED ( 21/100) [   2 ms]
Arguments
        stream:   [27, 714, 353, 523, 898, 692, 98, 586, 299, 831, 165, 934, 215, 904, 156, 654, 109, 819, 923, 801, 935, 320, 658, 853, 201, 233, 219, 224, 76, 562, 525, 178, 58, 413, 478, 512, 228, 565, 973, 748, 913, 408, 941, 265, 922, 270, 939, 387, 790, 136, 135, 817, 607, 31, 723, 592, 924, 120, 803, 116, 779, 169, 258, 652, 242, 877, 223, 124, 293, 371, 827, 938, 37, 842, 6, 253, 149, 847, 492, 322, 992, 429, 533, 90, 445, 373, 207, 465, 930, 423, 441, 949, 757, 953, 117, 264, 208, 308, 575, 508, 605, 251, 370, 173, 88, 400, 422, 859, 273, 328, 784, 184, 282, 661, 584, 680, 695, 401, 572, 295, 498, 443, 66, 227, 873, 567, 599, 179, 716, 278, 275, 835, 840, 405, 105, 122, 991, 933, 402, 882, 480, 444, 442, 874, 407, 648, 351, 256, 296, 238, 513, 526, 886, 261, 496, 110, 389, 420, 250, 335, 432, 10, 580, 781, 143, 60, 471, 244, 147, 180, 386, 472, 767, 969, 204, 963, 502, 314, 434, 915, 457, 633, 569, 518, 152, 22, 137, 825, 254, 546, 490, 376, 789, 730, 703, 130, 307, 909, 357, 132, 86, 310, 417, 805, 600, 699, 799, 174, 446, 193, 466, 313, 8, 956, 907, 739, 862, 123, 359, 484, 266, 530, 902, 461, 536, 235, 879, 141, 585, 100, 741, 171, 752, 594, 452, 188, 823, 778, 731, 210, 808, 164, 636, 26, 500, 855, 529, 392, 771, 226, 249, 627, 972, 284, 280, 766, 287, 561, 792, 78, 715, 708, 128, 375, 350, 470, 426, 428, 131, 787, 642, 921, 240, 822, 872, 896, 846, 418, 797, 5, 510, 43, 666, 996, 450, 57, 9, 998, 345, 337, 608, 102, 222, 816, 589, 365, 943, 725, 234, 414, 158, 791, 108, 170, 398, 501, 474, 928, 412, 755, 809, 24, 829, 974, 352, 486, 641, 532, 95, 674, 528, 954, 628, 449, 55, 21, 705, 286, 785, 676, 638, 870, 663, 183, 611, 884, 435, 268, 331, 32, 381, 153, 967, 259, 366, 121, 560, 794, 734, 845, 647, 485, 477, 305, 681, 73, 79, 302, 300, 950, 718, 203, 515, 694, 646, 65, 639, 671, 292, 754, 384, 759, 30, 597, 959, 828, 736, 700, 325, 439, 469, 69, 247, 717, 206, 51, 709, 404, 667, 798, 111, 768, 744, 181, 574, 221, 255, 390, 807, 900, 616, 776, 87, 702, 632, 377, 955, 230, 343, 625, 451, 957, 659, 999, 236, 707, 354, 19, 865, 657, 987, 49, 460, 71, 177, 849, 455, 760, 719, 951, 763, 634, 151, 737, 17, 99, 713, 269, 984, 762, 952, 537, 85, 506, 28, 848, 35, 383, 619, 388, 547, 598, 861, 303, 540, 683, 336, 368, 285, 160, 14, 166, 430, 612, 688, 436, 981, 406, 995, 756, 697, 542, 440, 643, 248, 13, 985, 220, 186, 637, 867, 989, 573, 202, 493, 411, 555, 288, 3, 20, 869, 618, 629, 796, 356, 926, 52, 391, 144, 347, 63, 304, 33, 624, 550, 276, 503, 769, 672, 986, 72, 197, 579, 686, 701, 968, 545, 554, 733, 107, 581, 39, 979, 4, 591, 142, 189, 685, 806, 459, 306, 74, 615, 664, 644, 283, 824, 534, 914, 851, 241, 814, 53, 660, 670, 881, 438, 139, 593, 750, 519, 698, 487, 727, 113, 257, 684, 114, 564, 103, 468, 742, 773, 358, 673, 483, 91, 566, 297, 106, 415, 385, 42, 623, 64, 38, 571, 944, 395, 743, 324, 199, 62, 475, 427, 761, 50, 327, 691, 326, 396, 175, 138, 917, 453, 155, 786, 54, 960, 577, 857, 888, 838, 187, 380, 289, 318, 448, 497, 669, 520, 272, 818, 885, 966, 609, 551, 892, 29, 965, 689, 231, 61, 876, 125, 891, 185, 994, 711, 309, 115, 504, 163, 36, 899, 93, 127, 919, 216, 945, 590, 780, 101, 908, 118, 606, 447, 844, 626, 603, 929, 34, 582, 897, 338, 596, 68, 983, 360, 329, 863, 655, 454, 677, 23, 903, 332, 245, 70, 330, 538, 172, 535, 795, 75, 394, 775, 409, 67, 980, 712, 858, 355, 421, 424, 47, 883, 94, 948, 527, 491, 878, 243, 544, 92, 630, 982, 548, 476, 764, 946, 557, 905, 871, 740, 617, 970, 783, 549, 811, 793, 927, 682, 651, 588, 80, 45, 578, 344, 25, 378, 232, 145, 631, 942, 812, 802, 729, 587, 48, 134, 918, 168, 167, 346, 294, 126, 44, 961, 552, 319, 517, 252, 482, 364, 315, 18, 710, 911, 843, 558, 133, 850, 333, 815, 568, 820, 724, 182, 640, 650, 813, 613, 893, 464, 749, 416, 868, 198, 800, 910, 830, 246, 211, 563, 83, 81, 425, 656, 393, 788, 890, 260, 489, 690, 906, 369, 990, 621, 522, 195, 323, 281, 653, 82, 821, 194, 576, 361, 56, 176, 511, 217, 964, 721, 15, 978, 866, 196, 601, 291, 205, 977, 602, 437, 488, 514, 839, 301, 212, 962, 521, 583, 372, 274, 958, 765, 920, 895, 841, 112, 745, 104, 726, 610, 334, 374, 720, 363, 89, 2, 556, 456, 832, 875, 321, 146, 916, 665, 397, 901, 860, 937, 728, 379, 706, 399, 947, 410, 804, 595, 140, 516, 382, 887, 509, 192, 997, 403, 975, 46, 747, 751, 988, 267, 704, 262, 1, 758, 993, 154, 458, 481, 837, 753, 209, 367, 263, 696, 693, 531, 553, 777, 668, 7, 463, 97, 218, 541, 662, 833, 976, 148, 738, 200, 854, 732, 41, 239, 279, 826, 774, 852, 277, 834, 16, 40, 864, 620, 431, 341, 746, 214, 810, 157, 129, 679, 912, 495, 348, 931, 467, 150, 604, 191, 349, 96, 543, 316, 433, 505, 925, 687, 524, 894, 190, 229, 159, 675, 645, 162, 419]

Failure info
        expected: 0
        result:   11

Average running time:    1 ms
Median running time:     1 ms
*** You've passed 20/100 tests. ***

But then if you copy that array into Python and sort it, the beginning of a sorted array is indeed [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 19, ..., so 11 is a right solution.

(Besides, the jump from "find absent" to "find the first positive absent value" is a bit surprising.)

5.17 (cpp) Sudoku checker fails with true != true

Test FAILED ( 35/745) [  14 us]
Arguments
        partial_assignment: [[0, 0, 0, 0, 0, 0, 0, 0, 0], [7, 0, 0, 5, 9, 8, 0, 2, 1], [0, 1, 0, 4, 0, 0, 9, 0, 3], [3, 0, 6, 7, 0, 0, 4, 0, 8], [8, 2, 0, 1, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 3, 0, 0, 0], [0, 8, 4, 3, 0, 7, 0, 5, 0], [6, 9, 0, 0, 0, 0, 2, 0, 0], [1, 3, 0, 0, 0, 2, 8, 0, 7]]

Failure info
        expected:           true
        result:             true

I suspect it's a valid error, and will report more - but it is utterly unreadable :)

Does anyone face Java compiler issues after import into IntelliJ?

Does anyone face Java compiler issues after import into IntelliJ?

/EPIJudge/epi_judge_java/epi/test_framework/GenericTestHandler.java
Error:(67, 22) java: cannot find symbol
symbol: method of(java.lang.reflect.Type[])
location: interface java.util.List

/EPIJudge/epi_judge_java/epi/test_framework/serialization_traits/TraitsFactory.java
Error:(21, 42) java: cannot infer type arguments for java.util.HashMap<K,V>
reason: cannot use '<>' with anonymous inner classes
Information:java: /Users/cpaladugula/code/EPIJudge/epi_judge_java/epi/test_framework/serialization_traits/TraitsFactory.java uses unchecked or unsafe operations.
Information:java: Recompile with -Xlint:unchecked for details.

/EPIJudge/epi_judge_java/epi/test_framework/TestUtils.java
Error:(30, 22) java: cannot find symbol
symbol: method of(java.lang.String[])
location: interface java.util.List

IntelliJ IDEA failed to execute tests

screen shot 2018-05-18 at 12 08 53

Not long ago, it was okay, until I upgraded to latest version of EPI Judge. Guess something in the test framework changed?

PS: it's ok to run the judge from the command line

Fix test case for descendant_and_ancestor_in_bst

The book says " A proper ancestor of a node is an ancestor that is not equal to the node; a proper descendant is defined similarly"
However in some test cases it is expected that the ancestor/descendent of middle to be same as middle. Is this correct behavior?

/Volumes/Data/EPIJudge/epi_judge_cpp/cmake-build-debug/descendant_and_ancestor_in_bst
Test FAILED (441/959)

Arguments
tree: ["18", "9", "29", "5", "14", "21", "34", "1", "null", "null", "17", "null", "25", "null", "35"]
possible_anc_or_desc_0: 17
possible_anc_or_desc_1: 9
middle: 9

Failure info
expected: true
result: false

int_as_array_increment.tsv dataset might miss negative number to verify plus 1 increment?

Hi,
As I'm coding for int_as_array_increment.cc I think the test cases are missing negative numbers for plus 1 increment.
The array is defined as vector theoretically there would be cases like <-1, 4 ,5> as number -145. To plus one it should produce -144. But if there is more than 2 '-' present in the data , the test case could be seem as invalid.

The test data so far doesn't seem to include those negative number cases.

bst_from_sorted_array test incorrect

The test checks for exact same level order traversal of the created BST. There could be several different minimal height trees with different level order traversals. What it needs to check is the height of the tree returned.

One example:

Arg 1: [-19, -17, -15, -12, -8, -7, -6, -5, -4, -1, 1, 2, 3, 4, 6, 7, 9, 12, 13, 17]
Expected: ["1", "-7", "7", "-15", "-4", "4", "13", "-17", "-8", "-5", "-1", "3", "6", "12", "17", "-19", null, "-12", null, "-6", null, null, null, "2", null, null, null, "9"]
Result:   ["-1", "-8", "6", "-17", "-6", "2", "12", "-19", "-15", "-7", "-5", "1", "3", "7", "13", null, null, null, "-12", null, null, null, "-4", null, null, null, "4", null, "9", null, "17"]

Both the constructed trees are of minimal height.

max_water_trappable.py fails on the book's solution

First, thanks for creating this. It's been very helpful for my personal interviewing studies!

After implementing both the book's solution and my solution, I've discovered that max_water_trappable.py fails for both. However, my solution agrees with the book's solution for the first test case.

Could there be some mistake with the test cases for this problem?

Test FAILED (   1/1001) [  25 us] 
	Arg 1: [0, 1, 2, 1, 3, 4, 4, 5, 1, 2, 0, 3, 1]
	Expected: 7
	Result:   30
	Explanation: Example in the book

The implementation the book gives is:

def calculate_trapping_water(heights):
    i, j, max_water = 0, len(heights) - 1, 0
    while i < j:
        width = j - 1
        max_water = max(max_water, width * min(heights[i], heights[j]))
        if heights[i] > heights[j]:
            j -= 1
        else:
            i += 1
    return max_water

Is Visual Studio 2015 not supported now?

I am unable to build due to errors in test framework:
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1>Build started 5/4/2018 9:42:43 AM.
1> 1>
1>PrepareForBuild:
1> Creating directory "C:\Users\v1a\epi\EPIJudge\epi_judge_cpp\vs\Debug".
1> Creating directory "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog".
1> InitializeBuildStatus:
1> Creating "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
1> CustomBuild:
1> Checking Build System
1> CMake does not need to re-run because C:/Users/v1a/epi/EPIJudge/epi_judge_cpp/vs/CMakeFiles/generate.stamp is up-to-date.
1> FinalizeBuildStatus:
1> Deleting file "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
1> Touching "Win32\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.14
2>------ Build started: Project: count_bits, Configuration: Debug Win32 ------
2>Build started 5/4/2018 9:42:43 AM.
2> 1>
2>PrepareForBuild:
2> Creating directory "count_bits.dir\Debug\count_bits.tlog".
2> InitializeBuildStatus:
2> Creating "count_bits.dir\Debug\count_bits.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
2> CustomBuild:
2> Building Custom Rule C:/Users/v1a/epi/EPIJudge/epi_judge_cpp/CMakeLists.txt
2> CMake does not need to re-run because C:/Users/v1a/epi/EPIJudge/epi_judge_cpp/vs/CMakeFiles/generate.stamp is up-to-date.
2> ClCompile:
2> count_bits.cc
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(68): error C3250: 'result': declaration is not allowed in 'constexpr' function body
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(18): note: see reference to function template instantiation 'int FirstFalseArg<>(bool)' being compiled
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(69): error C3256: 'result': variable use does not produce a constant expression
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(64): error C3259: 'constexpr' functions can only have one return statement
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(18): error C2131: expression did not evaluate to a constant
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(18): note: function violates 'constexpr' rules or has errors
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(18): note: see usage of 'FirstFalseArg'
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(19): error C2131: expression did not evaluate to a constant
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(19): note: function violates 'constexpr' rules or has errors
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(19): note: see usage of 'FirstFalseArg'
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(20): error C2131: expression did not evaluate to a constant
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(20): note: function violates 'constexpr' rules or has errors
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(20): note: see usage of 'FirstFalseArg'
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(21): error C2131: expression did not evaluate to a constant
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(21): note: function violates 'constexpr' rules or has errors
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(21): note: see usage of 'FirstFalseArg'
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(22): error C2131: expression did not evaluate to a constant
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(22): note: function violates 'constexpr' rules or has errors
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(22): note: see usage of 'FirstFalseArg'
2> 1>
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(495): error C2971: 'std::tuple_element': template parameter '_Index': '_Index': a variable with non-static storage duration cannot be used as a non-type argument
2> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(416): note: see declaration of 'std::tuple_element'
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(202): note: see declaration of '_Index'
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(202): note: see reference to class template instantiation 'tuple_element_t<default_valueAttribute,std::tuple<char,short,int,long>>' being compiled
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta.h(208): note: see reference to class template instantiation 'SubTuple<std::tuple<char,short,int,long>,0,4>::Impl<0,std::integer_sequencestd::_Ty,0,1,2,3>' being compiled
2> with
2> [
2> _Ty=std::size_t
2> ]
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(38): note: see reference to class template instantiation 'SubTuple<std::tuple<char,short,int,long>,0,4>' being compiled
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(32): note: see reference to class template instantiation 'FunctionalTraits<void (__cdecl *)(int,int)>' being compiled
2> c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(29): note: see reference to class template instantiation 'FunctionalTraits<void (__cdecl *)(TimedExecutor &,int)>' being compiled
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(40): error C2338:
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(55): error C2338:
2> 1>
2>c:\users\v1a\epi\epijudge\epi_judge_cpp\test_framework\test_utils_meta_test.h(59): error C2338:
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.97
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Amazing work!

Just a quick thank you. The EP Judge is Incredibly useful.

DeadlineDetection.java

Class GraphVertex is incomplete in EPIJudge/epi_judge_java/epi/DeadlockDetection.java

It is currently:

public static class GraphVertex {
    public List<GraphVertex> edges;
    public GraphVertex() { edges = new ArrayList<>(); }
  }

It should be:

  public static class GraphVertex {
    public enum Color { WHITE, GRAY, BLACK }
    public Color color;
    public List<GraphVertex> edges;
    public GraphVertex() {
      color = Color.WHITE;
      edges = new ArrayList<>();
    }
  }

Incorrect Expectation on Test (2/97) for problem 13.5 (Render a Calendar)

Input: [[1, 5], [2, 7], [4, 5], [6, 10], [8, 9], [9, 17], [11, 13], [12, 15], [14, 15], [9, 10]]
Expected: 4
Result: 3

This input is the same as the book's base case/example except it adds an event that runs from 9-10. However, this only bumps up the event count from 2 -> 3. The expectation for this case should be a 3 and the example code should be checked because it gives an incorrect answer for this problem. Love the book, hope this helps!

EDIT: The example code sorts by endpoints and computes the maximum number of events starting and ending at any certain hour. However, just because an event ends at 9 does not mean it should be counted as an "ongoing" event as there will still only be 3 events going on during the 9-10 hour.

Can't build cpp solution in Visual Studio 2017

So I followed the steps performed in the youtube video for setting up visual studio 2017 for cpp problems. But when I select "Start without debugging" I get this popup saying my project is out of date and asking whether I want to build them:
popup

When I select "Yes", I get this error:
attempt_to_build_count_bits

test cases

Where can I find the test cases for the problems?

Tree node display (binary_tree_to_string) incorrect

Current implementation of the code to convert a tree node to string in binary_tree_utils.py prints out the node data followed by right child and then left.

Conventionally the left child is always read out first. Easier while debugging.
In case we are following a different convention feel free to close this Issue and reject my pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.