Skip to content

Instantly share code, notes, and snippets.

View enderahmetyurt's full-sized avatar
🦄

Ender Ahmet Yurt enderahmetyurt

🦄
View GitHub Profile
@enderahmetyurt
enderahmetyurt / flippedy.rb
Created February 4, 2026 15:05
You are given a string consisting of lowercase words, each separated by a single space. Determine how many vowels appear in the first word. Then, reverse each following word that has the same vowel count.
# Examples:
# `flippedy("cat and mice")
# > "cat dna mice"
#
def flippedy(input)
words = input.split(" ")
vowels_count = words.first.scan(/[aeiou]/).count
@enderahmetyurt
enderahmetyurt / nearest_perfect_months.rb
Created February 4, 2026 15:36
February 2026 is a perfect month! Write a function that returns the closest previous and next perfect month around the given Gregorian year.
# Examples:
# nearestPerfectMonths(2025)
# > { prev: "2021-02", next: "2026-02" }
require 'date'
def find_nearest_perfect_months(year)
prev_year = year - 1
prev_year -= 1 until perfect_february?(prev_year)