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
AWWNAW
Dec 30, 2008

besides fuzz buzz

Adbot
ADBOT LOVES YOU

Catalyst-proof
May 11, 2011

better waste some time with you

Meiwaku posted:

I think normally you'd learn his stuff from a senior guy on the job, but there are some resources online. Unless you're ridiculously bad, it sounds like you have trouble managing complexity and abstraction.

Queue talk;
http://www.infoq.com/presentations/Simple-Made-Easy

I would change jobs quick if you don't currently work with someone who can help you develop further. In this industry they're a diamond in the rough, but they tend to clump together.

i'm just in a lovely spot right now. given a solo project in a satellite office, with technology that's not very visible within the company. it's like some terrible obstacle course but there's a promotion at the end for me, in theory

thanks for the talk, gonna give it a listen tonight

qntm
Jun 17, 2009

wasn't this one of those joke foods that the simpsons invented

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

AWWNAW posted:

I have to interview a developer tomorrow what sort of coding test should I give them

i guess the appropriateness of this depends on what sort of place you are but ask him to reverse a string of space-separated tokens in place so "ab cde fg" -> "ef cd ab" it's quite difficult and subtle and requires a lot of thought.


alternatively select a project euler problem in the 300s at random and watch them cry

Posting Principle
Dec 10, 2011

by Ralp
project euler problems are ag reat way to ensure you only hire spergs that you will hate working with

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Jerry SanDisky posted:

project euler problems are ag reat way to ensure you only hire spergs that you will hate working with

precisely

tef
May 30, 2004

-> some l-system crap ->

AWWNAW posted:

besides fuzz buzz

i heard one company asks people to write a boolean evaluator

of the form

expr = 0 ; 1 ; (expr) ; expr & expr ; expr | expr

ie (0|1)&0 (1&0&1) from left to right with no precedence.

seemed like a neat question

Shaggar
Apr 26, 2006

WHOIS John Galt posted:

i keep feeling like i'm at this crossroads

been writing poo poo for work and for home in python but every program i write that gets to about 5k lines starts getting really unmaintainable and difficult to refactor and add new functionality. mostly i get told to 'write more tests' which to me doesn't really feel like the right answer. like, let me write more code to try and maintain the code i have

so sometimes i feel like it's not taking advantage of language features or paradigms properly but i'm not just gonna learn something like concurrency or mapreduce or something to shoehorn it into what i'm learning

i guess the main issue is i don't really have a concrete problem to solve so no one can point me at a solution. but i do have a problem, it's "all my code is poo poo and difficult to maintain and it never really feels like i can trust it to do what i want it to do"

i'm looking at this http://www.cs.brown.edu/courses/cs173/2012/OnLine/ to try and maybe pick up some fundamentals that i missed when i was being a lazy shithead in school but like -- i can never really see how this maps into the real world. like, okay, here's how you make a calculator in some fake language in drracket. i'd much prefer some kind of heurestic as to the steps you should take when implementing some feature in a system. how you should define the data, thinking about where the data needs to go, presentation in a UI/webapp

i see the cool poo poo people do with, like, graphics programming. fractals and logo and poo poo. but that feels like playing around, like none of the programs i'll ever write at my job will require a fractal as the final output

i'm a bad coder

step 1: use java
step 2: use soa
step 3: be cool ftw

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

that's not the place that used to be the hawke & hunter is it?

X-BUM-RAIDER-X
May 7, 2008

tef posted:

i heard one company asks people to write a boolean evaluator

of the form

expr = 0 ; 1 ; (expr) ; expr & expr ; expr | expr

ie (0|1)&0 (1&0&1) from left to right with no precedence.

seemed like a neat question

this seems either easy or kinda difficult depending on the language

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

tef posted:

i heard one company asks people to write a boolean evaluator

of the form

expr = 0 ; 1 ; (expr) ; expr & expr ; expr | expr

ie (0|1)&0 (1&0&1) from left to right with no precedence.

seemed like a neat question

precedence seems like more fun

tef
May 30, 2004

-> some l-system crap ->
yeah, but it's more effort

code:
import operator

operators = { 
    '|': operator.or_,
    '&': operator.and_,
}

def booleval(expr):
    nums, ops = [], []

    while expr:
        a, expr = expr[0], expr[1:]

        if a in "10":
            nums.append(int(a))
        elif a in "(":
            num, expr = booleval(expr)
            nums.append(num)

        while ops and len(nums) >= 2:
            nums, args, op = nums[:-2], nums[-2:], ops.pop()
            val = operators[op](*args)
            nums.append(val)

        if a in "&|":
            ops.append(a)
        elif a == ")":
            break
    return nums[0], expr 

tef
May 30, 2004

-> some l-system crap ->

OBAMA BIN LOADIN posted:

this seems either easy or kinda difficult depending on the language

it's not too hard in most languages? it's just 'use a stack/recurse you butt'

edit: i might get bored and golf it.

tef fucked around with this message at 01:23 on Oct 22, 2012

Zombywuf
Mar 29, 2008

tef posted:

yeah, but it's more effort

code:
import operator

operators = { 
    '|': operator.or_,
    '&': operator.and_,
}

def booleval(expr):
    nums, ops = [], []

    while expr:
        a, expr = expr[0], expr[1:]

        if a in "10":
            nums.append(int(a))
        elif a in "(":
            num, expr = booleval(expr)
            nums.append(num)

        while ops and len(nums) >= 2:
            nums, args, op = nums[:-2], nums[-2:], ops.pop()
            val = operators[op](*args)
            nums.append(val)

        if a in "&|":
            ops.append(a)
        elif a == ")":
            break
    return nums[0], expr 

pfff, just add and if and a stack and you've got shunting yard.

tef
May 30, 2004

-> some l-system crap ->

Zombywuf posted:

pfff, just add and if and a stack and you've got shunting yard.

yep. for some reason (i'm a nutter), I tend to use a stack for ops, and recurse for parenthesis :3:

Rufus Ping
Dec 27, 2006





I'm a Friend of Rodney Nano

tef posted:

yeah, but it's more effort

code:
import operator

operators = { 
    '|': operator.or_,
    '&': operator.and_,
}

def booleval(expr):
    nums, ops = [], []

    while expr:
        a, expr = expr[0], expr[1:]

        if a in "10":
            nums.append(int(a))
        elif a in "(":
            num, expr = booleval(expr)
            nums.append(num)

        while ops and len(nums) >= 2:
            nums, args, op = nums[:-2], nums[-2:], ops.pop()
            val = operators[op](*args)
            nums.append(val)

        if a in "&|":
            ops.append(a)
        elif a == ")":
            break
    return nums[0], expr 

wouldnt a shift reduce be slightly neater

code:
stack=[]
while(cur = shift(tokens))
{
	stack.push(cur)

	while(true)
	{
		[a,b,c] = pop top 3 items off stack

		if (c == "(" && a == ")")
			stack.push(b)
		elseif (b == "&" && a != "(")
			stack.push(a & c)
		elseif (b == "|" && a != "(")
			stack.push(a | c)
		else break
	}
}
return stack.pop

Rufus Ping fucked around with this message at 01:41 on Oct 22, 2012

AWWNAW
Dec 30, 2008

you're all hired the bad news is you have to move to mississippi

AWWNAW
Dec 30, 2008

also i'm pretty sure 99.99999999999999999% o the candidates i will interview won't even be able to fizzbuz much less euler

tef
May 30, 2004

-> some l-system crap ->
i'm a top down parser weenie

Nomnom Cookie
Aug 30, 2009



Have them write a csv parser or maybe supply an XML parser and some malformed XML, then they do the needful w/o patching the parser

Nomnom Cookie
Aug 30, 2009



I like the csv parser one, I'm gonna use that

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

how about this. it's probably poo poo and very specific to the problem but whatevs.

Python code:
cum = None
op = None
stack = []

operators = {
    '|': lambda x, y: x | y,
    '&': lambda x, y: x & y
}
    
for c in list(s):
    if c == '(':
        if cum is not None:
            stack.append((op, cum))
            cum = op = None
    elif c in ['0', '1']:
        if op:
            cum = op(cum, int(c))
            op = None
        else:
            cum = int(c)
    elif c in ['|', '&']:
        op = operators[c]
    elif c == ')':
        if stack:
            op, scum = stack.pop()
            cum = op(scum, cum)

tef
May 30, 2004

-> some l-system crap ->
gently caress it

Python code:
import re
bool_eval=(lambda fn:lambda a:fn(fn,a))(lambda b,t,o=(lambda s,rx=re.compile(r'(\d)\|(\d)'):rx.sub((lambda m:str(int(m.group(1))|int(m.group(2)))),s)),a=(lambda s,rx=re.compile(r'(\d)\&(\d)'):rx.sub((lambda m:str(int(m.group(1))&int(m.group(2)))),s)),p=(lambda s,rx=re.compile(r'\((\d)\)'):rx.sub((lambda m:m.group(1)),s)):int(t)if len(t)<=1 else b(b,p(a(o(t)))))
http://codepad.org/N2cOK1qD :q:

Rufus Ping
Dec 27, 2006





I'm a Friend of Rodney Nano
regexes

homercles
Feb 14, 2010


Perl code:
1 while s/(?|(0|1)([&|])(0|1)|\((0|1)\))/$2 ? $2 eq '|' ? $1|$3 : $1&$3 : $1/e

tef
May 30, 2004

-> some l-system crap ->

homercles posted:

Perl code:
1 while s/(?|(0|1)([&|])(0|1)|\((0|1)\))/$2 ? $2 eq '|' ? $1|$3 : $1&$3 : $1/e


nice!

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

homercles posted:

Perl code:
1 while s/(?|(0|1)([&|])(0|1)|\((0|1)\))/$2 ? $2 eq '|' ? $1|$3 : $1&$3 : $1/e

poetry

tef
May 30, 2004

-> some l-system crap ->
i miss perl sometimes.

Catalyst-proof
May 11, 2011

better waste some time with you
i mentioned offhand to a friend that i found mutation testing an interesting concept. so naturally he starts condescending about how in a "perfect world" it would be wonderful to have everything 100% tested and that's /just not the way it is!/ and you learn that once you start working in a "fast paced environment"

gee thanks

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

AWWNAW posted:

besides fuzz buzz
given a linked list (forward links only) and unsigned integer return the node that far from the end.

Gazpacho fucked around with this message at 04:35 on Oct 22, 2012

homercles
Feb 14, 2010

oh look it's a rec descent regex with left recursion removed (and it probably even works)

code:
/(?(DEFINE)
    (?<t>     1 (?&te)*
            | 0 \| (?&t)
            | \( (?&t) \) (?&te)* )
    (?<te>    \| ( (?&t) | (?&f) )
               | & (?&t) )
    (?<f>     0 (?&fe)*
            | 1 & (?&f)
            | \( (?&f) \) (?&fe)* )
    (?<fe>   \| (?&f)
            | & ( (?&t) | (?&f) ) )
  )
  ^(?&t)$
/x || 0
what am i doing with my life :gonk:

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
perl good, perl programmrs bad

JawnV6
Jul 4, 2004

So hot ...

tef posted:

i just like flaming people, taking what they said and exaggerating it until it as obviously stupid to others, as it is to me.

mostly, being a dick to programmers on the internet is fun

tef
May 30, 2004

-> some l-system crap ->

homercles posted:

oh look it's a rec descent regex with left recursion removed (and it probably even works)

code:
/(?(DEFINE)
    (?<t>     1 (?&te)*
            | 0 \| (?&t)
            | \( (?&t) \) (?&te)* )
    (?<te>    \| ( (?&t) | (?&f) )
               | & (?&t) )
    (?<f>     0 (?&fe)*
            | 1 & (?&f)
            | \( (?&f) \) (?&fe)* )
    (?<fe>   \| (?&f)
            | & ( (?&t) | (?&f) ) )
  )
  ^(?&t)$
/x || 0
what am i doing with my life :gonk:

:swoon:

tef
May 30, 2004

-> some l-system crap ->

Gazpacho posted:

perl good, perl programmrs bad

the people left writing perl are pretty awesome.

the annoying people have moved onto php, ruby :v:, or python. it's just people using old versions of perl, new versions of perl, getting poo poo done and not being zealots or shitlords about it.

tef fucked around with this message at 08:26 on Oct 22, 2012

homercles
Feb 14, 2010

tef posted:

the people left writing perl are pretty awesome.

the annoying people have moved onto php, perl, or python. it's just people using old versions of perl, new versions of perl, getting poo poo done and not being zealots or shitlords about it.
tef accept messages so i can tell you that your post is premaCRAP everything i highlight goes BOLD

tef
May 30, 2004

-> some l-system crap ->
it's 8am. I should go to bed. I meant ruby.

tef
May 30, 2004

-> some l-system crap ->
although, here is a fun question

let's assume you have to use json for a format. (on the basis that for some reason, people love json, even though it is poo poo for what i'm about to ask, cos no-one ever got fired for using json).

how do you smuggle new data types into json?

one approach seems to be reserved attributes, '_links' for example, using leading underscores to mean 'hey, i'm being nasty'.

another is to use \/, as some library smuggles dates inside json by using "\/Date(.....)\/", relying that most encoders don't escape /.

personally, i'm tempted to use ascii control codes as the magic 'i am a terrible person' indicator, rather than relying on escaping magic, or underscores being sacred

so, if people want to do this terrible thing. what should they do?

salted hash browns
Mar 26, 2007
ykrop

tef posted:

although, here is a fun question

let's assume you have to use json for a format. (on the basis that for some reason, people love json, even though it is poo poo for what i'm about to ask, cos no-one ever got fired for using json).

how do you smuggle new data types into json?

one approach seems to be reserved attributes, '_links' for example, using leading underscores to mean 'hey, i'm being nasty'.

another is to use \/, as some library smuggles dates inside json by using "\/Date(.....)\/", relying that most encoders don't escape /.

personally, i'm tempted to use ascii control codes as the magic 'i am a terrible person' indicator, rather than relying on escaping magic, or underscores being sacred

so, if people want to do this terrible thing. what should they do?

if it was ~~java~~ i would just serialize the object no probs

Adbot
ADBOT LOVES YOU

salted hash browns
Mar 26, 2007
ykrop
also 8am bro? it's 1am here just gettin started

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