-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rust code for backtracking problems #79
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nikhilmitrax, thank you for writing the Rust solutions for the Backtracking chapter! Looks good overall, just a few comments for you to check.
@@ -0,0 +1,41 @@ | |||
pub fn combinations_of_sum_k(nums: Vec<i32>, target: i32) -> Vec<Vec<i32>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing rust solutions in the Sliding Windows chapter don't use pub fn
. If there is a reason to use pub fn
instead of fn
, please update the solutions in Sliding Windows. Otherwise, we can stick to fn
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe pub fn
makes more sense since the functions aren't really useful without having public visibility and being isolated in a file.
As is, the rust functions aren't particularly usable without a module setup and at least a project definition (Cargo.toml
)
I see 3 potential paths moving forward, and I'm perfectly fine with all 3 options, do you have a preference?
Options:
- Remove pub everywhere
- Add pub to all functions that should be usable outside a file.
- Add pub to all functions that should be usable outside a file, and add a Cargo.toml (possibly along with lib.rs and some tests, so that
cargo test
runs through the examples)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option 1 please!
Here is some background if you're interested: #54 (comment)
f3f21b2
to
8464870
Compare
Mainly porting the python algorithms, and trying to follow similar paradigm as the python code.
Mostly written by hand, albeit with AI autocomplete on.