Skip to content
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
6 changes: 6 additions & 0 deletions config/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ openrouter:
note: https://openrouter.ai/google/gemini-2.5-flash-lite-preview-06-17
done: false

moonshotai_kimi-k2:
name: moonshotai/kimi-k2
provider: openrouter.ai
note: https://openrouter.ai/moonshotai/kimi-k2
done: false

# Ollama модели
ollama:
ollama_llama3_2:
Expand Down
11 changes: 11 additions & 0 deletions tasks/t0-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def has_close_elements(numbers, threshold)
return false if numbers.size < 2

numbers.each_with_index do |num, i|
numbers[(i+1)..-1].each do |other|
return true if (num - other).abs <= threshold
end
end

false
end
24 changes: 24 additions & 0 deletions tasks/t1-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def separate_paren_groups(paren_string)
groups = []
current = ""
balance = 0

paren_string.each_char do |char|
next if char == ' '

current += char

if char == '('
balance += 1
elsif char == ')'
balance -= 1
end

if balance == 0 && !current.empty?
groups << current
current = ""
end
end

groups
end
12 changes: 12 additions & 0 deletions tasks/t10-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def make_palindrome(string)
return string if string.empty?

(0...string.length).each do |i|
suffix = string[i..-1]
if suffix == suffix.reverse
return string + string[0...i].reverse
end
end

string + string[0...-1].reverse
end
3 changes: 3 additions & 0 deletions tasks/t100-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def make_a_pile(n)
(0...n).map { |i| n + (n.odd? ? 2 * i : 2 * i) }
end
3 changes: 3 additions & 0 deletions tasks/t101-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def words_string(s)
s.split(/[,\s]+/).reject(&:empty?)
end
5 changes: 5 additions & 0 deletions tasks/t102-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def choose_num(x, y)
return -1 if x > y

y.even? ? y : (y - 1 >= x ? y - 1 : -1)
end
7 changes: 7 additions & 0 deletions tasks/t103-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def rounded_avg(n, m)
return -1 if n > m
sum = (n..m).sum
count = m - n + 1
avg = (sum.to_f / count).round
"0b#{avg.to_s(2)}"
end
3 changes: 3 additions & 0 deletions tasks/t104-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def unique_digits(numbers)
numbers.select { |num| num.to_s.chars.all? { |digit| digit.to_i.odd? } }.sort
end
20 changes: 20 additions & 0 deletions tasks/t105-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def by_length(arr)
number_words = {
1 => "One",
2 => "Two",
3 => "Three",
4 => "Four",
5 => "Five",
6 => "Six",
7 => "Seven",
8 => "Eight",
9 => "Nine"
}

filtered = arr.select { |num| num >= 1 && num <= 9 }
return [] if filtered.empty?

sorted = filtered.sort.reverse
reversed = sorted.reverse
reversed.map { |num| number_words[num] }
end
11 changes: 11 additions & 0 deletions tasks/t106-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def f(n)
return [] if n == 0

(1..n).map do |i|
if i.even?
(1..i).inject(:*)
else
(1..i).sum
end
end
end
17 changes: 17 additions & 0 deletions tasks/t107-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def even_odd_palindrome(n)
even_count = 0
odd_count = 0

(1..n).each do |num|
str = num.to_s
if str == str.reverse
if num.even?
even_count += 1
else
odd_count += 1
end
end
end

[even_count, odd_count]
end
7 changes: 7 additions & 0 deletions tasks/t108-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def count_nums(arr)
arr.count do |num|
digits = num.abs.digits.reverse
digits[0] = -digits[0] if num.negative?
digits.sum > 0
end
end
13 changes: 13 additions & 0 deletions tasks/t109-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def move_one_ball(arr)
return true if arr.empty?

n = arr.length
sorted = arr.sort

n.times do |i|
rotated = arr.rotate(-i)
return true if rotated == sorted
end

false
end
13 changes: 13 additions & 0 deletions tasks/t11-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def string_xor(a, b)
min_length = [a.length, b.length].min
result = []

min_length.times do |i|
bit_a = a[i]
bit_b = b[i]
xor_result = (bit_a == bit_b) ? '0' : '1'
result << xor_result
end

result.join
end
5 changes: 5 additions & 0 deletions tasks/t110-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def exchange(lst1, lst2)
odd_count = lst1.count { |x| x.odd? }
even_count = lst2.count { |x| x.even? }
odd_count <= even_count ? "YES" : "NO"
end
13 changes: 13 additions & 0 deletions tasks/t111-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def histogram(text)
return {} if text.empty?

counts = Hash.new(0)
text.each_char do |char|
counts[char] += 1 if char.match?(/[a-z]/)
end

return {} if counts.empty?

max_count = counts.values.max
counts.select { |_, count| count == max_count }
end
6 changes: 6 additions & 0 deletions tasks/t112-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def reverse_delete(s, c)
chars_to_remove = c.chars.to_set
result = s.chars.reject { |char| chars_to_remove.include?(char) }.join
is_palindrome = result == result.reverse
[result, is_palindrome]
end
6 changes: 6 additions & 0 deletions tasks/t113-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def odd_count(strings)
strings.map do |str|
odd_count = str.chars.count { |char| char.to_i.odd? }
"the number of odd elements #{odd_count}n the str#{odd_count}ng #{odd_count} of the #{odd_count}nput."
end
end
11 changes: 11 additions & 0 deletions tasks/t114-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def min_sub_array_sum(nums)
min_sum = nums[0]
current_sum = nums[0]

(1...nums.length).each do |i|
current_sum = [nums[i], current_sum + nums[i]].min
min_sum = [min_sum, current_sum].min
end

min_sum
end
4 changes: 4 additions & 0 deletions tasks/t115-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def max_fill(grid, capacity)
total_water = grid.flatten.count(1)
(total_water.to_f / capacity).ceil
end
3 changes: 3 additions & 0 deletions tasks/t116-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def sort_array(arr)
arr.sort_by { |num| [num.to_s(2).count('1'), num] }
end
8 changes: 8 additions & 0 deletions tasks/t117-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def select_words(s, n)
return [] if s.empty?

consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
words = s.split

words.select { |word| word.count(consonants) == n }
end
12 changes: 12 additions & 0 deletions tasks/t118-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def get_closest_vowel(word)
vowels = 'aeiouAEIOU'
return "" if word.length < 3

(word.length - 2).downto(1) do |i|
if vowels.include?(word[i]) && !vowels.include?(word[i-1]) && !vowels.include?(word[i+1])
return word[i]
end
end

""
end
13 changes: 13 additions & 0 deletions tasks/t119-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def match_parens(lst)
str1, str2 = lst
[str1 + str2, str2 + str1].any? { |s| balanced?(s) } ? 'Yes' : 'No'
end

def balanced?(str)
balance = 0
str.each_char do |char|
balance += char == '(' ? 1 : -1
return false if balance.negative?
end
balance.zero?
end
4 changes: 4 additions & 0 deletions tasks/t12-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def longest(strings)
return nil if strings.empty?
strings.max_by(&:length)
end
3 changes: 3 additions & 0 deletions tasks/t120-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def maximum(arr, k)
arr.sort.last(k)
end
3 changes: 3 additions & 0 deletions tasks/t121-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def sum_odd_even_pos(lst)
lst.each_slice(2).sum { |pair| pair[0].odd? ? pair[0] : 0 }
end
3 changes: 3 additions & 0 deletions tasks/t122-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def add_elements(arr, k)
arr.first(k).select { |num| num.abs.to_s.length <= 2 }.sum
end
12 changes: 12 additions & 0 deletions tasks/t123-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def get_odd_collatz(n)
odd_numbers = []
current = n

while current != 1
odd_numbers << current if current.odd?
current = current.even? ? current / 2 : 3 * current + 1
end

odd_numbers << 1
odd_numbers.sort
end
15 changes: 15 additions & 0 deletions tasks/t124-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def valid_date?(date_string)
return false unless date_string.match?(/\A\d{2}-\d{2}-\d{4}\z/)

month, day, year = date_string.split('-').map(&:to_i)

return false unless month.between?(1, 12)

days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

if year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)
days_in_month[1] = 29
end

day.between?(1, days_in_month[month - 1])
end
9 changes: 9 additions & 0 deletions tasks/t125-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def split_words(txt)
if txt.include?(' ')
txt.split(' ')
elsif txt.include?(',')
txt.split(',')
else
txt.chars.select { |c| c >= 'a' && c <= 'z' && (c.ord - 'a'.ord).odd? }.count
end
end
9 changes: 9 additions & 0 deletions tasks/t126-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def is_sorted?(lst)
return true if lst.empty?

counts = Hash.new(0)
lst.each { |num| counts[num] += 1 }
return false if counts.values.any? { |count| count > 2 }

lst == lst.sort
end
23 changes: 23 additions & 0 deletions tasks/t127-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def intersection(interval1, interval2)
start1, end1 = interval1
start2, end2 = interval2

intersection_start = [start1, start2].max
intersection_end = [end1, end2].min

return "NO" if intersection_start > intersection_end

length = intersection_end - intersection_start + 1

return "NO" if length < 2

is_prime = true
(2..Math.sqrt(length)).each do |i|
if length % i == 0
is_prime = false
break
end
end

is_prime ? "YES" : "NO"
end
8 changes: 8 additions & 0 deletions tasks/t128-moonshotai_kimi_k2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def prod_signs(arr)
return nil if arr.empty?

sum_abs = arr.map(&:abs).sum
sign_product = arr.map { |n| n <=> 0 }.reduce(1, :*)

sum_abs * sign_product
end
Loading