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.
 
  • Locked thread
hobbesmaster
Jan 28, 2008

gently caress them posted:

So nobody in the workplace ever does their own dynamic programming you just see someone else's implementation who is still in school or doing a thesis?

:downs:

if theres only a few cases it'd literally be faster to brute force it than come up with a proper algorithm

Adbot
ADBOT LOVES YOU

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

gently caress them posted:

So nobody in the workplace ever does their own dynamic programming you just see someone else's implementation who is still in school or doing a thesis?

:downs:

for this small set of numbers it would be cheapest to brute force it, as it wouldnt take much of your time to come up with a way to do that. if you;re just doing some boring old enterprise development you;re not going to have to go into hard out computer science every day, no.

it takes skill to understand and produce a scalable algorithm for this kind of thing, equally it takes some amount of skill to know when its not going to matter and you should just brute force it

also, though people will bitch over the term but i think that it can be good to think of software development as "engineering" in the sense that it is an application of the "science" of computer science so you might use quicksort but you don't have to come up with it.

Bloody
Mar 3, 2013

i do real computer science almost never at work. im either calling out to a library or doing bit-level janitoring (which occasionally involves heavy optimization but its more comp/elec eng at that point than cs)

Asymmetric POSTer
Aug 17, 2005

Bloody posted:

bit-level janitoring

:jackbud:

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

bobbilljim posted:

also, though people will bitch over the term but i think that it can be good to think of software development as "engineering" in the sense that it is an application of the "science" of computer science so you might use quicksort but you don't have to come up with it.

WELP.

I mean to be fair 99% of the optimization I look at comes down to "SQL query" or "list or tree or hash or whatever".

I'm just excited since I "really" programmed for the first time in a while, when just wiring poo poo to a database and putting in biz rules and jQuery/ko.js gets dreary.

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
if you like algorithms can i interest you in some "big data"

FamDav
Mar 29, 2008
do you know what a quadtree is

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

Bloody posted:

i do real computer science almost never at work. im either calling out to a library or doing bit-level janitoring (which occasionally involves heavy optimization but its more comp/elec eng at that point than cs)

love bitbanging but usually i shouldnt be doing it

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

FamDav posted:

do you know what a quadtree is

A tree with four children?

With 1 or 12 (there is no negative 1 or 12 as far as I can know in this problem) I will then go to +2, -2, +23, or -23 for 1, and for 23 it's +4, -4, +45, or -45. Four children. Quad tree.

Right?

hobbesmaster
Jan 28, 2008

FamDav posted:

do you know what a quadtree is

something half as cool as a octtree

Bloody
Mar 3, 2013

bobbilljim posted:

love bitbanging but usually i shouldnt be doing it

bitbanging isnt quite the same as bit janitoring but ya bitbanging both owns and sucks dilz

Bloody
Mar 3, 2013

yeah lemme just implement a fuckin uart rx in software *faaaarrtz*

FamDav
Mar 29, 2008

gently caress them posted:

A tree with four children?

With 1 or 12 (there is no negative 1 or 12 as far as I can know in this problem) I will then go to +2, -2, +23, or -23 for 1, and for 23 it's +4, -4, +45, or -45. Four children. Quad tree.

Right?

youre not gaining anything here tho over straight up recursion. there's no context that lets you decide which branch to take.

Moist von Lipwig
Oct 28, 2006

by FactsAreUseless
Tortured By Flan

Bloody posted:

yeah lemme just implement a fuckin uart rx in software *faaaarrtz*

wish u felt teh same way about implementing posts

Bloody
Mar 3, 2013

VLADIMIR GLUTEN posted:

wish u felt teh same way about implementing posts

xsd

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

FamDav posted:

youre not gaining anything here tho over straight up recursion. there's no context that lets you decide which branch to take.

I was thinking I could do partial sums of the left side and the right side of the 1,2,...,9 sequence and then sorta match them together and see if the two sum to 100 (or whatever). Then it's just 2sum :)

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

gently caress them posted:

A tree with four children?

With 1 or 12 (there is no negative 1 or 12 as far as I can know in this problem) I will then go to +2, -2, +23, or -23 for 1, and for 23 it's +4, -4, +45, or -45. Four children. Quad tree.

Right?
What about 1 +234 or 1 +2345?

tef
May 30, 2004

-> some l-system crap ->
so, it looks like you want to generate a bunch of sequences

so let's define our little language. i've taken the liberty of assuming add, sub and concat are left associative, and concat has a higher binding than add/sub

code:
operator(add, 5, left).
operator(sub, 5, left).
operator(cat, 10, left).

generate([],[]).
generate([T],[T]).
generate([H|T], [H,Op|Out]) :-
        \+ T = [],
        operator(Op,_,_),
        generate(T, Out).
the latter code basically says, a generated sequences is a list with operators between elements. you can so generate([1,2,3], X), and X will match with all of the possible sequences.

then we'll have to evaluate it

code:
apply(add, X, Y, O) :- O is X + Y.
apply(sub, X, Y, O) :- O is X - Y.
apply(cat, X, Y, O) :- % this doesn't handle negative numbers too well.
        number_codes(X,Xs),
        number_codes(Y, Ys),
        append(Xs, Ys, S),
        number_codes(O, S).
we could take easy way out and assume say 1 o 2 o 3 is (1 o 2) o 3, or 1 o (2 o 3), and ignore the binding.

code:
left_eval([O], O).
left_eval([X, Op, Y|T], O) :-
        apply(Op, X, Y, H),
        left_eval([H|T], O).


right_eval([O], O).
right_eval([X, Op, Y|T], O) :-
        right_eval([Y|T], H),
        apply(Op, X, H, O).
but let's not and do a stack evaluator

code:
stack_eval(In, O) :- stack_eval(In, [], [], O).

% stack_eval(Input, Ops, Nums, Output)

stack_eval([], [], [X], X).

stack_eval([], [Op|OpT], [X,Y|NumT], O) :-
        apply(Op, Y, X, H),
        stack_eval([], OpT, [H|NumT], O).

stack_eval([I|It], Ops, Nums, O) :-
        \+ operator(I,_,_),
        stack_eval(It, Ops, [I|Nums], O).

stack_eval([Op|In], Ops, Nums, O) :-
        operator(Op,_,_),
        stack_apply(Op, Ops, Nums, NewOps, NewNums),
        stack_eval(In, NewOps, NewNums, O).

stack_apply(Op, [], N, [Op], N).

stack_apply(Op, [Op2|Ops], [X,Y|N], NewOps, NewNums) :-
         subsumes(Op, Op2),
         apply(Op2, Y, X, H),
         stack_apply(Op, Ops, [H|N], NewOps, NewNums).

stack_apply(Op, [Op2|O], N, [Op,Op2|O], N) :-
         \+ subsumes(Op, Op2).

subsumes(Op1, Op2) :-
        operator(Op1, P1, A1),
        operator(Op2, P2, _),
        ( (A1 = left, P1 = P2); P1 < P2).
roughly, it recurses, first pushing items onto the item stack or operator stack, and then when the input is empty it pops off the operators in the stack and applies them. shunting yard innit.

ok, let's ask it to generate all the sequence which ends in 100

code:
?-  generate([1,2,3,4,5,6,7,8,9],O), stack_eval(O, 100).
O = [1, add, 2, add, 3, sub, 4, add, 5|...] ;
O = [1, add, 2, add, 3, cat, 4, sub, 5|...] ;
?-  findall(O, (generate([1,2,3,4,5,6,7,8,9],O), stack_eval(O, 100)), L), write(L).
[[1,add,2,add,3,sub,4,add,5,add,6,add,7,cat,8,add,9],
[1,add,2,add,3,cat,4,sub,5,add,6,cat,7,sub,8,add,9],
[1,add,2,cat,3,sub,4,add,5,add,6,add,7,cat,8,sub,9],
[1,add,2,cat,3,sub,4,add,5,cat,6,add,7,add,8,add,9],
[1,cat,2,add,3,add,4,add,5,sub,6,sub,7,add,8,cat,9],
[1,cat,2,add,3,sub,4,add,5,add,6,cat,7,add,8,add,9],
[1,cat,2,sub,3,sub,4,add,5,sub,6,add,7,add,8,cat,9],
[1,cat,2,cat,3,add,4,sub,5,add,6,cat,7,sub,8,cat,9],
[1,cat,2,cat,3,add,4,cat,5,sub,6,cat,7,add,8,sub,9],
[1,cat,2,cat,3,sub,4,sub,5,sub,6,sub,7,add,8,sub,9],
[1,cat,2,cat,3,sub,4,cat,5,sub,6,cat,7,add,8,cat,9]]
or

1 + 2 + 3 - 4 + 5 + 6 + 7&8 + 9
1 + 2 + 3&4 - 5 + 6&7 - 8 + 9
1 + 2&3 - 4 + 5 + 6 + 7&8 - 9
1 + 2&3 - 4 + 5&6 + 7 + 8 + 9
1&2 + 3 + 4 + 5 - 6 - 7 + 8&9
1&2 + 3 - 4 + 5 + 6&7 + 8 + 9
1&2 - 3 - 4 + 5 - 6 + 7 + 8&9
1&2&3 + 4 - 5 + 6&7 - 8&9
1&2&3 + 4&5 - 6&7 + 8 - 9
1&2&3 - 4 - 5 - 6 - 7 + 8 - 9
1&2&3 - 4&5 - 6&7 + 8&9

Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer
yeah I went prolog too but a little more pedestrian. I don't think clpfd is needed but eh
code:
:- use_module(library(clpfd)).

compress([], []).
compress([A], [A]).
compress([A, concat, B | Rest], O)         :- compress(A, B, C), compress([C | Rest], O).
compress([A, Op | Rest], [A , Op | Rest2]) :- compress(Rest, Rest2).
compress(A, B, C) :- atom_number(L, A), atom_number(R, B), atom_concat(L, R, LR), atom_number(LR, C).

sum([],  0).
sum([A], A).
sum([A, plus,  B | Rest], S) :- C #= A + B, sum([C | Rest], S).
sum([A, minus, B | Rest], S) :- C #= A - B, sum([C | Rest], S).

operation(plus).
operation(minus).
operation(concat).
valid([1,A,2,B,3,C,4,D,5,E,6,F,7,G,8,H,9]) :- maplist(operation, [A,B,C,D,E,F,G,H]).
value(L, S) :- valid(L), compress(L, C), sum(C, S).

show(plus,   ' + ').
show(minus,  ' - ').
show(concat, '').
show(L, S)  :- is_list(L), maplist(show, L, L1), foldl(atom_concat_rev, L1, '', S).
show(N, Ns) :- number(N), atom_number(Ns, N).
atom_concat_rev(A, B, C) :- atom_concat(B, A, C).

solve(N) :- findall(L, value(L, N), Ls), maplist(show, Ls, Ss), maplist(writeln, Ss), !.
code:
?- solve(100).
1 + 2 + 3 - 4 + 5 + 6 + 78 + 9
1 + 2 + 34 - 5 + 67 - 8 + 9
1 + 23 - 4 + 5 + 6 + 78 - 9
1 + 23 - 4 + 56 + 7 + 8 + 9
12 + 3 + 4 + 5 - 6 - 7 + 89
12 + 3 - 4 + 5 + 67 + 8 + 9
12 - 3 - 4 + 5 - 6 + 7 + 89
123 + 4 - 5 + 67 - 89
123 + 45 - 67 + 8 - 9
123 - 4 - 5 - 6 - 7 + 8 - 9
123 - 45 - 67 + 89
true.

tef
May 30, 2004

-> some l-system crap ->
:glomp:

tef
May 30, 2004

-> some l-system crap ->
yeah, i was going to just apply concat before applying sub/add but uh i like the shunting yard algorithm

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
prolog is cool

gently caress them posted:

So nobody in the workplace ever does their own dynamic programming you just see someone else's implementation who is still in school or doing a thesis?

:downs:

sometimes I'm impressed by 2banks' talent to sound insufferable

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Symbolic Butt posted:

prolog is cool


sometimes I'm impressed by 2banks' talent to sound insufferable

Sarcasm must just not carry over well I guess.

Bloody
Mar 3, 2013

prolog is cool

syntaxrigger
Jul 7, 2011

Actually you owe me 6! But who's countin?

rotor posted:

pretty much this unless you want to work with the kind of insufferable shitbag who thinks this is a reasonable interview question

I feel like the company that doesn't do this or some variation is a myth.

What should the interview process be like?

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

syntaxrigger posted:

I feel like the company that doesn't do this or some variation is a myth.

What should the interview process be like?

I try to ask questions that don't sound like they came out of a math book. then I'll ask em to write some simple text based game or something simple like that while I watch over the shoulder or screen share or whatever.

theadder
Dec 30, 2011


syntaxrigger posted:

What should the interview process be like?

posting

Luigi Thirty
Apr 30, 2006

Emergency confection port.

do you have stackoverflow set to go to Goatse in the computer's hosts file

Asymmetric POSTer
Aug 17, 2005

Luigi Thirty posted:

do you have stackoverflow set to go to Goatse in the computer's hosts file

lol

Moist von Lipwig
Oct 28, 2006

by FactsAreUseless
Tortured By Flan

Luigi Thirty posted:

do you have stackoverflow set to go to Goatse in the computer's hosts file

holy poo poo

syntaxrigger
Jul 7, 2011

Actually you owe me 6! But who's countin?

Luigi Thirty posted:

do you have stackoverflow set to go to Goatse in the computer's hosts file

Lmbo!

rotor posted:

I try to ask questions that don't sound like they came out of a math book. then I'll ask em to write some simple text based game or something simple like that while I watch over the shoulder or screen share or whatever.

Cool

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Luigi Thirty posted:

do you have stackoverflow set to go to Goatse in the computer's hosts file

:lol:

FamDav
Mar 29, 2008
for coding competency i like these two questions:

1) you're given a set containing a dictionary of words, starting word, and an ending word. provide me a word ladder from the starting word to the ending word.

a word ladder in this case is a a sequence of words that transforms the starting word into the ending word by only changing one character at a time. for example, if start is head and end is tail

head
heal
teal
tell
tall
tail

if they do one method of solving this quickly, i ask them if they can come up with another. if they use a queue, do it with recursion; recursion, use queue. if they do both, talk about how to make the queue version faster (2-sided bfs, a*).

2) implement a basic regular expression handler. you should be able to handle regular expressions that match combinations of the following rules. assume all regular expressions passed are well formed and all strings passed contain 0 or more literals.

- a literal (a-zA-Z0-9)
- a literal followed by a *, that takes 0 or more instances of the literal
- a literal followed by a +, that takes 1 or more instances of the literal
- a literal followed by a | followed by another literal, indicating that one of the two literals must match.
- a [ followed by a sequence of literals followed by ], indicating a set of literals that can be matched. should be treated as a literal for all other operators. a []-set cannot be inside another []-set.

i give out the first two rules and then add on as time permits. I like to ask about test cases, see what they think about how * and + should work, see how they handle refactoring for the the new rules, and also talk about what kind of bugs would occur if the regular expressions werent well-formed.


rotor posted:

I try to ask questions that don't sound like they came out of a math book. then I'll ask em to write some simple text based game or something simple like that while I watch over the shoulder or screen share or whatever.

are these good or bad questions rotor i need your validation :(

Bloody
Mar 3, 2013

FamDav posted:

for coding competency i like these two questions:

1) you're given a set containing a dictionary of words, starting word, and an ending word. provide me a word ladder from the starting word to the ending word.

a word ladder in this case is a a sequence of words that transforms the starting word into the ending word by only changing one character at a time. for example, if start is head and end is tail

head
heal
teal
tell
tall
tail

if they do one method of solving this quickly, i ask them if they can come up with another. if they use a queue, do it with recursion; recursion, use queue. if they do both, talk about how to make the queue version faster (2-sided bfs, a*).

2) implement a basic regular expression handler. you should be able to handle regular expressions that match combinations of the following rules. assume all regular expressions passed are well formed and all strings passed contain 0 or more literals.

- a literal (a-zA-Z0-9)
- a literal followed by a *, that takes 0 or more instances of the literal
- a literal followed by a +, that takes 1 or more instances of the literal
- a literal followed by a | followed by another literal, indicating that one of the two literals must match.
- a [ followed by a sequence of literals followed by ], indicating a set of literals that can be matched. should be treated as a literal for all other operators. a []-set cannot be inside another []-set.

i give out the first two rules and then add on as time permits. I like to ask about test cases, see what they think about how * and + should work, see how they handle refactoring for the the new rules, and also talk about what kind of bugs would occur if the regular expressions werent well-formed.


are these good or bad questions rotor i need your validation :(

Scuse me while I walk out

MeruFM
Jul 27, 2010
when did technical interviews become 8 hour gauntlets of random algo programming, gotcha questions, and brain teasers.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

MeruFM posted:

when did technical interviews become 8 hour gauntlets of random algo programming, gotcha questions, and brain teasers.

when interviewers decided it was more important to make themselves feel smart than to accurately gauge how competent a candidate was

Luigi Thirty
Apr 30, 2006

Emergency confection port.

you see a frog on its back in a blender. what color do you feel?

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
remember

quote:

In a surprising June 19th interview with the New York Times, Laszlo Bock, Google’s senior V.P. of “people operations,” explained why: the company discovered these brainteasers are “a complete waste of time,” and “don’t predict anything” when it comes to job success. Google shouldn’t be shocked. A psychologist would have known at the outset that tests of this nature hardly ever work, and that there are much better predictors of who will get hired and how they will perform.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

quote:

Not only are they relatively brief but also, over the past twenty years, psychologists have repeatedly found that few of a candidate’s responses matter. What is significant is the personal impression that the interviewer forms within the first minute (and sometimes less) of meeting the prospective hire. In one study, students were recorded as they took part in mock on-campus recruiting interviews that lasted from eight to thirty minutes. The interviewers evaluated them based on eleven factors, such as over-all employability, professional competency, and interpersonal skills. The experimenters then showed the first twenty or so seconds of each interview to untrained observers—the initial meet-and-greet, starting with the interviewee’s knock on the door and ending ten seconds after he was seated, before any questions—and asked them to rate the candidates on the same dimensions. What the researchers found was a high correlation between judgments made by the untrained eye in a matter of seconds and those made by trained interviewers after going through the whole process. On nine of the eleven factors, there was a resounding agreement between the two groups.

lol

reminder, death to all hr people

Adbot
ADBOT LOVES YOU

Bloody
Mar 3, 2013

FamDav posted:

for coding competency i like these two questions:

1) you're given a set containing a dictionary of words, starting word, and an ending word. provide me a word ladder from the starting word to the ending word.

a word ladder in this case is a a sequence of words that transforms the starting word into the ending word by only changing one character at a time. for example, if start is head and end is tail

head
heal
teal
tell
tall
tail

if they do one method of solving this quickly, i ask them if they can come up with another. if they use a queue, do it with recursion; recursion, use queue. if they do both, talk about how to make the queue version faster (2-sided bfs, a*).

2) implement a basic regular expression handler. you should be able to handle regular expressions that match combinations of the following rules. assume all regular expressions passed are well formed and all strings passed contain 0 or more literals.

- a literal (a-zA-Z0-9)
- a literal followed by a *, that takes 0 or more instances of the literal
- a literal followed by a +, that takes 1 or more instances of the literal
- a literal followed by a | followed by another literal, indicating that one of the two literals must match.
- a [ followed by a sequence of literals followed by ], indicating a set of literals that can be matched. should be treated as a literal for all other operators. a []-set cannot be inside another []-set.

i give out the first two rules and then add on as time permits. I like to ask about test cases, see what they think about how * and + should work, see how they handle refactoring for the the new rules, and also talk about what kind of bugs would occur if the regular expressions werent well-formed.


are these good or bad questions rotor i need your validation :(

like i mean this is probably a great test if your day-to-day work is going to be string janitoring but if it is then loving l m a o get a real job

  • Locked thread