Skip to main content
Post Undeleted by manatwork
added 25 characters in body
Source Link
manatwork
  • 20.6k
  • 5
  • 51
  • 81

Ruby, 3844 characters

->a,b{i=0;i+=1while a[i]==b[i];a[0a[i]&&a[i]==b[i];a[0,i]}

Sample run:

2.1.5 :001 > ->a,b{i=0;i+=1while a[i]==b[i];a[0a[i]&&a[i]==b[i];a[0,i]}["global"["global , "glossary"]
 => "glo"  

2.1.5 :002 > ->a,b{i=0;i+=1while a[i]==b[i];a[0a[i]&&a[i]==b[i];a[0,i]}["department" , "depart"]
 => "depart"  

2.1.5 :003 > ->a,b{i=0;i+=1while a[i]==b[i];a[0a[i]&&a[i]==b[i];a[0,i]}["glove", "dove"]
 => "" 

Ruby, 38 characters

->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}

Sample run:

2.1.5 :001 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["global" , "glossary"]
 => "glo" 
2.1.5 :002 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["department" , "depart"]
 => "depart" 
2.1.5 :003 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["glove", "dove"]
 => "" 

Ruby, 44 characters

->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}

Sample run:

2.1.5 :001 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["global , "glossary"]
 => "glo" 

2.1.5 :002 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["department", "depart"]
 => "depart" 

2.1.5 :003 > ->a,b{i=0;i+=1while a[i]&&a[i]==b[i];a[0,i]}["glove", "dove"]
 => ""
Post Deleted by manatwork
Source Link
manatwork
  • 20.6k
  • 5
  • 51
  • 81

Ruby, 38 characters

->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}

Sample run:

2.1.5 :001 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["global" , "glossary"]
 => "glo" 
2.1.5 :002 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["department" , "depart"]
 => "depart" 
2.1.5 :003 > ->a,b{i=0;i+=1while a[i]==b[i];a[0,i]}["glove", "dove"]
 => ""