##Quotes api
###Model Quote * text type string
- Build a RESTFUL API for Quote model
| # https://www.codewars.com/kata/snail | |
| def snail(matriz) | |
| result = [] | |
| step = 0 | |
| while matriz.size > 0 | |
| step = 0 if step > 3 | |
| case step | |
| when 0 | |
| result += matriz.shift |
| class Throttler | |
| def initialize(time_limit, &block) | |
| @block = block | |
| @created_at = Time.now | |
| @time_limit = time_limit | |
| @block.call() | |
| end | |
| def call |
| Verifying my Blockstack ID is secured with the address 13z2CgHWH2xyGaQWkxghJqASZgkmnux3wX https://explorer.blockstack.org/address/13z2CgHWH2xyGaQWkxghJqASZgkmnux3wX |
| def josephus(input, k) | |
| a = [] | |
| i = 0 | |
| while items.size > 0 | |
| i += k - 1 | |
| i = i % items.size | |
| a << items.slice!(i) | |
| end |
| class Base | |
| attr_reader :value | |
| def initialize(value) | |
| @value = value | |
| end | |
| end | |
| class Number < Base | |
| def plus |
| def solution(a) | |
| minor = 1/0.0 | |
| left = 0 | |
| right = a.reduce(:+) | |
| a[0..-2].each do |x| | |
| left += x | |
| right -= x |
| def intersection(a, b) | |
| hash = {} | |
| c = [] | |
| a.each do |x| | |
| hash[x] ? hash[x] += 1 : hash[x] = 1 | |
| end | |
| b.each do |x| | |
| c << x && hash[x] -= 1 if hash[x] && hash[x] > 0 |
| def diagonal(a) | |
| x = y = 0 | |
| out = [] | |
| limit = a.size - 1 | |
| (0..limit * 2).each do | |
| out << down(x,y,a) | |
| x += 1 if y == limit | |
| y += 1 if y < limit | |
| end | |
| out |