From 997762da6fac886b3bd8e88ea1b57a0714e757e7 Mon Sep 17 00:00:00 2001 From: Rachel Lyons Date: Tue, 14 Jun 2016 02:30:32 +0000 Subject: [PATCH] submitting work for assignment --- lib/find_non_repeated_letter.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/find_non_repeated_letter.rb b/lib/find_non_repeated_letter.rb index 4dc672d..d54c67f 100644 --- a/lib/find_non_repeated_letter.rb +++ b/lib/find_non_repeated_letter.rb @@ -9,6 +9,20 @@ def find_first_non_repeated_letter(str) - #write your method here - return true + i = 0 + + if str[i] != str[i+1] + return str[0] + else + while i < str.length + if str[i] == str[i+1] + i += 1 + elsif str[i+1] == str[i+2] + i += 1 + else + return str[i+1] + end + end + end + return nil end