1
0

3 Commity 674f8215bf ... 3f7fab687e

Autor SHA1 Správa Dátum
  Vinicius Teshima 3f7fab687e Adding Solution for 2806 2 týždňov pred
  Vinicius Teshima 4d49356526 Adding solution for 709 2 týždňov pred
  Vinicius Teshima 2b889dd22a Making language_chooser.sh ignores files/dirs that start with . 2 týždňov pred
3 zmenil súbory, kde vykonal 67 pridanie a 1 odobranie
  1. 32 0
      Go/2806.go
  2. 34 0
      Ruby/709.rb
  3. 1 1
      language_chooser.sh

+ 32 - 0
Go/2806.go

@@ -0,0 +1,32 @@
+package main
+
+import (
+	"os"
+	"fmt"
+)
+
+func accountBalanceAfterPurchase(purchaseAmount int) int {
+	var firstDigit int = purchaseAmount % 10
+	if firstDigit >= 5 {
+		return 100 - (purchaseAmount + (10 - firstDigit))
+	}
+
+	return 100 - (purchaseAmount - firstDigit)
+}
+
+func main() {
+	r := func(purchaseAmount int, exp int) {
+		fmt.Printf(
+			"accountBalanceAfterPurchase(%v) = %v | exp: %v\n",
+			purchaseAmount,
+			accountBalanceAfterPurchase(purchaseAmount),
+			exp,
+		)
+	}
+
+	r(9, 90)
+	r(15, 80)
+	r(10, 90)
+
+	os.Exit(0)
+}

+ 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

+ 1 - 1
language_chooser.sh

@@ -15,7 +15,7 @@
 prob="$1"
 test -n "$prob" || { echo "Pass the problem number"; exit 1;}
 
-lang_frek="$(find . -maxdepth 1 -mindepth 1 -not -path './.git' -type d \
+lang_frek="$(find . -maxdepth 1 -mindepth 1 -not -path './.*' -type d \
     | parallel -j1 'find {} -maxdepth 1 -mindepth 1 -type f | wc -l | xargs echo {}' \
     | sort -k2)"