Przeglądaj źródła

Adding solution for 709

Vinicius Teshima 2 tygodni temu
rodzic
commit
4d49356526
1 zmienionych plików z 34 dodań i 0 usunięć
  1. 34 0
      Ruby/709.rb

+ 34 - 0
Ruby/709.rb

@@ -0,0 +1,34 @@
+# 268. Missing Number
+
+# @param {String} s
+# @return {String}
+def to_lower_case(s)
+  bytes = s.bytes()
+  bytes_len = bytes.length()
+
+  ret = Array.new(bytes_len, 0)
+
+  i = 0
+  while i < bytes_len do
+      b = bytes[i]
+      ret[i] = (b >= 65 && b <= 90 ? b+32 : b).chr
+      i += 1
+  end
+
+  return ret.join('')
+end
+
+def main()
+  def r(s, exp)
+    puts "to_lower_case(#{s}) = #{to_lower_case(s)} | exp: #{exp}"
+  end
+
+  r("Hello", "hello")
+  r("here", "here")
+  r("LOVELY", "lovely")
+end
+
+
+if __FILE__ == $0
+  main()
+end