Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Created November 15, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanhandley/478c676274190c4ad842 to your computer and use it in GitHub Desktop.
Save seanhandley/478c676274190c4ad842 to your computer and use it in GitHub Desktop.
Einstein 15: Merging left_of? with implies?
# Implies
def i(a, b, c, d)
(0..4).any? do |i|
a[i] == b &&
c[i] == d
end
end
# Left of
def l(a, b, c, d)
(0..4).any? do |i|
a[i] == b &&
c[i+1] == d
end
end
# Modify implies? to take a positional modifier
def i(a, b, c, d, o = 0)
(0..4).any? do |i|
a[i] == b &&
c[i+o] == d
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment