Skip to content

Instantly share code, notes, and snippets.

View joalbertg's full-sized avatar
🎯
Focusing

Joalbert Andrés González joalbertg

🎯
Focusing
View GitHub Profile
@joalbertg
joalbertg / output.txt
Created June 7, 2022 17:19
challenge: product without current index
[]: []
[6]: [1]
[2, 4]: [4, 2]
[1, 1, 1, 1, 1]: [1, 1, 1, 1, 1]
[2, 2, 2, 2, 2]: [16, 16, 16, 16, 16]
[0, 1, 2, 3, 4]: [24, 0, 0, 0, 0]
[0, 1, 2, 0, 4]: [0, 0, 0, 0, 0]
[1, 2, 3, 4, 2]: [48, 24, 16, 12, 24]
@joalbertg
joalbertg / output.txt
Created May 23, 2022 20:00
challenge: phone number
# Task executed successfully.
# ---------------------------------
# Input parameters: ("0151-319723")
# Result: No
# OK
# ---------------------------------
# Input parameters: ("(123) 456-7890")
# Result: 1234567890
# OK
@joalbertg
joalbertg / count_even_substrings.rb
Last active May 23, 2022 17:30
challenge: count even substring
# frozen_string_literal: true
# quickstart
#
# ruby count_even_substrings.rb
def count_even_substrings(str)
j = 0
size = str.size
acc = []
@joalbertg
joalbertg / friendlier_uuid.rb
Last active May 20, 2022 19:00
Friendlier UUID
# frozen_string_literal: true
class FriendlierUuid
def initialize(uuid)
@uuid = uuid
end
def encode
remove_hyphens
conver_hexadecimal_to_bcd
@joalbertg
joalbertg / application.rb
Last active May 12, 2022 22:35
Initialize objects with default values
require 'pry'
require 'pry-nav'
class Application
def self.call(*args, &)
new(*args, &).call
end
private
@joalbertg
joalbertg / big.xml
Created May 10, 2022 20:14
Parsing huge XML in Ruby
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gauthorambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
# frozen_string_literal: true
# Quickstart
#
# Install:
# > gem install rspec --no-document
#
# Run tests
# > rspec -f d property_titles_service.rb
#
@joalbertg
joalbertg / README.md
Last active October 18, 2020 19:36
ruby: Technical Interview

Technical Interview

Multiply
0
0
2
2
-1
-1
@joalbertg
joalbertg / README.md
Created September 21, 2020 02:17
ruby: Observer Pattern

Observer Pattern

V1
  name:   Fred Flintstone
  title:  Crane Operator
  salary: 30000
35000
@joalbertg
joalbertg / README.md
Created September 7, 2020 03:34
ruby: Factory Method Pattern

Factory Method Pattern

Duck Duck0 says Quack!
Duck Duck1 says Quack!
Duck Duck2 says Quack!
Duck Duck0 is eating.
Duck Duck1 is eating.
Duck Duck2 is eating.