Cheryl's birthday: Difference between revisions
m
→{{header|Julia}}
(add Julia example) |
|||
Line 1,187:
uniqueday(parr) = filter(x -> sum(y -> y[1] == x[1], parr) == 1, parr)
# At the start, they come to know that they have no unique day of month to identify.
f1 = filter(m -> !(m[2] in [d[2] for d in uniqueday(dates)]), dates)
# After eliminating all months with unique dates, they now come to know the answer has a unique date.
bday = uniqueday(f1)[1]
println("Cheryl's birthday is $(bday[2]) $(bday[1]).")
</lang>{{out}}
<pre>
|