Deutsch   English   Français   Italiano  
<vrefb3$s307$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: DFS <nospam@dfs.com>
Newsgroups: comp.lang.c
Subject: Re: Suggested method for returning a string from a C program?
Date: Wed, 19 Mar 2025 09:03:33 -0400
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <vrefb3$s307$1@dont-email.me>
References: <vrd77d$3nvtf$2@dont-email.me> <vre5gt$jkpr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 Mar 2025 14:03:32 +0100 (CET)
Injection-Info: dont-email.me; posting-host="901d9964429cda711e0950a8728255b7";
	logging-data="920583"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18MrBru3srR7NKVfX2ceIgb"
User-Agent: Betterbird (Windows)
Cancel-Lock: sha1:++ylle97HWiaulYGGA1p6cygdXQ=
In-Reply-To: <vre5gt$jkpr$1@dont-email.me>
Content-Language: en-US
Bytes: 2022

On 3/19/2025 6:15 AM, bart wrote:
> On 19/03/2025 01:38, DFS wrote:
>>
>> I'm doing these algorithm problems at
>> https://cses.fi/problemset/list/
>>
>> For instance: Weird Algorithm
>> https://cses.fi/problemset/task/1068
> 
> This is related to the Collatz Conjecture. What's weird is not 
> mentioning it.

I wouldn't have known it was a famous math conjecture, but no doubt the 
author of the problem did.



>>                  len = strlen(result);
>>                  sprintf(result + len, "%d ", n);
> 
> And what's odd here is collating the results in a string (especially 
> when the possible number of steps is unknown). Why not just print it 
> straight to the console?


My initial submission used straight to console.  It was rejected for 
untold reasons, so I tried a variety of changes, including collating.

I went back to printing to console, and along with the other fixes the 
code was finally accepted.