Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Please elaborate.
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.
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 frominput()
is always a string. When I manually ranexpanded_form("1234")
, then1234
was made a string literal and used to initialize a string object or whatever. And the unmodifiedexpanded_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
@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
@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".
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, the2**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.
(listing of unmodified solution here)
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 usinginput()
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 toint
within yourfor
loop.Well then, do that, and be done. It definitely WorksForMe™
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.
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.
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.
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 ;)
But I am :D
Common man! Don't act like as you are tired of hearing me. The best way to stay silent is reply nothing.
I give up.
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.
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.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.
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...