From 6a1bad5633d24040911d945db27d885d49aa9d43 Mon Sep 17 00:00:00 2001 From: fartem Date: Fri, 27 Dec 2024 10:36:19 +0300 Subject: [PATCH 1/3] 2024-12-27 v. 7.5.1.1: small refactoring --- leetcode-ruby.gemspec | 2 +- lib/common/linked_list.rb | 4 ++-- lib/common/list_node_with_random.rb | 2 +- lib/common/next_tree_node.rb | 6 ++---- lib/common/node_with_neighbors.rb | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/leetcode-ruby.gemspec b/leetcode-ruby.gemspec index ad8f5d6a..882b5463 100644 --- a/leetcode-ruby.gemspec +++ b/leetcode-ruby.gemspec @@ -5,7 +5,7 @@ require 'English' ::Gem::Specification.new do |s| s.required_ruby_version = '>= 3.0' s.name = 'leetcode-ruby' - s.version = '7.5.1' + s.version = '7.5.1.1' s.license = 'MIT' s.files = ::Dir['lib/**/*.rb'] + %w[README.md] s.executable = 'leetcode-ruby' diff --git a/lib/common/linked_list.rb b/lib/common/linked_list.rb index c94fdb82..333f1ced 100644 --- a/lib/common/linked_list.rb +++ b/lib/common/linked_list.rb @@ -29,9 +29,9 @@ def self.from_array(values) # @param {ListNode} second # @return {Boolean} def self.are_equals(first, second) - return true if first.nil? && second.nil? + return true if !first && !second - return false if first.nil? || second.nil? + return false if !first || !second first.val == second.val && are_equals(first.next, second.next) end diff --git a/lib/common/list_node_with_random.rb b/lib/common/list_node_with_random.rb index 07da5ae7..dbd73a40 100644 --- a/lib/common/list_node_with_random.rb +++ b/lib/common/list_node_with_random.rb @@ -26,6 +26,6 @@ def self.are_equal(l1, l2) l2 = l2.next end - l1.nil? && l2.nil? + !l1 && !l2 end end diff --git a/lib/common/next_tree_node.rb b/lib/common/next_tree_node.rb index 1475c19d..4611972a 100644 --- a/lib/common/next_tree_node.rb +++ b/lib/common/next_tree_node.rb @@ -25,7 +25,7 @@ def self.are_equals(n1, n2) return are_equals(n1.left, n2.left) && are_equals(n1.right, n2.right) end - n1.nil? && n2.nil? + !n1 && !n2 end # @param {NextTreeNode} other @@ -40,7 +40,5 @@ def ==(other) end # @return {Integer} - def hash - [val, left, right, nxt].hash - end + def hash = [val, left, right, nxt].hash end diff --git a/lib/common/node_with_neighbors.rb b/lib/common/node_with_neighbors.rb index e47bb667..086e4603 100644 --- a/lib/common/node_with_neighbors.rb +++ b/lib/common/node_with_neighbors.rb @@ -15,7 +15,7 @@ def initialize(val, neighbors = nil) # @param {NodeWithNeighbors} n2 # @return {Boolean} def self.are_equals(n1, n2) - if !n1.nil? && !n2.nil? + if n1 && n2 return false unless n1.val == n2.val return false unless n1.neighbors.size == n2.neighbors.size @@ -27,6 +27,6 @@ def self.are_equals(n1, n2) return true end - n1.nil? && n2.nil? + !n1 && !n2 end end From 488b98c4b30e095bc988252e83a83cb96b5d8b45 Mon Sep 17 00:00:00 2001 From: fartem Date: Fri, 27 Dec 2024 10:42:33 +0300 Subject: [PATCH 2/3] 2024-12-27 v. 7.5.1.1: updated Ruby version for GitHub Actions --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3f2f95ac..d7f5b87e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,7 +7,7 @@ on: branches: [ master ] env: - RUBY_VERSION: 3.0 + RUBY_VERSION: 3.4.0 SIMPLECOV_THRESHOLD: 100 jobs: From 9613bc5daf399014c0659ed7fc8d93d1030d706e Mon Sep 17 00:00:00 2001 From: fartem Date: Fri, 27 Dec 2024 10:45:51 +0300 Subject: [PATCH 3/3] 2024-12-27 v. 7.5.1.1: updated Ruby version for GitHub Actions --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d7f5b87e..b914c56f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,7 +7,7 @@ on: branches: [ master ] env: - RUBY_VERSION: 3.4.0 + RUBY_VERSION: 3.3.6 SIMPLECOV_THRESHOLD: 100 jobs: