POV-Ray : Newsgroups : povray.off-topic : Reflections on employment : Re: Reflections on employment Server Time
28 Jul 2024 20:22:37 EDT (-0400)
  Re: Reflections on employment  
From: Orchid Win7 v1
Date: 2 Dec 2012 10:48:38
Message: <50bb7856$1@news.povray.org>
On 02/12/2012 03:06 PM, Warp wrote:
> Orchid Win7 v1<voi### [at] devnull>  wrote:
>> Here's a challenge - write me a C# function (or even just some
>> psuedocode) which will take a string containing space-delimited positive
>> integers, and return them in ascending order.
>
> If it were C++, I could write a few lines of code that does that,

Or, indeed, any half-sane programming language you care to use, really...

> although
> with the caveat that I would first have to ask what the return type should
> be

This is unspecified. Another space-delimited string would be fine, a 
list or array of integers would be fine, really any "appropriate" 
container is fine. What we're really looking for is

1) You can figure out how to split a string and parse it into integers.
2) You can sort the result.
3) You can return it to the caller.

Not forgetting item 0 ("you realise that this is what you need to do to 
solve the overall problem"). For example, sorting the ASCII substrings 
won't give the correct answer, because the integers may have different 
numbers of digits. So you actually have to parse them. (I /suppose/ 
padding the substrings with zeros would achieve the same thing... but 
parsing an integer isn't exactly hard.)

> and whether there should be any kind of error-checking or not (and if
> yes, how errors should be notified to the calling code.)

That would certainly add bonus points. But then, about the only error I 
can think of is if the string contains characters other than spaces and 
digits. Returning null would probably be fine.

> Space-delimited
> integers in a string happens to be one of the easiest things to parse in C++.
> (It would be much more complicated if the syntax were more complex.)

The matter is similar in C# - a standard library function performs this 
exact task. Which, presumably, is why it was chosen.

> I assume there's an at least as easy way of doing it in C#, but since
> I don't know the language I would fail the test.

At this point, we're not even asking for correct class or method names. 
Just something that looks like vaguely valid C# syntax and has logic 
which isn't obviously gibberish.

This is how easy we're making it, and nobody has yet managed to pull it off.

I weep.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.