Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #58172 > unrolled thread

Rosetta: Find the last Sunday of each month

Started by"Robert L." <No_spamming@noWhere_7073.org>
First post2017-04-26 06:28 +0000
Last post2017-04-26 06:28 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.forth


Contents

  Rosetta: Find the last Sunday of each month "Robert L." <No_spamming@noWhere_7073.org> - 2017-04-26 06:28 +0000

#58172 — Rosetta: Find the last Sunday of each month

From"Robert L." <No_spamming@noWhere_7073.org>
Date2017-04-26 06:28 +0000
SubjectRosetta: Find the last Sunday of each month
Message-ID<odpell$fh4$1@gioia.aioe.org>
> Write a program or a script that returns the last Sundays of
> each month of a given year. The year may be given through any
> simple input method in your language (command line, std in,
> etc).
> 
> Example of an expected output: 
> 
> ./last_sundays 2013
> 2013-01-27
> 2013-02-24
> 2013-03-31
> 2013-04-28
> 2013-05-26
> 2013-06-30
> 2013-07-28
> 2013-08-25
> 2013-09-29
> 2013-10-27
> 2013-11-24
> 2013-12-29

require 'date'

year = (ARGV[0]||2013).to_i
puts Date.new(year).upto(Date.new(year,12,31)).
select(&:sunday?).group_by(&:month).map{|_,v| v.last}

2013-01-27
2013-02-24
2013-03-31
2013-04-28
2013-05-26
2013-06-30
2013-07-28
2013-08-25
2013-09-29
2013-10-27
2013-11-24
2013-12-29

In Forth?

-- 
In his message [the Jew Nicolas] Sarkozy insisted that the French people must
change, that there will be dire consequences if they don't, and that not to
intermarry racially is bad for the survival of the country.
archive.org/download/DavidDuke_videos/StopTheGenocideOfEuropeanMankindDavidDuke-z43pcbr_el0.ogv

[toc] | [standalone]


Back to top | Article view | comp.lang.forth


csiph-web