Ad
  • Custom User Avatar

    ah i see here:

    repeat
    public String repeat(int count)

    Returns a string whose value is the concatenation of this string repeated count times.
    If this string is empty ***or count is zero then the empty string is returned.

    i thought logically if the return is a concatonation of the string repeated 'count' times
    then "string" + nothing else would still make "string" but java says it returns empty string so thats right.
    seems counter-inuitive though but i guess java says if u dont repeat it any times it returns an empty string not that string once.
    obviously java.lang is right, but it seems like they might could use a conterversial new intern with some bright ideas (jk)

  • Custom User Avatar

    i browsed through a bunch, and im not saying all but many of the very beginer ones contain or are built on some kind of logic that seems incongruent with the excersise. Im getting back into computer science but used to solve problems here when i was in HS around 2015-2016 and remember a similar experience. Not trying to be negative but literally all of the first 3 that i solved since making an account and coming back on here had a similar logical issue, i thought it worth mentioning.

  • Custom User Avatar

    hey check out my solution for explanation. Some of the very basic katas are buggy and you have to debug what they are actually asking vs what they label it as asking and then write logical code for yourself that you conciously edit to pass the tests. I dont mind so far but i can see how some beginners would become infuriated here quickly with some of these katas because you have to know enough to spot the logical errors of whoever wrote it so its like a 2-part game

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    i did- in 4 mins- but had to read through the tests they made to relaize they didnt want repetion but just number of times printed which is actually a completely different problem than what they labeled it as.

  • Custom User Avatar

    the logic for the method is badly written. it should return it once at 0- if you repeat it 1 time, it should print the string teice, 2 repeats should print 3 etc. but this example show 6 printing 6 times- so this isnt even a program of repeating its a program that asks for the number of times to print and then prints it that number of times, which is different than printing it a minimum of one time and then the number specifies the number of repeats which intuitively should be seperate from the initial one (which by definition would not be a repeat) so stringRepeat(0, a) should return "a" not "". the idea of repetion seems to be a confusing topic for the creator of the problem and it is designed in a way that contradicts itself and has very buggy tests.

    it made this test:

    @Test public void test0kata() {
    assertEquals("", Solution.repeatStr(0, "kata")); }

    the tests and problem should assume the String value being passed is printed once- or else it didnt exist in order to be repeated and had no business being passed as an argument in the first place.

    testing for assertEquals("", Solution.repeatStr(0, "kata")); instead of testing for assertEquals("kata", Solution.repeatStr(0, "kata")); (I.E. a default base value of the String passed said/printed at least once doesnt actually check if it was repeated it checks if it was ever said which is different. To check if it was repeated you need the 0 value to return the string one time and assume the first iteration is when you pass it as an argument. That shows it being repeated 0 times. if it was repeated 0 times and also never printed one time, it doesnt exist so you dont need to test for the case of repeating something that is never being said once because then it by nature would obviously not be repeated and therfore never passed as an argument in the first place.

    since this is a repeater we should assume that the lowest number accepted, 0, should correlate to the least amount of times it could be said/printed in order to exist- which in this case is 1.

    long story short this problem doesnt test your program as a repeater- it tests it as a printer-

    -to repeat once has to have a base from which to repeat-
    -therfore the return of this method at 0 repetitions should be the passed string one time.
    -if you want your solution to work make sure the numbers correlate to number of prints not number of repetions

    if it is a printer then yes, 0 copies should have 0 value- but if it is a repeater, 0 should mean print only once without any repetition.