Today's challenge is from davazp on CodeWars.
The function will accept an input of non-negative integers. If it is zero, it just returns "now". O...
For further actions, you may consider blocking this person and/or reporting abuse
JavaScript
With a little bit of cheating: instead of replacing the last comma with an "and", I just add the "and" to the last element and claim that everyone should be using Oxford comma to avoid misunderstandings.
Live demo on CodePen.
This feels overcomplicated. It probably can be done easier with a
map
or areduce
. I'll check later with more time.Hello Alvaro. Did u get a chance to work on this?🤓
LOL. I didn't 😓😬
Thats fine Alvaro. Are u on discord??
Not really. I have only used once or twice.
Cool.i like the way you explain things man. Just want to be in touch with you to ask some basic doubta as im a beginner. Is there any other way i can be in touch. Do u have wssap? I wont bother u much.dont be scared😅
I'm not going to lie: I've had bad experiences with this in the past. If you have questions and you post them here or in StackOverflow, I'll be happy to look at them and answer if I know the answer.
Easy to muck up, that's for sure. For awhile, I had this thing trying to say that
3600
was equal to several days (instead of an hour).Quite enjoyable. Turns out that Wolfram Alpha stops being terribly useful if you give it a large number of seconds, so had to go "sure, that looks right" a couple times.
Gist: gist.github.com/kerrishotts/e655d6...
Javascript (no idea whether this works or not :D )
I may change the formatter function to be more elegant and less crappy using slice and arrays and idontknow.
(Late) Rust Solution
Python3
Solution
Output
The
pretty_output
method was more challenging than I first thought, I did get a bit lazy with the if/elif/else statementsRuby
4500 seconds: 1 hour and 15 minutes
2000487 seconds: 23 days, 3 hours, 41 minutes and 27 seconds
42000487 seconds: 1 year, 121 days, 2 hours, 48 minutes and 7 seconds
1563739200 seconds: 49 years, 213 days and 20 hours
Elixir:
Ahh ya I didn't notice that on my first quick read through. I did get the commas right, I believe, so I got that going for me!
The part of this that I really like is just defining the conversion functions, it reads much better than the solution that I came up with in terms of how the conversions all work!
A functional style one in JS
that was fun 😋
Ya this answer ruined me 😆
Once I read it's the only way to 'cleanly' solve it I could think of!
I opted to force myself to go with a different iterativ-ish solution but this one gets my vote here!
This is great