by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 14 22:38
    @bjorno43 banned @minitechtips_twitter
  • May 14 22:37
    @bjorno43 banned @real-action
  • Feb 01 00:26
    @bjorno43 banned @Ndoua
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • May 10 2019 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 27 2019 19:46
    @mstellaluna banned @zhonghuacx
  • Apr 25 2019 17:12
    @mstellaluna banned @cmal
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:11
    thecodingaviator labeled #31179
  • Apr 01 2019 18:09
    thecodingaviator commented #31179
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:09
    thecodingaviator labeled #31182
  • Apr 01 2019 18:07
    thecodingaviator commented #31182
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator labeled #31190
  • Apr 01 2019 18:07
    thecodingaviator commented #31190
  • Apr 01 2019 18:05
    thecodingaviator commented #31157
  • Apr 01 2019 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

Cristián Berríos
@crisberrios
let me check
Suzanne Atkinson
@AdventureBear
I'm not breaking up into n groups, I'm returning groups of n length
I was understanding the first. But I think the 2nd is what's wanted.
which addresses something you brought up, what to do with the remainder.
so I should be able to fill (n) spots of the first grouped array, then move to the next group, without needing to know how many groups there will be. Until I'm at the end of the first array.
like dealing cards in to a group of n people in a way. Round 1, round 2, oops, not enough for round 3...
I think i need a break!
Cristián Berríos
@crisberrios
I see what's the error
check how many groups are you doing for the failed test cases
Suzanne Atkinson
@AdventureBear
can you please tell me?
Cristián Berríos
@crisberrios
I thought it was checking only for whole groups, but you also need to return partial groups
Suzanne Atkinson
@AdventureBear
I run out of things to add in the failed test
right
Cristián Berríos
@crisberrios
and I told you to use Math.floor for the number of groups
Suzanne Atkinson
@AdventureBear
I'm going to go grab lunch, I think I need some calories. BRB
Cristián Berríos
@crisberrios
but...
Suzanne Atkinson
@AdventureBear
HAHAH
"told you so..."
Cristián Berríos
@crisberrios
it should be Math.ceil
since you want the upper number of possible groups
so if the division returns 1.5
you would want to have 2 groups
Sudeepto
@Sudeepto
@AdventureBear we need to split the array into a multidimensional array containing arrays of size size right ??
Cristián Berríos
@crisberrios
@Sudeepto did yo manage to make it 1 column?
Suzanne Atkinson
@AdventureBear
@Sudeepto yes I think that is correct. but there may be leftovers so either a) we don't know/care about how many there will be, just keep adding until we run out. or b) use @crisberrios suggestion for math.ciel to get the max number, knowing that the final one may not be filled
Sudeepto
@Sudeepto
@crisberrios Nope . I am fiddling with the css . :(
@AdventureBear my only doubt was whether it is provided or not whether size will be a multiple of len(arr) as the array element .
Cristián Berríos
@crisberrios
@Sudeepto nope, it might not be a multiple
Sudeepto
@Sudeepto
@AdventureBear Okay that means that the multi-dimensional array's last element ,can have less than size elements. Right ?? :)
Suzanne Atkinson
@AdventureBear
yes
yes, lat element less than size elements
Sudeepto
@Sudeepto
@AdventureBear I solved your problem :) Reply if you want help okay ??
Suzanne Atkinson
@AdventureBear
ooh yes pleeeeeze!!!
Sudeepto
@Sudeepto
can I give you the solution code ?? Or some hints ??
@AdventureBear Is it okay here to share solutions ??
Suzanne Atkinson
@AdventureBear
yes there is no restriction or code of conduct prohibiting. FCC is a self-guided learning resource and pairing is encouraged. that's my understanding
Sudeepto
@Sudeepto
 function chunk(arr, size) {
  // Break it up.
  var myArr = [] ;

  while( true )
  if (arr.length > size) {
    myArr.push(arr.splice(0, size)) ;
  }
  else {
    myArr.push(arr) ;
    break ;
  }
  return myArr ;
}

chunk(['a', 'b', 'c', 'd'], 2);
Suzanne Atkinson
@AdventureBear
whoa, splicing an array???
I never would have looked for that.
Sudeepto
@Sudeepto
the splice method dynamically reduces the array and returns the elements as an array itself.
Suzanne Atkinson
@AdventureBear
that must be the key to this challenge!
so once it's splice, push takes care of the rest?
Sudeepto
@Sudeepto
So ['a', 'b', 'c', 'd'].splice(0, 2 ) returns ['a', 'b']
After that ['a', 'b', 'c', 'd'] reduce down to [ 'c', 'd'] as I spliced it out and returned it
Suzanne Atkinson
@AdventureBear
so simple
Sudeepto
@Sudeepto
The first argument of splice is the index of element in the array that you want to start and the second argument is the index one less of which is desired
So for ['a', 'b', 'c', 'd'].splice(0, 2 ) first index is 0th index and 2nd index is 2 - 1th i.e. 1
@AdventureBear After that , we just simply push the spliced index into our result index
Nathan
@terakilobyte
I’d prefer you share hints
lead the person to self discovery