DEV Community

Brittany
Brittany

Posted on

2 1

Day 35 : #100DaysofCode - A Code Challenge Completed

The weekend is over so better content coming soon, but today I completed code challenges, which was cool.

The ones that I completed were relatively easy, but it still feels good to be able to find solutions to coding challenges as a "codenewbie"

Challenge 1 - Remove the vowels from a string

The challenge asked for me to create a function that takes a string as an argument and returns a new string with all vowels removed.

I wrote the following code:

def disemvowel(string) 
  string.gsub(/[aeiouAEIOU]/, '')
end
Enter fullscreen mode Exit fullscreen mode

It worked perfectly and I was able to move on to the next challenge. However, as I go through challenges I realized that I do not only want to find the "answer" but I want to find multiple ways to solve the answer. So I also found another way to solve the problem using tr which "returns a copy of str with the characters in from_str replaced by the corresponding characters in to_str." :

def disemvowel(string)
  string.tr('aeiouAEIOU', "") 
end
Enter fullscreen mode Exit fullscreen mode

Both ways will work but as a software engineer it is important to constantly find different or new solutions for all problems that are presented to you. The same code can be written in many ways and in many different languages, it is important to learn and know different solutions for various issues that may arise.

Excited for future code challenges and the solutions I develop.

Song of the day:

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay