Fix AvoidHairpins to search within last window
See original GitHub issueI noticed that the AvoidHairpins specification does not search for hairpins within the last window. Intuitively, if I set my window size to be the same as my sequence length, the algorithm should find every hairpin in the sequence. In reality, though, this algorithm will not find any hairpins.
Here is some updated pseudocode that I briefly tested, it seems to be working:
for i in range(len(sequence) - stem_size:
word = sequence[i : i + stem_size]
if len(sequence) - i < window:
window = len(sequence) - i
if stem_size > window / 2:
break
rest = reverse[-(i + window) : -(i + stem_size)]
if word in rest:
// follow existing algorithm
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
These Hair Pins Are the Secret to Effortlessly Chic Updos
One Vogue editor breaks down why U-shaped hair pins are the secret to effortlessly chic hair at home and beyond.
Read more >How to Pick a Lock with a Bobby Pin - YouTube
Locked out? Or maybe you've always wondered how they do it in the movies? This quick video will give you some tips on...
Read more >Are Claw Clips Better for Thinning Hair? - Revela
They help prevent the heavy tugging and breakage that comes with putting hair up in a ponytail or pulled back with a headband....
Read more >How to wear hair clips like a cool girl
Hair clips can help in the styling process and compliment the bride's overall wedding look seamlessly. The best part is a bridal hair...
Read more >How to Open a Locked Door with a Bobby Pin - wikiHow
1. Open up a bobby pin and bend it at a 90-degree angle. Spread the wavy and straight ends of the bobby pin...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, it looks like you were right and you had the right fix (the mistake was to stop at
i-hairpin_window
instead ofi-stem-size
). I went ahead and pushed a commit to master which applies the fix (and a test for it) to save you a few clicks @veghp ! @NikashS let us know how it works for you.I think this issue should be closed (as per comment above).