These are chat archives for Codewars/codewars.com/kata-solving-help

24th
Aug 2016
Hieu Nguyen
@hieung02
Aug 24 2016 00:08
Hi - I am stuck on one of my kata...the Objective of the Kata is to return 1 when parameter1 contains 3 of the same consecutive integer and parameter2 contains 2 of the same consecutive integer.
For example: tripledouble(451999277,41177722899) === return 1
tripledouble(10560002, 100) === return 1
tripledouble(1222345, 12345) === return 0
''''
please see below for my code:

function tripledouble(num1, num2) {
//code me
var num1Arr = String(num1).split("");
var num2Arr = String(num2).split("");
var check1 = num1Arr.some(function (ele1, i){
if(ele1 === num1Arr[i+1] && ele1 === num1Arr[i+2]){
return true;
}else {
return false;
}
});

var check2 = num2Arr.some(function(ele2, i){
if (ele2 === num2Arr[i+1]){
return true;
}else {
return false;
}
});

return check1 && check2? 1:0;

}

......
I don't see any issue with my code, but I keep getting a few errors on the final submit...not sure what I am doing wrong
any help would be appreciated it
Adam Recvlohe
@arecvlohe
Aug 24 2016 03:05
can you make the code a bit more readable
@hieung02
Hieu Nguyen
@hieung02
Aug 24 2016 03:06
yes
blob
blob
does that work?
when I copy and paste, it always shows up odd...
Adam Recvlohe
@arecvlohe
Aug 24 2016 04:04
use the back ticks ```
Like  this
Or this
Hieu Nguyen
@hieung02
Aug 24 2016 04:04
cool
Adam Recvlohe
@arecvlohe
Aug 24 2016 04:04
Either way, i’ll take a look at it tomorrow, have a good night
Hieu Nguyen
@hieung02
Aug 24 2016 04:05
thx good night
Adam Recvlohe
@arecvlohe
Aug 24 2016 04:05
or day?
Hieu Nguyen
@hieung02
Aug 24 2016 04:05
haha

'''
function tripledouble(num1, num2) {

var num1Arr = String(num1).split("");
var num2Arr = String(num2).split("");

var check1 = num1Arr.some(function (ele1, i){
if(ele1 === num1Arr[i+1] && ele1 === num1Arr[i+2]){
return true;
}else {
return false;
}
});

var check2 = num2Arr.some(function(ele2, i){
if (ele2 === num2Arr[i+1]){
return true;
}else {
return false;
}
});

return check1 && check2? 1:0;

}
...

'''

'''
function tripledouble(num1, num2) {

var num1Arr = String(num1).split("");
var num2Arr = String(num2).split("");

var check1 = num1Arr.some(function (ele1, i){
if(ele1 === num1Arr[i+1] && ele1 === num1Arr[i+2]){
return true;
}else {
return false;
}
});

var check2 = num2Arr.some(function(ele2, i){
if (ele2 === num2Arr[i+1]){
return true;
}else {
return false;
}
});

return check1 && check2? 1:0;

}
'''

'''function tripledouble(num1, num2) {

var num1Arr = String(num1).split("");
var num2Arr = String(num2).split("");

var check1 = num1Arr.some(function (ele1, i){
if(ele1 === num1Arr[i+1] && ele1 === num1Arr[i+2]){
return true;
}else {
return false;
}
});

var check2 = num2Arr.some(function(ele2, i){
if (ele2 === num2Arr[i+1]){
return true;
}else {
return false;
}
});

return check1 && check2? 1:0;

}'''

Hieu Nguyen
@hieung02
Aug 24 2016 04:11
'''javascript
Adam Recvlohe
@arecvlohe
Aug 24 2016 04:11
three ticks
Text
three ticks
Hieu Nguyen
@hieung02
Aug 24 2016 04:13
thank you
function tripledouble(num1, num2) {

  var num1Arr = String(num1).split("");
  var num2Arr = String(num2).split("");


  var check1 = num1Arr.some(function (ele1, i){
      if(ele1 === num1Arr[i+1] && ele1 === num1Arr[i+2]){
        return true;
      }else {
        return false;
      }
  });

  var check2 = num2Arr.some(function(ele2, i){
      if (ele2 === num2Arr[i+1]){
        return true;
      }else {
        return false;
      }
  });

  return check1 && check2? 1:0;

}
I was using the the apostrophe...instead of the backticks...thx again
Adam Recvlohe
@arecvlohe
Aug 24 2016 04:21
:+1:
Adam Recvlohe
@arecvlohe
Aug 24 2016 12:34
From what I read you have to cross reference both numbers
if there is a straight triple of a number at any place in num1 and also a straight double of the same number in num2.
Adam Recvlohe
@arecvlohe
Aug 24 2016 13:05
You are only checking that there is a triple repeat in the first array, not what that repeat is or what other possible repeats are
@hieung02 ^^^
Adam Recvlohe
@arecvlohe
Aug 24 2016 13:12
to then reference back to array two
That would be one way of solving it
Adam Recvlohe
@arecvlohe
Aug 24 2016 13:19
keywords are “same number"
Joan Dimko
@jdimko
Aug 24 2016 15:23
Using C#, how can I print out a variable value?
Adam Recvlohe
@arecvlohe
Aug 24 2016 15:49
Console.WriteLine
?
@jdimko
Hieu Nguyen
@hieung02
Aug 24 2016 19:42
thank you @arecvlohe
Adam Recvlohe
@arecvlohe
Aug 24 2016 19:58
Np @hieung02
Hieu Nguyen
@hieung02
Aug 24 2016 20:40
oh...I think I misunderstood the kata problem...I thought I just have to find 3 consecutive int for num1 and 2 consecutive int for num2...I was not aware that the repeated int in num1 and num2 has to be the same...thank you again for your help Adam @arecvlohe
Adam Recvlohe
@arecvlohe
Aug 24 2016 21:01
you’re welcome @hieung02
half the battle is understanding the problem
Hieu Nguyen
@hieung02
Aug 24 2016 21:02
yes, that's so true haha @arecvlohe
Adam Recvlohe
@arecvlohe
Aug 24 2016 21:06
that happens to me all the time, but then i just do console.log and see the output
sometimes the kata instructions are not as explicit and users can get lost in the description
instead of understanding the problem
Hieu Nguyen
@hieung02
Aug 24 2016 21:20
yes, I notice I spend a lot of time thinking if I should assume some conditions of the kata...but, now I just code...and see if the code passes the tests....not sure if that is the best approach... @arecvlohe
Adam Recvlohe
@arecvlohe
Aug 24 2016 21:23
somtimes you have to because the kata is a bit unclear
but sometimes the kata is clear and you have to take the time to understand the problem
Hieu Nguyen
@hieung02
Aug 24 2016 22:16
true true @arecvlohe