Submitted solution to problem 126#43
Open
ricostynha1 wants to merge 2 commits into
Open
Conversation
parno
approved these changes
May 6, 2026
Contributor
parno
left a comment
There was a problem hiding this comment.
It looks like this was more involved than expected, but you made it work. I added a few small comments. If you merge main into your branch, that will enable to CI to run on your PR.
| ensures | ||
| count(v, v[i]) >= 3, | ||
| { | ||
| // decomposiiotn array in two 3 parts vp3 (until the 3 equal ) v3 (three equal) vsf (the final part) |
Contributor
There was a problem hiding this comment.
I think "decomposiiotn array in two 3" should be "decompose the array v into 3 parts:
|
|
||
| fn is_sorted(v: Vec<i32>) -> (ret: bool) | ||
| requires | ||
| v.len() <= i32::MAX, |
Contributor
There was a problem hiding this comment.
I suspect this precondition is unnecessary.
Contributor
Author
|
changes were performed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added solution to problem 126.
How it works:
(Mostly easy to do, but required some lemmas for concatenation).
The hard part was at the end to show that if a sequence is sorted, and no 3 in a row are equal, that implies that the count is necessarily equal to or less than 2 for each element:
This was done on the following:
And finally showing that by the property by contradiction, v2.len() must be smaller than or equal to 2.
[ One hard part to do was showing that the decomposition in v1 + v2 +v3 is possible; it required several lemmas, but it worked well ]