• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

what is this constraint all about?

 
Ranch Hand
Posts: 821
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I will be taking another coding test soon but this time round in another platform - CodeSignal.

So, now I am only practising the 3rd question - very slow progress.

And in this question : I notice there is a line that states :

Please see attached the full question


guranteed constraint :

2 ≤ m ≤ 100.



What is this constraint all about?

What if it is not <= 100 and not 2 but some other numbers, will it make a difference to the algorithms when calculating the distribution of the candies?

Candies.png
[Thumbnail for Candies.png]
 
Rancher
Posts: 978
23
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2 is less then or equal to m and m is less than or equal to 100 or, how i prefer it

m is greater than or equal to 2 and m is less than or equal to 100

it is nothing more than m is between 2 and 100 inclusive.
 
Bartender
Posts: 4633
182
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And try m = 1, m = 0, m = -5, m = 101 and m = 1.000.000, and see what happens.
 
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, for these types of problems, not just this problem:

Any constraints listed are an important part of the instructions for what you have to do.

That is, your solution must work for every possible value within the constraints.

Your solution need not do anything reasonable for anything outside the constraints.

They are telling you what you must pay attention to, and what you may ignore when considering your solution.

In real programming, we do quite a bit of work validating inputs and parameters, to make our code robust.

In these sorts of programming challenges, we focus on ensuring we obtain a correct solution within resource (e.g. cpu time and memory limits) for all legal inputs.

We do not go all out ensuring that the program generates clear error messages, without crashing, for inputs outside the constraints.

Please continue to make real programs you write for general use robust.  Any invalid inputs should be clearly complained about so the user can figure out what she did wrong.

Please do NOT waste time considering the behavior of your code for inputs that violate the constraints, you will not get such inputs, the constraints are a promise of that.

Sometimes it tells you which data types you will need, i.e. the range might not fit into an int, and you will need to use a long for that type and others computed from it.

Perhaps there is a value that something gets divided by in your code.  If the constraint tells you it is >= 2, you don't need to check it for being 0 before doing the division, etc. etc. etc.

So you get two things from the constraints:
1. Your program must work correctly for any and all values, or numbers of values, consistent with the constraints.
2. You should not waste time thinking about and coding for values outside of such constraints.
 
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I've said multiple times, if you learn nothing else from Calculus, you should learn its fundamental properties: range and domain. These determine what the acceptable inputs and expected outputs are for a given function. Or for that matter, a given Java method.

If you can demonstrate that your code adheres to the range and domain that were defined for that code and that you handle violations in an acceptable way, then you have effectively mathematically proven the reliability of your code.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:As I've said multiple times, if you learn nothing else from Calculus, you should learn its fundamental properties: range and domain. These determine what the acceptable inputs and expected outputs are for a given function. Or for that matter, a given Java method.

If you can demonstrate that your code adheres to the range and domain that were defined for that code and that you handle violations in an acceptable way, then you have effectively mathematically proven the reliability of your code.



Tim, this is great advice for most programming, but one positive change that I have made is that I no longer strive for rock-solid input validation and checking for conditions outside the constraints of a problem given on a timed programming challenge.  Such code which is so important in Real Life often doesn't contribute to the bottom line of getting correct answers for all cases which ARE allowed to show in inputs.

If you write your code exactly the same way for programming challenges that have clear constraints and to make usable programs with good UX for end users, you will either run out of time (sometimes CPU time, but most likely actual minutes) or have very exasperated users of your interactive or non-interactive end-user programs.

The appropriate amount of time spent on careful input validation and generating thoughtful, clear error messages in the two cases is diametrically opposed.

So, writing robust usable code for End Users:
1. The constraints are important!  You must generate efficient, correct answers for all inputs within these constraints.  2. You also must clearly communicate to the End User any violations of these constraints in input you receive, so they know what to fix (or to ask someone else to fix).


Writing code for code challenges:
1. The constraints are important!  You must generate efficient, correct answers for all inputs within these constraints.  2. They are generally a promise that you won't see other inputs, which basically become "Don't Care!" conditions for your solution.  Inputs outside these constraints may crash your program, generate bizarre results, go into infinite loops, and none of these will affect your score because they promised they won't happen.  Don't spend time trying to handle them or generate nice, understandable error messages for the, this is just Good Coding for Real User Solutions, but is a waste of both programmer and cpu time in most coding challenges.

On Interviews:
You should be closer to "Code Challenge" mode.  It is fine while you are typing out your code to mention aloud the various things you would be checking for and handling in real code, if they want to see one of those they will say "Yeah, put that in" but it is good to let them know you consider that.  They mostly want to see you generate correct results for valid inputs, many of them want to know that you can determine the cost of anything you do in Big O() notation and that you understand how to properly test code you wrote.
 
Tim Holloway
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. But I learned long ago that if you skip over the "things that will never happen", you'll get phoned at 3AM by an annoyingly cheerful system operator who will inform you that what should never happen - happened. And if you didn't load up the coade with anti-bugging and emergency logging, you'll spend many unhappy hours trying to diagnose and repair something that often ends up being trivial, all while under pressure to get it back online.

The "Git 'R Dun!" mentality is the root of most system failures and many security breaches, excluding those that aren't committed by persuading gullible users. Git 'R Dun is closely related to unrealistic development schedules, which is in turn based on AYHTDI ("All You Have To Do Is..."). I am extremely unsympathetic to the whole lot and I'm not alone here in my town in that viewpoint.

It is a rare system where the runtime overhead is such that validity checking can be safely dispensed with. And probably a poorly-designed one at that. Assuming that there's any sort of test framework - which is also "useless overhead".

I would have hoped that the pandemic would have disabused people of the virtues of running at 100%, much less the mythical 110%. Zero "wasted" time equals zero "what do we do when it breaks?" time.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yo Tim:

I don't disagree with you, but this discussion belongs at a much higher level than a Beginning Java forum.

The Feedback really needs to go higher than HackerRank and friends/competitors because they are responding to requests by Industry.

I can say that if you write any debug output, warning or error messages to standard output, your code will definitely fail the auto-check which compares STDOUT to expected in 99% of the cases.
I am not sure how often you can write to a non-combined STDERR, however, normally (and I don't want to over-generalize, but I've seen a LOT of these different sites and played with them) I don't think you can rely on getting away with it.

But you know what, you shouldn't expect any of these messages to ever trigger, because they generally (again, risk of over-generalization here, accepted) will NOT provide your code with any inputs that go outside the lines.

Add in the fact that you are usually on time constraint, often severe (I have received 100.00% on one coding challenge that I had 0.00% less than 60 seconds before submission cut-off yielding a score of 0.00%, not exaggerated for emphasis, it was literally the case)...and I would still question whether telling people completing timed coding challenges that they should use the same approach to illegal inputs and other odd circumstances that they would in coding a program for production use by untrained or semi-trained non-programmer users would be sound advice.

It is okay, if we disagree, but we may not actually disagree.  We might for instance think that cannabis product consumption after hours should be none of the government's or corporation's business, or even feel very strongly about it.  That wouldn't make me tell an individual seeking employment that they could party all they want, because it is none of their business what the test taker does.  I would think we should try to get the tests changed.

So I agree that there is way too much emphasis on "Speed At Any Cost" (way mostly in the check-it-in-the-fastest sense than in a runs-screaming-fast sense) but the right place to address it is not to get people taking tightly timed, usually auto-graded tests to writing highly flexible and robust code.  You may have a little more wriggle room on interviews, depending on the place, and some may even appreciate the thoroughness, but my answer was aimed at the particular situation the OP seems to currently be in, hence the "Please don't try to code the same way for production and speed-coding competitions" which I submit many of these often effectively are).
 
Tim Holloway
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's all this about STDOUT? I use loggers.

As for obsession with speed, that's a Junior-grade conceit. All Management cares is that no one's complaining. Anything else is just bragging points to fellow geeks.

As I said once long ago to a fellow geek: It's not like you can keep all those saved microseconds in a JAR for a rainy day.

I do note that coding contests are for geeks, but I tend to think in terms of professional practices myself.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:What's all this about STDOUT? I use loggers.

As for obsession with speed, that's a Junior-grade conceit. All Management cares is that no one's complaining. Anything else is just bragging points to fellow geeks.

As I said once long ago to a fellow geek: It's not like you can keep all those saved microseconds in a JAR for a rainy day.

I do note that coding contests are for geeks, but I tend to think in terms of professional practices myself.



I don't disagree with anything you wrote except in the context of this thread.

Whether we think it is good or not, a LOT of places use automated coding challenges as a bottleneck to screen out people that they will not invest any time talking to.

Others talk first, do coding challenge later, but still, you need to do okay on these to actually get hired.

There seem to be a fair number of these where, depending on which language you are using, it is fairly easy to miss points for some of the larger test cases by running out of CPU, not because of using an algorithm with a wrong O(), but just due to unnecessary work.  Sometimes a straight transliteration into another language will immediately succeed due to fudge factors, but that isn't really an option on an actual test (not enough time)...

Doing a 180 from this contention, I will share a recent experience from a friend of mine.
They had a live coding challenge, they were allowed to pick a language and an environment, and just screen share (this is not very common, but happened to me as well recently).

He Loves Ruby, so he picked Ruby.  If you don't use Ruby much, think JavaScript for the rest of this discussion.
He dislikes IDE's, so he just did it in Vim and command line, or whatever.

The problem wasn't very hard algorithmically, but had a lot of I/O and data massaging and stuff.

He was getting impossible "wrong answers" which he couldn't get rid of before the time ran out, he asked if he could fix it offline, and they said yes.

When he carefully went thru it, there was some step where he thought he had an int value but still had a String.  He was doing String comparisons on int values, and Ruby didn't complain at all, of course everyone knows that "11111" is less than "2", right?

He fixed it and handed it in again, wound up not getting that job (he has since been hired for another one).

His first things was "I know, I know, it would never compile in Java!!" -- well, yeah, that mistake would never have compiled in Java.  It was buried in many lines of code, it didn't jump out at him even looking for weirdness under time pressure.

It probably also would have shown as a Warning in an IDE (I am not sure, I am a little weak at Ruby, and it is possible to be sorting strings that just happen to be valid numbers alphabetically, just not sure)...

So I would say that it makes sense to stick things right into your STDOUT like System.out.println("ERRRORR!!  x is somehow negaive hear--this is imppossible!!"); while you are first writing your code.  Note the misspellings, because you are just typing it as fast as you can.

There are indeed open-book, take-home tests where they have you code something very non-trivial, and invite you to show how you would write production-ready code (tho they often specify that is NOT what they are looking for, just to see how you approach the problem and how easy it is to read your code).

I don't think we are on different sides of the fence on this one.  Coding contests may be for geeks, but most people would need to approach tightly-timed auto-graded code challenges for interviews in the manner of a coding contest, but with even greater time constraints.

EDIT -- corrected "do to" to "due to" (doo doo doo dah dah dah...) other spelling errors are intentional to graphically represent the extreme time-pressure frequently present on such challenges.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just one more thing.

I often spend the last 90 seconds of a tightly-timed coding challenge ripping out logging that had been useful during the raced testing/debugging cycle and hoping I don't accidentally break the compile of the code while doing so at breakneck speed (because I will have almost no time left to fix it if it does somehow break).

You are normally (not always but usually) in environments where you can't just leave that stuff in, because it breaks auto-checkers.

This is way different than when you are spending most of a day getting some code ready for check-in.  It is more like those stupid speed-eating challenges where someone eats 44 hot dogs in 8 and a half minutes to win.

At least it often feels that way to me, and note, I am in fact vegan.

I love food, and can eat quite a lot, and some people like my wife think I eat fast, but I would hate speed-eating challenges and would fare very poorly at them.

I can ignore those and just not participate, but am regularly coding in an equivalent style as part of seeking employment.  I don't love it, but have gotten much better at it, partially by learning the languages better, and partially by treating the Constraints as Sworn Promises that this is all that will be coming at my code.
 
Tim Holloway
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the reasons to use loggers in place of brute-force STDOUT prints is that you can switch them on and off without changing application code. The logging interfaces are specifically designed to have a minimal impact when not enabled. If you're ripping them out, you're defeating their intent. And yes, possibly exposing yourself to introducing bugs. Especially if you're not obsessive about braces on your conditionals like I am.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:One of the reasons to use loggers in place of brute-force STDOUT prints is that you can switch them on and off without changing application code. The logging interfaces are specifically designed to have a minimal impact when not enabled. If you're ripping them out, you're defeating their intent. And yes, possibly exposing yourself to introducing bugs. Especially if you're not obsessive about braces on your conditionals like I am.



I don't even know whether any of the logging frameworks could be casually used in environments like HackerRank and friends.  Maybe they can, and you could turn all the output to STDOUT (indirected) off by just changing one line...it would possibly be worth looking into.  It was my sense that they wouldn't be practically usable in these circumstances, but that could be wrong.
 
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:. . . but this discussion belongs at a much higher level than a Beginning Java forum. . . . except in the context of this thread.

If you hadn't later written the latter part, I would have disagreed with you.
Yes, validating input or arguments is a basic task which beginners should learn within a few weeks. The number of beginners' methods we see which might fail because they don't take account of the fact that Java® integers are implicitly signed, and which could easily be sorted out withbut I am coming round to the opinion that omitting the unsigned keyword was a mistake.
In the context of TG's current test, there is really no instruction to implement such validation, but a promise from the website that the domain of the function to be implemented will be 2...100inc., and it is therefore possible not to validate the input in the current context. In real life I would expect the calling code to supply inputs within the requested domain and the called code to throw an exception if the value is outwith the domain which it can handle. I would also expect any code other than that for private consumption only to declare the constraints in its documentation:-And you can tell I have forgotten all my HTML.
 
Tim Holloway
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I first took formal education in programming, my instructors were actually pretty insistent on validating data.

Now it does happen that it was acceptable to "inherit" validation in that once accepted in the workflow, one was allowed to assume that the data was trustworthy, but that's basically an indirect proof and close enough for most purposes.

Of course if you want really stringent data validation and constraints, that's what Ada was designed for.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Jesse Silverman wrote:. . . but this discussion belongs at a much higher level than a Beginning Java forum. . . . except in the context of this thread.

If you hadn't later written the latter part, I would have disagreed with you.
Yes, validating input or arguments is a basic task which beginners should learn within a few weeks. The number of beginners' methods we see which might fail because they don't take account of the fact that Java® integers are implicitly signed, and which could easily be sorted out with


You will never get me to disagree about this, except maybe in this context.

Campbell Ritchie wrote:
but I am coming round to the opinion that omitting the unsigned keyword was a mistake.


Both ways can bite you in the butt hard and silently.
What does this do in C/C++?



Answer:
Hello World!
Ouch!!!4294967294
Still love unsigned ints?

That is, it makes people very attentive to Lint warnings, or makes them wish that int values were either all signed or all unsigned.
I've taken C++ tests with say, 20 gotchas on them, this would have been one of the easiest two or three of the bunch!
For many, many years, the default for char was signed on about half the platforms, unsigned on the other half.  Fun, fun, fun!

Campbell Ritchie wrote:
In the context of TG's current test, there is really no instruction to implement such validation, but a promise from the website that the domain of the function to be implemented will be 2...100inc., and it is therefore possible not to validate the input in the current context. In real life I would expect the calling code to supply inputs within the requested domain and the called code to throw an exception if the value is outwith the domain which it can handle. I would also expect any code other than that for private consumption only to declare the constraints in its documentation:-



I love that, but both myself and the current OP of this thread will likely often be doing these in a context where they have *just enough time* to get the answer right at all, the typos in my debugging statements were meant to represent this real-world "constraint" (see what I did there?)
We may not love this or think it results in hiring the best programmers, but is more than fairly common, it is actually very common.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:When I first took formal education in programming, my instructors were actually pretty insistent on validating data.


Me too, amigo!

Tim Holloway wrote:
Now it does happen that it was acceptable to "inherit" validation in that once accepted in the workflow, one was allowed to assume that the data was trustworthy, but that's basically an indirect proof and close enough for most purposes.


I learned the term "belts and braces" from Campbell, a few minutes later, "belts and suspenders" from someone else, I think it was you...

Plenty of back-and-forth debate on the InterWebs on whether that is a good idea or violates DRY.

I have seen contexts where an encoding or decoding, which was non-idempotent and was mistakenly applied more than once in some context, resulting probably in a crash or truly insane behavior (C/C++) or unreadable garbage output (everywhere else), so one needs to be careful.  Simple checks can "belt-and-suspenders" but encoding/decoding, no.  I believe the last such situation I hit in Real Life had something that used to be a check and evolved into an encoding...so be careful but yeah.

 
Campbell Ritchie
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:, , , You will never get me to disagree about this, except maybe in this context. . . .

Does that mean we are disagreeing to agree?

What does this do in C/C++? . . .

Suffer from an implicit cast which compromises type‑safety. You would have to regard an unsigned int as a datatype distinct from an int and not allow implicit automatic conversions. Maybe an explicit (signed) or (unsigned) cast would be permissible. There is an inherent problem with casting primitives, which doesn't apply to casting reference types; it is possible to change both its type and its value.  And that is the problem you are showing.

. . . .

You can get an overflow error anywhere. And mixing unsigned and signed numbers sounds like a sure‑fire receipe for trouble.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Coming back to Java, this is the reason this apparently annoying thing is your best friend (requiring the explicit cast) as the ranges don't align:
jshell> byte b = -7
b ==> -7

jshell> char c = b
|  Error:
|  incompatible types: possible lossy conversion from byte to char
|  char c = b;
|           ^

jshell> short s = 8
s ==> 8

jshell> char c = s
|  Error:
|  incompatible types: possible lossy conversion from short to char
|  char c = s;
|           ^


Also the question of whether there are unsigned integral types in Java becomes a trick question about whether or not we call char an integral type or not (I've seen tutorial material and mock questions go both ways on this point):
jshell> char c = 200
c ==> '?'

jshell> char c = 97
c ==> 'a'

jshell> c *= 2 + 15
$7 ==> '?'

jshell> c >> 2
$8 ==> 412


Is a Java char an integral type?  It behaves like one, and at least better than C/C++, it is always unsigned.

My original point on the OP's question.
In general programming, all constraints should be validated, possibly in multiple places ("belt-and-suspenders").

In timed, auto-graded coding challenges, you should think of them as "what inputs your solution must work for, probably ignore anything outside these, they won't be in the input."
 
Tim Holloway
Saloon Keeper
Posts: 24329
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:
   What does this do in C/C++? . . .

Campbell Ritchie wrote:Suffer from an implicit cast which compromises type‑safety. You would have to regard an unsigned int as a datatype distinct from an int and not allow implicit automatic conversions. Maybe an explicit (signed) or (unsigned) cast would be permissible. There is an inherent problem with casting primitives, which doesn't apply to casting reference types; it is possible to change both its type and its value.  And that is the problem you are showing.



And that, incidentally, is why Ada was designed. That and to make it impossible to casually write software that mixes metric and Imperial measurements resulting in the loss of expensive spacecraft.  Incidentally, you can inform Boris Johnson that US food packaging typically contains both imperial and metric capacities even if we do all ignore the metric values. It doesn't seem to have slowed us down.

Anyway, I wasn't originally asserting that every method do detailed validity checking. I was stating that every method should contain JavaDocs that tell what happens if inputs are out of the expected domain and - ideally - what the output range will be for the benefit of consumers of that method's output (if any - and that includes when the "output" is an Exception!)
 
Campbell Ritchie
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:. . . that, incidentally, is why Ada was designed. . . .

And that makes it a high level language.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No disagreements to any of this (you know I learned the SI in elementary school, and was told to go home and teach my parents so they would be prepared when we switched over by '81 or so.  I never fully forgave Reagan for cancelling that -- in many of my Engineering courses, half the problems were in SI and half were in Imperial Units--UGH!!)

99% of Americans aren't sure what the Unit of Mass is in their own system.

I used slugs in Engineering school when I couldn't use kg...apparently that is no longer agreed upon...
What a can of worms!
https://www.physicsforums.com/threads/difference-between-weight-and-mass.661676/page-1
https://www.supercars.net/forum/threads/the-imperial-measurement-system-is-retarded.47056/

Just use kg already, I'd been waiting 40+ years...

Programmers should document their API's fully and clearly using the standard documentation format for the languages they are supplied in, including all pre-conditions and post-conditions, exceptions, etc.
I hope nobody disagrees with that.

Whether anything remotely approaching this standard is appropriate to recommend on tightly-timed, often auto-graded coding challenges that many job seekers need to pass to get hired for many jobs is all that I was questioning, or in fact, likely disagreeing with.

Whether or not such tests are a good bottleneck to pass candidates thru to obtain good programmers is a very worthy, relevant discussion that should occur somewhere else, preferably somewhere that people making hiring decisions and deciding on their enterprise's screening and testing procedures might read it.  The Original Post strongly indicated the context that the question was being asked in.
 
Jesse Silverman
Saloon Keeper
Posts: 1328
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just completed another one of these "tightly-timed-tests".

They were "nice" and explicitly told us that all input was going to be valid, do not waste time validating or generating error messages.

Even if they didn't, there were three non-trivial, unrelated problems to code in 90 minutes.

In my considered opinion, anyone who could complete all three and pass all tests is not only Very Good, but also Very Fast.

I got nowhere on one (probably considered the easiest but all about GET/POST, which I am relatively weak at).

One was about re-formatting a bunch of dates from one custom, weird odd format not recognized by any off-the-shelf stuff to another one like that.
I finished that in half an hour and passed every last test, there was one interesting Java thing involved (in my solution) that I may ask about later.

The other was a scheduling optimization problem.  I feared I'd wind up spending an hour on it and getting ZERO, but I sucked it up, worked thru it and got correct answers for 11 of 13 test cases, whatever partial credit that may have gotten me.

Again, even taking all constraints as Gospel, and wasting no time on "What if the Input doesn't match this?" one has to be really fast to get full credit.

Is that a good way for them to get the best developers?  I don't know that it is, but it is what they, and so many others are doing.

If whatever score I got was "good enough" to bother, they will expend several hundred dollars worth of their team's time to talk to me all day.

This is an extremely common practice, and my strong feelings about how to treat constraints as absolute givens in this thread is entirely in the spirit of preventing someone who COULD get thru such a gauntlet from wasting time on stuff that is "Don't Care" for these purposes, whether it is good or not.

I definitely spent time in such a manner when first approaching these, and unsurprisingly, tended to run out of time on problems I was capable of completing successfully.  The incomplete code that I got no credit for was VERY robust, etc.

If one successfully runs this gauntlet, one is free to expound on how important proper input validation is, about how robust one makes their code which may be called by others, etc. etc.

While the clock is ticking is no time to be thinking about those things.  The tests are designed so that one who would be able to get full credit in twice the time allowed is guaranteed to fail and not be spoken to any further.

Just saying, because I think about this thread each time I jump back onto the RaceTrack.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic