Skip to content

czanella/magic-square-34

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

magic-square-34

This repository holds the files for the Albrech Dürer's Magic Square website.

Probably the most interesting and reusable part of the code is the CombinationIterator class (js/CombinationIterator.js). It generates all ordered subsets from a set of n integers. For instance, the following code...

var iterator = new CombinationIterator(6, 4);
while (iterator.hasNext()) {
    console.log(iterator.getNext());
}

... outputs all subsets of 4 elements from the set [0, 1, 2, 3, 4, 5]:

[0, 1, 2, 3]
[0, 1, 2, 4]
[0, 1, 2, 5]
[0, 1, 3, 4]
[0, 1, 3, 5]
[0, 1, 4, 5]
[0, 2, 3, 4]
[0, 2, 3, 5]
[0, 2, 4, 5]
[0, 3, 4, 5]
[1, 2, 3, 4]
[1, 2, 3, 5]
[1, 2, 4, 5]
[1, 3, 4, 5]
[2, 3, 4, 5] 

The input parameters must both be larger than 0, and the first parameter can't be smaller than the second, otherwise an exception is thrown.

License

MIT © Carlos Zanella

About

A homage to Albrecht Dürer's magic square

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published