rust-practice / cargo-leet

Program to make working on leetcode problems locally more convenient
Apache License 2.0
5 stars 3 forks source link

Fails to generate code for problem #40

Closed c-git closed 1 year ago

c-git commented 1 year ago

Describe the bug When command is run instead of code being generated an error is received

Leetcode problem https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/

To Reproduce cargo leet gen https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/`

Error Message

Error: Failed to generate the name and module code

Caused by:
    0: Failed to get test cases for non-design problem
    1: Failed to convert downloaded test case into macro of input
    2: Failed to apply type information to the example from leetcode
    3: Expecting something that can be represented as a vec but got '5'

Expected behavior

N/A

Environment Info:

Additional context

N/A

c-git commented 1 year ago

Upon investigation it turns out they are passing a node of the actual tree as the 2nd argument. However in the sample input they only show the value of the node and hence the types do not match. This cannot be fixed and must be handled specially for this problem and thus will not fix. To work around this we've added support for input that doesn't match the type. The input just gets wrapped in a todo!()