Cheryl's birthday: Difference between revisions

m
→‎{{header|Sidef}}: updated code to use the built-in Date class
m (Thundergnat moved page Cheryl's Birthday to Cheryl's birthday: Follow normal task title capitalization policy)
m (→‎{{header|Sidef}}: updated code to use the built-in Date class)
Line 2,425:
=={{header|Sidef}}==
{{trans|Raku}}
<lang ruby>structfunc Datef(day, month) {
Date.parse("#{day} #{month}", "%d %B")
}
 
var dates = [
Datef(15, "May"),
Datef(16, "May"),
Datef(19, "May"),
Datef(17, "June"),
Datef(18, "June"),
Datef(14, "July"),
Datef(16, "July"),
Datef(14, "August"),
Datef(15, "August"),
Datef(17, "August")
]
 
 
var filtered = dates.grep {
dates.grep {
dates.map{ .day }.count(.day) == 1
}.map{ .month }.count(.month)  != 1
}
 
 
var birthday = filtered.grep {
filtered.map{ .day }.count(.day) == 1
}.group_by{ .month }.values.first_by { .len == 1 }[0]
 
 
say "Cheryl's birthday is #{birthday.monthfullmonth} #{birthday.day}."</lang>
{{out}}
<pre>
2,747

edits