From 8fbb85c5ffc8d433aadbb1fe7116a764465c5a67 Mon Sep 17 00:00:00 2001 From: dog Date: Sun, 13 Jul 2025 13:06:12 +0200 Subject: [PATCH] add - moonshotai_kimi-k2 - 83% ! --- config/models.yml | 6 ++++++ tasks/t0-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t1-moonshotai_kimi_k2.rb | 24 +++++++++++++++++++++++ tasks/t10-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t100-moonshotai_kimi_k2.rb | 3 +++ tasks/t101-moonshotai_kimi_k2.rb | 3 +++ tasks/t102-moonshotai_kimi_k2.rb | 5 +++++ tasks/t103-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t104-moonshotai_kimi_k2.rb | 3 +++ tasks/t105-moonshotai_kimi_k2.rb | 20 +++++++++++++++++++ tasks/t106-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t107-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t108-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t109-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t11-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t110-moonshotai_kimi_k2.rb | 5 +++++ tasks/t111-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t112-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t113-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t114-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t115-moonshotai_kimi_k2.rb | 4 ++++ tasks/t116-moonshotai_kimi_k2.rb | 3 +++ tasks/t117-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t118-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t119-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t12-moonshotai_kimi_k2.rb | 4 ++++ tasks/t120-moonshotai_kimi_k2.rb | 3 +++ tasks/t121-moonshotai_kimi_k2.rb | 3 +++ tasks/t122-moonshotai_kimi_k2.rb | 3 +++ tasks/t123-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t124-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t125-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t126-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t127-moonshotai_kimi_k2.rb | 23 ++++++++++++++++++++++ tasks/t128-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t129-moonshotai_kimi_k2.rb | 33 ++++++++++++++++++++++++++++++++ tasks/t13-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t130-moonshotai_kimi_k2.rb | 16 ++++++++++++++++ tasks/t131-moonshotai_kimi_k2.rb | 4 ++++ tasks/t132-moonshotai_kimi_k2.rb | 19 ++++++++++++++++++ tasks/t133-moonshotai_kimi_k2.rb | 3 +++ tasks/t134-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t135-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t136-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t137-moonshotai_kimi_k2.rb | 23 ++++++++++++++++++++++ tasks/t138-moonshotai_kimi_k2.rb | 3 +++ tasks/t139-moonshotai_kimi_k2.rb | 3 +++ tasks/t14-moonshotai_kimi_k2.rb | 3 +++ tasks/t140-moonshotai_kimi_k2.rb | 3 +++ tasks/t141-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t142-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t143-moonshotai_kimi_k2.rb | 10 ++++++++++ tasks/t144-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t145-moonshotai_kimi_k2.rb | 3 +++ tasks/t146-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t147-moonshotai_kimi_k2.rb | 16 ++++++++++++++++ tasks/t148-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t149-moonshotai_kimi_k2.rb | 3 +++ tasks/t15-moonshotai_kimi_k2.rb | 3 +++ tasks/t150-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t151-moonshotai_kimi_k2.rb | 5 +++++ tasks/t152-moonshotai_kimi_k2.rb | 3 +++ tasks/t153-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t154-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t155-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t156-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t157-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t158-moonshotai_kimi_k2.rb | 5 +++++ tasks/t159-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t16-moonshotai_kimi_k2.rb | 3 +++ tasks/t160-moonshotai_kimi_k2.rb | 2 ++ tasks/t161-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t162-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t163-moonshotai_kimi_k2.rb | 5 +++++ tasks/t17-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t18-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t19-moonshotai_kimi_k2.rb | 16 ++++++++++++++++ tasks/t2-moonshotai_kimi_k2.rb | 3 +++ tasks/t20-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t21-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t22-moonshotai_kimi_k2.rb | 3 +++ tasks/t23-moonshotai_kimi_k2.rb | 3 +++ tasks/t24-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t25-moonshotai_kimi_k2.rb | 18 +++++++++++++++++ tasks/t26-moonshotai_kimi_k2.rb | 5 +++++ tasks/t27-moonshotai_kimi_k2.rb | 3 +++ tasks/t28-moonshotai_kimi_k2.rb | 3 +++ tasks/t29-moonshotai_kimi_k2.rb | 3 +++ tasks/t3-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t30-moonshotai_kimi_k2.rb | 3 +++ tasks/t31-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t32-moonshotai_kimi_k2.rb | 24 +++++++++++++++++++++++ tasks/t33-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t34-moonshotai_kimi_k2.rb | 3 +++ tasks/t35-moonshotai_kimi_k2.rb | 3 +++ tasks/t36-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t37-moonshotai_kimi_k2.rb | 18 +++++++++++++++++ tasks/t38-moonshotai_kimi_k2.rb | 19 ++++++++++++++++++ tasks/t39-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t4-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t40-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t41-moonshotai_kimi_k2.rb | 3 +++ tasks/t42-moonshotai_kimi_k2.rb | 3 +++ tasks/t43-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t44-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t45-moonshotai_kimi_k2.rb | 3 +++ tasks/t46-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t47-moonshotai_kimi_k2.rb | 14 ++++++++++++++ tasks/t48-moonshotai_kimi_k2.rb | 4 ++++ tasks/t49-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t5-moonshotai_kimi_k2.rb | 10 ++++++++++ tasks/t50-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t51-moonshotai_kimi_k2.rb | 3 +++ tasks/t52-moonshotai_kimi_k2.rb | 3 +++ tasks/t53-moonshotai_kimi_k2.rb | 3 +++ tasks/t54-moonshotai_kimi_k2.rb | 3 +++ tasks/t55-moonshotai_kimi_k2.rb | 10 ++++++++++ tasks/t56-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t57-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t58-moonshotai_kimi_k2.rb | 3 +++ tasks/t59-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t6-moonshotai_kimi_k2.rb | 19 ++++++++++++++++++ tasks/t60-moonshotai_kimi_k2.rb | 4 ++++ tasks/t61-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t62-moonshotai_kimi_k2.rb | 5 +++++ tasks/t63-moonshotai_kimi_k2.rb | 12 ++++++++++++ tasks/t64-moonshotai_kimi_k2.rb | 10 ++++++++++ tasks/t65-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t66-moonshotai_kimi_k2.rb | 3 +++ tasks/t67-moonshotai_kimi_k2.rb | 4 ++++ tasks/t68-moonshotai_kimi_k2.rb | 17 ++++++++++++++++ tasks/t69-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t7-moonshotai_kimi_k2.rb | 3 +++ tasks/t70-moonshotai_kimi_k2.rb | 24 +++++++++++++++++++++++ tasks/t71-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t72-moonshotai_kimi_k2.rb | 3 +++ tasks/t73-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t74-moonshotai_kimi_k2.rb | 5 +++++ tasks/t75-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t76-moonshotai_kimi_k2.rb | 13 +++++++++++++ tasks/t77-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t78-moonshotai_kimi_k2.rb | 4 ++++ tasks/t79-moonshotai_kimi_k2.rb | 3 +++ tasks/t8-moonshotai_kimi_k2.rb | 5 +++++ tasks/t80-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t81-moonshotai_kimi_k2.rb | 19 ++++++++++++++++++ tasks/t82-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t83-moonshotai_kimi_k2.rb | 4 ++++ tasks/t84-moonshotai_kimi_k2.rb | 4 ++++ tasks/t85-moonshotai_kimi_k2.rb | 3 +++ tasks/t86-moonshotai_kimi_k2.rb | 3 +++ tasks/t87-moonshotai_kimi_k2.rb | 9 +++++++++ tasks/t88-moonshotai_kimi_k2.rb | 15 +++++++++++++++ tasks/t89-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t9-moonshotai_kimi_k2.rb | 7 +++++++ tasks/t90-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t91-moonshotai_kimi_k2.rb | 6 ++++++ tasks/t92-moonshotai_kimi_k2.rb | 4 ++++ tasks/t93-moonshotai_kimi_k2.rb | 10 ++++++++++ tasks/t94-moonshotai_kimi_k2.rb | 20 +++++++++++++++++++ tasks/t95-moonshotai_kimi_k2.rb | 11 +++++++++++ tasks/t96-moonshotai_kimi_k2.rb | 23 ++++++++++++++++++++++ tasks/t97-moonshotai_kimi_k2.rb | 3 +++ tasks/t98-moonshotai_kimi_k2.rb | 8 ++++++++ tasks/t99-moonshotai_kimi_k2.rb | 10 ++++++++++ 165 files changed, 1497 insertions(+) create mode 100644 tasks/t0-moonshotai_kimi_k2.rb create mode 100644 tasks/t1-moonshotai_kimi_k2.rb create mode 100644 tasks/t10-moonshotai_kimi_k2.rb create mode 100644 tasks/t100-moonshotai_kimi_k2.rb create mode 100644 tasks/t101-moonshotai_kimi_k2.rb create mode 100644 tasks/t102-moonshotai_kimi_k2.rb create mode 100644 tasks/t103-moonshotai_kimi_k2.rb create mode 100644 tasks/t104-moonshotai_kimi_k2.rb create mode 100644 tasks/t105-moonshotai_kimi_k2.rb create mode 100644 tasks/t106-moonshotai_kimi_k2.rb create mode 100644 tasks/t107-moonshotai_kimi_k2.rb create mode 100644 tasks/t108-moonshotai_kimi_k2.rb create mode 100644 tasks/t109-moonshotai_kimi_k2.rb create mode 100644 tasks/t11-moonshotai_kimi_k2.rb create mode 100644 tasks/t110-moonshotai_kimi_k2.rb create mode 100644 tasks/t111-moonshotai_kimi_k2.rb create mode 100644 tasks/t112-moonshotai_kimi_k2.rb create mode 100644 tasks/t113-moonshotai_kimi_k2.rb create mode 100644 tasks/t114-moonshotai_kimi_k2.rb create mode 100644 tasks/t115-moonshotai_kimi_k2.rb create mode 100644 tasks/t116-moonshotai_kimi_k2.rb create mode 100644 tasks/t117-moonshotai_kimi_k2.rb create mode 100644 tasks/t118-moonshotai_kimi_k2.rb create mode 100644 tasks/t119-moonshotai_kimi_k2.rb create mode 100644 tasks/t12-moonshotai_kimi_k2.rb create mode 100644 tasks/t120-moonshotai_kimi_k2.rb create mode 100644 tasks/t121-moonshotai_kimi_k2.rb create mode 100644 tasks/t122-moonshotai_kimi_k2.rb create mode 100644 tasks/t123-moonshotai_kimi_k2.rb create mode 100644 tasks/t124-moonshotai_kimi_k2.rb create mode 100644 tasks/t125-moonshotai_kimi_k2.rb create mode 100644 tasks/t126-moonshotai_kimi_k2.rb create mode 100644 tasks/t127-moonshotai_kimi_k2.rb create mode 100644 tasks/t128-moonshotai_kimi_k2.rb create mode 100644 tasks/t129-moonshotai_kimi_k2.rb create mode 100644 tasks/t13-moonshotai_kimi_k2.rb create mode 100644 tasks/t130-moonshotai_kimi_k2.rb create mode 100644 tasks/t131-moonshotai_kimi_k2.rb create mode 100644 tasks/t132-moonshotai_kimi_k2.rb create mode 100644 tasks/t133-moonshotai_kimi_k2.rb create mode 100644 tasks/t134-moonshotai_kimi_k2.rb create mode 100644 tasks/t135-moonshotai_kimi_k2.rb create mode 100644 tasks/t136-moonshotai_kimi_k2.rb create mode 100644 tasks/t137-moonshotai_kimi_k2.rb create mode 100644 tasks/t138-moonshotai_kimi_k2.rb create mode 100644 tasks/t139-moonshotai_kimi_k2.rb create mode 100644 tasks/t14-moonshotai_kimi_k2.rb create mode 100644 tasks/t140-moonshotai_kimi_k2.rb create mode 100644 tasks/t141-moonshotai_kimi_k2.rb create mode 100644 tasks/t142-moonshotai_kimi_k2.rb create mode 100644 tasks/t143-moonshotai_kimi_k2.rb create mode 100644 tasks/t144-moonshotai_kimi_k2.rb create mode 100644 tasks/t145-moonshotai_kimi_k2.rb create mode 100644 tasks/t146-moonshotai_kimi_k2.rb create mode 100644 tasks/t147-moonshotai_kimi_k2.rb create mode 100644 tasks/t148-moonshotai_kimi_k2.rb create mode 100644 tasks/t149-moonshotai_kimi_k2.rb create mode 100644 tasks/t15-moonshotai_kimi_k2.rb create mode 100644 tasks/t150-moonshotai_kimi_k2.rb create mode 100644 tasks/t151-moonshotai_kimi_k2.rb create mode 100644 tasks/t152-moonshotai_kimi_k2.rb create mode 100644 tasks/t153-moonshotai_kimi_k2.rb create mode 100644 tasks/t154-moonshotai_kimi_k2.rb create mode 100644 tasks/t155-moonshotai_kimi_k2.rb create mode 100644 tasks/t156-moonshotai_kimi_k2.rb create mode 100644 tasks/t157-moonshotai_kimi_k2.rb create mode 100644 tasks/t158-moonshotai_kimi_k2.rb create mode 100644 tasks/t159-moonshotai_kimi_k2.rb create mode 100644 tasks/t16-moonshotai_kimi_k2.rb create mode 100644 tasks/t160-moonshotai_kimi_k2.rb create mode 100644 tasks/t161-moonshotai_kimi_k2.rb create mode 100644 tasks/t162-moonshotai_kimi_k2.rb create mode 100644 tasks/t163-moonshotai_kimi_k2.rb create mode 100644 tasks/t17-moonshotai_kimi_k2.rb create mode 100644 tasks/t18-moonshotai_kimi_k2.rb create mode 100644 tasks/t19-moonshotai_kimi_k2.rb create mode 100644 tasks/t2-moonshotai_kimi_k2.rb create mode 100644 tasks/t20-moonshotai_kimi_k2.rb create mode 100644 tasks/t21-moonshotai_kimi_k2.rb create mode 100644 tasks/t22-moonshotai_kimi_k2.rb create mode 100644 tasks/t23-moonshotai_kimi_k2.rb create mode 100644 tasks/t24-moonshotai_kimi_k2.rb create mode 100644 tasks/t25-moonshotai_kimi_k2.rb create mode 100644 tasks/t26-moonshotai_kimi_k2.rb create mode 100644 tasks/t27-moonshotai_kimi_k2.rb create mode 100644 tasks/t28-moonshotai_kimi_k2.rb create mode 100644 tasks/t29-moonshotai_kimi_k2.rb create mode 100644 tasks/t3-moonshotai_kimi_k2.rb create mode 100644 tasks/t30-moonshotai_kimi_k2.rb create mode 100644 tasks/t31-moonshotai_kimi_k2.rb create mode 100644 tasks/t32-moonshotai_kimi_k2.rb create mode 100644 tasks/t33-moonshotai_kimi_k2.rb create mode 100644 tasks/t34-moonshotai_kimi_k2.rb create mode 100644 tasks/t35-moonshotai_kimi_k2.rb create mode 100644 tasks/t36-moonshotai_kimi_k2.rb create mode 100644 tasks/t37-moonshotai_kimi_k2.rb create mode 100644 tasks/t38-moonshotai_kimi_k2.rb create mode 100644 tasks/t39-moonshotai_kimi_k2.rb create mode 100644 tasks/t4-moonshotai_kimi_k2.rb create mode 100644 tasks/t40-moonshotai_kimi_k2.rb create mode 100644 tasks/t41-moonshotai_kimi_k2.rb create mode 100644 tasks/t42-moonshotai_kimi_k2.rb create mode 100644 tasks/t43-moonshotai_kimi_k2.rb create mode 100644 tasks/t44-moonshotai_kimi_k2.rb create mode 100644 tasks/t45-moonshotai_kimi_k2.rb create mode 100644 tasks/t46-moonshotai_kimi_k2.rb create mode 100644 tasks/t47-moonshotai_kimi_k2.rb create mode 100644 tasks/t48-moonshotai_kimi_k2.rb create mode 100644 tasks/t49-moonshotai_kimi_k2.rb create mode 100644 tasks/t5-moonshotai_kimi_k2.rb create mode 100644 tasks/t50-moonshotai_kimi_k2.rb create mode 100644 tasks/t51-moonshotai_kimi_k2.rb create mode 100644 tasks/t52-moonshotai_kimi_k2.rb create mode 100644 tasks/t53-moonshotai_kimi_k2.rb create mode 100644 tasks/t54-moonshotai_kimi_k2.rb create mode 100644 tasks/t55-moonshotai_kimi_k2.rb create mode 100644 tasks/t56-moonshotai_kimi_k2.rb create mode 100644 tasks/t57-moonshotai_kimi_k2.rb create mode 100644 tasks/t58-moonshotai_kimi_k2.rb create mode 100644 tasks/t59-moonshotai_kimi_k2.rb create mode 100644 tasks/t6-moonshotai_kimi_k2.rb create mode 100644 tasks/t60-moonshotai_kimi_k2.rb create mode 100644 tasks/t61-moonshotai_kimi_k2.rb create mode 100644 tasks/t62-moonshotai_kimi_k2.rb create mode 100644 tasks/t63-moonshotai_kimi_k2.rb create mode 100644 tasks/t64-moonshotai_kimi_k2.rb create mode 100644 tasks/t65-moonshotai_kimi_k2.rb create mode 100644 tasks/t66-moonshotai_kimi_k2.rb create mode 100644 tasks/t67-moonshotai_kimi_k2.rb create mode 100644 tasks/t68-moonshotai_kimi_k2.rb create mode 100644 tasks/t69-moonshotai_kimi_k2.rb create mode 100644 tasks/t7-moonshotai_kimi_k2.rb create mode 100644 tasks/t70-moonshotai_kimi_k2.rb create mode 100644 tasks/t71-moonshotai_kimi_k2.rb create mode 100644 tasks/t72-moonshotai_kimi_k2.rb create mode 100644 tasks/t73-moonshotai_kimi_k2.rb create mode 100644 tasks/t74-moonshotai_kimi_k2.rb create mode 100644 tasks/t75-moonshotai_kimi_k2.rb create mode 100644 tasks/t76-moonshotai_kimi_k2.rb create mode 100644 tasks/t77-moonshotai_kimi_k2.rb create mode 100644 tasks/t78-moonshotai_kimi_k2.rb create mode 100644 tasks/t79-moonshotai_kimi_k2.rb create mode 100644 tasks/t8-moonshotai_kimi_k2.rb create mode 100644 tasks/t80-moonshotai_kimi_k2.rb create mode 100644 tasks/t81-moonshotai_kimi_k2.rb create mode 100644 tasks/t82-moonshotai_kimi_k2.rb create mode 100644 tasks/t83-moonshotai_kimi_k2.rb create mode 100644 tasks/t84-moonshotai_kimi_k2.rb create mode 100644 tasks/t85-moonshotai_kimi_k2.rb create mode 100644 tasks/t86-moonshotai_kimi_k2.rb create mode 100644 tasks/t87-moonshotai_kimi_k2.rb create mode 100644 tasks/t88-moonshotai_kimi_k2.rb create mode 100644 tasks/t89-moonshotai_kimi_k2.rb create mode 100644 tasks/t9-moonshotai_kimi_k2.rb create mode 100644 tasks/t90-moonshotai_kimi_k2.rb create mode 100644 tasks/t91-moonshotai_kimi_k2.rb create mode 100644 tasks/t92-moonshotai_kimi_k2.rb create mode 100644 tasks/t93-moonshotai_kimi_k2.rb create mode 100644 tasks/t94-moonshotai_kimi_k2.rb create mode 100644 tasks/t95-moonshotai_kimi_k2.rb create mode 100644 tasks/t96-moonshotai_kimi_k2.rb create mode 100644 tasks/t97-moonshotai_kimi_k2.rb create mode 100644 tasks/t98-moonshotai_kimi_k2.rb create mode 100644 tasks/t99-moonshotai_kimi_k2.rb diff --git a/config/models.yml b/config/models.yml index 2e30826..6070db1 100644 --- a/config/models.yml +++ b/config/models.yml @@ -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: diff --git a/tasks/t0-moonshotai_kimi_k2.rb b/tasks/t0-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ed4ac3e --- /dev/null +++ b/tasks/t0-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t1-moonshotai_kimi_k2.rb b/tasks/t1-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..35a2b20 --- /dev/null +++ b/tasks/t1-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t10-moonshotai_kimi_k2.rb b/tasks/t10-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..5c96142 --- /dev/null +++ b/tasks/t10-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t100-moonshotai_kimi_k2.rb b/tasks/t100-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2107fb2 --- /dev/null +++ b/tasks/t100-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def make_a_pile(n) + (0...n).map { |i| n + (n.odd? ? 2 * i : 2 * i) } +end \ No newline at end of file diff --git a/tasks/t101-moonshotai_kimi_k2.rb b/tasks/t101-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..da249f5 --- /dev/null +++ b/tasks/t101-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def words_string(s) + s.split(/[,\s]+/).reject(&:empty?) +end \ No newline at end of file diff --git a/tasks/t102-moonshotai_kimi_k2.rb b/tasks/t102-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..af2562d --- /dev/null +++ b/tasks/t102-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def choose_num(x, y) + return -1 if x > y + + y.even? ? y : (y - 1 >= x ? y - 1 : -1) +end \ No newline at end of file diff --git a/tasks/t103-moonshotai_kimi_k2.rb b/tasks/t103-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..88359bc --- /dev/null +++ b/tasks/t103-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t104-moonshotai_kimi_k2.rb b/tasks/t104-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c608ae1 --- /dev/null +++ b/tasks/t104-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def unique_digits(numbers) + numbers.select { |num| num.to_s.chars.all? { |digit| digit.to_i.odd? } }.sort +end \ No newline at end of file diff --git a/tasks/t105-moonshotai_kimi_k2.rb b/tasks/t105-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..89f1452 --- /dev/null +++ b/tasks/t105-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t106-moonshotai_kimi_k2.rb b/tasks/t106-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..03d5181 --- /dev/null +++ b/tasks/t106-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t107-moonshotai_kimi_k2.rb b/tasks/t107-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b3066b1 --- /dev/null +++ b/tasks/t107-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t108-moonshotai_kimi_k2.rb b/tasks/t108-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..3a6b9dd --- /dev/null +++ b/tasks/t108-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t109-moonshotai_kimi_k2.rb b/tasks/t109-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..3bcf958 --- /dev/null +++ b/tasks/t109-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t11-moonshotai_kimi_k2.rb b/tasks/t11-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ed35fcb --- /dev/null +++ b/tasks/t11-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t110-moonshotai_kimi_k2.rb b/tasks/t110-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..958c049 --- /dev/null +++ b/tasks/t110-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t111-moonshotai_kimi_k2.rb b/tasks/t111-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..3a57204 --- /dev/null +++ b/tasks/t111-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t112-moonshotai_kimi_k2.rb b/tasks/t112-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..a73005f --- /dev/null +++ b/tasks/t112-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t113-moonshotai_kimi_k2.rb b/tasks/t113-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c3b94fc --- /dev/null +++ b/tasks/t113-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t114-moonshotai_kimi_k2.rb b/tasks/t114-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..87051b4 --- /dev/null +++ b/tasks/t114-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t115-moonshotai_kimi_k2.rb b/tasks/t115-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..9aa3ea3 --- /dev/null +++ b/tasks/t115-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def max_fill(grid, capacity) + total_water = grid.flatten.count(1) + (total_water.to_f / capacity).ceil +end \ No newline at end of file diff --git a/tasks/t116-moonshotai_kimi_k2.rb b/tasks/t116-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b8eb634 --- /dev/null +++ b/tasks/t116-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def sort_array(arr) + arr.sort_by { |num| [num.to_s(2).count('1'), num] } +end \ No newline at end of file diff --git a/tasks/t117-moonshotai_kimi_k2.rb b/tasks/t117-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..8bc154b --- /dev/null +++ b/tasks/t117-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t118-moonshotai_kimi_k2.rb b/tasks/t118-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..3c9736e --- /dev/null +++ b/tasks/t118-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t119-moonshotai_kimi_k2.rb b/tasks/t119-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..51525f9 --- /dev/null +++ b/tasks/t119-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t12-moonshotai_kimi_k2.rb b/tasks/t12-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..8b4ec03 --- /dev/null +++ b/tasks/t12-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def longest(strings) + return nil if strings.empty? + strings.max_by(&:length) +end \ No newline at end of file diff --git a/tasks/t120-moonshotai_kimi_k2.rb b/tasks/t120-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f4c6a42 --- /dev/null +++ b/tasks/t120-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def maximum(arr, k) + arr.sort.last(k) +end \ No newline at end of file diff --git a/tasks/t121-moonshotai_kimi_k2.rb b/tasks/t121-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..a6e7525 --- /dev/null +++ b/tasks/t121-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def sum_odd_even_pos(lst) + lst.each_slice(2).sum { |pair| pair[0].odd? ? pair[0] : 0 } +end \ No newline at end of file diff --git a/tasks/t122-moonshotai_kimi_k2.rb b/tasks/t122-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..109643e --- /dev/null +++ b/tasks/t122-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def add_elements(arr, k) + arr.first(k).select { |num| num.abs.to_s.length <= 2 }.sum +end \ No newline at end of file diff --git a/tasks/t123-moonshotai_kimi_k2.rb b/tasks/t123-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d060e82 --- /dev/null +++ b/tasks/t123-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t124-moonshotai_kimi_k2.rb b/tasks/t124-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..cb98b37 --- /dev/null +++ b/tasks/t124-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t125-moonshotai_kimi_k2.rb b/tasks/t125-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c646b8b --- /dev/null +++ b/tasks/t125-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t126-moonshotai_kimi_k2.rb b/tasks/t126-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..0eb4912 --- /dev/null +++ b/tasks/t126-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t127-moonshotai_kimi_k2.rb b/tasks/t127-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..df506f9 --- /dev/null +++ b/tasks/t127-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t128-moonshotai_kimi_k2.rb b/tasks/t128-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..141f161 --- /dev/null +++ b/tasks/t128-moonshotai_kimi_k2.rb @@ -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 \ No newline at end of file diff --git a/tasks/t129-moonshotai_kimi_k2.rb b/tasks/t129-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2dcf95f --- /dev/null +++ b/tasks/t129-moonshotai_kimi_k2.rb @@ -0,0 +1,33 @@ +def min_path(grid, k) + n = grid.length + positions = {} + grid.each_with_index do |row, i| + row.each_with_index do |val, j| + positions[val] = [i, j] + end + end + + directions = [[-1, 0], [1, 0], [0, -1], [0, 1]] + + queue = [] + (1..n*n).each do |val| + i, j = positions[val] + queue << [[val], i, j] + end + + while !queue.empty? + path, i, j = queue.shift + return path if path.length == k + + directions.each do |di, dj| + ni, nj = i + di, j + dj + next if ni < 0 || ni >= n || nj < 0 || nj >= n + + next_val = grid[ni][nj] + new_path = path + [next_val] + queue << [new_path, ni, nj] + end + + queue.sort_by! { |path, _, _| path } + end +end \ No newline at end of file diff --git a/tasks/t13-moonshotai_kimi_k2.rb b/tasks/t13-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2f7e560 --- /dev/null +++ b/tasks/t13-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def greatest_common_divisor(a, b) + return a.abs if b == 0 + return b.abs if a == 0 + a, b = a.abs, b.abs + while b != 0 + a, b = b, a % b + end + a +end \ No newline at end of file diff --git a/tasks/t130-moonshotai_kimi_k2.rb b/tasks/t130-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..467281c --- /dev/null +++ b/tasks/t130-moonshotai_kimi_k2.rb @@ -0,0 +1,16 @@ +def tri(n) + return [1] if n == 0 + + sequence = [1, 3] + return sequence if n == 1 + + (2..n).each do |i| + if i.even? + sequence << 1 + i / 2 + else + sequence << sequence[i - 1] + sequence[i - 2] + sequence[i - 3] + end + end + + sequence +end \ No newline at end of file diff --git a/tasks/t131-moonshotai_kimi_k2.rb b/tasks/t131-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..02e497d --- /dev/null +++ b/tasks/t131-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def digits(n) + odd_digits = n.to_s.chars.map(&:to_i).select(&:odd?) + odd_digits.empty? ? 0 : odd_digits.reduce(:*) +end \ No newline at end of file diff --git a/tasks/t132-moonshotai_kimi_k2.rb b/tasks/t132-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..7c62de9 --- /dev/null +++ b/tasks/t132-moonshotai_kimi_k2.rb @@ -0,0 +1,19 @@ +def is_nested?(string) + return false if string.length < 4 + + balance = 0 + max_depth = 0 + + string.each_char do |char| + if char == '[' + balance += 1 + max_depth = [max_depth, balance].max + elsif char == ']' + balance -= 1 + end + + return false if balance < 0 + end + + balance == 0 && max_depth >= 2 +end \ No newline at end of file diff --git a/tasks/t133-moonshotai_kimi_k2.rb b/tasks/t133-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d692341 --- /dev/null +++ b/tasks/t133-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def sum_squares(lst) + lst.map { |num| num.ceil ** 2 }.sum +end \ No newline at end of file diff --git a/tasks/t134-moonshotai_kimi_k2.rb b/tasks/t134-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..7faae7e --- /dev/null +++ b/tasks/t134-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def check_last_char_letter?(txt) + return false if txt.empty? + + last_char = txt[-1] + return false unless last_char.match?(/[a-zA-Z]/) + + return true if txt.length == 1 + + second_last_char = txt[-2] + second_last_char == ' ' +end \ No newline at end of file diff --git a/tasks/t135-moonshotai_kimi_k2.rb b/tasks/t135-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..94fe22b --- /dev/null +++ b/tasks/t135-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def can_arrange(arr) + return -1 if arr.empty? + + (1...arr.length).reverse_each do |i| + return i if arr[i] < arr[i - 1] + end + + -1 +end \ No newline at end of file diff --git a/tasks/t136-moonshotai_kimi_k2.rb b/tasks/t136-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..947b07d --- /dev/null +++ b/tasks/t136-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def largest_smallest_integers(lst) + negatives = lst.select { |n| n < 0 } + positives = lst.select { |n| n > 0 } + + largest_negative = negatives.empty? ? nil : negatives.max + smallest_positive = positives.empty? ? nil : positives.min + + [largest_negative, smallest_positive] +end \ No newline at end of file diff --git a/tasks/t137-moonshotai_kimi_k2.rb b/tasks/t137-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..a7837a4 --- /dev/null +++ b/tasks/t137-moonshotai_kimi_k2.rb @@ -0,0 +1,23 @@ +def compare_one(a, b) + parse_value = lambda do |val| + case val + when String + val.tr(',', '.').to_f + when Integer, Float + val.to_f + else + val.to_f + end + end + + a_num = parse_value.call(a) + b_num = parse_value.call(b) + + return nil if a_num == b_num + + if a_num > b_num + a + else + b + end +end \ No newline at end of file diff --git a/tasks/t138-moonshotai_kimi_k2.rb b/tasks/t138-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..df006c2 --- /dev/null +++ b/tasks/t138-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def is_equal_to_sum_even?(n) + n >= 8 && n.even? +end \ No newline at end of file diff --git a/tasks/t139-moonshotai_kimi_k2.rb b/tasks/t139-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..4bcc0eb --- /dev/null +++ b/tasks/t139-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def special_factorial(n) + (1..n).reduce(1) { |product, i| product * (1..i).reduce(1, :*) } +end \ No newline at end of file diff --git a/tasks/t14-moonshotai_kimi_k2.rb b/tasks/t14-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..610c8f4 --- /dev/null +++ b/tasks/t14-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def all_prefixes(string) + (1..string.length).map { |i| string[0...i] } +end \ No newline at end of file diff --git a/tasks/t140-moonshotai_kimi_k2.rb b/tasks/t140-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..9b74df4 --- /dev/null +++ b/tasks/t140-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def fix_spaces(text) + text.gsub(/ {3,}/, '-').gsub(' ', '_') +end \ No newline at end of file diff --git a/tasks/t141-moonshotai_kimi_k2.rb b/tasks/t141-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..bb445cf --- /dev/null +++ b/tasks/t141-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def file_name_check(file_name) + return 'No' unless file_name.count('.') == 1 + + name_part, extension = file_name.split('.') + return 'No' if name_part.empty? || extension.empty? + return 'No' unless name_part[0].match?(/[a-zA-Z]/) + return 'No' unless ['txt', 'exe', 'dll'].include?(extension) + + digit_count = file_name.count('0-9') + return 'No' if digit_count > 3 + + 'Yes' +end \ No newline at end of file diff --git a/tasks/t142-moonshotai_kimi_k2.rb b/tasks/t142-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..812d538 --- /dev/null +++ b/tasks/t142-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def sum_squares(lst) + lst.each_with_index.sum do |value, index| + if index % 3 == 0 + value ** 2 + elsif index % 4 == 0 + value ** 3 + else + value + end + end +end \ No newline at end of file diff --git a/tasks/t143-moonshotai_kimi_k2.rb b/tasks/t143-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..65e8ab4 --- /dev/null +++ b/tasks/t143-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def prime_length_words(sentence) + words = sentence.split + prime_words = words.select { |word| prime?(word.length) } + prime_words.join(' ') +end + +def prime?(n) + return false if n < 2 + (2..Math.sqrt(n)).none? { |i| n % i == 0 } +end \ No newline at end of file diff --git a/tasks/t144-moonshotai_kimi_k2.rb b/tasks/t144-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2c04d7e --- /dev/null +++ b/tasks/t144-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def simplify(x, n) + x_num, x_den = x.split('/').map(&:to_i) + n_num, n_den = n.split('/').map(&:to_i) + + result_num = x_num * n_num + result_den = x_den * n_den + + result_num % result_den == 0 +end \ No newline at end of file diff --git a/tasks/t145-moonshotai_kimi_k2.rb b/tasks/t145-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f651dbe --- /dev/null +++ b/tasks/t145-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def order_by_points(nums) + nums.each_with_index.sort_by { |num, idx| [num.abs.digits.sum, idx] }.map(&:first) +end \ No newline at end of file diff --git a/tasks/t146-moonshotai_kimi_k2.rb b/tasks/t146-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f97a4f7 --- /dev/null +++ b/tasks/t146-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def special_filter(nums) + nums.count do |num| + next false if num <= 10 + + digits = num.abs.to_s.chars.map(&:to_i) + first_digit = digits.first + last_digit = digits.last + + first_digit.odd? && last_digit.odd? + end +end \ No newline at end of file diff --git a/tasks/t147-moonshotai_kimi_k2.rb b/tasks/t147-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..55b6d00 --- /dev/null +++ b/tasks/t147-moonshotai_kimi_k2.rb @@ -0,0 +1,16 @@ +def get_max_triples(n) + return 0 if n < 3 + + a = (0...n).map { |i| i * i - i + 1 } + count = 0 + + (0...n).each do |i| + (i+1...n).each do |j| + (j+1...n).each do |k| + count += 1 if (a[i] + a[j] + a[k]) % 3 == 0 + end + end + end + + count +end \ No newline at end of file diff --git a/tasks/t148-moonshotai_kimi_k2.rb b/tasks/t148-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..602dc8a --- /dev/null +++ b/tasks/t148-moonshotai_kimi_k2.rb @@ -0,0 +1,12 @@ +def bf(planet1, planet2) + planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] + return [] unless planets.include?(planet1) && planets.include?(planet2) + + index1 = planets.index(planet1) + index2 = planets.index(planet2) + + min_index = [index1, index2].min + max_index = [index1, index2].max + + planets[(min_index + 1)...max_index] || [] +end \ No newline at end of file diff --git a/tasks/t149-moonshotai_kimi_k2.rb b/tasks/t149-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..977e80a --- /dev/null +++ b/tasks/t149-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def sorted_list_sum(lst) + lst.select { |str| str.length.even? }.sort_by { |str| [str.length, str] } +end \ No newline at end of file diff --git a/tasks/t15-moonshotai_kimi_k2.rb b/tasks/t15-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f00ed15 --- /dev/null +++ b/tasks/t15-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def string_sequence(n) + (0..n).to_a.join(' ') +end \ No newline at end of file diff --git a/tasks/t150-moonshotai_kimi_k2.rb b/tasks/t150-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..64c87d2 --- /dev/null +++ b/tasks/t150-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def x_or_y(n, x, y) + return y if n < 2 + return x if n == 2 + return y if n.even? + + (3..Math.sqrt(n)).step(2) do |i| + return y if n % i == 0 + end + + x +end \ No newline at end of file diff --git a/tasks/t151-moonshotai_kimi_k2.rb b/tasks/t151-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..6d8132e --- /dev/null +++ b/tasks/t151-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def double_the_difference(numbers) + numbers.select { |n| n.is_a?(Integer) && n.positive? && n.odd? } + .map { |n| n * n } + .sum +end \ No newline at end of file diff --git a/tasks/t152-moonshotai_kimi_k2.rb b/tasks/t152-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..a56738d --- /dev/null +++ b/tasks/t152-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def compare(game, guess) + game.zip(guess).map { |g, h| (g - h).abs } +end \ No newline at end of file diff --git a/tasks/t153-moonshotai_kimi_k2.rb b/tasks/t153-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d9440b7 --- /dev/null +++ b/tasks/t153-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def strongest_extension(class_name, extensions) + return nil if extensions.empty? + + strongest = extensions.max_by do |ext| + uppercase = ext.count('A-Z') + lowercase = ext.count('a-z') + uppercase - lowercase + end + + "#{class_name}.#{strongest}" +end \ No newline at end of file diff --git a/tasks/t154-moonshotai_kimi_k2.rb b/tasks/t154-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..1605391 --- /dev/null +++ b/tasks/t154-moonshotai_kimi_k2.rb @@ -0,0 +1,7 @@ +def cycpattern_check(a, b) + return true if b.empty? + return false if b.length > a.length + + doubled_b = b + b + (0...b.length).any? { |i| a.include?(doubled_b[i, b.length]) } +end \ No newline at end of file diff --git a/tasks/t155-moonshotai_kimi_k2.rb b/tasks/t155-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f6372bc --- /dev/null +++ b/tasks/t155-moonshotai_kimi_k2.rb @@ -0,0 +1,7 @@ +def even_odd_count(num) + num = num.abs + digits = num.to_s.chars.map(&:to_i) + even_count = digits.count { |digit| digit.even? } + odd_count = digits.count { |digit| digit.odd? } + [even_count, odd_count] +end \ No newline at end of file diff --git a/tasks/t156-moonshotai_kimi_k2.rb b/tasks/t156-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ac8ac75 --- /dev/null +++ b/tasks/t156-moonshotai_kimi_k2.rb @@ -0,0 +1,15 @@ +def int_to_mini_roman(number) + values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] + numerals = %w[m cm d cd c xc l xl x ix v iv i] + + result = '' + values.each_with_index do |value, index| + count = number / value + if count > 0 + result << numerals[index] * count + number -= value * count + end + end + + result +end \ No newline at end of file diff --git a/tasks/t157-moonshotai_kimi_k2.rb b/tasks/t157-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..6359397 --- /dev/null +++ b/tasks/t157-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def right_angle_triangle?(a, b, c) + return false if [a, b, c].any? { |side| side <= 0 } + + sides = [a, b, c].sort + return false if sides[0] + sides[1] <= sides[2] + + sides[0]**2 + sides[1]**2 == sides[2]**2 +end \ No newline at end of file diff --git a/tasks/t158-moonshotai_kimi_k2.rb b/tasks/t158-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b204d78 --- /dev/null +++ b/tasks/t158-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def find_max(words) + return "" if words.empty? + + words.max_by { |word| [-word.chars.uniq.size, word] } +end \ No newline at end of file diff --git a/tasks/t159-moonshotai_kimi_k2.rb b/tasks/t159-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f90dc62 --- /dev/null +++ b/tasks/t159-moonshotai_kimi_k2.rb @@ -0,0 +1,7 @@ +def eat(number, need, remaining) + needed_to_eat = [need - number, 0].max + actual_eaten = [needed_to_eat, remaining].min + total_eaten = number + actual_eaten + carrots_left = remaining - actual_eaten + [total_eaten, carrots_left] +end \ No newline at end of file diff --git a/tasks/t16-moonshotai_kimi_k2.rb b/tasks/t16-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c4adfee --- /dev/null +++ b/tasks/t16-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def count_distinct_characters(string) + string.downcase.chars.uniq.length +end \ No newline at end of file diff --git a/tasks/t160-moonshotai_kimi_k2.rb b/tasks/t160-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..19ac17a --- /dev/null +++ b/tasks/t160-moonshotai_kimi_k2.rb @@ -0,0 +1,2 @@ +def do_algebra(operator, operand) + result \ No newline at end of file diff --git a/tasks/t161-moonshotai_kimi_k2.rb b/tasks/t161-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..33586f4 --- /dev/null +++ b/tasks/t161-moonshotai_kimi_k2.rb @@ -0,0 +1,17 @@ +def solve(s) + has_letters = s.match?(/[[:alpha:]]/) + + if has_letters + s.chars.map do |char| + if char.match?(/[[:upper:]]/) + char.downcase + elsif char.match?(/[[:lower:]]/) + char.upcase + else + char + end + end.join + else + s.reverse + end +end \ No newline at end of file diff --git a/tasks/t162-moonshotai_kimi_k2.rb b/tasks/t162-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..fea712b --- /dev/null +++ b/tasks/t162-moonshotai_kimi_k2.rb @@ -0,0 +1,6 @@ +require 'digest/md5' + +def string_to_md5(text) + return nil if text.nil? || text.empty? + Digest::MD5.hexdigest(text) +end \ No newline at end of file diff --git a/tasks/t163-moonshotai_kimi_k2.rb b/tasks/t163-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..090fd46 --- /dev/null +++ b/tasks/t163-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def generate_even_numbers(a, b) + min = [a, b].min + max = [a, b].max + (min..max).select(&:even?) +end \ No newline at end of file diff --git a/tasks/t17-moonshotai_kimi_k2.rb b/tasks/t17-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..96caa15 --- /dev/null +++ b/tasks/t17-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def parse_music(music_string) + return [] if music_string.empty? + + music_string.split.map do |note| + case note + when 'o' then 4 + when 'o|' then 2 + when '.|' then 1 + end + end +end \ No newline at end of file diff --git a/tasks/t18-moonshotai_kimi_k2.rb b/tasks/t18-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..970cd97 --- /dev/null +++ b/tasks/t18-moonshotai_kimi_k2.rb @@ -0,0 +1,17 @@ +def how_many_times(string, substring) + return 0 if string.empty? || substring.empty? + + count = 0 + index = 0 + + while index <= string.length - substring.length + if string[index, substring.length] == substring + count += 1 + index += 1 + else + index += 1 + end + end + + count +end \ No newline at end of file diff --git a/tasks/t19-moonshotai_kimi_k2.rb b/tasks/t19-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..318f665 --- /dev/null +++ b/tasks/t19-moonshotai_kimi_k2.rb @@ -0,0 +1,16 @@ +def sort_numbers(numbers) + word_to_num = { + 'zero' => 0, + 'one' => 1, + 'two' => 2, + 'three' => 3, + 'four' => 4, + 'five' => 5, + 'six' => 6, + 'seven' => 7, + 'eight' => 8, + 'nine' => 9 + } + + numbers.split.sort_by { |word| word_to_num[word] }.join(' ') +end \ No newline at end of file diff --git a/tasks/t2-moonshotai_kimi_k2.rb b/tasks/t2-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..31cd918 --- /dev/null +++ b/tasks/t2-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def truncate_number(number) + number - number.floor +end \ No newline at end of file diff --git a/tasks/t20-moonshotai_kimi_k2.rb b/tasks/t20-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..491bffe --- /dev/null +++ b/tasks/t20-moonshotai_kimi_k2.rb @@ -0,0 +1,17 @@ +def find_closest_elements(numbers) + raise ArgumentError, "List must contain at least two numbers" if numbers.size < 2 + + sorted = numbers.sort + min_diff = Float::INFINITY + closest_pair = nil + + (0...sorted.size - 1).each do |i| + diff = sorted[i + 1] - sorted[i] + if diff < min_diff + min_diff = diff + closest_pair = [sorted[i], sorted[i + 1]] + end + end + + closest_pair +end \ No newline at end of file diff --git a/tasks/t21-moonshotai_kimi_k2.rb b/tasks/t21-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f410e2e --- /dev/null +++ b/tasks/t21-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def rescale_to_unit(numbers) + raise ArgumentError, "List must contain at least two elements" if numbers.size < 2 + + min = numbers.min + max = numbers.max + range = max - min + + return numbers.map { |num| (num - min) / range } +end \ No newline at end of file diff --git a/tasks/t22-moonshotai_kimi_k2.rb b/tasks/t22-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..679fd1c --- /dev/null +++ b/tasks/t22-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def filter_integers(values) + values.select { |value| value.is_a?(Integer) } +end \ No newline at end of file diff --git a/tasks/t23-moonshotai_kimi_k2.rb b/tasks/t23-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..54442c7 --- /dev/null +++ b/tasks/t23-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def strlen(string) + string.length +end \ No newline at end of file diff --git a/tasks/t24-moonshotai_kimi_k2.rb b/tasks/t24-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..6ace70e --- /dev/null +++ b/tasks/t24-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def largest_divisor(n) + return nil if n <= 1 + + (n / 2).downto(1) do |i| + return i if n % i == 0 + end + + nil +end \ No newline at end of file diff --git a/tasks/t25-moonshotai_kimi_k2.rb b/tasks/t25-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..e515bb3 --- /dev/null +++ b/tasks/t25-moonshotai_kimi_k2.rb @@ -0,0 +1,18 @@ +def factorize(n) + return [] if n == 1 + factors = [] + if n < 0 + factors << -1 + n = -n + end + divisor = 2 + while divisor * divisor <= n + while n % divisor == 0 + factors << divisor + n /= divisor + end + divisor += 1 + end + factors << n if n > 1 + factors +end \ No newline at end of file diff --git a/tasks/t26-moonshotai_kimi_k2.rb b/tasks/t26-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..1c87e23 --- /dev/null +++ b/tasks/t26-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def remove_duplicates(numbers) + counts = Hash.new(0) + numbers.each { |num| counts[num] += 1 } + numbers.select { |num| counts[num] == 1 } +end \ No newline at end of file diff --git a/tasks/t27-moonshotai_kimi_k2.rb b/tasks/t27-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ed68d69 --- /dev/null +++ b/tasks/t27-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def flip_case(string) + string.chars.map { |char| char == char.upcase ? char.downcase : char.upcase }.join +end \ No newline at end of file diff --git a/tasks/t28-moonshotai_kimi_k2.rb b/tasks/t28-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..7e06445 --- /dev/null +++ b/tasks/t28-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def concatenate(strings) + strings.join +end \ No newline at end of file diff --git a/tasks/t29-moonshotai_kimi_k2.rb b/tasks/t29-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..24d846e --- /dev/null +++ b/tasks/t29-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def filter_by_prefix(strings, prefix) + strings.select { |str| str.start_with?(prefix) } +end \ No newline at end of file diff --git a/tasks/t3-moonshotai_kimi_k2.rb b/tasks/t3-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..e3c66c3 --- /dev/null +++ b/tasks/t3-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def below_zero?(operations) + balance = 0 + operations.each do |operation| + balance += operation + return true if balance < 0 + end + false +end \ No newline at end of file diff --git a/tasks/t30-moonshotai_kimi_k2.rb b/tasks/t30-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..0a64957 --- /dev/null +++ b/tasks/t30-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def get_positive(numbers) + numbers.select { |num| num > 0 } +end \ No newline at end of file diff --git a/tasks/t31-moonshotai_kimi_k2.rb b/tasks/t31-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..09f668a --- /dev/null +++ b/tasks/t31-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def is_prime?(n) + return false if n < 2 + return true if n == 2 + return false if n.even? + + i = 3 + while i * i <= n + return false if n % i == 0 + i += 2 + end + + true +end \ No newline at end of file diff --git a/tasks/t32-moonshotai_kimi_k2.rb b/tasks/t32-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..4ad3b46 --- /dev/null +++ b/tasks/t32-moonshotai_kimi_k2.rb @@ -0,0 +1,24 @@ +def find_zero(xs) + n = xs.length - 1 + return -xs[0].to_f / xs[1] if n == 1 + + def poly(coeffs, x) + coeffs.each_with_index.reduce(0.0) { |sum, (c, i)| sum + c * (x ** i) } + end + + def derivative(coeffs) + coeffs.each_with_index.map { |c, i| c * i }[1..-1] + end + + deriv = derivative(xs) + + x = 0.0 + 100.times do + fx = poly(xs, x) + dfx = poly(deriv, x) + break if dfx.abs < 1e-10 + x = x - fx / dfx + end + + x +end \ No newline at end of file diff --git a/tasks/t33-moonshotai_kimi_k2.rb b/tasks/t33-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b263af1 --- /dev/null +++ b/tasks/t33-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def sort_third(l) + return [] if l.empty? + + third_indices = (0...l.size).select { |i| (i + 1) % 3 == 0 } + third_values = third_indices.map { |i| l[i] }.sort + + result = l.dup + third_indices.each_with_index do |original_index, sorted_index| + result[original_index] = third_values[sorted_index] + end + + result +end \ No newline at end of file diff --git a/tasks/t34-moonshotai_kimi_k2.rb b/tasks/t34-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f4aa471 --- /dev/null +++ b/tasks/t34-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def unique(list) + list.uniq.sort +end \ No newline at end of file diff --git a/tasks/t35-moonshotai_kimi_k2.rb b/tasks/t35-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..8051f22 --- /dev/null +++ b/tasks/t35-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def max_element(list) + list.max +end \ No newline at end of file diff --git a/tasks/t36-moonshotai_kimi_k2.rb b/tasks/t36-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..db12528 --- /dev/null +++ b/tasks/t36-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def fizz_buzz(n) + return 0 if n <= 0 + + count = 0 + (1...n).each do |num| + if num % 11 == 0 || num % 13 == 0 + count += num.to_s.count('7') + end + end + count +end \ No newline at end of file diff --git a/tasks/t37-moonshotai_kimi_k2.rb b/tasks/t37-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..10d3eb9 --- /dev/null +++ b/tasks/t37-moonshotai_kimi_k2.rb @@ -0,0 +1,18 @@ +def sort_even_elements(list) + return [] if list.empty? + + even_elements = list.each_with_index.select { |_, index| index.even? }.map(&:first) + sorted_even = even_elements.sort + + result = list.dup + even_index = 0 + + result.each_with_index do |_, index| + if index.even? + result[index] = sorted_even[even_index] + even_index += 1 + end + end + + result +end \ No newline at end of file diff --git a/tasks/t38-moonshotai_kimi_k2.rb b/tasks/t38-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..40396dd --- /dev/null +++ b/tasks/t38-moonshotai_kimi_k2.rb @@ -0,0 +1,19 @@ +def encode_cyclic(s) + s.chars.each_slice(3).map do |group| + if group.size == 3 + [group[1], group[2], group[0]] + else + group + end + end.flatten.join +end + +def decode_cyclic(s) + s.chars.each_slice(3).map do |group| + if group.size == 3 + [group[2], group[0], group[1]] + else + group + end + end.flatten.join +end \ No newline at end of file diff --git a/tasks/t39-moonshotai_kimi_k2.rb b/tasks/t39-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f1b4546 --- /dev/null +++ b/tasks/t39-moonshotai_kimi_k2.rb @@ -0,0 +1,15 @@ +def prime_fib(n) + raise ArgumentError, "n must be positive" if n < 1 + + prime?(num) = (2..Math.sqrt(num)).none? { |i| num % i == 0 } + + fib_primes = [] + a, b = 0, 1 + + while fib_primes.size < n + a, b = b, a + b + fib_primes << b if b > 1 && prime?(b) + end + + fib_primes.last +end \ No newline at end of file diff --git a/tasks/t4-moonshotai_kimi_k2.rb b/tasks/t4-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..782badf --- /dev/null +++ b/tasks/t4-moonshotai_kimi_k2.rb @@ -0,0 +1,7 @@ +def mean_absolute_deviation(numbers) + return 0.0 if numbers.empty? + + mean = numbers.sum / numbers.length + deviations = numbers.map { |x| (x - mean).abs } + deviations.sum / deviations.length +end \ No newline at end of file diff --git a/tasks/t40-moonshotai_kimi_k2.rb b/tasks/t40-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c21eab9 --- /dev/null +++ b/tasks/t40-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def triples_sum_to_zero(numbers) + return false if numbers.size < 3 + + numbers.combination(3) do |triple| + return true if triple.sum.zero? + end + + false +end \ No newline at end of file diff --git a/tasks/t41-moonshotai_kimi_k2.rb b/tasks/t41-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..cfd73a0 --- /dev/null +++ b/tasks/t41-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def car_race_collision(n) + n * n +end \ No newline at end of file diff --git a/tasks/t42-moonshotai_kimi_k2.rb b/tasks/t42-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b17ee9c --- /dev/null +++ b/tasks/t42-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def incr_list(list) + list.map { |num| num + 1 } +end \ No newline at end of file diff --git a/tasks/t43-moonshotai_kimi_k2.rb b/tasks/t43-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..bf09468 --- /dev/null +++ b/tasks/t43-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def pairs_sum_to_zero(numbers) + seen = {} + numbers.each do |num| + return true if seen.key?(-num) + seen[num] = true + end + false +end \ No newline at end of file diff --git a/tasks/t44-moonshotai_kimi_k2.rb b/tasks/t44-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..350ae95 --- /dev/null +++ b/tasks/t44-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def change_base(x, base) + raise ArgumentError, "Base must be between 2 and 9" unless base.between?(2, 9) + return "0" if x == 0 + + digits = [] + while x > 0 + digits.unshift(x % base) + x /= base + end + digits.join +end \ No newline at end of file diff --git a/tasks/t45-moonshotai_kimi_k2.rb b/tasks/t45-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..87eab87 --- /dev/null +++ b/tasks/t45-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def triangle_area(a, h) + 0.5 * a * h +end \ No newline at end of file diff --git a/tasks/t46-moonshotai_kimi_k2.rb b/tasks/t46-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..579b38e --- /dev/null +++ b/tasks/t46-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def fib4(n) + return 0 if n == 0 || n == 1 || n == 3 + return 2 if n == 2 + + a, b, c, d = 0, 0, 2, 0 + + 4.upto(n) do + e = a + b + c + d + a, b, c, d = b, c, d, e + end + + d +end \ No newline at end of file diff --git a/tasks/t47-moonshotai_kimi_k2.rb b/tasks/t47-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c634eed --- /dev/null +++ b/tasks/t47-moonshotai_kimi_k2.rb @@ -0,0 +1,14 @@ +def median(numbers) + raise ArgumentError, "Input must be an array" unless numbers.is_a?(Array) + raise ArgumentError, "Array cannot be empty" if numbers.empty? + raise ArgumentError, "All elements must be numeric" unless numbers.all? { |n| n.is_a?(Numeric) } + + sorted = numbers.sort + length = sorted.length + + if length.odd? + sorted[length / 2].to_f + else + (sorted[length / 2 - 1] + sorted[length / 2]) / 2.0 + end +end \ No newline at end of file diff --git a/tasks/t48-moonshotai_kimi_k2.rb b/tasks/t48-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..bc11d27 --- /dev/null +++ b/tasks/t48-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def is_palindrome?(text) + cleaned = text.downcase.gsub(/[^a-z]/, '') + cleaned == cleaned.reverse +end \ No newline at end of file diff --git a/tasks/t49-moonshotai_kimi_k2.rb b/tasks/t49-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..fa36b4a --- /dev/null +++ b/tasks/t49-moonshotai_kimi_k2.rb @@ -0,0 +1,17 @@ +def modp(n, p) + return 0 if p == 1 + return 1 if n == 0 + + result = 1 + base = 2 % p + + while n > 0 + if n.odd? + result = (result * base) % p + end + base = (base * base) % p + n = n >> 1 + end + + result +end \ No newline at end of file diff --git a/tasks/t5-moonshotai_kimi_k2.rb b/tasks/t5-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..752ea2e --- /dev/null +++ b/tasks/t5-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def intersperse(numbers, delimeter) + return [] if numbers.empty? + + result = [] + numbers.each_with_index do |num, index| + result << num + result << delimeter unless index == numbers.length - 1 + end + result +end \ No newline at end of file diff --git a/tasks/t50-moonshotai_kimi_k2.rb b/tasks/t50-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..38489bc --- /dev/null +++ b/tasks/t50-moonshotai_kimi_k2.rb @@ -0,0 +1,6 @@ +def decode_shift(s) + s.chars.map do |char| + shifted = char.ord - 5 + shifted < 97 ? shifted + 26 : shifted + end.map(&:chr).join +end \ No newline at end of file diff --git a/tasks/t51-moonshotai_kimi_k2.rb b/tasks/t51-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2071047 --- /dev/null +++ b/tasks/t51-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def remove_vowels(text) + text.gsub(/[aeiouAEIOU]/, '') +end \ No newline at end of file diff --git a/tasks/t52-moonshotai_kimi_k2.rb b/tasks/t52-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..055ab8b --- /dev/null +++ b/tasks/t52-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def below_threshold(numbers, threshold) + numbers.all? { |num| num < threshold } +end \ No newline at end of file diff --git a/tasks/t53-moonshotai_kimi_k2.rb b/tasks/t53-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..e3bbabc --- /dev/null +++ b/tasks/t53-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def add(x, y) + x + y +end \ No newline at end of file diff --git a/tasks/t54-moonshotai_kimi_k2.rb b/tasks/t54-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..8bc32d5 --- /dev/null +++ b/tasks/t54-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def same_chars?(s0, s1) + s0.downcase.chars.uniq.sort == s1.downcase.chars.uniq.sort +end \ No newline at end of file diff --git a/tasks/t55-moonshotai_kimi_k2.rb b/tasks/t55-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d04e774 --- /dev/null +++ b/tasks/t55-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def fib(n) + return 1 if n == 1 + return 1 if n == 2 + + a, b = 1, 1 + 3.upto(n) do + a, b = b, a + b + end + b +end \ No newline at end of file diff --git a/tasks/t56-moonshotai_kimi_k2.rb b/tasks/t56-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b322c66 --- /dev/null +++ b/tasks/t56-moonshotai_kimi_k2.rb @@ -0,0 +1,12 @@ +def correct_bracketing(brackets) + balance = 0 + brackets.each_char do |char| + if char == '<' + balance += 1 + elsif char == '>' + balance -= 1 + end + return false if balance < 0 + end + balance == 0 +end \ No newline at end of file diff --git a/tasks/t57-moonshotai_kimi_k2.rb b/tasks/t57-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..969f843 --- /dev/null +++ b/tasks/t57-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def monotonic?(arr) + return true if arr.length <= 1 + + increasing = true + decreasing = true + + (1...arr.length).each do |i| + increasing = false if arr[i] < arr[i-1] + decreasing = false if arr[i] > arr[i-1] + end + + increasing || decreasing +end \ No newline at end of file diff --git a/tasks/t58-moonshotai_kimi_k2.rb b/tasks/t58-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b3bf435 --- /dev/null +++ b/tasks/t58-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def common(l1, l2) + (l1 & l2).sort +end \ No newline at end of file diff --git a/tasks/t59-moonshotai_kimi_k2.rb b/tasks/t59-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..4f803a2 --- /dev/null +++ b/tasks/t59-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def largest_prime_factor(n) + factor = 2 + while factor * factor <= n + if n % factor == 0 + n /= factor + else + factor += 1 + end + end + n +end \ No newline at end of file diff --git a/tasks/t6-moonshotai_kimi_k2.rb b/tasks/t6-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..6cd7911 --- /dev/null +++ b/tasks/t6-moonshotai_kimi_k2.rb @@ -0,0 +1,19 @@ +def parse_nested_parens(paren_string) + return [] if paren_string.empty? + + paren_string.split.map do |group| + max_depth = 0 + current_depth = 0 + + group.each_char do |char| + if char == '(' + current_depth += 1 + max_depth = [max_depth, current_depth].max + elsif char == ')' + current_depth -= 1 + end + end + + max_depth + end +end \ No newline at end of file diff --git a/tasks/t60-moonshotai_kimi_k2.rb b/tasks/t60-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..3b81f41 --- /dev/null +++ b/tasks/t60-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def sum_to_n(n) + return 0 if n < 1 + n * (n + 1) / 2 +end \ No newline at end of file diff --git a/tasks/t61-moonshotai_kimi_k2.rb b/tasks/t61-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..cd01dcf --- /dev/null +++ b/tasks/t61-moonshotai_kimi_k2.rb @@ -0,0 +1,12 @@ +def correct_bracketing(brackets) + balance = 0 + brackets.each_char do |char| + if char == '(' + balance += 1 + elsif char == ')' + balance -= 1 + return false if balance < 0 + end + end + balance == 0 +end \ No newline at end of file diff --git a/tasks/t62-moonshotai_kimi_k2.rb b/tasks/t62-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d22bfb4 --- /dev/null +++ b/tasks/t62-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def derivative(coefficients) + return [] if coefficients.empty? || coefficients.size == 1 + + coefficients.each_with_index.map { |coeff, index| coeff * index }[1..-1] +end \ No newline at end of file diff --git a/tasks/t63-moonshotai_kimi_k2.rb b/tasks/t63-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..e5edf05 --- /dev/null +++ b/tasks/t63-moonshotai_kimi_k2.rb @@ -0,0 +1,12 @@ +def fibfib(n) + return 0 if n == 0 || n == 1 + return 1 if n == 2 + + a, b, c = 0, 0, 1 + + 3.upto(n) do + a, b, c = b, c, a + b + c + end + + c +end \ No newline at end of file diff --git a/tasks/t64-moonshotai_kimi_k2.rb b/tasks/t64-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2668078 --- /dev/null +++ b/tasks/t64-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def vowels_count(word) + return 0 if word.empty? + + vowels = %w[a e i o u A E I O U] + count = word.chars.count { |char| vowels.include?(char) } + + count += 1 if word[-1].downcase == 'y' + + count +end \ No newline at end of file diff --git a/tasks/t65-moonshotai_kimi_k2.rb b/tasks/t65-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..d84f993 --- /dev/null +++ b/tasks/t65-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def circular_shift(x, shift) + digits = x.to_s.chars + return x.to_s if digits.empty? + + if shift > digits.length + digits.reverse.join + else + shift = shift % digits.length + digits.rotate(-shift).join + end +end \ No newline at end of file diff --git a/tasks/t66-moonshotai_kimi_k2.rb b/tasks/t66-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..877787a --- /dev/null +++ b/tasks/t66-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def digit_sum(s) + s.chars.select { |char| char.match?(/[A-Z]/) }.sum(&:ord) +end \ No newline at end of file diff --git a/tasks/t67-moonshotai_kimi_k2.rb b/tasks/t67-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..224fcb4 --- /dev/null +++ b/tasks/t67-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def fruit_distribution(fruit_string, total_fruits) + apples, oranges = fruit_string.scan(/\d+/).map(&:to_i) + [total_fruits - apples - oranges, 0].max +end \ No newline at end of file diff --git a/tasks/t68-moonshotai_kimi_k2.rb b/tasks/t68-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..7567ce8 --- /dev/null +++ b/tasks/t68-moonshotai_kimi_k2.rb @@ -0,0 +1,17 @@ +def pluck(arr) + return [] if arr.empty? + + min_even = nil + min_index = nil + + arr.each_with_index do |value, index| + if value.even? + if min_even.nil? || value < min_even + min_even = value + min_index = index + end + end + end + + min_even.nil? ? [] : [min_even, min_index] +end \ No newline at end of file diff --git a/tasks/t69-moonshotai_kimi_k2.rb b/tasks/t69-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..4510db8 --- /dev/null +++ b/tasks/t69-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def search(lst) + frequency = Hash.new(0) + lst.each { |num| frequency[num] += 1 } + + result = -1 + frequency.each do |num, count| + result = num if count >= num && num > result + end + + result +end \ No newline at end of file diff --git a/tasks/t7-moonshotai_kimi_k2.rb b/tasks/t7-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..efff195 --- /dev/null +++ b/tasks/t7-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def filter_by_substring(strings, substring) + strings.select { |str| str.include?(substring) } +end \ No newline at end of file diff --git a/tasks/t70-moonshotai_kimi_k2.rb b/tasks/t70-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..cf177bc --- /dev/null +++ b/tasks/t70-moonshotai_kimi_k2.rb @@ -0,0 +1,24 @@ +def strange_sort_list(lst) + return [] if lst.empty? + + sorted = [] + remaining = lst.dup + + take_min = true + + until remaining.empty? + if take_min + min_val = remaining.min + remaining.delete_at(remaining.index(min_val)) + sorted << min_val + else + max_val = remaining.max + remaining.delete_at(remaining.index(max_val)) + sorted << max_val + end + + take_min = !take_min + end + + sorted +end \ No newline at end of file diff --git a/tasks/t71-moonshotai_kimi_k2.rb b/tasks/t71-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..e15a985 --- /dev/null +++ b/tasks/t71-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def triangle_area(a, b, c) + return -1 if [a, b, c].any? { |side| side <= 0 } + return -1 unless a + b > c && a + c > b && b + c > a + + s = (a + b + c) / 2.0 + area = Math.sqrt(s * (s - a) * (s - b) * (s - c)) + area.round(2) +end \ No newline at end of file diff --git a/tasks/t72-moonshotai_kimi_k2.rb b/tasks/t72-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2309a4a --- /dev/null +++ b/tasks/t72-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def will_it_fly?(q, w) + q == q.reverse && q.sum <= w +end \ No newline at end of file diff --git a/tasks/t73-moonshotai_kimi_k2.rb b/tasks/t73-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..7576438 --- /dev/null +++ b/tasks/t73-moonshotai_kimi_k2.rb @@ -0,0 +1,15 @@ +def smallest_change(arr) + return 0 if arr.empty? || arr.length == 1 + + left = 0 + right = arr.length - 1 + changes = 0 + + while left < right + changes += 1 if arr[left] != arr[right] + left += 1 + right -= 1 + end + + changes +end \ No newline at end of file diff --git a/tasks/t74-moonshotai_kimi_k2.rb b/tasks/t74-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..03403e3 --- /dev/null +++ b/tasks/t74-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def total_match(lst1, lst2) + sum1 = lst1.sum(&:length) + sum2 = lst2.sum(&:length) + sum1 <= sum2 ? lst1 : lst2 +end \ No newline at end of file diff --git a/tasks/t75-moonshotai_kimi_k2.rb b/tasks/t75-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b1bf478 --- /dev/null +++ b/tasks/t75-moonshotai_kimi_k2.rb @@ -0,0 +1,15 @@ +def is_multiply_prime?(a) + return false if a < 2 + + def prime?(n) + return false if n < 2 + (2..Math.sqrt(n)).none? { |i| n % i == 0 } + end + + primes = [] + (2..a).each do |i| + primes << i if prime?(i) && a % i == 0 + end + + primes.combination(3).any? { |combo| combo.inject(:*) == a } +end \ No newline at end of file diff --git a/tasks/t76-moonshotai_kimi_k2.rb b/tasks/t76-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ca69525 --- /dev/null +++ b/tasks/t76-moonshotai_kimi_k2.rb @@ -0,0 +1,13 @@ +def is_simple_power?(x, n) + return false if x < 1 || n < 1 + return true if x == 1 + return false if n == 1 + + current = n + while current <= x + return true if current == x + current *= n + end + + false +end \ No newline at end of file diff --git a/tasks/t77-moonshotai_kimi_k2.rb b/tasks/t77-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..8b628fa --- /dev/null +++ b/tasks/t77-moonshotai_kimi_k2.rb @@ -0,0 +1,6 @@ +def is_cube?(a) + return true if a == 0 + root = a.abs ** (1.0 / 3) + rounded_root = root.round + rounded_root ** 3 == a +end \ No newline at end of file diff --git a/tasks/t78-moonshotai_kimi_k2.rb b/tasks/t78-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f4bd9d2 --- /dev/null +++ b/tasks/t78-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def hex_key(hex_string) + prime_hex_digits = ['2', '3', '5', '7', 'B', 'D'] + hex_string.chars.count { |char| prime_hex_digits.include?(char) } +end \ No newline at end of file diff --git a/tasks/t79-moonshotai_kimi_k2.rb b/tasks/t79-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c31f744 --- /dev/null +++ b/tasks/t79-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def decimal_to_binary(decimal) + "db#{decimal.to_s(2)}db" +end \ No newline at end of file diff --git a/tasks/t8-moonshotai_kimi_k2.rb b/tasks/t8-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..08986e3 --- /dev/null +++ b/tasks/t8-moonshotai_kimi_k2.rb @@ -0,0 +1,5 @@ +def sum_product(numbers) + sum = numbers.sum + product = numbers.empty? ? 1 : numbers.reduce(:*) + [sum, product] +end \ No newline at end of file diff --git a/tasks/t80-moonshotai_kimi_k2.rb b/tasks/t80-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..9a43494 --- /dev/null +++ b/tasks/t80-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def is_happy?(s) + return false if s.length < 3 + + s.downcase.chars.each_cons(3) do |a, b, c| + return false if a == b || b == c || a == c + end + + true +end \ No newline at end of file diff --git a/tasks/t81-moonshotai_kimi_k2.rb b/tasks/t81-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c2bcdad --- /dev/null +++ b/tasks/t81-moonshotai_kimi_k2.rb @@ -0,0 +1,19 @@ +def numerical_letter_grade(grades) + grades.map do |grade| + case grade + when 4.0 then "A+" + when ->(g) { g > 3.7 } then "A" + when ->(g) { g > 3.3 } then "A-" + when ->(g) { g > 3.0 } then "B+" + when ->(g) { g > 2.7 } then "B" + when ->(g) { g > 2.3 } then "B-" + when ->(g) { g > 2.0 } then "C+" + when ->(g) { g > 1.7 } then "C" + when ->(g) { g > 1.3 } then "C-" + when ->(g) { g > 1.0 } then "D+" + when ->(g) { g > 0.7 } then "D" + when ->(g) { g > 0.0 } then "D-" + else "E" + end + end +end \ No newline at end of file diff --git a/tasks/t82-moonshotai_kimi_k2.rb b/tasks/t82-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..03fbe3b --- /dev/null +++ b/tasks/t82-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def prime_length?(string) + length = string.length + return false if length < 2 + (2..Math.sqrt(length)).each do |i| + return false if length % i == 0 + end + true +end \ No newline at end of file diff --git a/tasks/t83-moonshotai_kimi_k2.rb b/tasks/t83-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..1f7d9a0 --- /dev/null +++ b/tasks/t83-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def starts_one_ends(n) + return 2 if n == 1 + 2 * 10**(n - 1) - 10**(n - 2) +end \ No newline at end of file diff --git a/tasks/t84-moonshotai_kimi_k2.rb b/tasks/t84-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b425bd3 --- /dev/null +++ b/tasks/t84-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def sum_binary_digits(n) + sum = n.to_s.chars.map(&:to_i).sum + sum.to_s(2) +end \ No newline at end of file diff --git a/tasks/t85-moonshotai_kimi_k2.rb b/tasks/t85-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..66e8c68 --- /dev/null +++ b/tasks/t85-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def add_even_at_odd(lst) + lst.each_slice(2).sum { |pair| pair[1]&.even? ? pair[1] : 0 } +end \ No newline at end of file diff --git a/tasks/t86-moonshotai_kimi_k2.rb b/tasks/t86-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..72dfd31 --- /dev/null +++ b/tasks/t86-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def anti_shuffle(s) + s.split(/(\s+)/).map { |word| word.strip.empty? ? word : word.chars.sort.join }.join +end \ No newline at end of file diff --git a/tasks/t87-moonshotai_kimi_k2.rb b/tasks/t87-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..6baa84b --- /dev/null +++ b/tasks/t87-moonshotai_kimi_k2.rb @@ -0,0 +1,9 @@ +def get_row(lst, x) + result = [] + lst.each_with_index do |row, row_index| + row.each_with_index do |element, col_index| + result << [row_index, col_index] if element == x + end + end + result.sort_by { |row, col| [row, -col] } +end \ No newline at end of file diff --git a/tasks/t88-moonshotai_kimi_k2.rb b/tasks/t88-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..07c8213 --- /dev/null +++ b/tasks/t88-moonshotai_kimi_k2.rb @@ -0,0 +1,15 @@ +def sort_array(array) + return [] if array.empty? + return array.dup if array.size == 1 + + sorted = array.dup + sum = array.first + array.last + + if sum.odd? + sorted.sort! + else + sorted.sort!.reverse! + end + + sorted +end \ No newline at end of file diff --git a/tasks/t89-moonshotai_kimi_k2.rb b/tasks/t89-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..2734548 --- /dev/null +++ b/tasks/t89-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def encrypt(s) + s.chars.map do |char| + pos = char.ord - 'a'.ord + 1 + shift = pos * 2 + new_pos = (char.ord - 'a'.ord + shift) % 26 + ('a'.ord + new_pos).chr + end.join +end \ No newline at end of file diff --git a/tasks/t9-moonshotai_kimi_k2.rb b/tasks/t9-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..bdcd86f --- /dev/null +++ b/tasks/t9-moonshotai_kimi_k2.rb @@ -0,0 +1,7 @@ +def rolling_max(numbers) + max_so_far = nil + numbers.each_with_object([]) do |num, result| + max_so_far = max_so_far.nil? ? num : [max_so_far, num].max + result << max_so_far + end +end \ No newline at end of file diff --git a/tasks/t90-moonshotai_kimi_k2.rb b/tasks/t90-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..89ae2d9 --- /dev/null +++ b/tasks/t90-moonshotai_kimi_k2.rb @@ -0,0 +1,6 @@ +def next_smallest(list) + return nil if list.size < 2 + + unique_sorted = list.uniq.sort + unique_sorted.size < 2 ? nil : unique_sorted[1] +end \ No newline at end of file diff --git a/tasks/t91-moonshotai_kimi_k2.rb b/tasks/t91-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..f2d569c --- /dev/null +++ b/tasks/t91-moonshotai_kimi_k2.rb @@ -0,0 +1,6 @@ +def count_boredoms(text) + return 0 if text.empty? + + sentences = text.split(/[.!?]+/) + sentences.count { |sentence| sentence.strip.start_with?('I ') || sentence.strip == 'I' } +end \ No newline at end of file diff --git a/tasks/t92-moonshotai_kimi_k2.rb b/tasks/t92-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..5fa76a1 --- /dev/null +++ b/tasks/t92-moonshotai_kimi_k2.rb @@ -0,0 +1,4 @@ +def any_int?(x, y, z) + return false unless [x, y, z].all? { |num| num.is_a?(Integer) } + x + y == z || x + z == y || y + z == x +end \ No newline at end of file diff --git a/tasks/t93-moonshotai_kimi_k2.rb b/tasks/t93-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..ed6a14d --- /dev/null +++ b/tasks/t93-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def encode(message) + vowels = 'aeiouAEIOU' + message.chars.map do |char| + new_char = char.swapcase + if vowels.include?(new_char) + new_char = (new_char.ord + 2).chr + end + new_char + end.join +end \ No newline at end of file diff --git a/tasks/t94-moonshotai_kimi_k2.rb b/tasks/t94-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..15a2d68 --- /dev/null +++ b/tasks/t94-moonshotai_kimi_k2.rb @@ -0,0 +1,20 @@ +def sum_largest_prime_digits(numbers) + return 0 if numbers.empty? + + def prime?(n) + return false if n < 2 + return true if n == 2 + return false if n.even? + + (3..Math.sqrt(n)).step(2) do |i| + return false if n % i == 0 + end + true + end + + primes = numbers.select { |n| prime?(n) } + return 0 if primes.empty? + + largest_prime = primes.max + largest_prime.to_s.chars.map(&:to_i).sum +end \ No newline at end of file diff --git a/tasks/t95-moonshotai_kimi_k2.rb b/tasks/t95-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..9eb64b7 --- /dev/null +++ b/tasks/t95-moonshotai_kimi_k2.rb @@ -0,0 +1,11 @@ +def check_dict_case(hash) + return false if hash.empty? + + keys = hash.keys + return false unless keys.all? { |key| key.is_a?(String) } + + lower_case_keys = keys.all? { |key| key == key.downcase } + upper_case_keys = keys.all? { |key| key == key.upcase } + + lower_case_keys || upper_case_keys +end \ No newline at end of file diff --git a/tasks/t96-moonshotai_kimi_k2.rb b/tasks/t96-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..1583b16 --- /dev/null +++ b/tasks/t96-moonshotai_kimi_k2.rb @@ -0,0 +1,23 @@ +def count_up_to(n) + return [] if n <= 2 + + primes = [] + candidate = 2 + + while candidate < n + is_prime = true + + primes.each do |prime| + break if prime * prime > candidate + if candidate % prime == 0 + is_prime = false + break + end + end + + primes << candidate if is_prime + candidate += 1 + end + + primes +end \ No newline at end of file diff --git a/tasks/t97-moonshotai_kimi_k2.rb b/tasks/t97-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b719ce3 --- /dev/null +++ b/tasks/t97-moonshotai_kimi_k2.rb @@ -0,0 +1,3 @@ +def multiply(a, b) + (a.abs % 10) * (b.abs % 10) +end \ No newline at end of file diff --git a/tasks/t98-moonshotai_kimi_k2.rb b/tasks/t98-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..c40ad1d --- /dev/null +++ b/tasks/t98-moonshotai_kimi_k2.rb @@ -0,0 +1,8 @@ +def count_upper(s) + vowels = ['A', 'E', 'I', 'O', 'U'] + count = 0 + s.chars.each_with_index do |char, index| + count += 1 if index.even? && vowels.include?(char) + end + count +end \ No newline at end of file diff --git a/tasks/t99-moonshotai_kimi_k2.rb b/tasks/t99-moonshotai_kimi_k2.rb new file mode 100644 index 0000000..b06c893 --- /dev/null +++ b/tasks/t99-moonshotai_kimi_k2.rb @@ -0,0 +1,10 @@ +def closest_integer(value) + num = value.to_f + int_part = num.to_i + + if num >= 0 + (num - int_part) >= 0.5 ? int_part + 1 : int_part + else + (int_part - num) >= 0.5 ? int_part - 1 : int_part + end +end \ No newline at end of file