Path: ...!news-out.netnews.com!postmaster.netnews.com!us3.netnews.com!not-for-mail X-Trace: DXC=5nJPUff5[gZBW6J?LlRQ?47NQ;EPk]NUZ8^^mT@jJkDJJI@ZjWnWjB\Oa:X5b?f8h X-Complaints-To: support@blocknews.net Date: Tue, 18 Jun 2024 14:14:27 -0400 MIME-Version: 1.0 User-Agent: Betterbird (Windows) Subject: Re: Baby X is bor nagain Newsgroups: comp.lang.c References: <20240613002933.000075c5@yahoo.com> <20240613174354.00005498@yahoo.com> <20240617002924.597@kylheku.com> <20240618115650.00006e3f@yahoo.com> Content-Language: en-US From: DFS In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Lines: 19 Message-ID: <6671ce83$0$3620715$882e4bbb@reader.netnews.com> NNTP-Posting-Host: 127.0.0.1 X-Trace: 1718734467 reader.netnews.com 3620715 127.0.0.1:36827 Bytes: 1816 On 6/18/2024 12:11 PM, David Brown wrote: > if n % 2 == 1 : >         median = sorted(data)[n // 2] > else : >         median = sum(sorted(data)[(n // 2 - 1) : (n // 2 + 1)]) / 2 I think your else formula (n % 2 == 0) is incorrect: n = 4 data = [1,2,3,4] median = 2.5 Yours appears to sum (1,2,3) = 6 / 2 = 3. Am I reading it correctly?