-
-
Save wwalker/3271d4eaa14afca4cfe1c2b9bc925afd to your computer and use it in GitHub Desktop.
irb broken
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lcd(a,b) | |
total = 0 | |
if b.include?(a) | |
b_c = b.chars.uniq | |
for a_i in 0...(a.length) do | |
b_c.each do |e| | |
t_a = a | |
total += 1 if b.include?(t_a.insert(a_i, e)) | |
end | |
end | |
end | |
puts total | |
end | |
lcd("aa", "baaa") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wwalker@polonium:~$ ruby | |
def lcd(a,b) | |
total = 0 | |
if b.include?(a) | |
b_c = b.chars.uniq | |
for a_i in 0...(a.length) do | |
b_c.each do |e| | |
t_a = a | |
total += 1 if b.include?(t_a.insert(a_i, e)) | |
end | |
end | |
end | |
puts total | |
end | |
lcd("aa", "baaa") | |
1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wwalker@polonium:~$ irb | |
irb(main):001:0> def lcd(a,b) | |
irb(main):002:1> total = 0 | |
irb(main):003:1> if b.include?(a) | |
irb(main):004:2> b_c = b.chars.uniq | |
irb(main):005:2> for a_i in 0...(a.length) do | |
irb(main):006:3* b_c.each do |e| | |
irb(main):007:3* t_a = a | |
irb(main):008:3> total += 1 if b.include?(t_a.insert(a_i, e)) | |
irb(main):009:3> end | |
irb(main):010:2> end | |
irb(main):011:1> end | |
SyntaxError: (irb):11: syntax error, unexpected end-of-input, expecting keyword_end | |
from /home/wwalker/.asdf/installs/ruby/2.3.3/bin/irb:11:in `<main>' | |
irb(main):012:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment