Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Baby Stepper – 94 of 100 Days of Code

  • February 25, 2021February 26, 2021
  • by Richard Clarke

The little wins will take you further than you think.

I started a codewars challenge called Keep Hydrated. In the example, a cyclist drinks a certain amount of water over time. With the numbers given, create a program that calculates how much water they drink after a certain amount of time.

 

PSEUDOCODE

My pseudocode for this challenge goes:

  1. Prompt for time
  2. Round time down to an integer
  3. If even, divide by two for liters
  4. Else, subtract one first, THEN divide by two for liters of water
  5. Display the liters of water drank.

Everything went great! That was, until I ran into a weird error in Visual Studio Code. I got this warning that wouldn’t let me save my work. 

THE BUG

I tried editing the file security settings, but my account was still listed as an owner. In the end, I restarted my laptop and everything worked as expected. I could finally save!

GETTING INPUT

Kotlin uses a method called readLine() for obtaining input from the keyboard. I tested this in another program where I prompted users to enter their name and displayed it

ROUNDING DOWN

Kotlin has a function called .toInt() which converts decimals to integers. It truncates the decimal, meaning, it takes the number and only keeps the digit in the ones place. 1.5 becomes 1, 6.7 becomes 6, etc. In other words, it rounds down.

Getting back on codewars was a great move. No point in waiting to build apps before I use Kotlin. I can practice the language in the mean time.

I picked a good challenge to start with. It’s simple and I figured it out pretty fast. I wish I had started doing this sooner. Not to mention, working on this led me to solving that weird VS Code error. Even the little things bring experience!

Moving forward, I’ll start doing coding challenges regularly to keep my skills sharp.

Building big projects is important, but these small victories are just as necessary.

Join the mailing list to see updates like this every week!
Coding Fanatic

Sources:

Codewars Keep Hydrated Codingkata

Image by Free-Photos from Pixabay

Image by Simon from Pixabay

Image by Chuk Yong from Pixabay

 

Related

Handling a Coding Test – Road to Pro 9
Five Tips for Socializing Online – Road 2 Pro 10
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android Android Development AndroidDev development kotlin software software development

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress