Skip to content

2025-03-04 v. 8.8.1: added "1780. Check if Number is a Sum of Powers of Three" #970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
| 1685. Sum of Absolute Differences in a Sorted Array | [Link](https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array/) | [Link](./lib/medium/1685_sum_of_absolute_differences_in_a_sorted_array.rb) | [Link](./test/medium/test_1685_sum_of_absolute_differences_in_a_sorted_array.rb) |
| 1706. Where Will the Ball Fall | [Link](https://leetcode.com/problems/where-will-the-ball-fall/) | [Link](./lib/medium/1706_where_will_the_ball_fall.rb) | [Link](./test/medium/test_1706_where_will_the_ball_fall.rb) |
| 1721. Swapping Nodes in a Linked List | [Link](https://leetcode.com/problems/swapping-nodes-in-a-linked-list/) | [Link](./lib/medium/1721_swapping_nodes_in_a_linked_list.rb) | [Link](./test/medium/test_1721_swapping_nodes_in_a_linked_list.rb) |
| 1780. Check if Number is a Sum of Powers of Three | [Link](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/) | [Link](./lib/medium/1780_check_if_number_is_a_sum_of_powers_of_three.rb) | [Link](./test/medium/test_1780_check_if_number_is_a_sum_of_powers_of_three.rb) |
| 2116. Check if a Parentheses String Can Be Valid | [Link](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid/) | [Link](./lib/medium/2116_check_if_a_parentheses_string_can_be_valid.rb) | [Link](./test/medium/test_2116_check_if_a_parentheses_string_can_be_valid.rb) |
| 2425. Bitwise XOR of All Pairings | [Link](https://leetcode.com/problems/bitwise-xor-of-all-pairings/) | [Link](./lib/medium/2425_bitwise_xor_of_all_pairings.rb) | [Link](./test/medium/test_2425_bitwise_xor_of_all_pairings.rb) |
| 2429. Minimize XOR | [Link](https://leetcode.com/problems/minimize-xor/) | [Link](./lib/medium/2429_minimize_xor.rb) | [Link](./test/medium/test_2429_minimize_xor.rb) |
Expand Down
2 changes: 1 addition & 1 deletion leetcode-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'English'
::Gem::Specification.new do |s|
s.required_ruby_version = '>= 3.0'
s.name = 'leetcode-ruby'
s.version = '8.8.0'
s.version = '8.8.1'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
s.executable = 'leetcode-ruby'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

# https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/
# @param {Integer} n
# @return {Boolean}
def check_powers_of_three(n) = !n.to_s(3).include?('2')
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/medium/1780_check_if_number_is_a_sum_of_powers_of_three'
require 'minitest/autorun'

class CheckIfNumberIsASumOfPowersThreeTest < ::Minitest::Test
def test_default_one = assert(check_powers_of_three(12))

def test_default_two = assert(check_powers_of_three(91))

def test_default_three = assert(!check_powers_of_three(21))
end