We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8e97976 commit 26084ebCopy full SHA for 26084eb
Ruby Solutions/Easy/AB_check.rb
@@ -0,0 +1,14 @@
1
+# AB_check.rb
2
+# splashinn
3
+
4
+#Determine if two characters are separated a specific way in the string - return true if characters a and b are separated by exactly 3 places.
5
+def abCheck(str)
6
+ return false if(str.include?('a') == false || str.include?('b') == false || str.rindex('b') < str.rindex('a'))
7
+ return str.rindex('b') - str.rindex('a') == 4
8
9
+end
10
11
+p abCheck("bzzza") #false
12
+p abCheck("after badly") #false
13
+p abCheck("Laura sobs") #true
14
+p abCheck("aaaaddddd") #false
0 commit comments