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


Groups > comp.lang.forth > #58172

Rosetta: Find the last Sunday of each month

Path csiph.com!aioe.org!.POSTED!not-for-mail
From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject Rosetta: Find the last Sunday of each month
Date Wed, 26 Apr 2017 06:28:06 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 47
Message-ID <odpell$fh4$1@gioia.aioe.org> (permalink)
NNTP-Posting-Host F44e9/1w/zXwp2fsM0sNFw.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1
X-Complaints-To abuse@aioe.org
User-Agent XanaNews/1.18.1.6
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.forth:58172

Show key headers only | View raw


> 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

Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web