Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the solidity challenges, instead of comparing the user's contract to the one expected, we could compile and test the user's contract in the frontend. That's the purpose of this pr.
Why
Comparing the user's contract as a string with an expected solution is not optimal because it assumes there is only one correct way to write the contract. However, in reality, there can be multiple valid solutions that meet the requirements. For example, in the first challenge, "Data types," both
bool myBool = true;
andbool public myBool = true;
are correct and fulfill the requirements, but a simple string comparison would only recognize one as valid.How
To address this, I implemented a solution that directly compiles and tests the user's contract in the frontend. By doing this, the code is evaluated based on its functionality and whether it meets the exercise's requirements, rather than its exact syntax or structure. This allows for more flexibility and correctness in determining valid solutions.
Note
Currently, I've only implemented this solution for few challenges as examples. However, the same process can be applied to all other exercises for consistent evaluation. Note that the remaining challenges will not work yet because I have not implemented this solution for them.
You can test this solution for the following challenges: