Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Scaevolus posted:

Fizzshedding: dozens of replies arguing about implementations of a trivial interview question.

Reminder that if you do not produce the 100% most optimal solution to any problem in 30 minutes on a whiteboard you are a gibbering idiot who is unfit to clean the toilets much less do meaningful contributions to any project.

Adbot
ADBOT LOVES YOU

ephphatha
Dec 18, 2009




We haven't even started arguing about what encoding we're assuming yet (it's UTF-16).

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

coffeetable posted:

Reverse and compare is safest/easiest.
Not inherently. It's a matter of skill. A lot of interview algorithm questions are testing whether your impulse is always "go talk to Mr. Library" vs. being able to do, if necessary, the things that library code does.

raminasi
Jan 25, 2005

a last drink with no ice
:smug: Are you skilled enough to be able to dodge fencepost errors while re-implementing trivial, easily-available library code under time pressure in an environment where you can't test anything? :smug:

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
I like how interviewing is an almost totally separate skillset from actually programming on the job.

Why not just go from this subtle meta-game to full on noh plays and tea ceremonies? They're really asking "Do you have enough interviews/time spent preparing for interviews to answer this well?" at this point.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

GrumpyDoctor posted:

:smug: Are you skilled enough to be able to dodge fencepost errors while re-implementing trivial, easily-available library code under time pressure in an environment where you can't test anything? :smug:
:smug: all you want, this is unironically what interviewees should expect and prepare for.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Gazpacho posted:

:smug: all you want, this is unironically what interviewees should expect and prepare for.

Yes, I must learn how to interview instead of learn how to program and expect to be tested accordingly!

Otherwise how would we have people who interview well but can't code that well to have the usual content of this thread?

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Although I am quite sympathetic to the pressures of interviewing, it's a poor excuse for not even setting the goal of being able to present efficient solutions in person.

shrughes
Oct 11, 2008

(call/cc call/cc)

GrumpyDoctor posted:

:smug: Are you skilled enough to be able to dodge fencepost errors while re-implementing trivial, easily-available library code under time pressure in an environment where you can't test anything? :smug:

This is an actual skill, and it maps over to so-called actual programming. Making yourself worry about substring indices and the like unnecessarily is a bad thing, and as you get better at development, your search algorithm for implementation strategies gets better at finding and selecting harder-to-mess-up solutions.

Steve French posted:

Is it? Can you show an elegant tail recursive solution?

also, just because scala

code:
  s.view == s.view.reverse

I just spent like 15 minutes trying to find good HP 48 documentation so I could create an elegent UserRPL solution which I thought would look something like this:

code:
« DUP SREV == »
or maybe at worst

code:
« NUMS DUP REVLIST == »
Little did I remember how shittastic the string libraries were.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Gazpacho posted:

Although I am quite sympathetic to the pressures of interviewing, it's a poor excuse for not even setting the goal of being able to present efficient solutions in person.

Wait, are quick fast "can you figure this out and show you can solve problems" questions suddenly now "you are either pretty amazing and can actually figure out something optimal in 2-5 minutes"? Or is it "lol do you remember this?"

Nobody is against setting the goal of presenting efficient solutions. The issue is realistic expectations based on the time allotted to do anything. I just expect that people expect something based on the time spent and resources available, not :smug:lord bullshit. If you want that, give them the resources they'd use on the job, and give them a reasonable amount of time to do it, dammit.

I've had interviews go like that - hey, use the internet, books, and hell the computer itself to write some code! And guess what, it wasn't nearly as stressful, and I got to actually think about different ways of doing things, and arrive at something that was efficient, instead of just "did I do this before and remember it." People who can't actually program won't be able to slip through that, and people who haven't memorized the standard interview repertoire aren't skipped over, they're allowed to solve an actual problem.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
My first comment was only to point out that low-level algorithm questions do exist in interviews, and the interviewers are then looking for an algorithm solution.

It has not been that long ago that I got an algorithm question as part of a timed screen, and ended up giving a brute-force solution. So I get it. Still, there is a theoretical framework developed mainly by Hoare and Dijkstra that can, with enough practice, be used to approach such problems while catching and correcting the common errors.

Gazpacho fucked around with this message at 04:11 on Feb 3, 2014

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
What you said is reasonable; I'll shut up.

Optimus Prime Ribs
Jul 25, 2007

A little while ago a guy I know, for whatever reason, wanted to remove all instances of ./ and ../ from a string (e.g. "./../../foo/bar.txt") and decided to use regular expressions to do it. This is the pattern that he came up with to match the ./ and ../ parts:
code:
^(?:.*?)(?:[\.|//]*)(.*?)$
It ends up matching the entire string because of the $ anchor (removing that makes it work). It's not as terrible as some regex horrors go, but I don't know how he wrote that and didn't think to himself "y'know, there is probably a simpler way to write this".

Incidentally another dude posted in the same thread as the guy above about how he wanted to match text that is formatted like >foo = >hello world or >foo = "hello world" (I don't know why he wanted both) and came up with this gem:
code:
[\s\t\n]*>(\w+)[\s\t]*=[\s\t]*(?:(?:"(.*?)")|>(\w+))[\n\t\s]*
I don't even know what to say about that one.

EAT THE EGGS RICOLA
May 29, 2008

what are you talking about those both own

evensevenone
May 12, 2001
Glass is a solid.

Steve French posted:

Is it? Can you show an elegant tail recursive solution?

Deus Rex posted:

this would be cool in a language that uses structural sharing for strings, I guess.

Steve French posted:

Allocating n/2 extra strings is cooler than allocating 1 extra string

plebs and your languages without pointers.
C code:
int isPalindrome(char * s,int len) {
   if (len < 2) return 1;
   else if (s[0] != s[len-1]) return 0;
   else return isPalindrome(&s[1],len-2);
}

biznatchio
Mar 31, 2001


Buglord

Damiya posted:

Really? I don't know that I agree with that. I produce good code as an employee but if you give me a problem that I can tell is going to be well solved, many times before me, gently caress yea I'm gonna go to Google to see if there's an implementation jump off point.

It's one thing if someone is just blindly copying stack overflow with no adaptation or fitting the solution to the problem. But why would you want to hire someone that doggedly insists on reinventing every wheel?

There's a lot to be said for reusing existing, working, already-debugged solutions; but if your bar for build versus borrow doing so is as low as writing a simple string reverse, that says a lot. It's literally faster to just write it yourself than it is to open up your browser, search for it, find, and vet a copy/paste solution -- at least once you're at a certain level of skill.

Look Around You
Jan 19, 2009

biznatchio posted:

There's a lot to be said for reusing existing, working, already-debugged solutions; but if your bar for build versus borrow doing so is as low as writing a simple string reverse, that says a lot. It's literally faster to just write it yourself than it is to open up your browser, search for it, find, and vet a copy/paste solution -- at least once you're at a certain level of skill.

Knowledge of the language is important too, obviously.

code:
public static String reverseString(String in) {
	String ret = "";
	for (int i = in.length() - 1; i >= 0; i--) {
		ret += in.charAt(i);
	}
	return ret;
}
is probably a pretty bad way to handle this problem in Java.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Gazpacho posted:

Not inherently. It's a matter of skill. A lot of interview algorithm questions are testing whether your impulse is always "go talk to Mr. Library" vs. being able to do, if necessary, the things that library code does.
I agree you should be able to give non-library answers, but I feel you should only give them if it's explicitly stated that they want answers without using library functions, or "okay now solve it a different way".

In this case, reverse and compare is the safest/easiest answer because it's the simplest, clearest answer. There are worse habits than writing complex code without a good reason, but not many.

qntm
Jun 17, 2009

Ephphatha posted:

We haven't even started arguing about what encoding we're assuming yet (it's UTF-16).

Reversing a Unicode string is highly nontrivial what with combining characters. All of the above works fine as long as you're in ASCII, or taking "string" to mean "sequence of bytes", but that's about it.

ErIog
Jul 11, 2001

:nsacloud:

qntm posted:

Reversing a Unicode string is highly nontrivial what with combining characters. All of the above works fine as long as you're in ASCII, or taking "string" to mean "sequence of bytes", but that's about it.

In reference to the guy that said "rolling your own code" would be preferable to "using a function from a library,"... this right here is a good example of why using library functions for something is preferable to rolling your own bullshit untested nonsense because you can't be bothered to Google the contents of the standard library of the language you're using. Library functions tend to have been tested, have documentation, and be robust enough to handle things you weren't thinking about when you were rolling your own code instead of using that library function.

The interview test question of, "walk us through the logic of how you would replicate this standard library function" is perfectly sound, but sounds like a pretty huge horror in any kind of real work environment that's supposed to be sane.

ErIog fucked around with this message at 16:05 on Feb 3, 2014

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
It's stupid to ding someone in an interview for making syntax errors or generally pseudocoding the question.

I've written a decent amount of C#, but without Intellisense I'd be sunk as gently caress. It's more important that talent can reason out the problem than remember the specific syntax for calling a static method or memorizing method signatures.

Anyway, that level of pedantry is what email tests should be for. Do a pre-screen for anyone you're interested in bringing in for an interview. The goal should be that they produce testable, well-reasoned code that compiles and spits out the right answer. Then ask more process oriented questions in the interview.

return0
Apr 11, 2007

ErIog posted:

rolling your own bullshit untested nonsense

The purpose of asking someone to reverse an array is to see if they can solve a trivial problem using an algorithm, because they might have to write code that isn't implemented in a library.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

return0 posted:

The purpose of asking someone to reverse an array is to see if they can solve a trivial problem using an algorithm,
No, that'd be the purpose of asking someone to reverse an array without using library functions.

return0
Apr 11, 2007

coffeetable posted:

No, that'd be the purpose of asking someone to reverse an array without using library functions.

Okay, so imagine that as a result of asking that question you discover they can't reverse an array without a library function - is this useful information to you, as the interviewer, which you didn't have before? If so it's a worthwhile question, right?

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

return0 posted:

Okay, so imagine that as a result of asking that question you discover they can't reverse an array without a library function - is this useful information to you, as the interviewer, which you didn't have before? If so it's a worthwhile question, right?

It's a useful question both with the library function qualifier and without it. Without that qualifier though, the candidate can't assume that the question is intended to divine whether they can write an algorithm. It may well be intended to divine "does this candidate try ready-made solutions before inventing her own?"

return0
Apr 11, 2007
Ah okay, I understand what you are saying now, I thought you were insane and suggesting the question itself had no value rather than just ambiguous to the interviewee.

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe


What could possibly go wrong.

JawnV6
Jul 4, 2004

So hot ...
Those are some precious bits they're saving! I can't imagine the debug that roots that out. Auto-dialer stuck emitting a bunch of 9's?

Steve French
Sep 8, 2003

evensevenone posted:

plebs and your languages without pointers.
C code:
int isPalindrome(char * s,int len) {
   if (len < 2) return 1;
   else if (s[0] != s[len-1]) return 0;
   else return isPalindrome(&s[1],len-2);
}


If you're going to build a shed with pointers,
C code:
int isPalindrome(char *s, size_t len) {
  char *e = s + len - 1;
  while (s < e) if (*s++ != *e--) return 0;
  return 1;
}

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
I believe at this point the mouse was given a cookie a year ago.

Nippashish
Nov 2, 2005

Let me see you dance!
Apart from the brief foray into unicode discussion, the palindrome testing requirements have gotten more lax as the implementations have gotten more clever.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JawnV6 posted:

Those are some precious bits they're saving! I can't imagine the debug that roots that out. Auto-dialer stuck emitting a bunch of 9's?

Assuming they normalize to just the digits (although I'm not sure that's always valid to do), it'll be an integer, which shouldn't have fractional rounding problems. However, a CGFloat is in fact a float on 32-bit platforms (it being 64 bits on 64-bit platforms is also a hilarious horror, by the way), and a float gives you slightly less than 7 decimal digits of precision, so...

It would need to be a uint64_t to reliably express even a ten-digit U.S. phone number. But I assume that all clients want it as a string, so it's not really an optimization at all unless you're keeping a ton of these in memory at once.

Admiral H. Curtiss
May 11, 2010

I think there are a bunch of people who can create trailing images. I know some who could do this as if they were just going out for a stroll.
You also lose information about leading zeroes, or formatting information like spaces, braces, or hyphens. It's a terrible idea to store a phone number as an actual number.

Steve French
Sep 8, 2003

Admiral H. Curtiss posted:

You also lose information about leading zeroes, or formatting information like spaces, braces, or hyphens. It's a terrible idea to store a phone number as an actual number.

A good point about leading zeroes, and I'm certainly not saying storing it as a number isn't awful, but when would you really care about formatting information? I guess it could be useful to distinguish between phone numbers in different areas of the world that might have the same number/sequence of digits. But presumably some normalization to complete numbers with country codes would solve all of the above issues.

nielsm
Jun 1, 2009



Does it make sense to do arithmetic on it? No? Then it isn't a number, even if it's numeric.
A really basic rule of thumb, but I have no idea where you should be teaching it. Maybe it would be smarter for society to stop using numbers for non-scalars.

NFX
Jun 2, 2008

Fun Shoe
But you can use the decimal places for country codes!

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Polygon did a feature about Street Fighter 2. Related tidbit is about bugs in the game called "handcuffs" where Guile can lock the player to him for the rest of the game, and the "air throw" where Guile could throw a player from anywhere on the screen. Imagine being responsible for a bug on one of your company's best selling arcade games.

http://www.polygon.com/a/street-fighter-2-oral-history/chapter-3

MOTOHIDE ESHIRO (PROGRAMMER, GUILE): posted:


That was actually my first programming job at Capcom when I joined the company. So the hardest thing was basically everything — getting used to the difference between what I learned in school as a programmer and the way you really do things on the ground. ...

I'll tell you the story of when I heard about [Guile's glitches]. We were having an event where we had invited players and journalists to come play Street Fighter 2. It was one of the first times it was even out there — it was just starting to get big — and the higher-ups picked me to play an exhibition match against some users. We were having the staff play against other people. And a journalist — a game journalist, a Japanese guy — approached me and said, "Hey, check this out. I found this crazy Magic Throw with Guile." And he showed it to me. When I first saw that, the first thing I thought was, "I have to quit. I can't do this anymore. I think I'm gonna quit my job." And luckily, Mr. Nishitani said, "Hey, if you're gonna let something like that bother you then you can't make games anymore period. You can't go to another company and do it either. This is part of the business." So he stopped me from making any drastic moves. But yeah, I felt terrible.

His boss seemed cool with it

AKIRA NISHITANI: posted:

I remember Mr. Eshiro coming to me, yeah. He was new to the company at that time and there were processes he was supposed to take, but I don't think he went through all those, which led to the bugs. So because of that, he felt really responsible and came to me, but I didn't take it that seriously. I was like, "Oh, what are you talking about?" I never seriously considered letting him quit.

Motohide Eshiro later became producer for the Ace Attorney games.

JawnV6
Jul 4, 2004

So hot ...

NFX posted:

But you can use the decimal places for country codes!

And we'll store the version ID in the mantissa!!

Polio Vax Scene
Apr 5, 2009



I've been given an assignment to create an XSL that will insert the appropriate RTF tags to format XML to a client's liking.

You heard right, RTF. I'm going to manually insert these tags all over an XSL file so that XML goes in one end and a pretty doc (with an RTF extension) comes out the other.

Will post trip report if my brain does not melt out one of my ears before I'm done.

bonus round: One of the items on the client list is a watermark

Polio Vax Scene fucked around with this message at 21:41 on Feb 3, 2014

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Might as well save some time and annoyance and just kill yourself now.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply