Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def in_str(needle, haystack)
  2. for i in (0..haystack.chars.length - 1)
  3. if needle.chars[0] == haystack.chars[i]
  4. found = true
  5. for j in (0..needle.chars.length - 1)
  6. if needle[j] != haystack[i + j]
  7. found = false
  8. break
  9. end
  10. end
  11. if found
  12. puts "Found needle #{needle} in #{haystack} at position #{i}"
  13. end
  14. end
  15. end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement