5 kyu

Department scheduler [simple]

87 of 150MMMAAANNN
Description
Loading description...
Scheduling
Algorithms
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar
    • The parameter name in all languages for month is kinda misleading because the format given is in MMYYYY

    • It's assumed that you should return an array of arrays with n names in it, but:

      Output Array of arrays, each representing a day in the given month. Each day array contains three employee names.

      Why there is three in the description when each day array should contain n employee names?

    • Description should be language-agnostic

  • 4500zenja1 Avatar

    It's assumed that you should return an array of arrays with n names in it, but:

    Output

    • Array of arrays, each representing a day in the given month. Each day array contains three employee names.

    Why there is three in the description when each day array should contain n employee names?

    • RealKenshiro Avatar

      Because

      schedule(['Smith', 'Jones', 'Gonzalez', 'White', 'Jackon', 'Taylor'], '022015', 3) <--- n = 3

      Issue marked resolved by RealKenshiro 3 years ago
    • 4500zenja1 Avatar

      Sorry, but it seems you are wrong: you have provided the example test, for which n = 3, indeed, — but I was asking about the overall output — because there must be *n* people at work each day. Surely there are tests where n = 2 or 4 or 9, aren't there?

    • RealKenshiro Avatar

      I don't think you really understood the problem.

      It is your task to find a way to make n people work each day.

      1. for n = 4, you could have (if it's possible):

      x0, x1, x2, x3 the first day

      x4, x5, x6, x7 the second,

      etc ..

      1. for n = 5, you could have (if it's possible):

      x0, x1, x2, x3, x4 the first day

      x5, x6, x7, x8, x9 the second,

      etc ..

    • 4500zenja1 Avatar

      Usually Output paragraph has been written for the common case and for all possible testcases — in this kata, the paragraph is correct only for n = 3, while for others it's not.

  • user9644768 Avatar

    Ruby 3.0 should be enabled.

  • G_kuldeep Avatar

    whats the matter with this..

    format_message
    return message.replace("\n", "<:LF:>")
    AttributeError: 'tuple' object has no attribute 'replace' (python)

    • MMMAAANNN Avatar

      Your message is unclear. I don't see anyting titled "format_message" in the Kata code. What your message says is you cannot replace anything in a tuple (obviously, because a tuple is an immutable type). Please explain where you saw this if you want further assistance.

    • G_kuldeep Avatar

      full error ;

        File "main.py", line 56, in <module>
          Test.expect(validation == '', validation)
        File "/runner/frameworks/python/cw-2.py", line 22, in expect
          display('FAILED', message)
        File "/runner/frameworks/python/cw-2.py", line 14, in display
          type.upper(), mode.upper(), label, format_message(message)))
        File "/runner/frameworks/python/cw-2.py", line 9, in format_message
          return message.replace("\n", "<:LF:>")
      AttributeError: 'tuple' object has no attribute 'replace'
      
    • MMMAAANNN Avatar

      OMG, this looks like an error somewehere in the framework that runs tests, not in the test suite code itself. Somehow it fails because it cannot handle tuples properly.

    • FArekkusu Avatar

      Test.expect(validation == '', validation)

      Or, you know, the tests are broken?

    • MMMAAANNN Avatar

      https://github.com/Codewars/codewars.com/wiki/Codewars-Python-Test-Framework-V2#truthness-test It looks conformant with the statement test.expect(boolean, message) - do you see a problem or have a suggestion of a fix?

    • MMMAAANNN Avatar

      Can I please see your solution so I can test this?

    • G_kuldeep Avatar

      This comment has been hidden.

    • FArekkusu Avatar

      It looks conformant with the statement test.expect(boolean, message)

      In which reality does a non-string qualify as a message? And by writing Test.expect(actual == expected) you're practically asking for trouble.

    • MMMAAANNN Avatar

      Okay, thanks. I found the bug. You don't see the full contents of test suite yet. The validation variable contains the actual message of what is wrong, not the expected value. If that message is empty, this means you've passed the tests on the case. Hence comparison of validation results with empty string - and it is absolutely okay for this context.

      My bug was in another line of the test suite, where instead of string substitution there was a tuple (due to a typo). This bug is now fixed. You can continue debugging your solution now (it still needs work).

      Issue marked resolved by MMMAAANNN 5 years ago
  • bouchert Avatar

    The sample tests don't work in Python 3 because the print statements have a bare argument. You need to change print result to print(result) in both cases and then it will work in both Python 2 and Python 3.

    • MMMAAANNN Avatar

      This site did not have py3 support when the kata was written. I have updated the example cases so now it should work.

      Issue marked resolved by MMMAAANNN 8 years ago
  • haferjir Avatar

    Wow. One of the finest katas I've seen so far. So I'm really sorry to bother with this fine kata and it's a really small complaint.

    The descriptions says the format of the month is mmyyyy while I think the ruby tests actually do mm/yyyy.

    • MMMAAANNN Avatar

      I am not sure about Ruby as I do not have much experience with that language (Giacomo did the translation), but from looking at the code I think that the data is actually passed in mmyyyy format, not mm/yyyy format. Please do not confuse what is passed to the function with what is shown in the console, as the slash is actually being inserted in the console output describing the test.

      Please re-check whether the issue actually exists and if it does not, mark it as resolved.

      Thank you for your kind words about my kata! I am conceiving a much more complicated variation of it, but it will be published in Python (and I cannot say when it gets published, as I have some unresolved things yet). Keep looking at the katas I author if you don't want to miss it :)

    • haferjir Avatar

      I think you're right, but it still feels confusing that the output in the tests differs from the input. But it's a very small issue so I don't bother you anymore. (:

      Issue marked resolved by haferjir 10 years ago
  • GiacomoSorbi Avatar

    JS translation submitted and it was quite the bloodbath :D

    I hope now everything is fine, if not just let me know :)

    • MMMAAANNN Avatar

      Thank you very much!

    • GiacomoSorbi Avatar

      Ruby translation submitted too :)

      Oh, while I am at it, I must complimenti you for all the work in creating the tests (which in this case was much, much harder than solving the kata itself); some of your ideas were also as interesting as elegant: kudos!

    • MMMAAANNN Avatar

      I am getting an error when trying to approve your translation:

      Description cannot be approved, recent changes from related record must be merged first.

      What should I do?

    • MMMAAANNN Avatar

      I finally found how to resolve this. I had to change description so that it corresponded to the initial state before your Ruby translation.

      Funny thing is that the description edit that prevented me from accepting your Ruby translation was actually made by you during JS translation. (None => None/null).

    • GiacomoSorbi Avatar

      Yeah, it happens when someone changes the description (in this case it was still me); apparently copy&pasting the new description didn't work either.

      Sorry for the inconvenience: next time just have me fork the translation with a more recent description, so to spare you some annoyance :)

      That said, I hope the aforementioned next time will come soon, as working with you is surely a pleasure :)

    • MMMAAANNN Avatar

      Oh, there still are a couple of Geometry katas untranslated, and I would really appreciate your help there! In the meantime, I have some plans for harder similar scheduling katas and for some more geometry katas too.

  • ChristianECooper Avatar

    It's probably worth including some rules about the leap years. :)

    • MMMAAANNN Avatar

      I thought it was obvious that the year can be a leap year. Please suggest wording if you think it is a necessary clarification.

    • GiacomoSorbi Avatar

      I thought that was obvious too, but usually Christian has a better hand in dealing with descriptions and instructions than mine, so I took the liberty of adding one final paragraph to the kata description.

      [Also: JS and Ruby versions should follow shortly if I don't encounter any serious problem in translating them]

    • MMMAAANNN Avatar

      Thank you! Looks fine.

      Suggestion marked resolved by MMMAAANNN 10 years ago