Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def in_str(needle, haystack)
- for i in (0..haystack.chars.length - 1)
- if needle.chars[0] == haystack.chars[i]
- found = true
- for j in (0..needle.chars.length - 1)
- if needle[j] != haystack[i + j]
- found = false
- break
- end
- end
- if found
- puts "Found needle #{needle} in #{haystack} at position #{i}"
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement