Ad
  • Custom User Avatar

    Thanks for your thoughts and ideas! The short answer is yes, it can be.

    If you read the wiki article linked, you'll see a couple examples where you have more specific notation for variables with multiple subsets. For example, arru8NumberList is an array of unsigned 8-bit integers ("arru8"). The problem I found when trying to make more detailed implementation is that it either becomes very repetative, (e.g. one massive function with 50 if conditions) and the actual difficulty comes in writing tests for the function. I think ultimately, the actual fun and interesting part of the challenge is condensed into the code I've written.

    I've given it some more thought, and I think something that could be more fun would be setting up other conditions for the prefixes, and checking if the value inside of the variable meets the conditions for the given prefix.

    input: var='arru8NumberList', val=[300, 301, 302...] output: False
    
    input: var='arru8NumberList', val=[0, 1, 2, ... 255] output: True
    

    That's a bad example for python, but the point is still the same. For a challenge like that, you'll still have to check the type() the way I was, but you'll have to actually use other logic to return True/False

  • Custom User Avatar

    Is this applicable for all the different types of data, including subsets of the same type (i.e. sets v.s. frozensets, bytes v.s. bytearray)? If not, I think that'd be a good way to add onto this and turn it into a kata, as well as maybe adding some new types in your test cases to add double-/triple-word typenames.

  • Custom User Avatar

    @JefeThePug: if you post code, better to fork the kumite.

  • Custom User Avatar
  • Custom User Avatar

    (built from seraph's original change to any type)

  • Custom User Avatar

    Well, declaring as a string forces any input to be formatted as a string, from what I can tell, so I just put an int as the test to make sure that the code runs for all possible inputs, including potential miscommunication with the script for "None" or "Null" jokes.

  • Custom User Avatar

    Good contribution! However, you declared the parameter food_source as a string and later pass an interger as a value in the tests. Perhaps you should declare food_source as Any if you want it to be "any" type of datatype?

  • Custom User Avatar

    I just made the arguments forced strings, so you can put whatever you want in whatever slot.