HTML and CSS Reference
In-Depth Information
The patern is a two-dimensional (2D) array. The irst dimension contains every patern.
Each patern is a list of the other paterns that do not overlay with it.
For example, the following A patern does not overlap with the C and D shapes. We represent
it with the ensuing equaion:
array['A'] = [ 'C', 'D'];
For a patern that always overlaps with the others, an empty array will be assigned.
Engage thrusters
In the following steps, we code the logic that allows us to compare two given
quest composiions:
1. In the composition.js file, we have the following class variable to represent the
relaionship of the overlapping paterns. It indicates the patern that overlaps with
other paterns. The index of the nonOverlappedPattern array is the patern ID,
and the corresponding array value is the list of paterns that do not overlap with
that patern:
// static variable. available as only one copy among all
composition instances.
Composition.nonOverlappedPattern = [
[], // pattern 0
[2], // pattern 1, doesn't overlap with pattern 2.
[1], // pattern 2, doesn't overlap with pattern 1.
[], // pattern 3
[], // pattern 4
[6], // pattern 5, doesn't overlap with pattern 6.
[5], // pattern 6, doesn't overlap with pattern 5.
2. We create the following new method in the Composition method that can turn a
composiion back to a one-dimension array:
Composition.prototype.toSequence = function() {
var seq = [];
for (var i=0; i <; i++) {
for (var j=0; j <[i].length; j++ ) {
return seq;
Search WWH ::

Custom Search