Ad
  • Custom User Avatar
  • Custom User Avatar

    Guys, do you know something about what this mothefuing coderwars.com has done to my account. They suspended my account for 3 days because I had pointed them using some slang words. I was expecting that they would permanently kick me out of this platform but no. They are the mothefuers. Now infront of you all, I am going to call codewars.com a special mothefuer. They are my dic* sucrs.

  • Custom User Avatar
    >>> type(input())
    <class 'str'>
    

    yes! I was right about something! lol

    (edit)

    So I began to learn about Python's type system. I was wrong about "" maybe forcing what you typed to become a string, because the return from input() is always a string. When I manually ran expanded_form("1234"), then 1234 was made a string literal and used to initialize a string object or whatever. And the unmodified expanded_form() already works on strings. Oh hey look, expanded_form(str(1234)) also works. HMMMMMMmmmmm!! You can't already cast an integer to a list, so your code chokes on integers, but you can cast something to something else and something else to something useful. But it seems you are wholeheartedly opposed to changing anything to match codewars.com kata & test harness usage of the type system, as if it should already work, only because other software and other websites do things differently. It's your choice and your own failure, now.

    gl hf

  • Custom User Avatar

    @rowcased

    I know my code is not working on codewars and I don't even want to make my code run on codewars. Read the conversation (controversy) from the beginning.

    Fu** the codewars.com

  • Custom User Avatar

    @dbtx

    In the line; expanded_form("any_int_number") is just to check whether the function perform its tasks or not.
    To handle exceptions like you wrote as "expanded_form(14376)", I can use "if-else" like this below;

    num = input()
    if num.isdigit() == False:
    print("You must enter number")
    else:
    expanded_form(num)

    This way, I can handle error but handling error isn't the issue. The main thing is whether my code performs the desired task or not. And the answer is "Yes" and definetely "Yes".

  • Custom User Avatar

    Go and run my code in your IDE and then come here. My code will ask you a prompt, give any number and my code will expand that number. Below is the code.

    I believe you, that it works for you. However, there is no interactive prompt for user input in that code immediately below that line. So I'll suppose you have some other wrapper / helper function defined, or something. It's not a big problem, other than the level of attention to detail 'required' to be a programmer. Anyway, I'm fairly sure that what you typed into such an interactive prompt isn't an integer. It likely comes into existence as a string: an array (or list, or whatever) of symbols (hopefully) corresponding to a number's digits in base ten, provided that you typed nothing outside of 0 ... 9 (or - + ., whatever). Probably. Again, I don't really know Python.

    Furthermore, even if it isn't natively a string, you (or the duck type system) might have stored it as a string before calling expanded_form() on it. Of course your code would work then, given a string. But a number is not a string-- it is not identical to an array containing its digits in base-anything. Yes, the 2**n digits in base two are all there, but that is not an array or list, either...

    I inserted the same five characters in three places to make your code work here. I also typed your solution as-is into an interactive python prompt on my machine, and then ran it.

    >>> def expanded_form(num):
    

    (listing of unmodified solution here)

    >>> expanded_form("14376")
    '10000 + 4000 + 300 + 70 + 6'
    >>> expanded_form(14376)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 2, in expanded_form
    TypeError: 'int' object is not iterable
    >>>
    

    Everything is exactly as expected. Did you enter 123456 or did you enter "123456"? The latter forces the number to be received and handled as a string, and then your original function works. EDIT: actually it breaks when using input() because the value is already stored as a string and the quotes become part of the string and prevent the conversion of each character back to int within your for loop.

    "You will be given a number" and I am dealing with the number in my code in the form of string.

    Well then, do that, and be done. It definitely WorksForMe™

  • Custom User Avatar

    No, your code is absolutely not working on Codewars because in its very first line it attempts the impossible by trying to make a list from the input, which is guaranteed to be an integer (not a string), and so it fails immediately.

    That's the end of it. If you want it to work on Codewars you need to accept the fact that the input will be an integer and adapt your code to handle it correctly.

  • Custom User Avatar

    Are you trying to say that my code isn't working? Go and paste my code to any of your editor and code will perform much better than your shit.

    I am trying to say from the beginning that my code cannot fit inside codewars.com. Hence, my code cannot perform only in codewars.com; else it performs everywhere.

  • Custom User Avatar

    this gives all the developers a freedom of writing code

    Developers of course have lots of freedom to write code, but part of programming is making that code work. If you want to work with numbers as strings, then simply turn the number into a string! You still have complete freedom, but you have to make it actually work.

    If you remove the requirement of code actually working, then it is no longer code, its just text.

  • Custom User Avatar

    Your solution runs & passes the tests, after very small changes.

    I don't even "know" Python. I think the most time I spent with it was while playing with the Panda game engine for a week, back around 2010, so that would be the vigorously deprecated Python 2.xx anyway ;)

  • Custom User Avatar

    Don't act like as you are tired of hearing me.

    But I am :D

  • Custom User Avatar

    Common man! Don't act like as you are tired of hearing me. The best way to stay silent is reply nothing.

  • Custom User Avatar
  • Custom User Avatar

    My solution exactly performed the requirements and I have dealed with numbers in my code. If you don't agree, go ahead and type the below code in your IDE.

    x = "7326"
    print(x.isdigit())

    Your IDE will return "True" because the provided value of x is string but a number and the question says, "You will be given a number" and I am dealing with the number in my code in the form of string. Hence, I'm proud on my code.

    Every developer should feel freedom to write code. Heard about "Hacking"? If yes, then the hackers always write their code in their own way instead of copying from others and this gives all the developers a freedom of writing code.

  • Custom User Avatar

    Where does the question says that I have to work with ints.

    It says it in the first sentence of the description: "You will be given a number", and int is a natural type for numbers in Python. Your answer should be a string, yes, but this part is not the problem. The problem is how you handle the input, and input is an int.

    my program does this, no matter ints or strings

    This is not true. Your code works if the input would be a string, but it does not work if the input is an int.

    There should always be the programmer's choice to write the code on their own

    This assumption is very wrong. Almost every code works under some assumptions, because it has to realize some requirements, and fit into some constraints. A programmer might have some freedom how to implement insides of their solution, but they still need to stick to the rules imposed by the interface and protocol. And in this challenge it is explicitly specified that the input is a number. You have to make your solution work with numbers, or it will be not conformant with the requirements. Your solution does not conform to the requirements stated in the description.

  • Loading more items...