6 kyu
Build Tower
42,653 of 106,6048fdafs2
Loading description...
Strings
ASCII Art
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
Not a kata suggestion.
This comment has been hidden.
This comment has been hidden.
Basic tests pass, but random tests give me an error: java.lang.reflect.InvocationTargetException What could cause the problem?
easy
This comment has been hidden.
your comment is unreadable please check docs: https://docs.codewars.com/references/markdown#code-block
simplified version of the Diamond exercise, if you've come across that before
I managed to create the algorithm, however, it was very extensive. I passed the test, but I was not satisfied.
try this:
This comment has been hidden.
The description should have some mention of the spaces around the asterisks for each floor. While it can be inferred that there needs to be spaces to actually make it look like pyramid, if it's not mentioned in the description then it can easily be overlooked. I managed to solve this one, but I was extremely confused by why my code wasn't passing originally when each floor had the correct amount of asterisks. The description describes what a floor looks like with no spaces, implying that each floor should only have asterisks. It's not until after you check the test cases that you can notice it needs spaces. At least not for newer and learning programmers.
You can literally see the spaces in the examples in the description.
Fell for that as well.. refactoring..
This comment has been hidden.
in what language?
JavaScript
There might be a bug in the test code of this kata for javascript
No, there isn't.
Not a kata issue, the problem is in your code.
The error, that I am getting from the Test and Sumbit, is expected [] to deeply equal [ '*' ]
and of the test sample Test.assertDeepEquals(towerBuilder(1), ["*"])
It only towerBuilder(1) that ought to returns ["*"] Any passed parameter that less than 1 or " " will return []
What is _ expected [] to deeply equal [ '*' ] _ about?
My code statify all the description and sample tests
Apart from nFloors parameter that is less than one or empty string, what are the other conditions that will return [] that is, expected [] to deeply equal [ '*' ]
In that error message, your code is wrongly returning
[]
when it should be returning['*']
My code return
['*']
when the passed in nFloors is1
, anything less than one or NaN, it will return[]
So what is the condition or case, that will make
towerbuilder()
to return['*']
other than1
?No, but your code returns an empty array with that input and you can see that here: https://pythontutor.com/visualize.html#mode=edit
My code only return
[]
when the passed innFloors
is0
or" "
orNaN
When the passed in
nFloors
is1
, my code will return['*']
I have ran test on my code severally and it statified tthe descriptions and sample test on the page. I will like to pass my code to you to test, if possible
I've already tested it, and it doesn't return
['*']
for 1. Use Pythontutor to see what your code does, step by step. It doesn't enter in any of your loops and it returns an empty array.I wrote the code on my laptop, then copied it to the platform! I just refreshed the platform now and re-copied it, and everything went well. Thank you for the support, and sorry for the inconvenience
This comment has been hidden.
I must have missed that out, while I was typing the solution to the platform, after I have worked and tested the code with vim and vimspector
This comment has been hidden.
This comment has been hidden.
Tests don't seem to match instructions, tests have large random whitespaces around the tower whilst this wasn't on the aforementioned page. The instructions require you have a one char gap around the edges until you reach the bottom but they don't request massive gaps.
Please state the language you're talking about.
C# turns out you were supposed to have space around the asterisks, up until the last line, thanks anyway
pretty easy
yup
Nice!
Output on CW alters compared to output on VS. VS produces correct ouput but CW changes it entirely
No, it doesn't. In VS you call your function only once, unlike in the tests, where it's called several times in a row.
Why does this change the output?
Because previous values are stored in the tower argument.
Swift translation
.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/182.
Please join the discussion to help us identify duplicate kata and retire them.
expected:< *[ ],***>, but was:< *[],***> what is a problem with that
maybe you forgot to add '\n'
It is unclear but you need to return instead of printing to the console
i'm having the same problem now...
I have done all the floors correctly but the empty space thought.
This comment has been hidden.
I have done all the floors correctly but the empty space thought.
This comment has been hidden.
Thank you @benjaminzwhite about the Issue tage. Need to mention that the code I wrote len(x) == len(floor) -2 was not the code that give me the correct built as I write it and I am sure that I will git the error. And Bro you are 1kyu !!
Too challenging for a 6 kyu, should be corrected
This comment has been hidden.
Your latest code does not account for leading and trailing space-padding. You are on the right track and using the same technique in your iterative body shall do the trick.
It looks like it doesn't know the function replaceAll() for JavaScript...
I made my pyramid look like the example code, with brackets, but I am still not getting a deep equal.
Instructions should contain the requirements of the task, like, for example, stating that your characters must be inserted into an array.
It's already in the description, and you can see that in the sample tests too.
Either way, added it in the text.
Can see it, if it were inferred, but inferrence from reading code is not in the description of the task either. Just seemed like the kind of problem a 1kyu might see as trivial, but a near-complete newcomer could absolutely trip over; This is expected to be done by users ranked at only 7 kyu, after all. Thanks for editing so the noobs can focus on practicing their code rather than practicing interpreting an instruction with multiple potential interpretations.
This comment has been hidden.
If you look closely at the examples in the description you can see that the strings, enclosed between
"
are all of the same length on each level of the tower. That means that you have to fill each line with spaces to center the asterisks.This comment has been hidden.
convert what type ? it's obvious from the description that you have to return an Array of Strings, but you are returning a String
It doesn't mention the word 'array' ANYWHERE in the description, so no, it is not clear. The information may be there, but if it were obvious then I would not have had this issue...
"A tower block is represented with " * " character." implies that the tower is constructed with characters, not an array of strings constructed from characters. Only upon closer examination of the expected output do we see our first inference of an array being involved.
what does it look like, if not a strings array ?
"Only upon closer examination of the expected output do we see our first inference of an array being involved."
What do those words mean?
I was not instructed to create an array, I was expected to infer that an array must be created despite what the instructions told me to do. Inference is not obvious.
I can make a string that looks like that. All those characters in the same order. That would be, TO THE WORD following the instructions and it would provide a negative result.
The instructions are not clear. This issue is not resolved.
This comment has been hidden.
Now it says:
This one had me going for a while. Very fun!
This comment has been hidden.
You must return your array, just
return arr;
. I don't do much Java butreturn new arr[0];
is probably invalid (new
is used to declare a new object). I've tried your code,return arr
works (it doesn't throw an error), but it seems your array doesn't contain the correct strings. You must be missing something. You must return an array of strings, not a string; don't include line-feeds, that may be the problem.Thanks alot! Its resolved
exaaactlyyyy😡
This comment has been hidden.
Instead of printing it, insert each line into an array and return that.
Factor Translation
Approved
Random tests in Rust generate zeros.
Fixed
D translation
approved
This comment has been hidden.
This comment has been hidden.
['*', ]
in Python sample tests:You don't suggest anything.
Java random test throws java.lang.reflect.InvocationTargetException basic test works, and everything works in compiler
I am having the same issue. Did you manage to find the solution for this by any chance?
My error was the same and was solved by eliminating the use of the method substring
I was solved by checking nFloors by zero.
(author is inactive)
approv2d
C translation (author gone)
Approved :)
It was told, that nFloors is positive integer, but there was zero in one of tests. Very bad (((
in Java ?
NASM Translation: https://www.codewars.com/kumite/6295294f033da70064b88b14?sel=6295294f033da70064b88b14
NASM Translation: https://www.codewars.com/kumite/6295294f033da70064b88b14?sel=6295294f033da70064b88b14 Please accept.
I'd expect to see the method name in camel-case
towerBuilder(int f)
for Java.The problem with changing the function name is that it would invalidate all of the current solutions.
I don't know in Java but in some languages it's possible to use aliases or other workarounds to do it.
I recently managed to create a method such as this for C# ... so, challenge accepted!
I guess we can check both "TowerBuilder" and "towerBuilder" method names through reflection and call one of them. It should keep existing solutions valid with the ability to write new code in a proper naming. The sample code also needs to be updated to enforce best practices.
Should be fixed now.
ok, that one had me thinking, well done=)
This comment has been hidden.
If you struggle with this kata, you can watch 3 and 39 video in Amulya's Academy youtube channel -> playlist: Python Pattern Printing Programs Video Tutorial.
C++: Attempt tests throw warnings (see message below).
Fixed.
In file included from main.cpp:7: ./tests.cpp:45:33: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare] for(size_t i = 1; i <= nFloors; i++)
Is this an error on my part? I am assuming maybe this is something that is verifying the integrity of what i've returned in tests.cpp so I am unsure.
I've passed the initial testing suite but the attempt submission exits with this.
No, it comes from the tests. Reraised as an issue.
This comment has been hidden.
I had to add this fuzz to make it compile.
Check if it works now.
ok
The examples have the char ' at the beginning and ending of the pyramid, while the solution requires the output to be a pyramid without the them, please fix it.
If you're talking about the kata's description it is shared amongst all languages, in some of them you can use
'
or"
for strings. Please state the language you're talking about, is it C#? See thisTraceback (most recent call last): File "main.py", line 2, in import codewars_test as test ModuleNotFoundError: No module named 'codewars_test'
Something must be wrong with the kata because I got the error above
Make sure you select the latest Python version
3.8
in the trainer (at the top of the page), save your code locally (or you will lose it), and click on reset at the bottom of the page. That should fix the issue.This comment has been hidden.
Look at the format of the input in
sample tests
(at the bottom right of the page). If you don't know to use arrays in your language, you need to search for its documentation.OP solved it, closing
This comment has been hidden.
Очень интересно, но ничего непонятно.
Direct duplicate of this kata. Raised here since this kata is newer, although maybe this version is worth keeping since it has more languages.
It's slightly different and it feels like the other one is harder because of execution-time constraint.
Retired!
Egyptians should love this one
You shouldn't write nested loops because it increases Big O notation(from O(n) to O(n*n)).
This comment has been hidden.
C# ? Did you tried PadLeft and PadRight?
nope its python... idk c#, in any case are those functions in c#?
This comment has been hidden.
expected 1 to deeply equal [ '*' ] what does it mean i have wrote it bt doesnt work
Your code returned
1
instead of[ '*' ]
Please say which language you're using when posting in discourse, since tests may depend on it (moreover in this kata the format of the result is also different in some of them). A priori it means that you return something like 1 where tests expect ['*']...
javascript also i entered ['*'] and the other but it didint work
So, your code returns 1; where it should return an array (see the description and the test cases).
already did check but i puted an intiger of 3 floors ?????
This kata has no problem in Javascript; your code does not do what is expected, what more could we do for you? Maybe this can help: Troubleshooting Your Solution.
I've solved the question. I'm making the pyramids to the exact specifications. But somehow it does not want me to pad the asterisks with spacings. And when I remove the spaces, it wants me to pad it. How can this be?
Im coding with c#.
This kata has been solved more than 44000 times, more than 3900 times in C#. This is not a kata issue but a problem with your code. You must be missing something. You can ask for help or ask a question but don't post an issue for that (and add a spoiler flag if you give elements of solution). Maybe this can help: Troubleshooting Your Solution.
This comment has been hidden.
use "\t" certainly not, one can see in test cases these are spaces.
I did not solve this kata in C# and I'm quite bad in this language, however if I run your code on basic tests, I get this:
Expected: "*" But was: " *"
You see there's one extra space in your result. Check your code...
Thank you for your "heads up".
No problem, glad you solved it eventually ;)
expected [ '', '', '***' ] to deeply equal [ '*' ] what i did that
Hey! are there examples?
There are, but I believe due to size of the description, they do not show on main page.
It took me a bit to notice you can scroll down kata descriptions - so I suggest just that!
However one of the examples given was... (note the Whitespaces, Python)
This comment has been hidden.
You should describe, in words, how many astrisks there should be per floor instead of relying on examples.
That's part of the challenge! Can you recognize the pattern at play?
Test was not completed due to buffer error
Are you using print() as a debugging tool?
If so, consult: https://docs.codewars.com/training/troubleshooting/#maxbuffer
It should answer all your issues!
This comment has been hidden.
This comment has been hidden.
Tests in PHP are ok.
Coffeescript
Crystal
Julia
(author inactive)
I approved, thanks, but I've just realized there's a mistake in the function name in Crystal: should be "tower_builder" to match with tests. Can you change it?
fixed, thanks for approving and catching the minor issues
I was getting error: 'None should equal ...' (my answer looked the same as theirs)
I changed my print() to return and it worked.
This is fine, the point of the function is to return the array of strings (or whatever you did for your language), not to print it out to the screen.
I don't understand the challenge... you pass a number representing floors and ?
And then you keep reading the description and see the examples about how to build the tower. In javascript it's an array of strings.
i sugest you should be patient and do 8 or 7 kyu kata, no need to rush bro
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Hello, please don't post solutions in kata's Discourse. There is a Solutions section for that matter, and even there, mark your post as having spoiler content when they do.
Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
okay sorry i am really newbie
No problem.
This comment has been hidden.
I found the problem finally. It didnt allow me '\xa0' to use as space. So I just made a normal empty string like this ' '.
How did you end up picking
'\xa0'
over a regular space? ('\x20'
)o_O
This comment has been hidden.
That's not possible (after high completion) and not optimal to allow two sort of solutions to pass the kata
How tall can you build a tower before it topples?
Surprisingly challenging for a 6 kyu! Very fun, learned something new.
This comment has been hidden.
This comment has been hidden.
I spent an entire day trying to figure this kata out just because I failed to notice that the number of asterisks on each line was odd.
I feel you man! You're not alone. Can't believe I misread the instruction all this time.
its kinda complex for me
Great Kata!
This comment has been hidden.
Not an issue. Your solution is wrong.
Elixir translation
Updated fork: https://www.codewars.com/kumite/5f10d7f485ada6001941aed9?sel=5f11098baeb2c7002e9430f0
Speed improvement; now completes in < 1/3 the time.
We did the same exercise before Christmas holidays, we built a Christmas tree. Good old times before corona.... :/
may be mistake in first basic test, watch out
Max Buffer Size Reached (1.5 MiB)
in Python
when trying to Attempt
Things to check:
Not a kata issue, you print to console too much, probably instead of returning the answer.
this question sucks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Damn!!!!!!!!!!!!
Thank you for your feedback, constructive opinion, and suggestions how to improve the kata.
im getting write output in other compiler why this compiler not accepting my correct solution
See here.
This comment has been hidden.
OP solved it, closing
Hey there, I'm coding with Javascript, tested it on local and it's running fine, but when pasted in Codewars it returns undefined, is someone having the same issue? a little help would be appreaciated
You're not returning anything.
It's returning 'undefined' but it should be returning what's displayed in log
Are you returning the same thing you're printing? Your function should have a
return
line.YEs finally got through it, thank you!
I cant for the life of me figure out the spacing, got the right amount fo stars (C++),can someone help with the spacing
each string has an equal number of spaces on each side. the last string has none.
does this happen with anybody else that all my tests have passed but the screen just isnt accepting after i click my attempt button. all my results for test are greenlit but it wont let me pass. this has happened twice now and is very frustrating when i have to skip the kata even though i have completed it.
Hi @akshat1010, there are preliminary tests known as 'Sample Tests' or 'Example Tests'. But that's not all you need to pass the kata. There are additional fixed tests when you click ATTEMPT, along with even more random tests.
i understand that but even though it doesnt show any error when i click attempt, my screen just doesnt get passed after it.
i get the concept. . number of '' in each level == (2n - 1). so i created seperate variable for each let space = " "; let astrise = ""
but don't know how to build Tower.
I've implemented my solution with Python and the function returns a list which has passed all tests, however, each "floor" of the tower is displayed in the same line when I run this function.
How can I adjust the code so that each floor (list item) gets displayed in a separate line, while still returning a function (rather than turning a list into a string consisting of line items)?
Python won't display a single output on seperate lines unless a string spefically contains a line break, you can't tell seperate array elements to display on seperate lines in a single return.
To get the function to return the tower with the breaks already included, you will have to turn it in to a string.
Otherwise when calling the function you will need to do something along the lines of this, to make each floor display on its own line.
even when my python code passes all 48 tests, im getting a "Exit Code: 137 - Max Buffer Size Reached (1.5 MiB)" message
There are 100 tests in Python, are you printing too much to the console? If so, try removing the prints.
You're right, i removed my prints and issue was resolved
thank you
my code can calculate the number of asterisk (increment by 2odd number per level, see below result) but it still throwing an error because of the wrong spacing. Any tips?
['', '', '', '', '*****']
It makes me uncomfortable that this is 'build a tower', and not a pyramid
This comment has been hidden.
Use as a parameter for center not 0, but the length of the string you need inlcuding whitespaces
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
This comment has been hidden.
return
? (note: I don't do C++, but...)OP solved it, closing
This comment has been hidden.
You may edit the description to fit to the selected language. I was confused by the ' ' in the examples because I thought that means the tower should have walls consisting of '
You can use the markdown language for it: https://www.codewars.com/docs/kata-creator
example for c# + python: ```csharp
``` ```python
```
This will lead to merge conflicts in adding new languages, so it's best to leave it as it is as one can view the sample tests for the language-specific output
Approved some pending translations and changed single quotes for double quotes (if some language uses both for strings the safe bet is using double quotes I think).
This comment has been hidden.
Hi,
Seems you're "rather new" to cw, so here are some general guidelines about the comments:
Issue
: problem in the kata itself (description, wrong tests, wrong internal solution...)Suggestions
: well, I guess that part is clearQuestion
anything else that is related to you having a problem solving a kata -> that's you, currently.When you post issues:
When you post a question: well, most of the above apply too x)
When you post code, use proper github markdown, so that it's readable.
And for your current problem, I don't do JS but... Are you sure you're actually returning something?
cheers
This comment has been hidden.
You have to return the recursive call too for it to work. Your code has another problem, don't use global vars, they keep their values between tests.
This comment has been hidden.
Mark your post as having spoiler content next time, your function should return, not send the output to the console.
Hi Chrono! Thanks a lot for your reply and apologies about that!
This comment has been hidden.
Use markdown formatting when pasting code here, but you can see there is a difference with spaces in those strings.
c++ translation base code contains an error: return std::vectorstd:::string(); --> return std::vectorstd::string();
fixed
This comment has been hidden.
ask yourself: why the assertion message is saying that
None should equal ...
? From where does thatNone
come? Why you function is "returning" that?'looks lie u solved it'
Expected: '[" ",""]', instead got: '[" * ","***"]' is an error that I belive is with the tests itself. It is supposed to generate towers with *, although the blanket test says otherwise.
don't mutate the input (do NEVER do that...)
This comment has been hidden.
Please don't raise questions about why your code doesn't work as issues ;-)
Also, you should mark code as spoilers.
Please don't use
\xa0
for blanks. Just a whitespace is fine ;-)This comment has been hidden.
You have to return an array of strings, you're returning a string there.
HI, Thanks for great kata. But, i can't run my kata, i got error: "The server timed out waiting for the request to be processed. This may be due to high server load. Please try your request again."
Apparently it's not something in my code but rather something to do with the "issue processing the web request".
Not an issue
And what is it? I can't attempt it too with the same problem, but still can run sample tests and pass them.
This comment has been hidden.
You can change " " with " " :)
Not an issue
I am being thrown a type error for using padStart.
TypeError: tower[j].padStart is not a function at towerBuilder at Object.handleError at ContextifyScript.Script.runInThisContext at Object.runInThisContext
My code works in Repl.it.
padStart is not supported in Node v6
Not an issue. Check language version ;-)
It wouldnt compile on python, it's giving me the following error:
"The server timed out waiting for the request to be processed. This may be due to high server load. Please try your request again."
Apparently it's not something in my code but rather something to do with the "issue processing the web request".
Not an issue
Passsed it. However, the instructions are not clear that the space padding for each floor is decreasing. Deciphering missing instructions should not be part of the coding challenge.
I passed the three sample tests but when I go to attempt I get this error: "Unexpected token { in JSON at position 1394669". Is this something I did or a bug?
In javascript version of the test, the expected is not what desribed. The last element seems not correct.
The blanket tests have the actual and expected in the reverse order. So what is expected is the actual, and the actual is the expected.
Looks like a bug to me
Probably not solvable at the moment, but now that real tests are editable again, fixed.
This comment has been hidden.
Why are you using
"\xa0"
instead of" "
? Not a kata issue.I have a solution, it passes the tests and there are no errors on the output, but for some reason I can not publish my decision. What is the problem?
Currently Codewars platform is experiencing issues.
https://github.com/Codewars/codewars.com/issues/893
Man, this kata in C# made me realize how inconsistent PadRight and PadLeft are. Reeeeeeeeeeeeeeeeeeeeee.
This comment has been hidden.
howMany has the possibility of being a decimal number due to your math. Be sure to properly convert it to an integral value!
This comment has been hidden.
The part that is taking the processor time is the
var len=1+Math.pow(2,(nFloors-1))
. This is since the input can be up to 100, meaning it will have to calculate 2100 a bunch of times.You can refactor this to a simplier formula. Try to work this out and change the formula up. If you can't, just comment and I'll just tell you.
Thank you AcesOfGlory, I just want to make sure my logic is correct, I will try to do it.
Again, thank you for your comment.
When trying to code this in c++, the system is not allowing me to use the fill constructor for strings. It says 'no matching constructor for initialization of 'std::string''. Could be v.14 doesn't allow this anymore, but documentation I've found doesn't indicate any changes.
Hi! Put character into single quotation marks, like this '*'. Then compiler will count it as single char. Double quotation marks, like this "*", means that you have a C-string char* containing 1 symbol.
I've just passed the C++ kata, not an issue
As @Andrey mentions there is an error with some test-cases having trailing white-spaces.
Here is what I got in one of my failed tests:
Expected: ' [ " * " ," *** ", "***** ", "****** " ]' , instead got: '[ " * ", " *** ", " ***** ", "*******" ]'
the kata wants space each floor too. for example if your tower's last floor has 6 star, than your first floor need to have 1 star and 5 spaces. your second floor needs to have 2 stars 4 spaces, your third floor needs to have 3 stars 3 spaces and goes on. you must add spaces too. i know, it is silly but kata's tests want it.
This comment has been hidden.
You're meant to return the answer as a single value and that value is each subsequent string contained in a list. You are just printing each subsequent string back to the console. Append each string to a list and return the list instead.
This comment has been hidden.
Unclear issue, closing
That's a detail, but there is typo in C++ solution example "return std::vectorstd:::string();". It should be "::" instead of "::::".
C-Translation kumited.
merge conflict + translator gone, forked
This comment has been hidden.
Not an issue
I have my kata completed and tested but something is wrong with the codewars test: I got this for fn(2) and fn(3) Expected: '[" * ",""]' instead got: '[" * ",""]'
Expected: '[" * "," *** ",""]', instead got: '[" * "," *** ",""]'
Obvioulsly there's a space missing in the expected fn(3) answer. fn(2) is exactly the same and still fails. Any clues?
Default C++ code is not compilable (one extra ':' is present). This is not an actual issue, but it feels wrong to have a compilation error in the default code.
fixed
Hello I need some please My Test code is below
This comment has been hidden.
Can someone please help me out on why I keep failing this Kata My Code Snippets are below
Please I need some help with this propblem . My code is in the comments below .
This comment has been hidden.
In the test cases, several of the results look to be missing spaces towards the bottom teirs of the tower (see the last two indexes in the Expected array below). Wouldn't the second to last (index 3 in the below example) still have one space on each end?
Expected: '[" * "," *** "," ***** ","",""]', instead got: '[" * "," *** "," ***** "," ******* ","*******"]'
Edit: It looks like the comment strips out some of the extra spaces/padding in the array indexes, but either way, the second to last in the expected doesn't have any space paddings on either side as it looks like it should.
The example tests already provided a clear illustration of the output
When executing default Python solution (what is printed when first training), I get:
File "", line 8 test.describe("Tests") ^ IndentationError: expected an indented block
This is true for both Python 2 and 3 versions.
You did not indent your code properly.
Awesome! Thanks for a nice Kata. I'm new here, learning python. So I posted a working answer, should i wait until it's approved? Because it seems after posting I still cannot view others solutions.
Only translations need approval. You need to
submit
your solution once it's passed all test cases. I cannot find your solution in theSolutions
so I guess you haven't submitted it yet.PHP Translation Kumited - please accept :D
Sorry for this late reply. Many thanks for your PHP version :) Approved.
C++-Translation kumited.
Please check it and approve. Thanks! ;)
This is the message I got when I was trying to approve your version:
Description cannot be approved, recent changes from related record must be merged first.
Is there anything I need to do? Thanks for your contribution and Sorry for my late reply.Hi
8fdafs2
,i make the new fork of my translation. Try to approve it again. Thank a lot! ;)
Approved! Thanks.
C#-Translation kumited!
https://www.codewars.com/kumite/57e53bb07fbcc94dd500039c
Please check and approve it! :-)
Looks great. Thank you! I notice that in the random test section:
It's your kata and your decision.
But my version is really random. Your version is a sequence. If someone knows that, he could let his solution exact return the expected values without an algorithm that solves the problem. In my version this isn't possible.
But it is you decision, if you like I change the translation the way you like it.
This comment has been hidden.
Done!
Better and easier would be to take the array with numbers from 0 to 99. And then shuffling this array.
But it's also ok this way. And it is your kata. :-) I am only the supporter/contributor. :-)
Approved! I suppose you could change the translation the way you want as long as it makes sense... This kata is open to any good ideas... Thank you.
But now, there is the problem, that n could be 0. In the description you wrote, that that would never be happen. Maybe we should change "var j = rand.Next(0, r + 1);" into "var j = rand.Next(1, r + 2);" ?
I changed it right now. Now it is correct. Every number from 1 to 100 is exactly used once. In random order. (Your code has the problem, that sometime parts of the array are not set and so they would be 0, what is forbidden by your description.)
Now, all should be correct and fine. :-)
Thank you! Yes, your approach will do the right job. However my implementation of the "inside-out" algorithm is correct. The line I made wrong is inside the 2nd loop:
The instructions don't match the test cases, and the test cases themselves are inconsistent. The in the expected output it adds two stars so each count is odd, but in the description it increases by one (odd, even, odd...). The spacing on the outside of the values is inconsistent in the test cases.
In the description the star increases by two hence every floor will have an odd number of stars. Just confused about the 'inconsistent' part... No such issue have been reported so far so How about you read the description again and try one more time?
This comment has been hidden.
I am getting a little confused here ;-) What would you mean by 'new lines'?
This comment has been hidden.
It's only one of the coding conventions that I am using when the element is too 'long' or in this case it's also for a better visual presentation of the 'tower'.
suggestion marked resolved
Nice Kata but a bit more description would have been helpful or at least one more tower would have saved time understanding it easily. Otherwise, I loved it! thank you.
Thank you! Description updated, please check. :>
There is a bit confusing typo in Python Basic Tests:
test.assert_equals(tower_builder(1), ['*', ])
instead of:test.assert_equals(tower_builder(1), ['*'])
. Nevertheless, it works :)Trailing Comma: For single-element tuple, it's mandatory; for multi-element tuple, it's optional. For list/dict/args, adding trailing comma is a matter of style... and I think it's encouraged to do so.
Honestly, I have not even thought that it was done on purpose, since it's the first time I encountered such a syntax in lists (I know about tuples). Thanks for the info, after studying the issue came to the conclusion that it really makes sense.
suggestion marked resolved
The tests dont insist that each floor is printed on a different line , if that is what was inteneded
You can definitely print the 'Tower' out for debug purpose. But please return the list at the end of your function so as to be validated by test cases. :)
I guess it is necessary for the test functions, would be good if you could insist on use of '\n' somewhere!
If the target return value was chosen to be a string instead of a list then use of '\n' would be a must :)
I think it's a duplicate but I can't find the original kata.
I don't know that. Once you find it please leave a message. TIA :-)