Beta

Build a Bridge

Description
Loading description...
Algorithms
Puzzles
  • Please sign in or sign up to leave a comment.
  • Blind4Basics Avatar

    New one... ;o

    0     *===========*       
    1       =*     *=         
    2     *=         =       *
    3       *            *    
    4       *     *           
    5        *              * 
    6 *             *         
    7  *                   *  
    8  *                     *
    9 *                     * 
    0       *             *   
    1 *                     * 
    2    *                   *
    3       *              *  
    

    It's never explained what are the rules about the supports:

    • where do they start under the brigde?
    • what size should they have?
    • what happens when the bridge is at the last or second to last row of the matrix? (not tested, apparently)
    • it's not said if the support should override blocks characters or not (for now, they do...)

    for instance, the current rules call for "non sensical" brigdes. Imo, you should ask for supports that actually support something, meaning, they should be extended until they either reach the blocks, or the beginning/end of the "matrix" (considere this as a suggestion only). And they should stop before overwritting a block character (this part is rather an issue... Well, let's say a "strong" suggestion...)

    another point: your tests allow the user the mutate the input. Not a problem in the way we usual write this, because it doesn't affect the tests, but that's bad practice in general, for this kind of input. So I'd suggest that you go for one of those two options:

    • either you clearly state the user can mutate the input
    • or or you state he cannot, and then you need to add specific tests for that.

    edit:

    and you need real sample tests, as I said below, testing for meangful cases (like, all the edge cases I talked about above!)

    • kvbc Avatar

      The supports are always the same

      *===========*
        =       =
       =         =
      

      The bridge will never be on the last or second to last row of the matrix, but it's not stated anywhere, my bad.

      Yea, they're "non sensical" bridges. These appear only in random tests so I will probably add some more tests and make them "sensical".

      Not sure what you mean by "the user can mutate the input". I'm new to codewars, could you explain some more, please ^_^

    • Blind4Basics Avatar

      so I will probably add some more tests and make them "sensical".

      if you wanna make them "sensical" (the random tests), you'd have to add more constraints in your random generator.

      mutation of the input

      look at my solution: I'm changing the content of the input matrix on the fly, rather than creating a fresh one. That means the input is modified in your tests after you executed my function. Again, that's not a problemwith the current setup of the tests, but that's not good practice. Hence my two suggestions above about that.

    • kvbc Avatar

      should be done

    • Blind4Basics Avatar

      ok. But you realize you're adding new behaviors without changing the specifications in the description? You just added the "unbounded support" thing while:

      • it is shown in the example and never talked about in the description
      • nothing is said about what's the condition to stop the expansion. => when a block char is found aside of it? in the current direction? (meaning we won't overwrite blocks anymore?)

      you really should gather your thoughts about what are every requirements, then rewrite the full description from scratch.

      And what about the other points?

      btw: the sentence below feels wrong to me. I'm not sure but I believe you're talking about verticality, here, while you use width?

      The y position of the bridge will always be lower than (width - 2):

    • kvbc Avatar

      It is talked in the specifications, in the last point. And it is said that it stops when it hits the edge or "sticks" to a solid block What other points? My bad, fixed

    • Blind4Basics Avatar

      ...You're still overwritting the block with the supports... :/

      [ '*==================*',
        '  =    *    *    =  ',
        ' *          *     = ',
        '     *            *=',
        '       *         *  ',
        '   *              * ',
        '*             *     ',
        '       *        *   ',
        '       *    *       ',
        '       *     *      ',
        '*            *      ' ] 
      [ '*==================*',
        '  =    *    *    =  ',
        ' =          *     = ',
        '=    *            *=',
        '       *         *  ',
        '   *              * ',
        '*             *     ',
        '       *        *   ',
      
    • kvbc Avatar

      Okay, I changed the specifications. Now you are extending the support till it hits a solid block

  • Blind4Basics Avatar

    ... x/

    -------------------------
      01234567890123456789012345
    
    0                           
    1                           
    2                           
    3                           
    4               *  *        
    5                           
    6                           
    7                           
    8                           
    9                           
    0                           
    -------------------------
    

    seriously...? seems your random tests are flawed.

    and I just saw there is a test with 3 pillars. That should be in the description...

  • Blind4Basics Avatar

    hi,

    the description is lacking a lot of things:

    • what are the characteristics of the pillars? different heights? (seems they can according to the description, but see the party about the sample tests) different widths? fixed? one pillar can be different from the other?
    • the info about the support should be in the specifications, not in the examples part
    • the first example of the description being given with ^ chars is a bad idea, since it will never be an actual input. The question marks are much more appropriate, here.
    • the initial solution contains a helper function whose action isn't explained (even if evident...)

    And the sample tests are close to useless to the user, for now, because you only test for different materials and not different sizes.

    • kvbc Avatar
      • What do you mean by 'pillars', the *? If so then it's said in the description that it should build a bridge between 2 highest and closest ones
      • You're right, i'm going to change that
      • My bad, i'm also going to change that
      • I'm going to add some comments

      and i'm going to add more sample tests

    • kvbc Avatar
      • It should build a bridge between 2 highest and closest ones
      • Added "Specifications"
      • Updated the first example
      • Helper function explained in the initial solution
      Issue marked resolved by kvbc 5 years ago
    • Blind4Basics Avatar

      yes, by "pillars", I meant *.

      That's better, but still not enough:

      • in the example, you wrote 13>8 while it should be 13>=8
      • the specification part shoud hold all specs.
      • talking about building the bridge between the to highest and closest is still not precise enough:
        • when 3 pillars, should we build one single bridge or two?
        • sounds like the correct wording is rather "the highest possible bridge" rather than talking about the two highest possible blocks.
        • what is the precedence, in case I find a lower candidate bridge which is shorter than a higher one?

      If I interpret your sentence, I'd guess that I'm supposed to buil one single bridge when 3 blocks/pillars. Is that correct?

      => As you can see, it still needs some work. ;)

    • kvbc Avatar
      • You're right, i'm going to correct that
      • That's also right, i'm going to add all the specifications
      • I think it's pretty clear that we should build one single bridge
      • Thanks for that, i'll change that
      • Well it's all about the highest bridge, so you should take the higher one

      Yes, you're supposted to build a one single highest possible bridge. I'm on it.

    • user9644768 Avatar

      I think it's pretty clear that we should build one single bridge

      What to do in this case:

      
      
      BBB         BBB          BBB
      BBB         BBB          BBB
      BBB         BBB          BBB
      BBB         BBB          BBB
      
    • Blind4Basics Avatar

      I think it's pretty clear that we should build one single bridge

      well, it's not as long as it's actually stated that way. ;) (mostly because there are a lot of details you didn't give, so that's an opened door to hypothesis)

    • kvbc Avatar

      My bad. I forgot to mention, that there will always be only one possibility of building a bridge per row

  • user9644768 Avatar

    No random tests(check my solution to see why that is needed)