As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

[Programming] Page overflow to new thread

14142444647101

Posts

  • zeenyzeeny Registered User regular
    Orca wrote: »
    Elaro wrote: »
    What's NIH syndrome?

    Not Invented Here, AKA, time to reimplement a complicated thing worse for no good reason!

    Not for no good reason maaan, it's because because "We will do better" (tm) and "How hard can it be?". This shit extends even further. In my observation, the percentage of people working in software development and not able to deal with code/software written "by others" and not "by them or for them" is only raising. Hearing that "something needs to be re-written" by a developer 1 month deep into a domain/workplace is one of the strongest indications of a low quality hire, as far as I am concerned.

  • a5ehrena5ehren AtlantaRegistered User regular
    My particular NIH pet-peeve is people doing system calls out to the shell to invoke scp or whatever instead of just using libcurl. It's right there! We already have it in the load!

  • LD50LD50 Registered User regular
    You could roll your own dynamic dispatch by rewriting all function calls to call out to the shell to invoke your own application.

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    My only NIH problem is that I am not fond of "black boxes." I don't like not knowing why something does what it does (aside from libraries built into a language or framework of course).

    I'm having an issue on the .NET project I joined at the end of June. Someone else started it (who no longer works for the company) and wrote this awful query builder instead of using the built in Entity Framework stuff. There's no standard Controller/Manager/Repository pattern here. You use this weird class in the controllers that is slow as dirt because it's using IEnumerable instead of IQueryable. For those of you who aren't .NET developers, this means that the data is pulled from the database first and then filtered/sorted, rather than letting SQL do all of that. As you can imagine, that creates tremendous performance issues.

  • CampyCampy Registered User regular
    Rolling your own ORM's a paddlin'!

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    I'm really hoping the upcoming V2 of this app begins with a healthy dose of dynamite.

  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Ear3nd1l wrote: »
    My only NIH problem is that I am not fond of "black boxes." I don't like not knowing why something does what it does (aside from libraries built into a language or framework of course).

    I'm having an issue on the .NET project I joined at the end of June. Someone else started it (who no longer works for the company) and wrote this awful query builder instead of using the built in Entity Framework stuff. There's no standard Controller/Manager/Repository pattern here. You use this weird class in the controllers that is slow as dirt because it's using IEnumerable instead of IQueryable. For those of you who aren't .NET developers, this means that the data is pulled from the database first and then filtered/sorted, rather than letting SQL do all of that. As you can imagine, that creates tremendous performance issues.

    I’m ok with something being a black-box. The issue I take is that people really don’t document them very well and side effects are one of the most overlooked pieces of documentation.

    So, while I won’t rewrite the library*, I will lose time to understanding it and the documenting the shit out of it at the API level so the next poor sod has a snowballs chance in hell.

    *unless I find one or more major bug that probably will cause us to lose customers.

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    I can agree with that. I guess the reason I don't like black boxes is because they aren't typically documented very well.

  • gavindelgavindel The reason all your software is brokenRegistered User regular
    Ear3nd1l wrote: »
    I can agree with that. I guess the reason I don't like black boxes is because they aren't typically documented very well.

    Wait. Are you saying disassembly and debugging doesn't count as documentation?

    Book - Royal road - Free! Seraphim === TTRPG - Wuxia - Free! Seln Alora
  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    gavindel wrote: »
    Ear3nd1l wrote: »
    I can agree with that. I guess the reason I don't like black boxes is because they aren't typically documented very well.

    Wait. Are you saying disassembly and debugging doesn't count as documentation?

    Only on Tuesdays.

  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    Hey programmy people. I'm trying to run some tests on Hackerrank in prep for an actual employment coding challenge. Hackerrank gave me a fizbuzz test, which I have made up my own fizzbuzz answer before so I figured it would be easy, but they wanted to do it where the results change based on user input and I had a way harder time with that. This is as far as I got before time ran out:
    def fizzBuzz(n):
        for i in range(200000):
            x = i + 1
            fizz = x % 3 == 0
            buzz = x % 5 == 0
    
            if fizz:
                if buzz:
                    print('FizzBuzz')
                else:
                    print('Fizz')
            elif buzz: 
                print('Buzz')
            else:
                print (x)
            
    if __name__ == "__main__" :
        giveMEANumber = int(input())
        fizzBuzz(giveMEANumber)
    

    So I was able to include the range they wanted, but I can't figure out how to pass the user input in to limit the output. Help?

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • CarpyCarpy Registered User regular
    edited August 2020
    You're already passing it into the fizzBuzz function so you just need to use n to limit your range function.
    for i in range(n):
    

    Edit: rereading our posts and I may not be correctly parsing which part you're asking for help with.

    Edit 2: if instead the range has to be over 200000 then a simple way is to just add a short circuit if
    x=i + 1
    if x<n:
        fizz = x%3 == 0
        ....
    
    I don't know hackerrank so no idea if the wasted iterations in this one will ding you

    Carpy on
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    Carpy wrote: »
    You're already passing it into the fizzBuzz function so you just need to use n to limit your range function.
    for i in range(n):
    

    Edit: rereading our posts and I may not be correctly parsing which part you're asking for help with.

    Edit 2: if instead the range has to be over 200000 then a simple way is to just add a short circuit if
    x=i + 1
    if x<n:
        fizz = x%3 == 0
        ....
    
    I don't know hackerrank so no idea if the wasted iterations in this one will ding you

    So I need two things from the function:
    1) it should return fizzbuzz up to the number provided by the user
    2) If the user provides a number over 200k, it should return nothing

    If I make the range n, then how do I prevent it from going over 200k?

    Edit: Also, any time I tried to do a comparison between x and n in my code, I got an error stating that I wasn't allowed to compare strings to integers.

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • AiouaAioua Ora Occidens Ora OptimaRegistered User regular
    So to send you down the right path:

    You would want to validate 'n' before starting the for loop and then break out in some way if it's over the limit.

    Inside a function (but not a loop) you'd want toeither...
    raise an exception
    return something instead of continuing

    life's a game that you're bound to lose / like using a hammer to pound in screws
    fuck up once and you break your thumb / if you're happy at all then you're god damn dumb
    that's right we're on a fucked up cruise / God is dead but at least we have booze
    bad things happen, no one knows why / the sun burns out and everyone dies
  • CarpyCarpy Registered User regular
    Simplest way is to verify n is less than your max before you start into your for loop
    if n <= 200000:
        for i in range(n):
            ....
    

    As for your edit I'm not totally sure what would be causing the issue. input() returns a string but if you're just entering a string number that shouldn't be an issue since you're correctly casting it to an int(). You can print the type() of x and n before you compare them to see which one is showing up as a string and breaking the comparison.

  • CarpyCarpy Registered User regular
    Vowels has the right of it, in any real situation you'd want to do something to indicate the user entered a wrong number. Automated grading systems can be picky about that though, if it expects a silent fail then throwing an exception might break a poorly written one.

  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    Ok that worked. One of the things i had tried was just declaring n <= 200000 as if it were a variable, but I see now that's just a boolean and variables don't work like that. The if was the key.

    Thank you!!

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    Sigh. I need guidance again. This time it's writing a triplet program. I actually have one written, that by itself wasn't hard, what's hard is figuring out their output system and writing my program to that.

    So this is what I had before getting to the test code:
    #!/bin/python3
    
    def triplets(t, d): 
      
        found = True
        for i in range(0, d-2): 
          
            for j in range(i+1, d-1): 
              
                for k in range(j+1, d): 
                  
                    if (t[i] + t[j] + t[k] == 0): 
                        print(t[i], t[j], t[k]) 
                        found = True
          
                 
        if (found == False): 
            print("-1") 
      
    if __name__ == "__main__" :
        t = [1, 4, -4, 5, 0, -6]
        d = len(t) 
        triplets(t, d) 
    

    And that works fine. But instead of my nice neat stuff above, they have some output code that I can't quite seem to understand, and I have to write around it:
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        t = int(input().strip())
    
        d_count = int(input().strip())
    
        d = []
    
        for _ in range(d_count):
            d_item = int(input().strip())
            d.append(d_item)
    
        res = triplets(t, d)
    
        fptr.write(str(res) + '\n')
    
        fptr.close()
    

    I know what strip does, removes chars from left and right, though I'm not really sure why they gave d an empty list.

    I'm also having a hard time running this code on my Windows machine because I assume "OUTPUT_PATH" is for linux based on the way it's written. I have a linux server to play around on in Linux academy but I haven't been able to log in there this evening, so I'm stuck in being able to test it locally, though obviously I can test it in the Hackerrank environment.

    Just adding my above code (minus the if __name__ == "__main__" : section ) and using their output code gives me errors and no returns, but I'm not sure what to change to fix it. :( I wish they'd just let me write my own program instead of having the output code, though I suppose maybe that's to 'help' me.

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • dporowskidporowski Registered User regular
    Unless I'm a lot less sober than I think I am, initialising found to true means that you'll never hit your failure case, as your success case sets it to true... Which it is already.

    As for that output code, I don't think anything on Hackerrank is intended to be run locally, so I imagine it's just for rendering on the remote.

  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    dporowski wrote: »
    Unless I'm a lot less sober than I think I am, initialising found to true means that you'll never hit your failure case, as your success case sets it to true... Which it is already.

    As for that output code, I don't think anything on Hackerrank is intended to be run locally, so I imagine it's just for rendering on the remote.

    No, found = true works in the original code. The problem I'm having is getting errors with their output script, saying that I can't use the operands I'm using for list and int. But if I can't, then why did they work before the output script was added?
    Traceback (most recent call last):
      File "Solution.py", line 39, in <module>
        res = triplets(t, d)
      File "Solution.py", line 14, in triplets
        for i in range(0, d-2): 
    TypeError: unsupported operand type(s) for -: 'list' and 'int'
    

    To try to figure out the output code, I'm sorta rewriting it without the fptr stuff to see if I can work it out.

    Edit: Like this, but it's still giving me the operand error on my local PC:
    if __name__ == "__main__" :
        
        t = int(input().strip())
        d_count = int(input().strip())
    
        d = []
    
        for _ in range(d_count):
            d_item = int(input().strip())
            d.append(d_item)
        
        triplets(t, d)
    


    Edit again: so if I understand the error it's saying I can't subtract from a list, but again if that's true why could I do it before? Lists are mutable in python why wouldn't I be able to subtract from them?

    Also, the original triplets program works w/o the found = True so I went ahead and deleted it, don't remember why I had it there. Still puzzling over the lists thing tho.

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    Ugh, I have to start over anyway because they don't want triplets equal to zero, they want triplets that add up to a number of the user's choosing, so I have to rework it.

    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    Through sheer luck I found out the problem with the operand error. I was switching the variables around, it was the t variable that I should have been subtracting from using their output, not the d variable (woulda been nice if they choose variable names that mean something, huh?)

    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • dporowskidporowski Registered User regular
    edited August 2020
    If you initialise found to True, then the case at lines 17-18 would never happen, as found will never be set to False.

    Targeting a different number than 0 is also not a lot of work, btw. (Though I'll not say more, as I don't want to say too much. You know.)

    I believe you're getting your operand error because (from the look of their output code) they're treating d as the input array, and you're treating it as the length of list t. A general suggestion (and tip that'll serve you well) is always err on the side of overly descriptive object names.
    triplets(length, array)
    
    is much less ambiguous than
    triplets(a, b)
    
    , and the more lengthy and complex the thing you write, the more help this is.

    dporowski on
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    edited August 2020
    dporowski wrote: »
    If you initialise found to True, then the case at lines 17-18 would never happen, as found will never be set to False.

    Targeting a different number than 0 is also not a lot of work, btw. (Though I'll not say more, as I don't want to say too much. You know.)

    I believe you're getting your operand error because (from the look of their output code) they're treating d as the input array, and you're treating it as the length of list t. A general suggestion (and tip that'll serve you well) is always err on the side of overly descriptive object names.
    triplets(length, array)
    
    is much less ambiguous than
    triplets(a, b)
    
    , and the more lengthy and complex the thing you write, the more help this is.

    I didn't select the variable names, believe me I'm not a fan of what they choose. I'm only editing what I'm allowed to edit, so I had to go w/ their variables.

    Edit: I'm guessing they don't give the variables meaningful names since it would give away solutions to the problem.

    Sigh. I don't think I'm going to figure this out before the time limit, dammit.

    Edit again: To be clear, they don't just want a different number from zero, which wouldn't be hard. They want to return the count of numbers that add up to the user-given sum, where all three numbers are also a<b<c, and I can figure out how to do one of those things but not both.

    Cambiata on
    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • dporowskidporowski Registered User regular
    I am honestly lost for reaction to "and they won't let you name the variables properly", because jesus christ. That is awful, and you have my sympathies.

  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    Since my timer ran out, I'm just going to spend the next week working on it and trying to come up with the answer.

    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • CampyCampy Registered User regular
    dporowski wrote: »
    I am honestly lost for reaction to "and they won't let you name the variables properly", because jesus christ. That is awful, and you have my sympathies.

    Yeah, this is absolute crazy town. Good naming is, IMO, legit one of the most important things when writing maintainable code. Modern refactoring tools have basically made it a none-problem to rename all and sundry, so there is no argument for including such shite on any sort of code katas.

    Unless you're writing vanilla JS or something, and then you're fucked from the get go anyways.

  • Ear3nd1lEar3nd1l Eärendil the Mariner, father of Elrond Registered User regular
    Whoever created the idea of online coding assessments should be drawn and quartered.

  • CampyCampy Registered User regular
    Speaking of coding assignments, I've just sent off a tech test to a prospective employer.

    I'm applying for my first "proper" senior role, so I'm hoping what I've written conveys that level of competence. The job was on a friends recommendation, so even if I fail, hopefully I'll actually get some feedback on what was lacking.

  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    Cambiata wrote: »
    Since my timer ran out, I'm just going to spend the next week working on it and trying to come up with the answer.

    This is the kind of attitude that will land you a programming job, so keep it up.

  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    dporowski wrote: »
    I am honestly lost for reaction to "and they won't let you name the variables properly", because jesus christ. That is awful, and you have my sympathies.

    I’m more shocked that there wasn’t a description of the inputs. Like, “a is the length of the input list, and b is the input list”, regardless of variable naming the parameters should have a brief description (so even if they named the second parameter array, I would still expect some documentation “array is the list of input numbers as a {list|tuple}.”

  • TelMarineTelMarine Registered User regular
    dporowski wrote: »
    I am honestly lost for reaction to "and they won't let you name the variables properly", because jesus christ. That is awful, and you have my sympathies.

    I’m more shocked that there wasn’t a description of the inputs. Like, “a is the length of the input list, and b is the input list”, regardless of variable naming the parameters should have a brief description (so even if they named the second parameter array, I would still expect some documentation “array is the list of input numbers as a {list|tuple}.”

    There usually is, at least on Leetcode. Haven't really used Hackerrank, but poor variable naming is par for the course. I'm not sure why, maybe it's easier and people are lazy as fuck. Over the years I've tended to go with long variable names since the IDE takes care of all that stuff for you and I've taken to the approach of that I try to get the code to read like an english sentence.

    3ds: 4983-4935-4575
  • thatassemblyguythatassemblyguy Janitor of Technical Debt .Registered User regular
    TelMarine wrote: »
    dporowski wrote: »
    I am honestly lost for reaction to "and they won't let you name the variables properly", because jesus christ. That is awful, and you have my sympathies.

    I’m more shocked that there wasn’t a description of the inputs. Like, “a is the length of the input list, and b is the input list”, regardless of variable naming the parameters should have a brief description (so even if they named the second parameter array, I would still expect some documentation “array is the list of input numbers as a {list|tuple}.”

    There usually is, at least on Leetcode. Haven't really used Hackerrank, but poor variable naming is par for the course. I'm not sure why, maybe it's easier and people are lazy as fuck. Over the years I've tended to go with long variable names since the IDE takes care of all that stuff for you and I've taken to the approach of that I try to get the code to read like an english sentence.

    To the bolded, if the problems are pulled from old-school dry-erase-board style interviewing, it's often easier to just go "a, b, c, x, y, z, i, j, k" for room/writing time since the applicant doesn't have hand-write auto-complete, and will often short-hand the variables anyway to keep a solution on the board or to assist with time.

    The inputs to the problems were always well documented in this case, and if they weren't then it was part of the interview for the applicant to ask the interviewer to clearly define the inputs/outputs.

  • bowenbowen How you doin'? Registered User regular
    I love how after like 20 years fizzbuzz is still what all programmers rely on to determine someone's skills and that, after 20 years, it's still super reliable at weeding out people.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • SpawnbrokerSpawnbroker Registered User regular
    My company has switched to a code debugging exercise, which I'm not sure is better. Nobody really knows how to interview correctly in this industry. Fizzbuzz was very successful at finding people who couldn't code at my old job, despite it being a very well-known problem. I even gave them the modulo operator for free, because if they knew how to write a loop, congratulations, you passed, here's some other questions

    Steam: Spawnbroker
  • SoggybiscuitSoggybiscuit Tandem Electrostatic Accelerator Registered User regular
    My company has switched to a code debugging exercise, which I'm not sure is better. Nobody really knows how to interview correctly in this industry. Fizzbuzz was very successful at finding people who couldn't code at my old job, despite it being a very well-known problem. I even gave them the modulo operator for free, because if they knew how to write a loop, congratulations, you passed, here's some other questions

    Like, I'm not even a programmer, I'm a scientist and I know about and use the modulo operator on a semi-regular basis. Usually I'll use it to debug something I have to loop over by printing out every 1000th result or similar.

    Are you telling me people are interview for jobs as programmer without knowing about it?

    Steam - Synthetic Violence | XBOX Live - Cannonfuse | PSN - CastleBravo | Twitch - SoggybiscuitPA
  • LD50LD50 Registered User regular
    My company has switched to a code debugging exercise, which I'm not sure is better. Nobody really knows how to interview correctly in this industry. Fizzbuzz was very successful at finding people who couldn't code at my old job, despite it being a very well-known problem. I even gave them the modulo operator for free, because if they knew how to write a loop, congratulations, you passed, here's some other questions

    Like, I'm not even a programmer, I'm a scientist and I know about and use the modulo operator on a semi-regular basis. Usually I'll use it to debug something I have to loop over by printing out every 1000th result or similar.

    Are you telling me people are interview for jobs as programmer without knowing about it?

    People will interview for programming jobs without even knowing how to write hello world.

  • SpawnbrokerSpawnbroker Registered User regular
    There is no regulatory body like doctors and lawyers have that can tell a company if a person is a reasonably passable programmer. Anyone can walk in and declare that they can code. Add on the fact that programming is a very in-demand field that pays a lot of money with a relatively low barrier to entry, and you have a lot of people who try to "fake it til they make it" by applying to programming jobs. Even worse is that software is usually the thing that is easiest to break in your company and powers a lot of your core business, so a bad hire can literally ruin your company.

    So the only way companies can protect themselves from making disastrous hires is by relying on current employees vouching for someone or by giving them a coding test to make sure they can actually solve problems. Some companies take it too far (I have some stories about my Google/Amazon/Facebook/Microsoft interviews over the years, hoo boy), but they do it because they have no other way of making sure that you aren't one of the people trying to cheat their way into a job that they have no business in.

    Steam: Spawnbroker
  • CambiataCambiata Commander Shepard The likes of which even GAWD has never seenRegistered User regular
    bowen wrote: »
    I love how after like 20 years fizzbuzz is still what all programmers rely on to determine someone's skills and that, after 20 years, it's still super reliable at weeding out people.

    I WISH the places I've applied for used fizzbuzz.

    "If you divide the whole world into just enemies and friends, you'll end up destroying everything" --Nausicaa of the Valley of Wind
  • SpoitSpoit *twitch twitch* Registered User regular
    There is no regulatory body like doctors and lawyers have that can tell a company if a person is a reasonably passable programmer. Anyone can walk in and declare that they can code. Add on the fact that programming is a very in-demand field that pays a lot of money with a relatively low barrier to entry, and you have a lot of people who try to "fake it til they make it" by applying to programming jobs. Even worse is that software is usually the thing that is easiest to break in your company and powers a lot of your core business, so a bad hire can literally ruin your company.

    So the only way companies can protect themselves from making disastrous hires is by relying on current employees vouching for someone or by giving them a coding test to make sure they can actually solve problems. Some companies take it too far (I have some stories about my Google/Amazon/Facebook/Microsoft interviews over the years, hoo boy), but they do it because they have no other way of making sure that you aren't one of the people trying to cheat their way into a job that they have no business in.

    Are there any other industries where they have developed a whole other sub industry for preparing for interviews? I guess test-prep for the Bar and the LSAT and the like, but that's not quite the same

    steam_sig.png
This discussion has been closed.