Ad
  • Custom User Avatar

    Same with JavaScript

  • Custom User Avatar

    Because sort isn't stable in all of them.

  • Custom User Avatar

    Possibly yeah :/ I am just not sure why it spits out different results on different platforms

  • Default User Avatar

    Maybe you have the answer...

    First, it's a question not an issue of the kata (notice that 7505 people passed the JS kata; if there were problems somebody else would already said!). Second, the answer is: your code is wrong:-) I strongly doubt that it gives correct answers for all tests on another platform...

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Yes, printing the input, in javascript, use console.log()

  • Custom User Avatar

    i honestly dont know why but i have corrected it. I just want to see the test that I failed so i can go over why they failed, is there any way to do that?

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    anyway to get a pass for this code ^^

  • Custom User Avatar
    // Writing nessecary functions for later
    let isPower = (n) => { 
      if (n===1) {  
        return true; 
      }
      for (let x=2; x<=Math.sqrt(n); x++) { 
        let y = 2;
        let p = Math.pow(x, y);
        while (p<=n && p > 0) {
          if (p===n) {
            return true
          } else {
            y++;
            p = Math.pow(x, y);
          }
        }
    
      } 
      return false; 
    } 
    let pFac = (x,i,r) => {
      r=[];for(;x>=2;){for(i=2;x%i;++i);r.push(i);x/=i}return r}
    // end of prerequisite functions
    
    // Real stuff 
    let slayAchilles = (army) => {
      
      let powArmy = army.filter(y => {
      if (isPower(y) === true) {
        return true
      }
      let powers = pFac(y).reduce((end, num) => {
        if (num in end) {
        end[num]++;
        } else {
        end[num] = 1;
        }
        return end
      }, {})
        let vArr = Object.values(powers)
        if (vArr.length >= 2 && !vArr.includes(1)) {
          return false
        }
        return true
        })
    
      return powArmy
    }
    

    Yeah i figured a bit of it out and i think this code works its just that it exits the code on the 36th test. My code needs to be optimized apparently but i have no idea how lol.

  • Default User Avatar

    Rather than post that much code and expect someone to explain why it doesn't work, can you give more info?

    Does it work at all, if not what errors do you see in the console?

    If it works but only for some cases, which cases does it fail on? Can you provide a test case which your code does not pass?

    Giving a bit more info will likely get you a more helpful response.

  • Custom User Avatar

    sorry, now it is formatted properly

  • Custom User Avatar

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

  • Loading more items...