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.
the input is an
unsigned
(32-bit) so it logically cannot be negative; the output is anunsigned long long
(64-bit). the tests do show you the input, expected and actual values. your code does not take care of avoiding integer overflow.I am having problems with this kata in C language.
Example- My test will fail with the following message:
"for n = 2494392752, expected 4168116981449254, but got 0"
Despite showing n as a positive integer, this is seemingly not the case as I get a different, non-zero output when changing n to the absolute value of n. This would only make sense if n was somehow negative.
Additionally, for cases such as this, nothing is printing to the console, allowing me to debug the issue. There are no errors, and I have tried printing both the unsigned long n (unmutated from the function argument) as well as its necessary cast to int.
Approved
Groovy Translation
yessir
some of the tests in the "attempt" section i guess have issues so dont feel too bad. If the main test fails although you have the exact input, check to see if your output has an extra space at the end or in the begining, good luck.
same as what did!
You're welcome. From your current code, delete the main method you wrote and press test and submit, it should work.
Oh okay thankss!
You don't write a main method here, just write alphabet_position method. Read this: https://docs.codewars.com/training/training-example
I'm using c++ in this question and I'm getting the error "conflicting types for 'main'" but I'm just using a single main function and the given alphabet_position function. The code is working fine on other platforms so what is the issue here?
There is no memory limit in this kata. Your solution has a bug.
I am using C++ and this Kata always exits with std::bad_alloc precisely after running the second test prompt with no problem. I feel like this has too little memory assigned, I can't conceive of a way to make my code any shorter. I am simply running one if else if per character in the given string with one extension on the resultant string each and then removing the last character after the for loop to get rid of the last space efficiently so I can just add it in the single extension command of the others. To get the alphabet number I am implicitly converting the chars to the decimal ASCII and subtracting from it to know what to append to the string. I know there exists one function where you can make a reference directory and just directly append by reference but I can't for the life of me find how to do that no matter what I google. This is really frustrating as I feel my solution is really not that bad and yet it is not enough. Do you need to be a C++ Genius to solve a 6Kyu Kata? This should at least be higher kyu for the little memory.
The Mods here are so wonderful!
no problem
welcome to the site
happy coding
Loading more items...