Ad
  • Default User Avatar

    I am very new to codewars but this one was way too easy, felt more like 7kyu or so, is it possible to edit it and to add some more challanging code to it?
    If yes, would love to help with it.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    No, you're just blind for... ;)

    (not my mother tongue either ;) )

  • Default User Avatar

    Mmmmmh...

    Adding that, it should work, I think:

    @staticmethod
    def expect(boolVal, message="FAILED TEST!"):
        if not boolVal: raise Exception(message)
    

    Note: the problem here is maybe that the print statments didn't need parentheses in python 2?

  • Default User Avatar

    "... or (b) considered to be an exception and put entirely into lower case unless it is the first word, which is always capitalised."

    ;)

  • Default User Avatar

    Hi,

    I'm not sure to understand what you want... :o

    If you want a way to make compatible your IDE implementation with the test class used on codewars (I think that's what you're talking about), I used that for big katas development:

    class Test(object):
        @staticmethod
        def it(message): print(" \n{}\n".format(message))
        
        @staticmethod
        def describe(message): print(" \n{}\n".format(message))
        
        @staticmethod
        def assert_equals(actual, expected, message="FAILED TEST!"):
            if actual != expected: raise Exception(message)
    

    On codewars, it's actually test.assert_equals but there is surely some aliasing somewhere, because that works with Test.assert_equals as I use in my code too.

    EDIT: note that you can add test=Test after that to avoid any troubles with capitalization between your machine and CW's sample tests for example.

  • Default User Avatar

    Yeah, this is a problem I know well enough too... (the "blind for basics" thing... ;-o )

    ;-D

  • Default User Avatar
    • one live cell with n < 2 or n > 3 alive cells around dies
    • one dead cell with n == 3 alive cells around araise from the dead

    (yes, I live in the matrix, I guess... A bit too much, at least... ;) )

    EDIT: crossed message with your update

  • Default User Avatar

    Hello, I think you just misunderstood, that are three living cells are necessary to become alive.

  • Default User Avatar

    \o/

    "Pythonized java code", yeah, that's the idea! ;) (when it's possible... And that's not always... Java is quite often a pin in the ass compared to python :/ )

    About oneliners (some call that "golfing"), it's generally more the eqivalent of BAD streams usage. The real equivalent in python of """good streams""" (note the number of quotation marks... ;-o ) would be list comprehension.

    (sigh... I'lov' python... 8-) ;) )

  • Default User Avatar

    Hi,

    I had a hard time with that too. ;)

    Actually, do not forget to consider that the field is unlimited, EVEN AT THE BEGINNING! ;) Meaning you should consider the starting grid being actually:

    start = [[0, 0, 0, 0, 0],
             [0, 1, 0, 0, 0],
             [0, 0, 1, 1, 0],
             [0, 1, 1, 0, 0],
             [0, 0, 0, 0, 0]]
    

    ...and there you'll have your answer. ;)

  • Default User Avatar

    No problem (at least I tried! So I wasn't wrong when I decided to quit my seller studies... ;-) )

    (and I didn't know about performances (Java is my second language))

    Cheers!

  • Default User Avatar

    Hi,

    Unfortunately, there nothing to do anymore abuot that: on codewars, the tests of katas with more than 500 completions are locked... ;-/

  • Default User Avatar

    Streams are improvments of Java 8. Lots of programmers prefer "old ways", but that demands just a bit of habits to read and understand this. The only drawback of streams is that it might be hard to debug, yes, but it makes your code more compact, clearer (when you're used to it) because with less useless types declarations, you only read the usefull steps of your algorithm. So yes, I find it best practice. Meaning, "most of the times"... ;)

  • Default User Avatar

    Only with the red-account from CodeWars. There you get an option "Head-to-Head Compare" in which in most cases you see the execution duration.

  • Loading more items...