8000 GitHub - erana111/F5
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

erana111/F5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iterator

Function: iterator([arg1[, arg2[, ...]]]) Arguments: arg1, arg2, ... Each argument can be either an array or another iterator.

This function returns an iterator object which provides two methods: next() and hasNext(). Each successive call to the iterator's next() method should return the next element in an iteration of the logical list of elements which would be the result of concatenating each element of the collections passed as arguments to the constructor of this iterator. Note that this list is never actually generated by the underlying implementation. As its name implies, the hasNext() method should return true whenever a successive call to the next() would return a value which is not undefined.

Example: The following should produce the output "123456789ABCDEF".

  var iter1 = iterator(["4", "5", "6"]);
  var iter2 = iterator(["A", "B", "C"]);
  var iter3 = iterator(iter2, ["D", "E", "F"]);
  var iter4 = iterator(["1", "2", "3"], iter1, ["7", "8", "9"], iter3);

  var output = "";
  while (iter4.hasNext()) {
      output += iter4.next();
  }
  console.log(output);

BNB

Consider the following problem:
    There are m distinct buckets and n identical balls and each bucket can contain 0 or more balls.
    All balls are arranged into the buckets, and there several combinations to arrange them.
    For example, if there are 2 buckets and 3 balls, we can have the following arrangement:
    
           bucket 1  |  bucket 2 
           ---------------------
               3     |     0
               2     |     1
               1     |     2
               0     |     3

    Another example, where m=3 and n=3:
   
           bucket 1  |  bucket 2  |  bucket 3
           ----------------------------------
               3     |     0      |     0
               2     |     1      |     0
               2     |     0      |     1
               1     |     2      |     0
               1     |     1      |     1
               1     |     0      |     2
               0     |     3      |     0
               0     |     2      |     1
               0     |     1      |     2
               0     |     0      |     3

Write a function that receives m (number of buckets) and n (number of balls) as arguments and prints out 
all of the possible balls-in-buckets permutations. Please note that each permutation must be printed 
out once. 

** Helper function/s are allowed and are encouraged.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0