Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let none_alone = (coll, fit) => {
- let[first,second,third, ...tail] = [...coll]
- let skip_one = () => ([first, second, third, ...tail] =
- [second, third, ...tail])
- let skip_third = () => ([first, second, third, ...tail] =
- [...tail])
- while(first !== undefined) {
- if(!fit(first)) skip_one()
- else if(!fit(second)) return false
- else if(!fit(third)) skip_third()
- else skip_one()
- }
- return true
- }
- let gHappy = (str) => none_alone(str, (c) => (c == 'g'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement