Instantly share code, notes, and snippets.

# lbvf50mobile

• Sort options
Created Aug 1, 2020
Codewars.com: The reject() function.
View reject.js
 // https://www.codewars.com/kata/52988f3f7edba9839c00037d The reject() function. let reject = (a,x) => a.filter( z => ! x(z));
Created Aug 1, 2020
Codewars.com: Nth power rules them all!
View modified_sum.py
 # https://www.codewars.com/kata/58aed2cafab8faca1d000e20 Nth power rules them all! def modified_sum(a, n): return sum(x**n for x in a) - sum(a)
Created Aug 1, 2020
Leetcode: 1037. Valid Boomerang.
View is_boomerang.rb
 # Leetcode: 1037. Valid Boomerang. # https://leetcode.com/problems/valid-boomerang/ # @param {Integer[][]} points # @return {Boolean} def is_boomerang(points) p0,p1,p2 = points x0,y0 = p0 x1,y1 = p1 x2,y2 = p2 a = (y1-y0)/(x1-x0)
Created Aug 1, 2020
Leetcode: 1030. Matrix Cells in Distance Order.
View all_cells_dist_order.rb
 # Leetcode: 1030. Matrix Cells in Distance Order. # https://leetcode.com/problems/matrix-cells-in-distance-order/ # Runtime: 208 ms, faster than 50.00% of Ruby online submissions for Matrix Cells in Distance Order. # Memory Usage: 14.3 MB, less than 50.00% of Ruby online submissions for Matrix Cells in Distance Order. # @param {Integer} r # @param {Integer} c # @param {Integer} r0 # @param {Integer} c0 # @return {Integer[][]} def all_cells_dist_order(r, c, r0, c0)
Created Aug 1, 2020
Leetcode: 1047. Remove All Adjacent Duplicates In String.
View remove_duplicates.rb
 # Leetcode: 1047. Remove All Adjacent Duplicates In String. # https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/submissions/ # Runtime: 72 ms, faster than 93.10% of Ruby online submissions for Remove All Adjacent Duplicates In String. # Memory Usage: 12.3 MB, less than 33.33% of Ruby online submissions for Remove All Adjacent Duplicates In String. # @param {String} s # @return {String} def remove_duplicates(s) a = s.gsub(/(.)\1/,'') while(a != s) s = a
Last active Aug 1, 2020
Just PHP FUN 065.
Created Jul 31, 2020
Codewars.com: Fibonacci's FizzBuzz.
View fibs_fizz_buzz.py
 # https://www.codewars.com/kata/57bf599f102a39bb1e000ae5 Fibonacci's FizzBuzz. def fibs_fizz_buzz(n): if 1 == n: return [1] if 2 == n: return [1,1] a,b,i = 1,1,2 ans = [1,1] while i < n: new_b = a+b a,b = b,new_b if 0 == new_b%15: new_b = "FizzBuzz"
Created Jul 31, 2020
Codewars.com: Convert an array of strings to array of numbers.
View toNumberArray.js
 // https://www.codewars.com/kata/5783d8f3202c0e486c001d23 Convert an array of strings to array of numbers. let toNumberArray = x => x.map(x => +x)
Last active Jul 31, 2020
Leetcode: 1029. Two City Scheduling.
View two_city_sched_cost.rb
 # Leetcode: 1029. Two City Scheduling. # https://leetcode.com/problems/two-city-scheduling/ # Runtime: 224 ms, faster than 9.30% of Ruby online submissions for Two City Scheduling. # Memory Usage: 10.2 MB, less than 100.00% of Ruby online submissions for Two City Scheduling. # @param {Integer[][]} costs # @return {Integer} def two_city_sched_cost(costs) @dp = {} @costs = costs top_down(0,costs.size/2, costs.size/2)
Last active Jul 31, 2020
Leetcode: 1025. Divisor Game.
View divisor_game.rb
 # Leetcode: 1025. Divisor Game. # https://leetcode.com/problems/divisor-game/ # Runtime: 48 ms, faster than 51.35% of Ruby online submissions for Divisor Game. # Memory Usage: 9.6 MB, less than 25.00% of Ruby online submissions for Divisor Game. # @param {Integer} n # @return {Boolean} def divisor_game(n) n%2 == 0 end
You can’t perform that action at this time.