Skip to content
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

Finished task025 #16

Merged
merged 7 commits into from
Oct 1, 2024
Merged

Finished task025 #16

merged 7 commits into from
Oct 1, 2024

Conversation

amarshah1
Copy link
Contributor

@amarshah1 amarshah1 commented Sep 26, 2024

Finished task 025. I have not run verusfmt yet, will wait for your ok so that you can see the changes.

Specification uses Seq instead of Seq. This is to avoid the sequence conversion issue we discussed on Slack. Happy to discuss further!

Copy link
Contributor

@parno parno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on Task 25! I've added some comments. Also, your PR seems to include changes to Task 15, but I think that may be due to your branch being out of date with main, since those changes already landed, right?


pub fn factorize(n: u8) -> (factorization: Vec<u8>)
requires
1 < n < 255,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to exclude 0 and 255?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And would the proofs change significantly for u32 or u64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to exclude 0 and 1 since they don't have prime factorizations. 255 needs to be excluded otherwise there will be an overflow on the last iteration of the loop. The proofs won't change for u32 or u64

Copy link
Contributor

@parno parno Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the suggested Python solution will return an empty list if n is 0 or 1. I guess that's one way of signaling that there is no prime factorization.

255 needs to be excluded otherwise there will be an overflow on the last iteration of the loop.

Could we address that by making m a u16?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we address that by making m a u16?

Yes, done!

It seems like the suggested Python solution will return an empty list if n is 0 or 1. I guess that's one way of signaling that there is no prime factorization.

Sure, I've extended it to include 1. I don't including 0 makes sense here: technically any prime number is a "factor" of 0, so it doesn't make sense to return the empty list. Similarly, I don't think defining this on negative numbers makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sounds reasonable to me. Thanks for making the changes!

tasks/human_eval_025.rs Outdated Show resolved Hide resolved
tasks/human_eval_025.rs Outdated Show resolved Hide resolved
tasks/human_eval_025.rs Show resolved Hide resolved
tasks/human_eval_025.rs Outdated Show resolved Hide resolved
@amarshah1
Copy link
Contributor Author

I have made all of the changes requested or replied to your where I haven't.

Yes, there are no new changes to 015. I forgot to sync my fork. Sorry about that!

@parno parno merged commit 24726b0 into secure-foundations:main Oct 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants