Ok, here's what I would try:

weeks=: 0 0 -.~0&".@>a:-.~,|:<;._1;._2]0 :0
|1643 1646|1715 1720|1743 1750|1814 1824|1840 1907|
|1644 1646|1716 1720|1744 1746|1815 1816|1841 1842|
|1645 1650|1718 1724|1745 1750|1816 1820|1842 1846|
|1646 1650|1719 1724|1746 1749|1817 1820|1843 1846|
|1648 1703|1721 1737|1748 1803|1818 1824|1844 1846|
|1649 1729|1724 1729|1749 1750|1820 1911|1845 1846|
|1650 1711|1725 1737|1750 1820|1821 1824|1846 1851|
|1651 1707|1726 1729|1751 1803|1824 1838|1848 1907|
|1701 1707|1727 1729|1801 1803|1825 1829|1851 1903|
|1702 1707|1729 1742|1803 1820|1826 1829|1901 1903|
|1703 1707|1730 1737|1804 1816|1827 1829|1902 1903|
|1706 1711|1732 1733|1805 1824|1828 1838|1907 1911|
|1707 1711|1732 1803|1806 1807|1829 1833|1908 1911|
|1708 1711|1733 1746|1807 1811|1830 1833|1911 1916|
|1709 1720|1734 1742|1808 1811|1831 1833|         |
|1710 1737|1736 1746|1809 1811|1832 1833|         |
|1711 1724|1737 1742|1810 1811|1833 1838|         |
|1712 1720|1738 1742|1811 1911|1834 1838|         |
|1713 1724|1741 1746|1812 1816|1838 1907|         |
|1714 1716|1742 1750|1813 1816|1839 1907|         |
)

mat=: ,.&.|:  NB. performance ok on large args?
keeper=: ,^:(4 > [: +/ ] 1&e.@I."1 (0 1)+[) mat


   #weeks
94
   #keeper/&.|.weeks
49

I hope this helps,

---
Raul

On Mon, Apr 1, 2019 at 1:41 PM R.E. Boss <[email protected]> wrote:
>
> Yes, because in the result 1650 1711 was omitted first, so 1701 1707 could 
> stay.
>
> BTW, the remark of Mike Day was correct.
>
>
> R.E. Boss
>
>
> > -----Oorspronkelijk bericht-----
> > Van: Programming <[email protected]>
> > Namens Henry Rich
> > Verzonden: maandag 1 april 2019 18:41
> > Aan: [email protected]
> > Onderwerp: Re: [Jprogramming] Max 4 overlapping intervals.
> >
> > Wait a minute... 1701 1707 overlaps 4 previous intervals, but you left it 
> > in your
> > result.
> >
> > Henry Rich
> >
> > On 4/1/2019 6:18 AM, R.E. Boss wrote:
> > > Given a series of intervals of weeks, given by the begin week up to and
> > including the end week, each week denoted by yyww, with yy last two digits
> > of year and ww the weeknumber.
> > > +---------+---------+---------+---------+---------+
> > > |1643 1646|1715 1720|1743 1750|1814 1824|1840 1907|
> > > |1644 1646|1716 1720|1744 1746|1815 1816|1841 1842|
> > > |1645 1650|1718 1724|1745 1750|1816 1820|1842 1846|
> > > |1646 1650|1719 1724|1746 1749|1817 1820|1843 1846|
> > > |1648 1703|1721 1737|1748 1803|1818 1824|1844 1846|
> > > |1649 1729|1724 1729|1749 1750|1820 1911|1845 1846|
> > > |1650 1711|1725 1737|1750 1820|1821 1824|1846 1851|
> > > |1651 1707|1726 1729|1751 1803|1824 1838|1848 1907|
> > > |1701 1707|1727 1729|1801 1803|1825 1829|1851 1903|
> > > |1702 1707|1729 1742|1803 1820|1826 1829|1901 1903|
> > > |1703 1707|1730 1737|1804 1816|1827 1829|1902 1903|
> > > |1706 1711|1732 1733|1805 1824|1828 1838|1907 1911|
> > > |1707 1711|1732 1803|1806 1807|1829 1833|1908 1911|
> > > |1708 1711|1733 1746|1807 1811|1830 1833|1911 1916|
> > > |1709 1720|1734 1742|1808 1811|1831 1833|         |
> > > |1710 1737|1736 1746|1809 1811|1832 1833|         |
> > > |1711 1724|1737 1742|1810 1811|1833 1838|         |
> > > |1712 1720|1738 1742|1811 1911|1834 1838|         |
> > > |1713 1724|1741 1746|1812 1816|1838 1907|         |
> > > |1714 1716|1742 1750|1813 1816|1839 1907|         |
> > > +---------+---------+---------+---------+---------+
> > >
> > > Question: starting with the first interval I want all intervals removed 
> > > which
> > overlap 4 or more previous intervals, like the 7th interval 1650 1711 does.
> > > Looplessness required, elegance preferred.
> > >
> > > My solution, which I hope is correct, is
> > > +---------+---------+---------+
> > > |1643 1646|1741 1746|1830 1833|
> > > |1644 1646|1742 1750|1831 1833|
> > > |1645 1650|1743 1750|1832 1833|
> > > |1646 1650|1748 1803|1834 1838|
> > > |1648 1703|1751 1803|1838 1907|
> > > |1649 1729|1801 1803|1839 1907|
> > > |1651 1707|1804 1816|1840 1907|
> > > |1701 1707|1805 1824|1908 1911|
> > > |1706 1711|1806 1807|1911 1916|
> > > |1708 1711|1807 1811|         |
> > > |1709 1720|1808 1811|         |
> > > |1712 1720|1812 1816|         |
> > > |1713 1724|1813 1816|         |
> > > |1721 1737|1817 1820|         |
> > > |1724 1729|1818 1824|         |
> > > |1725 1737|1820 1911|         |
> > > |1730 1737|1821 1824|         |
> > > |1732 1733|1825 1829|         |
> > > |1732 1803|1826 1829|         |
> > > |1738 1742|1827 1829|         |
> > > +---------+---------+---------+
> > >
> > >
> > > R.E. Boss
> > > ----------------------------------------------------------------------
> > > For information about J forums see
> > http://www.jsoftware.com/forums.htm
> >
> >
> > ---
> > This email has been checked for viruses by AVG.
> > https://www.avg.com
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to