Friday 13th or Black Friday is considered as an unlucky day. Calculate how many unlucky days are in the given year.
Can you find the number of Fri...
For further actions, you may consider blocking this person and/or reporting abuse
JavaScript
Live demo on CodePen
Brilliant solution, very simple and effective. Although I think
? 1 : 0
is not necessary :pYes. It's not really necessary because
true
is turn into 1, andfalse
to 0. I have a second version using that and a reducer in the demo.Javascript shorty
Javascript:
You can determine the number of Fridays in a given year as the number of days between the 13th of one and the next month is fixed. All you need to know is the day of January 13th and whether the year is a leap-year.
In one single Smalltalk line, because we can:
Perl solution, using the core library Time::Piece.
It works because grep in scalar context returns the number of trues.
Elixir:
My python sol :
//Go
package kata
import
(
"time"
)
func UnluckyDays(year int) int {
unlucky:=0
for m:=1;m<=12;m++ {
}
return unlucky
}
Python