6 kyu

Old Mobile Display

98 of 208mmalkavian
Description
Loading description...
Strings
ASCII Art
Fundamentals
  • Please sign in or sign up to leave a comment.
  • trashy_incel Avatar

    JS fork

    • improved and hopefully clearer description
    • better error messages
    • mocha + chai
  • LetMeeDie Avatar

    and what to return if n is below 20 or n is above 100?

    • LosBlobbos Avatar

      There is no upper limit, the description simply states values in tests can be big.
      the least 20 characters or least 30% means thats the lower limit of the display, any values less than that should be considered to be 20 or 30%

    • LetMeeDie Avatar

      че ты высрал

  • Blind4Basics Avatar

    the CodeWars logo is always in the middle horizontally

    The centering is inconsistent with the "reference" str.center. The kata should be either updated to make it consistent about that or the expected centering should be clearly stated.

    In addition:

    • the note about min values for n and p should be put at the beginning of the "rules" part (like... just after we talked about them...!)
    • the debugging is especially painfull, considering the centering problem and the fact that the assertion messages needs to be copied/pasted to make a head to head compare by hand => it would be good to add a dsiplay of both the actual and the expected displays
  • lechevalier Avatar

    Python translation (version 3.4) There is a floating point error in kata test function:

    Parameters: n = 85, p = 140 So height is 119 lines (no decimal) But in test function, it yields 118.999..., then truncating to 118 lines.

    Height calculus must be change from

    h = int(n * (p / 100.0))
    

    to

    h = int(n * p / 100.0)
    
    • mmalkavian Avatar

      You are right lechevalier, I added a small hint in the description. Although I want you to notice that these are some few corner cases.

      Considering a range from 20 to 150

      tot = 0
      found= 0
      for i in range(20,150):
          for j in range(20,150):
              tot += 1
              t1 = int((i*j)/100.0)
              t2 = int(i*(j/100.0))
              if t1 != t2:
                  found += 1
                  print i,j," --- >",t1," vs ",t2
      print found, tot
      

      We'll get :

      n    p         v1      v2
      25  116  --- > 29  vs  28
      45  140  --- > 63  vs  62
      50  58  --- >  29  vs  28
      50  114  --- > 57  vs  56
      50  116  --- > 58  vs  57
      85  140  --- > 119  vs  118
      90  70  --- >  63  vs  62
      90  140  --- > 126  vs  125
      100 29  --- >  29  vs  28
      100 57  --- >  57  vs  56
      100 58  --- >  58  vs  57
      100 113  --- > 113  vs  112
      100 114  --- > 114  vs  113
      100 115  --- > 115  vs  114
      100 116  --- > 116  vs  115
      
      15 cases over 16900
      

      a small python glitch, but indeed a good catch.

      Issue marked resolved by mmalkavian 9 years ago
    • lechevalier Avatar

      Thanks for the scale but actually dividing by p, then multiply by m returns a "wrong" result. You need to correct test cases by the suggestion I put. As this case is rare, there will be nearly no impact on already given solutions and future solutions will always be correct.

    • mmalkavian Avatar

      I did modify the tests, the code validates but it won't let me publish it.

    • lechevalier Avatar

      That's strange, I had this problem too when trying to edit the old kata Character Counter and Bars Graph.

    • mmalkavian Avatar

      The approximation float-integer is an old-time problem and python is not exempt by it. I've used the int() approximation as a reference to avoid users to figure out how to get those numbers by struggling with hideous ceil(), floor() and round().

    • lechevalier Avatar

      Good practice indeed. Don't forget to multiply first instead of dividing, even if your numbers are big: Python handles better big integers than small floating point numbers.

      However here, as CW doesn't allow the modification of your kata, I'm betting on a problem with python handling.

    • lechevalier Avatar

      @mmalkavian CW issues seem to be solved, could you try to edit now?

  • Vajni Avatar

    The test case should need a double check for random numbers. I had 129 for "n" and 19 for "p" but the result that was given had like 38 lines, wherease it should be 24?

    Thanks for your answer in advance!

    P.s.: Nice kata!

  • gabs22 Avatar

    I apologize if I misunderstood, my english isn't quite so good, but I believe that this part of the description might be misleading, ambiguous, or at least hard to understand:

    the CodeWars logo is always in the middle horizontally and in the half-1 line vertically;
    

    I say this because the CodeWars logo actually isn't always in the middle horizontally. I took some time to figure out that, when 'n' was odd (of course), I had to actually put it always in the first horizontal half for achieving the right solution.

    Take a look at your examples, specially at the one with (25,30). CodeWars is 8 characters away from the left border, and 9 characters away from the right border. Counting the 8 characters from CodeWars, we have 8 + 8 + 9 = 25. This isn't middle, this is first half.

    Although this, I enjoyed a lot your kata, keep up the good work. :)

    • mmalkavian Avatar
      • Excuse me, you are aligning the "C", I'm aligning the center of "Codewars", the "ew", there's no more middle than that.

      • This should be a question, not an issue; more so, if you already solved it.

      • Thank you.

    • mmalkavian Avatar

      [nothing]

      Issue marked resolved by mmalkavian 9 years ago
  • user5036852 Avatar

    Nice kata! Thanks!