diff --git a/.codacy.yml b/.codacy.yml deleted file mode 100644 index 0672c33..0000000 --- a/.codacy.yml +++ /dev/null @@ -1,7 +0,0 @@ -languages: - JavaScript: true -exclude_paths: -- "js/dist/*.js" -- "js/dist/**/*.js" -- "test/*.js" -- "test/**/*.js" diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 0672c33..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,7 +0,0 @@ -languages: - JavaScript: true -exclude_paths: -- "js/dist/*.js" -- "js/dist/**/*.js" -- "test/*.js" -- "test/**/*.js" diff --git a/.groc.json b/.groc.json deleted file mode 100644 index 56e8333..0000000 --- a/.groc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "glob": [ - "js/src/**/*.js", - "README.md" - ], - "github": true -} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index ffd48eb..0000000 --- a/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "esnext": true -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9a0746b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: node_js -node_js: - - "iojs" - - "0.12" - - "0.11" - - "0.10" -install: - - npm -d install -script: - - npm test -after_success: - - ./node_modules/.bin/coveralls < coverage/lcov.info || true - - ./node_modules/.bin/codeclimate < coverage/lcov.info || true diff --git a/3sum/_3sum_n2.html b/3sum/_3sum_n2.html new file mode 100644 index 0000000..92d1bd5 --- /dev/null +++ b/3sum/_3sum_n2.html @@ -0,0 +1,32 @@ +3sum/_3sum_n2
js/src/3sum/_3sum_n2.js

Hypothesis :

+
    +
  • A is sorted in increasing order
  • +
  • B is sorted in increasing order
  • +
  • |A| > 0
  • +
  • |B| > 0
  • +
var _3sum_n2 = function (A, ai, aj, B, bi, bj, C, ci, cj, fn) { + + var hi, lo, a, b, c, v; + + for (; ci < cj; ++ci) { + lo = ai; + hi = bj - 1; + + do { + + a = A[lo]; + b = B[hi]; + c = C[ci]; + v = a + b; + + if (-c === v) fn(a, b, c); + + if (-c < v) --hi; + else ++lo; + + } while (lo < aj && hi >= bi); + } + +}; + +exports._3sum_n2 = _3sum_n2;
\ No newline at end of file diff --git a/4sum/sortxy_n3.html b/4sum/sortxy_n3.html new file mode 100644 index 0000000..b83ee9b --- /dev/null +++ b/4sum/sortxy_n3.html @@ -0,0 +1,48 @@ +4sum/sortxy_n3
js/src/4sum/sortxy_n3.js

X is sorted in increasing order +Y is sorted in increasing order +compare takes 4 arguments and returns <=> 0 +output takes 4 arguments

var sortxy_n3 = function ( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) { + + var a , b , c , d , s ; + + if ( Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2 ) { + return ; + }

+

| X |

+

Xi Xj


+

| Y |

+

Yi Yj

a = X[Xi1] ; + b = Y[Yj1] ; + c = X[Xj2] ; + d = Y[Yi2] ; + + s = compare( a , b , c , d ) ; + + if ( s === 0 ) { + + output( Xi1 , Yj1 , Xj2 , Yi2 ) ; + + sortxy_n3( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yi1 , Yj1 - 1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yj1 , Yj1 , Xi2 , Xj2 - 1 , Yi2 , Yj2 , output ) ; + + } + + else if ( s < 0 ) { + + sortxy_n3( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yi1 , Yj1 , Xi2 , Xj2 - 1 , Yi2 , Yj2 , output ) ; + + } + + else { + + sortxy_n3( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 - 1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n3( compare , X , Y , Xi1 , Xj1 , Yj1 , Yj1 , Xi2 , Xj2 , Yi2 + 1 , Yj2 , output ) ; + + } + + +} ; + +exports.sortxy_n3 = sortxy_n3 ;
\ No newline at end of file diff --git a/4sum/sortxy_n4.html b/4sum/sortxy_n4.html new file mode 100644 index 0000000..27b8ad8 --- /dev/null +++ b/4sum/sortxy_n4.html @@ -0,0 +1,34 @@ +4sum/sortxy_n4
js/src/4sum/sortxy_n4.js

X is sorted in increasing order +Y is sorted in increasing order +compare takes 4 arguments and returns <=> 0 +output takes 4 arguments

var sortxy_n4 = function ( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) { + + var a , b , c , d , s ; + + if ( Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2 ) { + return ; + }

+

| X |

+

Xi Xj


+

| Y |

+

Yi Yj

a = X[Xi1] ; + b = Y[Yi1] ; + c = X[Xi2] ; + d = Y[Yi2] ; + + s = compare( a , b , c , d ) ; + + if ( s === 0 ) { + + output( Xi1 , Yi1 , Xi2 , Yi2 ) ; + + } + + sortxy_n4( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 + 1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 , Yi1 , Xi2 + 1 , Xj2 , Yi2 , Yj2 , output ) ; + sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 , Yi1 , Xi2 , Xi2 , Yi2 + 1 , Yj2 , output ) ; + +} ; + +exports.sortxy_n4 = sortxy_n4 ;
\ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 58777e3..0000000 --- a/LICENSE +++ /dev/null @@ -1,661 +0,0 @@ -GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. diff --git a/README.md b/README.md deleted file mode 100644 index 978ff39..0000000 --- a/README.md +++ /dev/null @@ -1,155 +0,0 @@ -:rocket: [Algorithms](https://github.com/make-github-pseudonymous-again/js-algorithms#readme) -[![License](https://img.shields.io/github/license/make-github-pseudonymous-again/js-algorithms.svg?style=flat)](https://raw.githubusercontent.com/make-github-pseudonymous-again/js-algorithms/main/LICENSE) -[![GitHub issues](https://img.shields.io/github/issues/make-github-pseudonymous-again/js-algorithms.svg?style=flat)](https://github.com/make-github-pseudonymous-again/js-algorithms/issues) -== - -

- - -
xkcd.com -

- -Playground for algorithms in JavaScript. -This is a child project of [js-library](https://github.com/make-github-pseudonymous-again/js-library) -and -the twin project of [js-data-structures](https://github.com/make-github-pseudonymous-again/js-data-structures). - - -## :newspaper: Description - -This project is just a playground for any algorithm that doesn't fit in any -of those projects, - -### :flashlight: Searching - - [@aureooms/js-search](https://github.com/make-github-pseudonymous-again/js-search): - Searching algorithms for JavaScript - -### :waning_gibbous_moon: Merging - - - [aureooms/js-merging](https://github.com/make-github-pseudonymous-again/js-merging): merging for JavaScript - -### :cake: Partitioning - - [@aureooms/js-partition](https://github.com/make-github-pseudonymous-again/js-partition): - Partitioning algorithms for JavaScript - - [@aureooms/js-splitting](https://github.com/make-github-pseudonymous-again/js-splitting): - Array splitting algorithms for JavaScript - -### :point_down: Selection - - [aureooms/js-selection](https://github.com/make-github-pseudonymous-again/js-selection): selection for JavaScript - -### :signal_strength: Sorting - - [@aureooms/js-sort](https://github.com/make-github-pseudonymous-again/js-sort): - Sorting algorithms for JavaScript - -#### :balance_scale: Comparison sorting - - - :notebook_with_decorative_cover: [@comparison-sorting/specification](https://github.com/comparison-sorting/specification): Comparison sorting specification for JavaScript - - :leaves: [@comparison-sorting/heap-sort](https://github.com/comparison-sorting/heap-sort): Heapsort for JavaScript - - :rabbit2: [@comparison-sorting/quick-sort](https://github.com/comparison-sorting/quick-sort): Quicksort for JavaScript - - :rewind: [@comparison-sorting/insertion-sort](https://github.com/comparison-sorting/insertion-sort): Insertion sorting algorithms for JavaScript - - :person_fencing: [@comparison-sorting/merge-insertion-sort](https://github.com/comparison-sorting/merge-insertion-sort): Ford-Johnson algorithm for JavaScript - - :dragon: [@comparison-sorting/merge-sort](https://github.com/comparison-sorting/merge-sort): Mergesort for JavaScript - - :musical_score: [@comparison-sorting/odd-even-merge-sort](https://github.com/comparison-sorting/odd-even-merge-sort): Batcher's odd-even mergesort for JavaScript - -#### :zzz: Integer sorting - - - :oden: [@integer-sorting/radix-sort](https://github.com/integer-sorting/radix-sort): Radix sorting algorithms for JavaScript - - [aureooms/js-countingsort](https://github.com/make-github-pseudonymous-again/js-countingsort): countingsort for JavaScript - - [aureooms/js-bucketsort](https://github.com/make-github-pseudonymous-again/js-bucketsort): bucketsort for JavaScript - -### :symbols: Strings - Nothing yet. - -### :hocho: Hashing - Nothing yet. - -### :triangular_ruler: Geometry - - [@aureooms/js-cg](https://github.com/make-github-pseudonymous-again/js-cg) : computational geometry code bricks for JavaScript - -### :globe_with_meridians: Graphs - - [@aureooms/js-gn](https://github.com/make-github-pseudonymous-again/js-gn) : graphs and networks code bricks for JavaScript - - :oden: [@graph-algorithm/topological-sorting](https://github.com/graph-algorithm/topological-sorting): - Topological sorting algorithms for Javascript - - :haircut_woman: [@graph-algorithm/minimum-cut](https://github.com/graph-algorithm/minimum-cut): - Minimum cut algorithms for JavaScript - - :blossom: [@graph-algorithm/maximum-matching](https://github.com/graph-algorithm/maximum-matching): - Maximum matching algorithms for JavaScript - -### :1234: Numbers - - - :zzz: [@aureooms/js-integer](https://github.com/make-github-pseudonymous-again/js-integer) : - Integers for JavaScript (ℤ) - - :woman_farmer: [@aureooms/js-rational-field](https://github.com/make-github-pseudonymous-again/js-rational-field) : Rational field for JavaScript (ℚ) - -#### :symbols: Arithmetic - - :elephant: [@aureooms/js-integer-big-endian](https://github.com/make-github-pseudonymous-again/js-integer-big-endian): Arbitrary precision arithmetic for integers in big-endian order for JavaScript - - :pizza: [@aureooms/js-rational](https://github.com/make-github-pseudonymous-again/js-rational) : rational numbers code bricks for JavaScript - - :mermaid: [@aureooms/js-modular-arithmetic](https://github.com/make-github-pseudonymous-again/js-modular-arithmetic): Modular arithmetic for JavaScript. - - :globe_with_meridians: [@aureooms/js-complex](https://github.com/make-github-pseudonymous-again/js-complex) : complex numbers code bricks for JavaScript - - :wavy_dash: [@aureooms/js-polynomial](https://github.com/make-github-pseudonymous-again/js-polynomial) : sparse and dense polynomials code bricks for JavaScript - -#### :two: :three: :five: :seven: Number theory - - :butterfly: [@aureooms/js-fft](https://github.com/make-github-pseudonymous-again/js-fft) : Fast Fourier transform algorithms for JavaScript - - [@aureooms/js-prime](https://github.com/make-github-pseudonymous-again/js-prime) : Prime numbers for JavaScript - -#### :shell: Integer sequences - - [@aureooms/js-integer-sequences](https://github.com/make-github-pseudonymous-again/js-integer-sequences) : Integer sequences for JavaScript - - [@aureooms/js-fibonacci](https://github.com/make-github-pseudonymous-again/js-fibonacci) : Fibonacci numbers for JavaScript - -### :game_die: Randomness - - [@randomized/random](https://github.com/randomized-algorithm/random): Randomness algorithms for JavaScript - - [@entropy-source/pseudo-random](https://github.com/entropy-source/pseudo-random) : Pseudorandom number generators for JavaScript - -### :brain: Hard problems - - :satisfied: [@aureooms/js-sat](https://github.com/make-github-pseudonymous-again/js-sat) : Boolean formula satisfiability algorithms for Javascript - - :school_satchel: [@aureooms/js-knapsack](https://github.com/make-github-pseudonymous-again/js-knapsack) : - Knapsack problem algorithms for JavaScript - - :test_tube: [@aureooms/js-metaheuristics](https://github.com/make-github-pseudonymous-again/js-metaheuristics) : - Metaheuristic algorithms for JavaScript - -### :left_right_arrow: Sytems of equalities and inequalities - - [@aureooms/js-equation](https://github.com/make-github-pseudonymous-again/js-equation) : equations system code bricks for JavaScript - -### :broom: Combinatorics - - :exclamation: [@combinatorics/factorial](https://github.com/computational-combinatorics/factorial): Factorial function for JavaScript - - :seat: [@combinatorics/permutation](https://github.com/computational-combinatorics/permutation): Permutations library for JavaScript - - :zebra: [@combinatorics/n-permutations](https://github.com/computational-combinatorics/n-permutations): Set n-permutations for JavaScript - - :hippopotamus: [@combinatorics/n-combinations](https://github.com/computational-combinatorics/n-combinations): Set n-combinations for JavaScript - - :rhinoceros: [@combinatorics/n-multicombinations](https://github.com/computational-combinatorics/n-multicombinations): Set n-multicombinations for JavaScript - - :bento: [@combinatorics/set-partition](https://github.com/computational-combinatorics/set-partition): Set partition algorithms for Javascript - - -Those packages aim to provide *code bricks* that are as generic as possible. -Some examples are a Gauss-Jordan method that can work with any number model, a -Karatsuba algorithm that can handle any input size, a Graham Scan algorithm -that works with clockwise or counter clockwise ordering, and a Monotone Chain -algorithm that can be used as a triangulation algorithm without any change. - -## :scroll: Reference - -A list of links and projects focusing on algorithm implementation. - -### :coffee: Projects implementing algorithms in JavaScript - - - https://github.com/felipernb/algorithms.js - - https://github.com/mgechev/javascript-algorithms - - https://github.com/nzakas/computer-science-in-javascript - - https://github.com/benoitvallon/computer-science-in-javascript - - http://www.nayuki.io - -### :peacock: Projects implementing algorithms in other languages - - - https://github.com/xtaci/algorithms (C++) - - https://github.com/fragglet/c-algorithms (C) - - https://github.com/nryoung/algorithms (Python) - - https://github.com/kanwei/algorithms (Ruby) - - https://github.com/phishman3579/java-algorithms-implementation (Java) - - https://github.com/patmorin/ods (C++, Java, Python) - - http://www.nayuki.io (C, C++, Java, C#, Python, Haskell, MATLAB and others) - - http://rosettacode.org (All kinds of languages) - -### :link: Others - - - http://stackoverflow.com/questions/26301/your-favourite-algorithm-and-the-lesson-it-taught-you - - http://cglab.ca/publications.html diff --git a/array/iter.html b/array/iter.html new file mode 100644 index 0000000..8269a0f --- /dev/null +++ b/array/iter.html @@ -0,0 +1,16 @@ +array/iter
var fiter = function ( i, j, fn ) { + for ( ; i < j ; ++i ) { + fn( i ); + } +}; + +var biter = function ( i, j, fn ) { + while ( --j >= i ) { + fn( j ); + } +}; + + + +exports.fiter = fiter; +exports.biter = biter;
\ No newline at end of file diff --git a/assets/behavior.js b/assets/behavior.js new file mode 100644 index 0000000..da78d54 --- /dev/null +++ b/assets/behavior.js @@ -0,0 +1,969 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window);(function() { + var MAX_FILTER_SIZE, appendSearchNode, buildNav, buildTOCNode, clearFilter, clearHighlight, currentNode$, currentQuery, fileMap, focusCurrentNode, highlightMatch, moveCurrentNode, nav$, searchNodes, searchableNodes, selectNode, selectNodeByDocumentPath, setCurrentNodeExpanded, setTableOfContentsActive, tableOfContents, toc$, toggleTableOfContents, visitCurrentNode; + + tableOfContents = [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".md", ".markdown", ".mkd", ".mkdn", ".mdown"], + "commentsOnly": true, + "name": "Markdown" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/README.md", + "projectPath": "README.md", + "targetPath": "index", + "pageTitle": "index", + "title": "index" + }, + "depth": 1, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "Description", + "slug": "description" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "Reference", + "slug": "reference" + }, + "depth": 2, + "children": [ + { + "type": "heading", + "data": { + "level": 3, + "title": "Projects implementing algorithms in JavaScript", + "slug": "projects-implementing-algorithms-in-javascript" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Projects implementing algorithms in other languages", + "slug": "projects-implementing-algorithms-in-other-languages" + }, + "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "Others", + "slug": "others" + }, + "depth": 3 + } + ] + } + ] + }, { + "type": "folder", + "data": { + "path": "3sum", + "title": "3sum" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/3sum/_3sum_n2.js", + "projectPath": "js/src/3sum/_3sum_n2.js", + "targetPath": "3sum/_3sum_n2", + "pageTitle": "3sum/_3sum_n2", + "title": "_3sum_n2" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "4sum", + "title": "4sum" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/4sum/sortxy_n3.js", + "projectPath": "js/src/4sum/sortxy_n3.js", + "targetPath": "4sum/sortxy_n3", + "pageTitle": "4sum/sortxy_n3", + "title": "sortxy_n3" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "| X |", + "slug": "-x-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| Y |", + "slug": "-y-" + }, + "depth": 2 + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/4sum/sortxy_n4.js", + "projectPath": "js/src/4sum/sortxy_n4.js", + "targetPath": "4sum/sortxy_n4", + "pageTitle": "4sum/sortxy_n4", + "title": "sortxy_n4" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "| X |", + "slug": "-x-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| Y |", + "slug": "-y-" + }, + "depth": 2 + } + ] + } + ] + }, { + "type": "folder", + "data": { + "path": "array", + "title": "array" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/array/iter.js", + "projectPath": "js/src/array/iter.js", + "targetPath": "array/iter", + "pageTitle": "array/iter", + "title": "iter" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "bdp", + "title": "bdp" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/bdp/bdpdc.js", + "projectPath": "js/src/bdp/bdpdc.js", + "targetPath": "bdp/bdpdc", + "pageTitle": "bdp/bdpdc", + "title": "bdpdc" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "select(...) partitions the array in tree regions", + "slug": "select-partitions-the-array-in-tree-regions" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| <= h | h | >= h |", + "slug": "-lt-h--h--gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r scrambled |", + "slug": "-bampr-scrambled-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r scrambled |", + "slug": "-bampr-scrambled-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r <= h | h | b&r >= h |", + "slug": "-bampr-lt-h--h--bampr-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r < h | b&r = h | h | b&r > h |", + "slug": "-bampr-lt-h--bampr--h--h--bampr-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r < h | b&r = h | h | b&r = h | b&r > h |", + "slug": "-bampr-lt-h--bampr--h--h--bampr--h--bampr-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b&r < h | b&r = h | h | b&r = h | b&r > h |", + "slug": "-bampr-lt-h--bampr--h--h--bampr--h--bampr-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r < h | b&r = h | h | b&r = h | b&r > h |", + "slug": "-b-lt-h--r-lt-h--bampr--h--h--bampr--h--bampr-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r < h | b&r = h | h | b&r = h | b > h | r > h |", + "slug": "-b-lt-h--r-lt-h--bampr--h--h--bampr--h--b-gt-h--r-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | b > h | r < h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--b-gt-h--r-lt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | b > h | r < h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--b-gt-h--r-lt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | r > h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--b-gt-h--r-lt-h--r-gt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r<h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--r-gt-h--bgth-amp-rlth-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r<h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--r-gt-h--bgth-amp-rlth-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | r < h | b&r = h | h | b&r = h | b > h | r < h |", + "slug": "-b-lt-h--r-gt-h--r-lt-h--bampr--h--h--bampr--h--b-gt-h--r-lt-h-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | b>h & r<h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--bgth-amp-rlth-" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| b < h | r > h | b&r = h | h | b&r = h | b>h & r<h |", + "slug": "-b-lt-h--r-gt-h--bampr--h--h--bampr--h--bgth-amp-rlth-" + }, + "depth": 2 + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/bdp/bdpdn2.js", + "projectPath": "js/src/bdp/bdpdn2.js", + "targetPath": "bdp/bdpdn2", + "pageTitle": "bdp/bdpdn2", + "title": "bdpdn2" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "birthdays", + "title": "birthdays" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/birthdays/samebirthday.js", + "projectPath": "js/src/birthdays/samebirthday.js", + "targetPath": "birthdays/samebirthday", + "pageTitle": "birthdays/samebirthday", + "title": "samebirthday" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "epsilon", + "title": "epsilon" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/epsilon/absepsilon.js", + "projectPath": "js/src/epsilon/absepsilon.js", + "targetPath": "epsilon/absepsilon", + "pageTitle": "epsilon/absepsilon", + "title": "absepsilon" + }, + "depth": 2, + "outline": [] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/epsilon/relepsilon.js", + "projectPath": "js/src/epsilon/relepsilon.js", + "targetPath": "epsilon/relepsilon", + "pageTitle": "epsilon/relepsilon", + "title": "relepsilon" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "kldt", + "title": "kldt" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/kldt/evenkldtto2sum.js", + "projectPath": "js/src/kldt/evenkldtto2sum.js", + "targetPath": "kldt/evenkldtto2sum", + "pageTitle": "kldt/evenkldtto2sum", + "title": "evenkldtto2sum" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "A <- | t | t | t | t | t | t | t | t | t |", + "slug": "a-lt--t--t--t--t--t--t--t--t--t-" + }, + "depth": 2 + } + ] + }, { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/kldt/oddkldtto3sum.js", + "projectPath": "js/src/kldt/oddkldtto3sum.js", + "targetPath": "kldt/oddkldtto3sum", + "pageTitle": "kldt/oddkldtto3sum", + "title": "oddkldtto3sum" + }, + "depth": 2, + "outline": [] + } + ] + }, { + "type": "folder", + "data": { + "path": "minima", + "title": "minima" + }, + "depth": 1, + "children": [ + { + "type": "file", + "data": { + "language": { + "nameMatchers": [".js"], + "pygmentsLexer": "javascript", + "multiLineComment": ["/*", "*", "*/"], + "singleLineComment": ["//"], + "ignorePrefix": "}", + "foldPrefix": "^", + "name": "JavaScript" + }, + "sourcePath": "/home/aureooms/dev/js/js-algorithms/js/src/minima/clarkson.js", + "projectPath": "js/src/minima/clarkson.js", + "targetPath": "minima/clarkson", + "pageTitle": "minima/clarkson", + "title": "clarkson" + }, + "depth": 2, + "outline": [ + { + "type": "heading", + "data": { + "level": 2, + "title": "Description and context in", + "slug": "description-and-context-in" + }, + "depth": 2 + }, { + "type": "heading", + "data": { + "level": 2, + "title": "| minima set | candidate elements | discarded elements |", + "slug": "-minima-set--candidate-elements--discarded-elements-" + }, + "depth": 2 + } + ] + } + ] + } + ]; + + nav$ = null; + + toc$ = null; + + setTableOfContentsActive = function(active) { + var html$; + html$ = $('html'); + if (active) { + nav$.addClass('active'); + return html$.addClass('popped'); + } else { + nav$.removeClass('active'); + return html$.removeClass('popped'); + } + }; + + toggleTableOfContents = function() { + return setTableOfContentsActive(!nav$.hasClass('active')); + }; + + currentNode$ = null; + + focusCurrentNode = function() { + var currentNodeBottom, currentNodeTop; + currentNodeTop = currentNode$.offset().top - toc$.children(':visible').first().offset().top; + currentNodeBottom = currentNodeTop + currentNode$.children('.label').height(); + if (currentNodeTop < toc$.scrollTop()) { + toc$.scrollTop(currentNodeTop); + } + if (currentNodeBottom > toc$.scrollTop() + toc$.height()) { + return toc$.scrollTop(currentNodeBottom - toc$.height()); + } + }; + + setCurrentNodeExpanded = function(expanded) { + var parents$; + if (expanded) { + currentNode$.addClass('expanded'); + } else { + if (currentNode$.hasClass('expanded')) { + currentNode$.removeClass('expanded'); + } else { + parents$ = currentNode$.parents('li'); + if (parents$.length > 0) { + selectNode(parents$.first()); + } + } + } + return focusCurrentNode(); + }; + + selectNode = function(newNode$) { + currentNode$.removeClass('selected'); + newNode$.addClass('selected'); + currentNode$ = newNode$; + return focusCurrentNode(); + }; + + selectNodeByDocumentPath = function(documentPath, headerSlug) { + var j, len, link, ref, urlChunks; + if (headerSlug == null) { + headerSlug = null; + } + currentNode$ = fileMap[documentPath]; + if (headerSlug) { + ref = currentNode$.find('.outline a'); + for (j = 0, len = ref.length; j < len; j++) { + link = ref[j]; + urlChunks = $(link).attr('href').split('#'); + if (urlChunks[1] === headerSlug) { + currentNode$ = $(link).parents('li').first(); + break; + } + } + } + currentNode$.addClass('selected expanded'); + currentNode$.parents('li').addClass('expanded'); + return focusCurrentNode(); + }; + + moveCurrentNode = function(up) { + var i, j, len, newIndex, node, visibleNodes$; + visibleNodes$ = toc$.find('li:visible:not(.filtered)'); + newIndex = 0; + for (i = j = 0, len = visibleNodes$.length; j < len; i = ++j) { + node = visibleNodes$[i]; + if (node === currentNode$[0]) { + newIndex = up ? i - 1 : i + 1; + if (newIndex < 0) { + newIndex = 0; + } + if (newIndex > visibleNodes$.length - 1) { + newIndex = visibleNodes$.length - 1; + } + break; + } + } + return selectNode($(visibleNodes$[newIndex])); + }; + + visitCurrentNode = function() { + var labelLink$; + labelLink$ = currentNode$.children('a.label'); + if (labelLink$.length > 0) { + return window.location = labelLink$.attr('href'); + } + }; + + MAX_FILTER_SIZE = 10; + + searchableNodes = []; + + appendSearchNode = function(node$) { + var text$; + text$ = node$.find('> .label .text'); + return searchableNodes.push([text$.text().toLowerCase(), node$, text$]); + }; + + currentQuery = ''; + + searchNodes = function(queryString) { + var c, filtered, j, k, l, len, len1, len2, matched, matcher, nodeInfo, p, results; + queryString = queryString.toLowerCase().replace(/\s+/, ''); + if (queryString === currentQuery) { + return; + } + currentQuery = queryString; + if (queryString === '') { + return clearFilter(); + } + matcher = new RegExp(((function() { + var j, len, results; + results = []; + for (j = 0, len = queryString.length; j < len; j++) { + c = queryString[j]; + results.push(c.replace(/[-[\]{}()*+?.,\\^$|#\s]/, "\\$&")); + } + return results; + })()).join('.*')); + matched = []; + filtered = []; + for (j = 0, len = searchableNodes.length; j < len; j++) { + nodeInfo = searchableNodes[j]; + if (matcher.test(nodeInfo[0])) { + matched.push(nodeInfo); + } else { + filtered.push(nodeInfo); + } + } + if (matched.length > MAX_FILTER_SIZE) { + return clearFilter(); + } + nav$.addClass('searching'); + for (k = 0, len1 = filtered.length; k < len1; k++) { + nodeInfo = filtered[k]; + nodeInfo[1].removeClass('matched-child'); + nodeInfo[1].addClass('filtered'); + clearHighlight(nodeInfo[2]); + } + results = []; + for (l = 0, len2 = matched.length; l < len2; l++) { + nodeInfo = matched[l]; + nodeInfo[1].removeClass('filtered matched-child'); + nodeInfo[1].addClass('matched'); + highlightMatch(nodeInfo[2], queryString); + results.push((function() { + var len3, m, ref, results1; + ref = nodeInfo[1].parents('li'); + results1 = []; + for (m = 0, len3 = ref.length; m < len3; m++) { + p = ref[m]; + results1.push($(p).addClass('matched-child')); + } + return results1; + })()); + } + return results; + }; + + clearFilter = function() { + var j, len, nodeInfo, results; + nav$.removeClass('searching'); + currentQuery = ''; + results = []; + for (j = 0, len = searchableNodes.length; j < len; j++) { + nodeInfo = searchableNodes[j]; + nodeInfo[1].removeClass('filtered matched-child'); + results.push(clearHighlight(nodeInfo[2])); + } + return results; + }; + + highlightMatch = function(text$, queryString) { + var char, foundIndex, furthestIndex, j, len, lowerText, markedText, nodeText; + nodeText = text$.text(); + lowerText = nodeText.toLowerCase(); + markedText = ''; + furthestIndex = 0; + for (j = 0, len = queryString.length; j < len; j++) { + char = queryString[j]; + foundIndex = lowerText.indexOf(char, furthestIndex); + markedText += nodeText.slice(furthestIndex, foundIndex) + ("" + nodeText[foundIndex] + ""); + furthestIndex = foundIndex + 1; + } + return text$.html(markedText + nodeText.slice(furthestIndex)); + }; + + clearHighlight = function(text$) { + return text$.text(text$.text()); + }; + + fileMap = {}; + + buildNav = function(metaInfo) { + var j, len, node, sourceURL; + nav$ = $("
\n").appendTo($('body')); + toc$ = nav$.find('.toc'); + if (metaInfo.githubURL) { + if (metaInfo.documentPath === 'index') { + sourceURL = metaInfo.githubURL; + } else { + sourceURL = metaInfo.githubURL + "/blob/master/" + metaInfo.projectPath; + } + nav$.find('.tools').prepend("
  • \n \n View source on GitHub\n \n
  • "); + } + for (j = 0, len = tableOfContents.length; j < len; j++) { + node = tableOfContents[j]; + toc$.append(buildTOCNode(node, metaInfo)); + } + return nav$; + }; + + buildTOCNode = function(node, metaInfo) { + var c, children$, clickLabel, discloser, discloser$, j, label$, len, node$, ref, ref1, ref2; + node$ = $("
  • "); + discloser = null; + switch (node.type) { + case 'file': + node$.append("" + node.data.title + ""); + clickLabel = function(evt) { + if (evt.target === discloser) { + node$.toggleClass('expanded'); + evt.preventDefault(); + return false; + } + return selectNode(node$); + }; + break; + case 'folder': + node$.append("" + node.data.title + ""); + clickLabel = function(evt) { + selectNode(node$); + node$.toggleClass('expanded'); + evt.preventDefault(); + return false; + }; + } + if (((ref = node.children) != null ? ref.length : void 0) > 0) { + children$ = $('
      '); + ref1 = node.children; + for (j = 0, len = ref1.length; j < len; j++) { + c = ref1[j]; + children$.append(buildTOCNode(c, metaInfo)); + } + node$.append(children$); + } + label$ = node$.find('> .label'); + label$.click(clickLabel); + discloser$ = $('').prependTo(label$); + if (!(((ref2 = node.children) != null ? ref2.length : void 0) > 0)) { + discloser$.addClass('placeholder'); + } + discloser = discloser$.get(0); + if (node.type === 'file') { + fileMap[node.data.targetPath] = node$; + } + appendSearchNode(node$); + return node$; + }; + + $(function() { + var lastMousedownTimestamp, metaInfo, search$, toggle$; + metaInfo = { + relativeRoot: $('meta[name="groc-relative-root"]').attr('content'), + githubURL: $('meta[name="groc-github-url"]').attr('content'), + documentPath: $('meta[name="groc-document-path"]').attr('content'), + projectPath: $('meta[name="groc-project-path"]').attr('content') + }; + nav$ = buildNav(metaInfo); + toc$ = nav$.find('.toc'); + search$ = $('#search'); + selectNodeByDocumentPath(metaInfo.documentPath, window.location.hash.replace('#', '')); + search$.focus(function() { + return setTableOfContentsActive(true); + }); + lastMousedownTimestamp = null; + nav$.mousedown(function(evt) { + if (evt.target !== toggle$[0]) { + return lastMousedownTimestamp = evt.timeStamp; + } + }); + search$.blur(function(evt) { + if (evt.timeStamp - lastMousedownTimestamp < 10) { + return search$.focus(); + } else { + return setTableOfContentsActive(false); + } + }); + toggle$ = nav$.find('.toggle'); + toggle$.click(function(evt) { + if (search$.is(':focus')) { + search$.blur(); + } else { + search$.focus(); + } + return evt.preventDefault(); + }); + toggle$.mousedown(function(evt) { + return evt.preventDefault(); + }); + $('body').keydown(function(evt) { + if (nav$.hasClass('active')) { + switch (evt.keyCode) { + case 13: + visitCurrentNode(); + break; + case 37: + setCurrentNodeExpanded(false); + break; + case 38: + moveCurrentNode(true); + break; + case 39: + setCurrentNodeExpanded(true); + break; + case 40: + moveCurrentNode(false); + break; + default: + return; + } + return evt.preventDefault(); + } + }); + search$.bind('keyup search', function(evt) { + return searchNodes(search$.val()); + }); + search$.keydown(function(evt) { + if (evt.keyCode === 27) { + if (search$.val().trim() === '') { + return search$.blur(); + } else { + return search$.val(''); + } + } + }); + return $('.code.folded').each(function(index, code) { + var code$; + code$ = $(code); + return code$.click(function(evt) { + code$.toggleClass('folded'); + evt.preventDefault(); + return false; + }); + }); + }); + +}).call(this); diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..3804e61 --- /dev/null +++ b/assets/style.css @@ -0,0 +1 @@ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}html{line-height:1}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}q,blockquote{quotes:none}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none}a img{border:none}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}html,body{height:100%}#document{min-height:100%}body{max-width:33em}.segment{padding:0.5em 0 0.5em 33em;white-space:nowrap}.segment:first-child{padding-top:4.1em}.segment:last-child{padding-bottom:2em}.segment .comments,.segment .code{display:inline-block;vertical-align:top;padding:0 2em}.segment .comments{margin-left:-33em;width:29em;white-space:normal}.segment .code{white-space:pre}#meta{position:absolute;left:33em;padding:0.25em 1em}@media (max-width: 53em){html{font-size:1em}}@media (max-width: 52.94111em){html{font-size:0.99889em}}@media (max-width: 52.88222em){html{font-size:0.99778em}}@media (max-width: 52.82333em){html{font-size:0.99667em}}@media (max-width: 52.76444em){html{font-size:0.99556em}}@media (max-width: 52.70556em){html{font-size:0.99444em}}@media (max-width: 52.64667em){html{font-size:0.99333em}}@media (max-width: 52.58778em){html{font-size:0.99222em}}@media (max-width: 52.52889em){html{font-size:0.99111em}}@media (max-width: 52.47em){html{font-size:0.99em}}@media (max-width: 52.41111em){html{font-size:0.98889em}}@media (max-width: 52.35222em){html{font-size:0.98778em}}@media (max-width: 52.29333em){html{font-size:0.98667em}}@media (max-width: 52.23444em){html{font-size:0.98556em}}@media (max-width: 52.17556em){html{font-size:0.98444em}}@media (max-width: 52.11667em){html{font-size:0.98333em}}@media (max-width: 52.05778em){html{font-size:0.98222em}}@media (max-width: 51.99889em){html{font-size:0.98111em}}@media (max-width: 51.94em){html{font-size:0.98em}}@media (max-width: 51.88111em){html{font-size:0.97889em}}@media (max-width: 51.82222em){html{font-size:0.97778em}}@media (max-width: 51.76333em){html{font-size:0.97667em}}@media (max-width: 51.70444em){html{font-size:0.97556em}}@media (max-width: 51.64556em){html{font-size:0.97444em}}@media (max-width: 51.58667em){html{font-size:0.97333em}}@media (max-width: 51.52778em){html{font-size:0.97222em}}@media (max-width: 51.46889em){html{font-size:0.97111em}}@media (max-width: 51.41em){html{font-size:0.97em}}@media (max-width: 51.35111em){html{font-size:0.96889em}}@media (max-width: 51.29222em){html{font-size:0.96778em}}@media (max-width: 51.23333em){html{font-size:0.96667em}}@media (max-width: 51.17444em){html{font-size:0.96556em}}@media (max-width: 51.11556em){html{font-size:0.96444em}}@media (max-width: 51.05667em){html{font-size:0.96333em}}@media (max-width: 50.99778em){html{font-size:0.96222em}}@media (max-width: 50.93889em){html{font-size:0.96111em}}@media (max-width: 50.88em){html{font-size:0.96em}}@media (max-width: 50.82111em){html{font-size:0.95889em}}@media (max-width: 50.76222em){html{font-size:0.95778em}}@media (max-width: 50.70333em){html{font-size:0.95667em}}@media (max-width: 50.64444em){html{font-size:0.95556em}}@media (max-width: 50.58556em){html{font-size:0.95444em}}@media (max-width: 50.52667em){html{font-size:0.95333em}}@media (max-width: 50.46778em){html{font-size:0.95222em}}@media (max-width: 50.40889em){html{font-size:0.95111em}}@media (max-width: 50.35em){html{font-size:0.95em}}@media (max-width: 50.29111em){html{font-size:0.94889em}}@media (max-width: 50.23222em){html{font-size:0.94778em}}@media (max-width: 50.17333em){html{font-size:0.94667em}}@media (max-width: 50.11444em){html{font-size:0.94556em}}@media (max-width: 50.05556em){html{font-size:0.94444em}}@media (max-width: 49.99667em){html{font-size:0.94333em}}@media (max-width: 49.93778em){html{font-size:0.94222em}}@media (max-width: 49.87889em){html{font-size:0.94111em}}@media (max-width: 49.82em){html{font-size:0.94em}}@media (max-width: 49.76111em){html{font-size:0.93889em}}@media (max-width: 49.70222em){html{font-size:0.93778em}}@media (max-width: 49.64333em){html{font-size:0.93667em}}@media (max-width: 49.58444em){html{font-size:0.93556em}}@media (max-width: 49.52556em){html{font-size:0.93444em}}@media (max-width: 49.46667em){html{font-size:0.93333em}}@media (max-width: 49.40778em){html{font-size:0.93222em}}@media (max-width: 49.34889em){html{font-size:0.93111em}}@media (max-width: 49.29em){html{font-size:0.93em}}@media (max-width: 49.23111em){html{font-size:0.92889em}}@media (max-width: 49.17222em){html{font-size:0.92778em}}@media (max-width: 49.11333em){html{font-size:0.92667em}}@media (max-width: 49.05444em){html{font-size:0.92556em}}@media (max-width: 48.99556em){html{font-size:0.92444em}}@media (max-width: 48.93667em){html{font-size:0.92333em}}@media (max-width: 48.87778em){html{font-size:0.92222em}}@media (max-width: 48.81889em){html{font-size:0.92111em}}@media (max-width: 48.76em){html{font-size:0.92em}}@media (max-width: 48.70111em){html{font-size:0.91889em}}@media (max-width: 48.64222em){html{font-size:0.91778em}}@media (max-width: 48.58333em){html{font-size:0.91667em}}@media (max-width: 48.52444em){html{font-size:0.91556em}}@media (max-width: 48.46556em){html{font-size:0.91444em}}@media (max-width: 48.40667em){html{font-size:0.91333em}}@media (max-width: 48.34778em){html{font-size:0.91222em}}@media (max-width: 48.28889em){html{font-size:0.91111em}}@media (max-width: 48.23em){html{font-size:0.91em}}@media (max-width: 48.17111em){html{font-size:0.90889em}}@media (max-width: 48.11222em){html{font-size:0.90778em}}@media (max-width: 48.05333em){html{font-size:0.90667em}}@media (max-width: 47.99444em){html{font-size:0.90556em}}@media (max-width: 47.93556em){html{font-size:0.90444em}}@media (max-width: 47.87667em){html{font-size:0.90333em}}@media (max-width: 47.81778em){html{font-size:0.90222em}}@media (max-width: 47.75889em){html{font-size:0.90111em}}@media (max-width: 47.7em){html{font-size:0.9em}}@media (max-width: 47.64111em){html{font-size:0.89889em}}@media (max-width: 47.58222em){html{font-size:0.89778em}}@media (max-width: 47.52333em){html{font-size:0.89667em}}@media (max-width: 47.46444em){html{font-size:0.89556em}}@media (max-width: 47.40556em){html{font-size:0.89444em}}@media (max-width: 47.34667em){html{font-size:0.89333em}}@media (max-width: 47.28778em){html{font-size:0.89222em}}@media (max-width: 47.22889em){html{font-size:0.89111em}}@media (max-width: 47.17em){html{font-size:0.89em}}@media (max-width: 47.11111em){html{font-size:0.88889em}}@media (max-width: 47.05222em){html{font-size:0.88778em}}@media (max-width: 46.99333em){html{font-size:0.88667em}}@media (max-width: 46.93444em){html{font-size:0.88556em}}@media (max-width: 46.87556em){html{font-size:0.88444em}}@media (max-width: 46.81667em){html{font-size:0.88333em}}@media (max-width: 46.75778em){html{font-size:0.88222em}}@media (max-width: 46.69889em){html{font-size:0.88111em}}@media (max-width: 46.64em){html{font-size:0.88em}}@media (max-width: 46.58111em){html{font-size:0.87889em}}@media (max-width: 46.52222em){html{font-size:0.87778em}}@media (max-width: 46.46333em){html{font-size:0.87667em}}@media (max-width: 46.40444em){html{font-size:0.87556em}}@media (max-width: 46.34556em){html{font-size:0.87444em}}@media (max-width: 46.28667em){html{font-size:0.87333em}}@media (max-width: 46.22778em){html{font-size:0.87222em}}@media (max-width: 46.16889em){html{font-size:0.87111em}}@media (max-width: 46.11em){html{font-size:0.87em}}@media (max-width: 46.05111em){html{font-size:0.86889em}}@media (max-width: 45.99222em){html{font-size:0.86778em}}@media (max-width: 45.93333em){html{font-size:0.86667em}}@media (max-width: 45.87444em){html{font-size:0.86556em}}@media (max-width: 45.81556em){html{font-size:0.86444em}}@media (max-width: 45.75667em){html{font-size:0.86333em}}@media (max-width: 45.69778em){html{font-size:0.86222em}}@media (max-width: 45.63889em){html{font-size:0.86111em}}@media (max-width: 45.58em){html{font-size:0.86em}}@media (max-width: 45.52111em){html{font-size:0.85889em}}@media (max-width: 45.46222em){html{font-size:0.85778em}}@media (max-width: 45.40333em){html{font-size:0.85667em}}@media (max-width: 45.34444em){html{font-size:0.85556em}}@media (max-width: 45.28556em){html{font-size:0.85444em}}@media (max-width: 45.22667em){html{font-size:0.85333em}}@media (max-width: 45.16778em){html{font-size:0.85222em}}@media (max-width: 45.10889em){html{font-size:0.85111em}}@media (max-width: 45.05em){html{font-size:1em}body{margin:0 auto}.segment{padding:0;white-space:normal;max-width:29em;margin:0 auto}.segment .comments,.segment .code{display:block;padding:1em}.segment .comments{margin-left:0;width:auto}.segment .code{display:block;overflow-y:hidden;overflow-x:auto}.segment .code .wrapper{display:inline-block}#meta{position:static;margin:2em 0 0 0;overflow-y:hidden;overflow-x:auto}#meta .file-path{display:inline-block}}nav{position:fixed;top:0;right:0;width:20em}@media (max-width: 45.05em){nav{left:0;width:100%}}nav .tools{position:relative;z-index:100}nav .tools li{display:table-cell;vertical-align:middle;text-align:center;white-space:nowrap;height:2.1em;padding:0 0.55em}nav .tools .github{padding:0}nav .tools .github a{display:block;height:2.1em;width:2.1em;text-indent:-9001em}nav .tools .search{width:100%}nav .tools .search input{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;display:block;width:100%}nav .toc{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;position:absolute;top:2.1em;bottom:0;width:100%;overflow-x:hidden;overflow-y:auto}nav .toc li{position:relative}nav .toc .label{display:block;line-height:2em;padding:0 0.55em 0 0.55em}nav .toc li li .label{padding-left:1.1em}nav .toc li li li .label{padding-left:1.65em}nav .toc li li li li .label{padding-left:2.2em}nav .toc li li li li li .label{padding-left:2.75em}nav .toc li li li li li li .label{padding-left:3.3em}nav{-moz-transition:height 150ms 0;-o-transition:height 150ms 0;-webkit-transition:height 150ms 0;transition:height 150ms 0}nav .tools .toggle{-moz-transition:background 150ms;-o-transition:background 150ms;-webkit-transition:background 150ms;transition:background 150ms}nav.active{-moz-transition:height 0;-o-transition:height 0;-webkit-transition:height 0;transition:height 0;height:100%}nav .toc{-moz-transition:right 150ms;-o-transition:right 150ms;-webkit-transition:right 150ms;transition:right 150ms;right:-100%}nav.active .toc{right:0}@media (max-width: 45.05em){nav .toc{-moz-transition:left 150ms;-o-transition:left 150ms;-webkit-transition:left 150ms;transition:left 150ms;right:auto;left:-100%}nav.active .toc{left:0}}@media (max-width: 45.05em){body{-moz-transition:left 150ms;-o-transition:left 150ms;-webkit-transition:left 150ms;transition:left 150ms;position:relative;left:0}html.popped{overflow:hidden}html.popped body{left:100%;overflow:hidden}}nav .toc .children,nav .toc .outline{display:none}nav .toc .expanded>.children,nav .toc .expanded>.outline,nav .toc .expanded>.outline .children{display:block}nav .toc .discloser{-moz-transition-property:-moz-transform,-webkit-transform,-o-transform,-moz-transform;-o-transition-property:-moz-transform,-webkit-transform,-o-transform,-o-transform;-webkit-transition-property:-moz-transform,-webkit-transform,-o-transform,-webkit-transform;transition-property:-moz-transform -webkit-transform -o-transform transform;-moz-transition-duration:200ms;-o-transition-duration:200ms;-webkit-transition-duration:200ms;transition-duration:200ms;-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg);display:inline-block;height:9px;width:9px;padding:0.2em;margin:0.2em 0.2em -0.2em 0.2em;vertical-align:baseline;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowOEFDRENGQzE2NEUxMUUxODdDNUQ2ODM0QzVGRkVBMSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowOEFDRENGRDE2NEUxMUUxODdDNUQ2ODM0QzVGRkVBMSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjA4QUNEQ0ZBMTY0RTExRTE4N0M1RDY4MzRDNUZGRUExIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjA4QUNEQ0ZCMTY0RTExRTE4N0M1RDY4MzRDNUZGRUExIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+nQHMgwAAAM1JREFUeNpi/P//P0NJSYkuAwNDJhDXAPE7BjIAExIbZNA9IC4CYjZKDAIBfiDuBeLzQOxBiUEwoAXE26FYixKDYMAD6rpeqGvJNogBGl5F0PDLpMQgGBAC4mlQF9pTYhAMGADxASBeB8RylBgEA4FAfAOIW4CYhxKDQIAZxmChwJD1QFwGxHfINegaEGcB8UFyA/sd1AA9dEOIddFfIJ4OzdAfcSkiZNAOIC6GegcvwGXQHagBm8jNtB+hBmiTYgi6i+ZCw+EFOWkBIMAA1W4l62UzKWwAAAAASUVORK5CYII=') center center no-repeat;background-size:9px 9px}nav .toc .discloser.placeholder,nav .toc .expanded>.outline .discloser{background:none}nav .toc .expanded>.label .discloser{-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-webkit-transform:rotate(90deg);transform:rotate(90deg)}nav .toc .filtered>.label{display:none}nav .toc .matched-child>.label{display:block}nav .toc .matched-child>.children,nav .toc .matched-child>.outline,nav .toc .matched-child>.outline .children{display:block}nav .toc .matched>.children,nav .toc .matched>.outline,nav .toc .matched>.outline .children{display:block}nav.searching .toc .discloser{display:none}.comments .wrapper{font-family:"Helvetica Neue",Helvetica,"Droid Sans",sans-serif;font-weight:300;font-size:0.9375em;line-height:1.35}.comments .wrapper h1,.comments .wrapper h2,.comments .wrapper h3,.comments .wrapper h4,.comments .wrapper h5,.comments .wrapper h6{font-family:"HelveticaNeue-UltraLight","Helvetica Neue",Helvetica,"Droid Sans",sans-serif;font-weight:100;letter-spacing:0.0625em;line-height:1.25;margin-bottom:0.5em}.comments .wrapper h1{font-size:2.5em}.comments .wrapper h2{font-size:2em}.comments .wrapper h3{font-size:1.6em}.comments .wrapper h4{font-size:1.4em}.comments .wrapper h5{font-size:1.3em}.comments .wrapper h6{font-size:1.2em}.comments .wrapper p{margin:1em 0}.comments .wrapper>*:first-child{margin-top:0}.comments .wrapper>*:last-child{margin-bottom:0}.comments .wrapper ol,.comments .wrapper ul{padding-left:1.75em;margin:1em 0}.comments .wrapper ol li{list-style:decimal}.comments .wrapper ul li{list-style:disc}.comments .wrapper li{margin:1em 0}.comments .wrapper li:first-child{margin-top:0}.comments .wrapper li:last-child{margin-bottom:0}.comments .wrapper code{display:inline-block;padding:0.25em 0.25em 0 0.25em}.comments .wrapper pre{display:block;overflow-x:auto;overflow-y:hidden;margin-bottom:1em}.comments .wrapper pre .hljs-comment,.comments .wrapper pre .hljs-template_comment,.comments .wrapper pre .diff .hljs-header,.comments .wrapper pre .hljs-doctype,.comments .wrapper pre .hljs-pi,.comments .wrapper pre .lisp .hljs-string,.comments .wrapper pre .hljs-javadoc{color:#93a1a1;font-style:italic}.comments .wrapper pre .hljs-keyword,.comments .wrapper pre .hljs-winutils,.comments .wrapper pre .method,.comments .wrapper pre .hljs-addition,.comments .wrapper pre .css .hljs-tag,.comments .wrapper pre .hljs-request,.comments .wrapper pre .hljs-status,.comments .wrapper pre .nginx .hljs-title{color:#859900}.comments .wrapper pre .hljs-number,.comments .wrapper pre .hljs-command,.comments .wrapper pre .hljs-string,.comments .wrapper pre .hljs-tag .hljs-value,.comments .wrapper pre .hljs-rules .hljs-value,.comments .wrapper pre .hljs-phpdoc,.comments .wrapper pre .tex .hljs-formula,.comments .wrapper pre .hljs-regexp,.comments .wrapper pre .hljs-hexcolor{color:#2aa198}.comments .wrapper pre .hljs-title,.comments .wrapper pre .hljs-localvars,.comments .wrapper pre .hljs-chunk,.comments .wrapper pre .hljs-decorator,.comments .wrapper pre .hljs-built_in,.comments .wrapper pre .hljs-identifier,.comments .wrapper pre .vhdl .hljs-literal,.comments .wrapper pre .hljs-id,.comments .wrapper pre .css .hljs-function{color:#268bd2}.comments .wrapper pre .hljs-attribute,.comments .wrapper pre .hljs-variable,.comments .wrapper pre .lisp .hljs-body,.comments .wrapper pre .smalltalk .hljs-number,.comments .wrapper pre .hljs-constant,.comments .wrapper pre .hljs-class .hljs-title,.comments .wrapper pre .hljs-parent,.comments .wrapper pre .haskell .hljs-type{color:#b58900}.comments .wrapper pre .hljs-preprocessor,.comments .wrapper pre .hljs-preprocessor .hljs-keyword,.comments .wrapper pre .hljs-pragma,.comments .wrapper pre .hljs-shebang,.comments .wrapper pre .hljs-symbol,.comments .wrapper pre .hljs-symbol .hljs-string,.comments .wrapper pre .diff .hljs-change,.comments .wrapper pre .hljs-special,.comments .wrapper pre .hljs-attr_selector,.comments .wrapper pre .hljs-important,.comments .wrapper pre .hljs-subst,.comments .wrapper pre .hljs-cdata,.comments .wrapper pre .clojure .hljs-title,.comments .wrapper pre .css .hljs-pseudo{color:#cb4b16}.comments .wrapper pre .hljs-deletion{color:#dc322f}.comments .wrapper pre .tex .hljs-formula{background:#eee8d5}.comments .wrapper pre code{padding:1em}.comments .wrapper blockquote{padding:0 1em}.comments .wrapper strong{font-weight:700}.comments .wrapper em{font-style:italic}html{background:#4a525a}#document{background:#f5fbff url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuMCIgeTE9IjAuNSIgeDI9IjEuMCIgeTI9IjAuNSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzI3MmMzMCIvPjxzdG9wIG9mZnNldD0iMzAlIiBzdG9wLWNvbG9yPSIjM2U0NTRjIi8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjNGE1MjVhIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g') 33em no-repeat;background:#f5fbff -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, #272c30),color-stop(30%, #3e454c),color-stop(100%, #4a525a)) 33em no-repeat;background:#f5fbff -moz-linear-gradient(left, #272c30,#3e454c 0.3em,#4a525a 1em) 33em no-repeat;background:#f5fbff -webkit-linear-gradient(left, #272c30,#3e454c 0.3em,#4a525a 1em) 33em no-repeat;background:#f5fbff linear-gradient(to right, #272c30,#3e454c 0.3em,#4a525a 1em) 33em no-repeat;margin-right:-1em;padding-right:1em}@media (max-width: 45.05em){#document{margin-right:0;padding-right:0}}#meta>*{font-family:"Helvetica Neue",Helvetica,"Droid Sans",sans-serif;font-weight:300;font-size:0.9375em;line-height:1.35;text-shadow:#272c30 1px 1px 0}#meta>*,#meta>* a{color:#9faab7}#meta>* a{text-decoration:none}.comments .wrapper{font-family:"Helvetica Neue",Helvetica,"Droid Sans",sans-serif;font-weight:300;font-size:0.9375em;line-height:1.35;text-shadow:#fff 1px 1px 0;color:#4a525a}.code .wrapper{font-family:"Droid Sans Mono",Menlo,Monaco,monospace;font-size:0.75em;line-height:1.4;text-shadow:#272c30 1px 1px 0;color:#cbd1d8}.code .wrapper .hljs{display:block;padding:0.5em}.code .wrapper .hljs-comment,.code .wrapper .hljs-template_comment,.code .wrapper .diff .hljs-header,.code .wrapper .hljs-doctype,.code .wrapper .hljs-pi,.code .wrapper .lisp .hljs-string,.code .wrapper .hljs-javadoc{color:#b1bac4;font-style:italic}.code .wrapper .hljs-keyword,.code .wrapper .hljs-winutils,.code .wrapper .method,.code .wrapper .hljs-addition,.code .wrapper .css .hljs-tag,.code .wrapper .hljs-request,.code .wrapper .hljs-status,.code .wrapper .nginx .hljs-title{color:#e0c090}.code .wrapper .hljs-string{color:#e9baba}.code .wrapper .hljs-property{color:#b9d0af}.code .wrapper .hljs-function{color:#abd9cf}.code .wrapper .hljs-class{color:#cee4dd}.code .wrapper .hljs-number,.code .wrapper .hljs-command,.code .wrapper .hljs-tag .hljs-value,.code .wrapper .hljs-rules .hljs-value,.code .wrapper .hljs-phpdoc,.code .wrapper .tex .hljs-formula,.code .wrapper .hljs-regexp,.code .wrapper .hljs-hexcolor{color:#cba8d6}.code .wrapper .hljs-title,.code .wrapper .hljs-localvars,.code .wrapper .hljs-chunk,.code .wrapper .hljs-decorator,.code .wrapper .hljs-built_in,.code .wrapper .hljs-identifier,.code .wrapper .vhdl .hljs-literal,.code .wrapper .hljs-id,.code .wrapper .css .hljs-function{color:#a9c2ba}.code .wrapper .hljs-attribute,.code .wrapper .hljs-variable,.code .wrapper .lisp .hljs-body,.code .wrapper .smalltalk .hljs-number,.code .wrapper .hljs-constant,.code .wrapper .hljs-class .hljs-title,.code .wrapper .hljs-parent,.code .wrapper .haskell .hljs-type{color:#b9d0af}.code .wrapper .hljs-preprocessor,.code .wrapper .hljs-preprocessor .hljs-keyword,.code .wrapper .hljs-pragma,.code .wrapper .hljs-shebang,.code .wrapper .hljs-symbol,.code .wrapper .hljs-symbol .hljs-string,.code .wrapper .diff .hljs-change,.code .wrapper .hljs-special,.code .wrapper .hljs-attr_selector,.code .wrapper .hljs-important,.code .wrapper .hljs-subst,.code .wrapper .hljs-cdata,.code .wrapper .clojure .hljs-title,.code .wrapper .css .hljs-pseudo{color:#cee4dd}.code .wrapper .hljs-deletion{color:#dc322f}.code .wrapper .tex .hljs-formula{background:#e9baba}@media (max-width: 45.05em){.code{-moz-border-radius:0.4em;-webkit-border-radius:0.4em;border-radius:0.4em;-moz-box-shadow:#272c30 0 0 0.5em 0.2em inset;-webkit-box-shadow:#272c30 0 0 0.5em 0.2em inset;box-shadow:#272c30 0 0 0.5em 0.2em inset;background:#4a525a}.code .wrapper{-moz-box-shadow:#4a525a 0 0 0.25em 0.75em;-webkit-box-shadow:#4a525a 0 0 0.25em 0.75em;box-shadow:#4a525a 0 0 0.25em 0.75em;background:#4a525a}}@media (max-width: 29em){.code{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}}nav{text-shadow:#f0f0f0 1px 1px 0;color:#4a525a}nav .tools,nav .toc{font-family:"Helvetica Neue",Helvetica,"Droid Sans",sans-serif;font-weight:300;font-size:0.9375em;line-height:1.35}nav .tools{-moz-box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;-webkit-box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;background:url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIwLjkiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjZGNkY2QiIHN0b3Atb3BhY2l0eT0iMC45Ii8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNncmFkKSIgLz48L3N2Zz4g');background:-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(255,255,255,0.9)),color-stop(100%, rgba(205,205,205,0.9)));background:-moz-linear-gradient(top, rgba(255,255,255,0.9),rgba(205,205,205,0.9));background:-webkit-linear-gradient(top, rgba(255,255,255,0.9),rgba(205,205,205,0.9));background:linear-gradient(to bottom, rgba(255,255,255,0.9),rgba(205,205,205,0.9));-moz-border-radius-bottomleft:0.4em;-webkit-border-bottom-left-radius:0.4em;border-bottom-left-radius:0.4em;border-bottom:1px solid #4a525a;border-left:1px solid #4a525a}@media (max-width: 53em){nav .tools{-moz-border-radius-bottomleft:0;-webkit-border-bottom-left-radius:0;border-bottom-left-radius:0}}nav .tools li{border-right:1px solid #4a525a}nav .tools li:last-child{border-right:none}nav .tools .toggle{cursor:pointer}nav .tools .github a{-moz-transition:opacity 200ms;-o-transition:opacity 200ms;-webkit-transition:opacity 200ms;transition:opacity 200ms;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50);opacity:0.5;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAwCAYAAACScGMWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG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DLu/8tuy0wP+8NuXh/jdds/8BU9Fet3uXrc2RM7a0NBOjq1ECB0CtBMVoUu2psZxrVbrOKM5emeE2bj7iz27Ilauf/EZR2srVE3tXvP8ui+R55Hla9Z9tfDx2cVVFy6YP9r5acaRQ4deLZk9K9Nlt5fs3r0nc3h+4RRbc+PJAETL5RH0jWHOMKQPk+fM7+7cq+NjSSQum4M01V8nZ//9FfXyxRevXJ02ZtTI6TGxsVf6ZWWv2LP946ms8iofkDOsKeBx/06j1WtPHC99E7XEizSfA7LZ6LSSOzBl7lPuTkqOtn/bO53J3WHLAx4G6igRlvPPZO6FFiy/B2j5V0hLQvYNPcY4AVB/Sa3BEqwTCLnSo3e4S//oiGHFDTXh3cDFsIVMZXH8N4z8bbX/CjAA0UTEH4oMvREAAAAASUVORK5CYII=') center center no-repeat;background-size:19.5px 24px}nav .tools .github a:hover{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=90);opacity:0.9}nav.active .tools{-moz-border-radius-bottomleft:0;-webkit-border-bottom-left-radius:0;border-bottom-left-radius:0}nav.active .tools .toggle{background:rgba(205,205,205,0.9);position:relative}nav .toc{-moz-box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;-webkit-box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;box-shadow:rgba(0,0,0,0.3) 0 0 0.5em 0.1em;background:rgba(230,230,230,0.9);border-left:1px solid #4a525a}nav .toc .label{color:#4a525a;text-decoration:none;border-top:1px solid rgba(192,192,192,0.9);border-bottom:1px solid rgba(192,192,192,0.9);margin-top:-1px}nav .toc .label:hover{background:rgba(205,205,205,0.9)}nav .toc .file>.label{font-weight:bold}nav .toc .selected>.label{background:#f5fbff}nav .toc .label em{font-weight:bold}nav .toc .file>.label em{color:#101214}nav .toc .matched-child>.label{filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=65);opacity:0.65;text-shadow:none;background:rgba(192,192,192,0.9)}@media (max-width: 45.05em){nav .tools,nav .toc{border-left-width:0}nav .tools{background:url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2NkY2RjZCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');background:-webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff),color-stop(100%, #cdcdcd));background:-moz-linear-gradient(top, #ffffff,#cdcdcd);background:-webkit-linear-gradient(top, #ffffff,#cdcdcd);background:linear-gradient(to bottom, #ffffff,#cdcdcd)}nav .toc{background:#e6e6e6}}.comments .wrapper a{display:inline-block;color:#a8614e;text-decoration:none}.comments .wrapper a:hover,.comments .wrapper a:hover *{text-decoration:underline}.comments .wrapper code{font-family:"Droid Sans Mono",Menlo,Monaco,monospace;font-size:0.75em;line-height:1.4;border:1px solid #e6e0d5}.comments .wrapper pre,.comments .wrapper code{-moz-border-radius:0.4em;-webkit-border-radius:0.4em;border-radius:0.4em;background:#fbf8f3}.comments .wrapper pre{-moz-box-shadow:#f2ece3 0 0 0.4em 0.2em;-webkit-box-shadow:#f2ece3 0 0 0.4em 0.2em;box-shadow:#f2ece3 0 0 0.4em 0.2em;border:1px solid #d9c9af}.comments .wrapper pre code{border-width:0;background:transparent}.comments .wrapper blockquote{border-left:0.15em solid #959fa8;margin-left:-0.15em}body{-webkit-text-size-adjust:100%}input[type="search"]{-moz-border-radius:1em;-webkit-border-radius:1em;border-radius:1em;-moz-box-shadow:#ddd 0 1px 1px 0 inset;-webkit-box-shadow:#ddd 0 1px 1px 0 inset;box-shadow:#ddd 0 1px 1px 0 inset;border:1px solid #959595;padding:0.15em 0.8em}.comments.doc-section .wrapper{color:#252519}.comments.doc-section.doc-section-private .wrapper,.comments.doc-section.doc-section-protected .wrapper,.comments.doc-section.doc-section-internal .wrapper{color:#7f7f7f}.comments.doc-section .doc-section-header{font:bold 18px "helvetica neue",helvetica,sans-serif}.comments.doc-section .docs .doc-section-header code{font-size:18px}.code .marker,.code .marker.wrapper,.code .wrapper.marker{display:none}.code.folded .wrapper{display:none;cursor:default}.code.folded .marker{-moz-border-radius:0.2em;-webkit-border-radius:0.2em;border-radius:0.2em;-moz-box-shadow:#2f3539 1px 1px 1px 0;-webkit-box-shadow:#2f3539 1px 1px 1px 0;box-shadow:#2f3539 1px 1px 1px 0;display:inline-block;border:1px solid #73787f;padding:0.2em 0.5em;margin-left:-0.5em;margin-right:-0.5em;background:#58616b;font:12px "Droid Sans Mono",Menlo,Monaco,monospace;text-shadow:#2f3539 1px 1px 0px;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:-moz-none;-ms-user-select:none;user-select:none}.code.folded .marker .c1{color:#73787f;font-style:normal}.code.folded .marker:hover{background:#5f6872}.code.folded .marker:hover .c1{color:#7b8087}.code.folded .marker .c1:after{content:" …"} diff --git a/bdp/bdpdc.html b/bdp/bdpdc.html new file mode 100644 index 0000000..a07ba6b --- /dev/null +++ b/bdp/bdpdc.html @@ -0,0 +1,177 @@ +bdp/bdpdc

      Bichromatic dominating pairs using the divide and conquer chainsaw.

      +

      see F. P. Preparata and M. I. Shamos, Computational Geometry, NY, 1985, p. 366.

      +

      Here the algorithm handles non-strict ( >= ) dominance.

      +

      select( f, a, i, j, k ) where + f is a comparator + a the array of points + [i, j[ the range to search in the array + k the index to select

      +

      select(...) partitions the array in tree regions

      +

      | <= h | h | >= h |

      +

      i .... k k+1 .... j-1

      +

      eq( d, v ) template for a function eq( a ) + returns true iff coordinate d of a equals v

      +

      ne( d, v ) template for a function ne( y ) + returns true iff coordinate d of a is not equal to v

      +

      color( point ) + = 0 if point is blue + = 1 if point is red

      +

      p = split( predicate, a, i, j ) + rearranges an array so that all elements for which predicate is false + are in interval [i, p[ and all other elements are in interval [p, j[

      +

      swap( a, ai, aj, b, bi ) + swap elements from a in interval [ai, aj[ with elements from b in interval + [bi, bi + aj - ai[

      let __bdpdc__ = function ( select, __eq__, __ne__, color, split, swap ) {

      a is an array of points

      +
      note that we only consider points starting
      +at index i and ending at index j-1 in a
      +

      points are arrays of coordinates

      +
      d = dj - di is the number of coordinates of each point
      +

      f is a template for a function {coordinates^2} -> {<0, =0, >0} named f

      +
      i.e. for coordinates a and b
      +
      +  f( a, b ) < 0 means a < b;
      +  f( a, b ) = 0 means a = b;
      +  f( a, b ) > 0 means a > b.
      +

      out is the output array

      let bdpdc = function* ( __f__, a, i, j, di, dj ) { + + let k, h, x, y, p, q, m, n, _m, _n;

      empty or one element array case

      if ( i >= j - 1 ) return ;

      base case : dj - di = d = 0 +enumerate all red / blue pairs +[i, p[ contains only blue points +[p, j[ contains only red points +p = index of first red point

      if ( di === dj ) {

      move all blue points left and all red points right +(arbitrary choice)

      p = split( color, a, i, j );

      for each red point

      for ( x = p ; x < j ; ++x ) {

      for each blue point

      for ( y = i ; y < p ; ++y ) { + + yield [ a[x], a[y] ] ; + + } + } + + }

      recursion fairy

      +

      we compute m such that h is the median of +the ith coordinate of all points

      else {

      +

      | b&r scrambled |

      +

      i j

      k = ( i + j ) / 2 | 0;

      +

      | b&r scrambled |

      +

      i k j

      select median element +O(n)

      select( __f__( di ), a, i, j, k ); + + h = a[k][di];

      +

      | b&r <= h | h | b&r >= h |

      +

      i k j

      we do 3 recursive calls

      +

      first: for red and blue points with di < h in R^d +we do not consider points with di = h because either

      +
        +
      1. red = h, blue < h --> handled by last call
      2. +
      3. red < h, blue = h --> red cannot dominate blue
      4. +
      5. red = h, blue = h --> handled by last call +(would be "red cannot dominate blue" for strict dominance +in this 3rd case)
      6. +
      +

      second: for red and blue points with di > h in R^d +we do not consider points with di = h for similar reasons as above

      +

      last: for red points with di >= h and blue points with di <= h in R^{d-1} +(would be > and < for strict dominance)

      +

      note that we do not need to handle the case where red < h and blue >= h +or red <= h and blue > h since red cannot dominate blue in those cases

      first recursive call +we only consider points that have di < h +since all points that have di = h will be handled later

      move median elements from [ i, k [ in the [ x, k [ interval, x >= i +O(n)

      x = split( __eq__( di, h ), a, i, k );

      +

      | b&r < h | b&r = h | h | b&r > h |

      +

      i x k j

      yield* bdpdc( __f__, a, i, x, di, dj );

      move median elements from [ k + 1, j [ in the [ y, j [ interval, y <= j +O(n)

      y = split( __ne__( di, h ), a, k + 1, j );

      +

      | b&r < h | b&r = h | h | b&r = h | b&r > h |

      +

      i x k y j

      yield* bdpdc( __f__, a, y, j, di, dj );

      since we do not touch median elements in the first two +recursive calls they are still at the correct place

      Now we want to

      +
        +
      • move red points such that di < h to the right
      • +
      • move red points such that di >= h to the left
      • +
      +

      /!\ Note that we also might think that we should

      +
        +
      • move blue points such that di > h to the right
      • +
      • move blue points such that di <= h to the left +but after the selection algorithm this is already the case
      • +

      +

      | b&r < h | b&r = h | h | b&r = h | b&r > h |

      +

      i x k y j

      p = split( color, a, i, x );

      +

      | b < h | r < h | b&r = h | h | b&r = h | b&r > h |

      +

      i p x k y j

      q = split( color, a, y, j );

      +

      | b < h | r < h | b&r = h | h | b&r = h | b > h | r > h |

      +

      i p x k y q j

      we now want to swap r < h elements with r > h elements +we have 3 cases

      +
        +
      1. x - p = j - q
      2. +
      3. x - p < j - q
      4. +
      5. x - p > j - q
      6. +
      m = x - p; + n = j - q;
        +
      1. x - p = j - q
      2. +
      if ( m === n ) { + swap( a, q, j, a, p );

      +

      | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h |

      +

      i p x k y q j

      j = y;

      +

      | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h |

      +

      i p x k j ...

      }
        +
      1. x - p < j - q
      2. +
      else if ( m < n ) { + + swap( a, p, x, a, q );

      +

      | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | r > h |

      +

      i p x k y q q+m j

      we now want to swap b > h and r < h elements with r > h elements + [y,q[ [q,q+m[ [q+m,j[ +we have 2 cases

      +
        +
      1. (q + m) - y >= j - (q + m) [OR >]
      2. +
      3. (q + m) - y < j - (q + m) [OR <=]
      4. +
      _m = (q + m) - y; + _n = j - (q + m);
        +
      1. (q + m) - y >= j - (q + m)
      2. +
      if ( _m >= _n ) { + swap( a, q + m, j, a, y ); + }
        +
      1. (q + m) - y < j - (q + m)
      2. +
      else { + swap( a, j - _m, j, a, y ); + }

      +

      | b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r<h |

      +

      i p x k y y+_n j

      j = y + _n;

      +

      | b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r<h |

      +

      i p x k y j ...

      }
        +
      1. x - p > j - q
      2. +
      else { + + swap( a, q, j, a, p );

      +

      | b < h | r > h | r < h | b&r = h | h | b&r = h | b > h | r < h |

      +

      i p p+n x k y q j

      we now want to swap r < h with b&r = h elements +we have 2 cases

      +
        +
      1. x - (p + n) >= y - x
      2. +
      3. x - (p + n) < y - x
      4. +
      _m = x - (p + n); + _n = y - x;
        +
      1. x - (p + n) >= y - x
      2. +
      if ( _m >= _n ) { + swap( a, x, y, a, p + n ); + }
        +
      1. x - (p + n) < y - x
      2. +
      else { + swap( a, y - _m, y, a, p + n ); + }

      +

      | b < h | r > h | b&r = h | h | b&r = h | b>h & r<h |

      +

      i p p+n k y-_m j

      j = y - _m;

      +

      | b < h | r > h | b&r = h | h | b&r = h | b>h & r<h |

      +

      i p p+n k j ...

      }

      [i, j[ now contains only b <= h and r >= h points +in this new interval, all r points dominate b points +for the ith coordinate +we can thus ask the recursion fairy to take care of the other +dj - di - 1 dimensions left

      yield* bdpdc( __f__, a, i, j, di + 1, dj ); + + } + + }; + + return bdpdc; + +}; + +exports.__bdpdc__ = __bdpdc__;
      \ No newline at end of file diff --git a/bdp/bdpdn2.html b/bdp/bdpdn2.html new file mode 100644 index 0000000..73a4143 --- /dev/null +++ b/bdp/bdpdn2.html @@ -0,0 +1,46 @@ +bdp/bdpdn2

      Bichromatic dominating pairs using a naïve O(d * n^2) algorithm.

      +

      Here the algorithm handles non-strict ( >= ) dominance.

      +

      color( point ) + = 0 if point is blue + = 1 if point is red

      +

      p = split( predicate, a, i, j ) + rearranges an array so that all elements for which predicate is false + are in interval [i, p[ and all other elements are in interval [p, j[

      let __bdpdn2__ = function ( color, split ) {

      a is an array of points

      +
      note that we only consider points starting
      +at index i and ending at index j-1 in a
      +

      points are arrays of coordinates

      +
      d = dj - di is the number of coordinates of each point
      +

      f is a template for a function {coordinates^2} -> {<0, =0, >0} named f

      +
      i.e. for coordinates a and b
      +
      +  f( a, b ) < 0 means a < b;
      +  f( a, b ) = 0 means a = b;
      +  f( a, b ) > 0 means a > b.
      let bdpdn2 = function* ( __f__, a, i, j, di, dj ) { + + let x, y, p, d, f;

      empty or one element array case

      if ( i >= j - 1 ) return ;

      move all blue points left and all red points right +(arbitrary choice)

      [i, p[ contains only blue points +[p, j[ contains only red points +p = index of first red point

      p = split( color, a, i, j );

      for each red point

      red : for ( x = p ; x < j ; ++x ) {

      for each blue point

      blue : for ( y = i ; y < p ; ++y ) { + + for ( d = di ; d < dj ; ++d ) { + + f = __f__( d ); + + if ( f( a[x], a[y] ) < 0 ) { + continue blue; + } + + } + + yield [ a[x], a[y] ] ; + + } + } + + }; + + return bdpdn2; + +}; + +exports.__bdpdn2__ = __bdpdn2__;
      \ No newline at end of file diff --git a/birthdays/samebirthday.html b/birthdays/samebirthday.html new file mode 100644 index 0000000..ae88d5a --- /dev/null +++ b/birthdays/samebirthday.html @@ -0,0 +1,26 @@ +birthdays/samebirthday

      Computes the probability ( [0, 1] ) for at least 1 of k people +out of n to have his birthday the same day as someone else.

      +

      hypothesis : k <= n and k <= days

      var samebirthday = function ( k, n, days ) { + + var i, p; + + p = 1; + + for ( i = 1 ; i < k ; ++i ) { + + p = p * ( days - i ) / days; + + } + + for ( ; i < n ; ++i ) { + + p = p * ( days - k ) / days; + + } + + + return 1 - p; + +}; + +exports.samebirthday = samebirthday;
      \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index efc624a..0000000 --- a/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "homepage": "https://make-github-pseudonymous-again.github.io/js-algorithms", - "name": "aureooms-js-algorithms", - "license": "AGPL-3.0", - "description": "playground for algorithmic code bricks in JavaScript", - "version": "3.0.7", - "main": "js/dist/algorithms.js", - "ignore": [ - "js/index.js", - "js/src", - "test", - "pkg.json", - "package.json", - ".groc.json", - ".travis.yml", - ".gitignore", - "README.md", - "inch.json", - ".codeclimate.yml" - ] -} \ No newline at end of file diff --git a/component.json b/component.json deleted file mode 100644 index b1cdf5a..0000000 --- a/component.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "main": "js/dist/algorithms.js", - "name": "aureooms-js-algorithms", - "scripts": [ - "js/dist/algorithms.js" - ], - "description": "playground for algorithmic code bricks in JavaScript", - "license": "AGPL-3.0", - "version": "3.0.7", - "repo": "aureooms/js-algorithms" -} \ No newline at end of file diff --git a/epsilon/absepsilon.html b/epsilon/absepsilon.html new file mode 100644 index 0000000..c6f55d2 --- /dev/null +++ b/epsilon/absepsilon.html @@ -0,0 +1,16 @@ +epsilon/absepsilon
      var __absepsilon__ = function ( epsilon ) { + + + return function ( a, b ) { + + var r; + + r = a - b; + + return r < -epsilon ? -1 : r > epsilon ? 1 : 0; + + }; + +}; + +exports.__absepsilon__ = __absepsilon__;
      \ No newline at end of file diff --git a/epsilon/relepsilon.html b/epsilon/relepsilon.html new file mode 100644 index 0000000..1acaa35 --- /dev/null +++ b/epsilon/relepsilon.html @@ -0,0 +1,28 @@ +epsilon/relepsilon
      var __relepsilon__ = function ( epsilon ) { + + + return function ( a, b ) { + + var r; + + if ( b === 0 ) { + return a; + } + + else if ( a === 0 ) { + return -b; + } + + else { + + r = a / b - 1; + + return r < -epsilon ? -1 : r > epsilon ? 1 : 0; + + } + + }; + +}; + +exports.__relepsilon__ = __relepsilon__;
      \ No newline at end of file diff --git a/inch.json b/inch.json deleted file mode 100644 index bb05fa6..0000000 --- a/inch.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files" : { - "included": [ "js/src/**/*.js" ] - } -} diff --git a/index.html b/index.html new file mode 100644 index 0000000..2f44857 --- /dev/null +++ b/index.html @@ -0,0 +1,84 @@ +index

      js-algorithms

      +

      Algorithms code bricks in JavaScript. This is a child project of +js-library and the twin project +of js-data-structures.

      +

      NPM license +NPM version +Bower version +Build Status +Coverage Status +Dependencies Status +devDependencies Status +Code Climate +NPM downloads per month +GitHub issues +Inline docs

      +

      Description

      +

      This project is just a playground for any algorithm that doesn't fit in any +of those project,

      + +

      Those packages aim to provide code bricks that are as generic as possible. +Some examples are a Gauss-Jordan method that can work with any number model, a +Karatsuba algorithm that can handle any block size, a Graham Scan algorithm +that works with clockwise or counter clockwise ordering, and a Monotone Chain +algorithm that can be used as a triangulation algorithm without any change.

      +

      Reference

      +

      A list of links and projects focusing on algorithm implementation.

      +

      Projects implementing algorithms in JavaScript

      + +

      Projects implementing algorithms in other languages

      + +

      Others

      +
      \ No newline at end of file diff --git a/js/dist/algorithms.js b/js/dist/algorithms.js deleted file mode 100644 index 5588699..0000000 --- a/js/dist/algorithms.js +++ /dev/null @@ -1,1193 +0,0 @@ -"use strict"; - -var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); - -function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } - -(function () { - - 'use strict'; - - var definition = function definition(exports, undefined) { - - /* js/src/3sum */ - /* js/src/3sum/_3sum_n2.js */ - - /** - * Hypothesis : - * - A is sorted in increasing order - * - B is sorted in increasing order - * - |A| > 0 - * - |B| > 0 - */ - - var _3sum_n2 = function _3sum_n2(A, ai, aj, B, bi, bj, C, ci, cj, fn) { - - var hi, lo, a, b, c, v; - - for (; ci < cj; ++ci) { - lo = ai; - hi = bj - 1; - - do { - - a = A[lo]; - b = B[hi]; - c = C[ci]; - v = a + b; - - if (-c === v) fn(a, b, c); - - if (-c < v) --hi;else ++lo; - } while (lo < aj && hi >= bi); - } - }; - - exports._3sum_n2 = _3sum_n2; - /* js/src/4sum */ - /* js/src/4sum/sortxy_n3.js */ - - /** - * X is sorted in increasing order - * Y is sorted in increasing order - * compare takes 4 arguments and returns <=> 0 - * output takes 4 arguments - * - */ - var sortxy_n3 = function sortxy_n3(compare, X, Y, Xi1, Xj1, Yi1, Yj1, Xi2, Xj2, Yi2, Yj2, output) { - - var a, b, c, d, s; - - if (Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2) { - return; - } - - // ----------------------------- - // | X | - // ----------------------------- - // Xi Xj - - // ----------------------------- - // | Y | - // ----------------------------- - // Yi Yj - - a = X[Xi1]; - b = Y[Yj1]; - c = X[Xj2]; - d = Y[Yi2]; - - s = compare(a, b, c, d); - - if (s === 0) { - - output(Xi1, Yj1, Xj2, Yi2); - - sortxy_n3(compare, X, Y, Xi1 + 1, Xj1, Yi1, Yj1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n3(compare, X, Y, Xi1, Xi1, Yi1, Yj1 - 1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n3(compare, X, Y, Xi1, Xi1, Yj1, Yj1, Xi2, Xj2 - 1, Yi2, Yj2, output); - } else if (s < 0) { - - sortxy_n3(compare, X, Y, Xi1 + 1, Xj1, Yi1, Yj1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n3(compare, X, Y, Xi1, Xi1, Yi1, Yj1, Xi2, Xj2 - 1, Yi2, Yj2, output); - } else { - - sortxy_n3(compare, X, Y, Xi1, Xj1, Yi1, Yj1 - 1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n3(compare, X, Y, Xi1, Xj1, Yj1, Yj1, Xi2, Xj2, Yi2 + 1, Yj2, output); - } - }; - - exports.sortxy_n3 = sortxy_n3; - - /* js/src/4sum/sortxy_n4.js */ - - /** - * X is sorted in increasing order - * Y is sorted in increasing order - * compare takes 4 arguments and returns <=> 0 - * output takes 4 arguments - * - */ - var sortxy_n4 = function sortxy_n4(compare, X, Y, Xi1, Xj1, Yi1, Yj1, Xi2, Xj2, Yi2, Yj2, output) { - - var a, b, c, d, s; - - if (Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2) { - return; - } - - // ----------------------------- - // | X | - // ----------------------------- - // Xi Xj - - // ----------------------------- - // | Y | - // ----------------------------- - // Yi Yj - - a = X[Xi1]; - b = Y[Yi1]; - c = X[Xi2]; - d = Y[Yi2]; - - s = compare(a, b, c, d); - - if (s === 0) { - - output(Xi1, Yi1, Xi2, Yi2); - } - - sortxy_n4(compare, X, Y, Xi1 + 1, Xj1, Yi1, Yj1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n4(compare, X, Y, Xi1, Xi1, Yi1 + 1, Yj1, Xi2, Xj2, Yi2, Yj2, output); - sortxy_n4(compare, X, Y, Xi1, Xi1, Yi1, Yi1, Xi2 + 1, Xj2, Yi2, Yj2, output); - sortxy_n4(compare, X, Y, Xi1, Xi1, Yi1, Yi1, Xi2, Xi2, Yi2 + 1, Yj2, output); - }; - - exports.sortxy_n4 = sortxy_n4; - - /* js/src/array */ - /* js/src/array/iter.js */ - - var fiter = function fiter(i, j, fn) { - for (; i < j; ++i) { - fn(i); - } - }; - - var biter = function biter(i, j, fn) { - while (--j >= i) { - fn(j); - } - }; - - exports.fiter = fiter; - exports.biter = biter; - - /* js/src/bdp */ - /* js/src/bdp/bdpdc.js */ - - /** - * Bichromatic dominating pairs using the divide and conquer chainsaw. - * - * see F. P. Preparata and M. I. Shamos, Computational Geometry, NY, 1985, p. 366. - * - * Here the algorithm handles non-strict ( >= ) dominance. - * - * select( f, a, i, j, k ) where - * f is a comparator - * a the array of points - * [i, j[ the range to search in the array - * k the index to select - * - * select(...) partitions the array in tree regions - * ----------------------------- - * | <= h | h | >= h | - * ----------------------------- - * i .... k k+1 .... j-1 - * - * __eq__( d, v ) template for a function eq( a ) - * returns true iff coordinate d of a equals v - * - * __ne__( d, v ) template for a function ne( y ) - * returns true iff coordinate d of a is not equal to v - * - * color( point ) - * = 0 if point is blue - * = 1 if point is red - * - * p = split( predicate, a, i, j ) - * rearranges an array so that all elements for which predicate is false - * are in interval [i, p[ and all other elements are in interval [p, j[ - * - * swap( a, ai, aj, b, bi ) - * swap elements from a in interval [ai, aj[ with elements from b in interval - * [bi, bi + aj - ai[ - * - */ - - var __bdpdc__ = function __bdpdc__(select, __eq__, __ne__, color, split, swap) { - - /** - * a is an array of points - * - * note that we only consider points starting - * at index i and ending at index j-1 in a - * - * points are arrays of coordinates - * - * d = dj - di is the number of coordinates of each point - * - * - * __f__ is a template for a function {coordinates^2} -> {<0, =0, >0} named f - * - * i.e. for coordinates a and b - * - * f( a, b ) < 0 means a < b; - * f( a, b ) = 0 means a = b; - * f( a, b ) > 0 means a > b. - * - * out is the output array - * - */ - - var bdpdc = regeneratorRuntime.mark(function bdpdc(__f__, a, i, j, di, dj) { - var k, h, x, y, p, q, m, n, _m, _n; - - return regeneratorRuntime.wrap(function bdpdc$(context$4$0) { - while (1) switch (context$4$0.prev = context$4$0.next) { - case 0: - k = undefined, h = undefined, x = undefined, y = undefined, p = undefined, q = undefined, m = undefined, n = undefined, _m = undefined, _n = undefined; - - if (!(i >= j - 1)) { - context$4$0.next = 3; - break; - } - - return context$4$0.abrupt("return"); - - case 3: - if (!(di === dj)) { - context$4$0.next = 19; - break; - } - - // move all blue points left and all red points right - // (arbitrary choice) - - p = split(color, a, i, j); - - // for each red point - - x = p; - - case 6: - if (!(x < j)) { - context$4$0.next = 17; - break; - } - - y = i; - - case 8: - if (!(y < p)) { - context$4$0.next = 14; - break; - } - - context$4$0.next = 11; - return [a[x], a[y]]; - - case 11: - ++y; - context$4$0.next = 8; - break; - - case 14: - ++x; - context$4$0.next = 6; - break; - - case 17: - context$4$0.next = 32; - break; - - case 19: - - // ------------------------------------------------------- - // | b&r scrambled | - // ------------------------------------------------------- - // i j - - k = (i + j) / 2 | 0; - - // ------------------------------------------------------- - // | b&r scrambled | - // ------------------------------------------------------- - // i k j - - // select median element - // O(n) - - select(__f__(di), a, i, j, k); - - h = a[k][di]; - - // ------------------------------------------------------- - // | b&r <= h | h | b&r >= h | - // ------------------------------------------------------- - // i k j - - // we do 3 recursive calls - // - // first: for red and blue points with di < h in R^d - // we do not consider points with di = h because either - // - // 1. red = h, blue < h --> handled by last call - // 2. red < h, blue = h --> red cannot dominate blue - // 3. red = h, blue = h --> handled by last call - // (would be "red cannot dominate blue" for strict dominance - // in this 3rd case) - // - // second: for red and blue points with di > h in R^d - // we do not consider points with di = h for similar reasons as above - // - // last: for red points with di >= h and blue points with di <= h in R^{d-1} - // (would be > and < for strict dominance) - // - // note that we do not need to handle the case where red < h and blue >= h - // or red <= h and blue > h since red cannot dominate blue in those cases - - // first recursive call - // we only consider points that have di < h - // since all points that have di = h will be handled later - - // move median elements from [ i, k [ in the [ x, k [ interval, x >= i - // O(n) - - x = split(__eq__(di, h), a, i, k); - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r > h | - // ------------------------------------------------------- - // i x k j - - return context$4$0.delegateYield(bdpdc(__f__, a, i, x, di, dj), "t0", 24); - - case 24: - - // move median elements from [ k + 1, j [ in the [ y, j [ interval, y <= j - // O(n) - - y = split(__ne__(di, h), a, k + 1, j); - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i x k y j - - return context$4$0.delegateYield(bdpdc(__f__, a, y, j, di, dj), "t1", 26); - - case 26: - - // since we do not touch median elements in the first two - // recursive calls they are still at the correct place - - // Now we want to - // - move red points such that di < h to the right - // - move red points such that di >= h to the left - // - // /!\ Note that we also might think that we should - // - move blue points such that di > h to the right - // - move blue points such that di <= h to the left - // but after the selection algorithm this is already the case - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i x k y j - - p = split(color, a, i, x); - - // ------------------------------------------------------- - // | b < h | r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i p x k y j - - q = split(color, a, y, j); - - // ------------------------------------------------------- - // | b < h | r < h | b&r = h | h | b&r = h | b > h | r > h | - // ------------------------------------------------------- - // i p x k y q j - - // we now want to swap r < h elements with r > h elements - // we have 3 cases - // 1. x - p = j - q - // 2. x - p < j - q - // 3. x - p > j - q - - m = x - p; - n = j - q; - - // 1. x - p = j - q - - if (m === n) { - swap(a, q, j, a, p); - - // ------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | - // ------------------------------------------------------- - // i p x k y q j - - j = y; - - // ------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | - // ------------------------------------------------------- - // i p x k j ... - } - - // 2. x - p < j - q - - else if (m < n) { - - swap(a, p, x, a, q); - - // --------------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | r > h | - // --------------------------------------------------------------- - // i p x k y q q+m j - - // we now want to swap b > h and r < h elements with r > h elements - // [y,q[ [q,q+m[ [q+m,j[ - // we have 2 cases - // 1. (q + m) - y >= j - (q + m) [OR >] - // 2. (q + m) - y < j - (q + m) [OR <=] - - _m = q + m - y; - _n = j - (q + m); - - // 1. (q + m) - y >= j - (q + m) - if (_m >= _n) { - swap(a, q + m, j, a, y); - } - // 2. (q + m) - y < j - (q + m) - else { - swap(a, j - _m, j, a, y); - } - - // --------------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r h | b&r = h | h | b&r = h | r > h | b>h & r j - q - - else { - - swap(a, q, j, a, p); - - // --------------------------------------------------------------- - // | b < h | r > h | r < h | b&r = h | h | b&r = h | b > h | r < h | - // --------------------------------------------------------------- - // i p p+n x k y q j - - // we now want to swap r < h with b&r = h elements - // we have 2 cases - // 1. x - (p + n) >= y - x - // 2. x - (p + n) < y - x - - _m = x - (p + n); - _n = y - x; - - // 1. x - (p + n) >= y - x - if (_m >= _n) { - swap(a, x, y, a, p + n); - } - // 2. x - (p + n) < y - x - else { - swap(a, y - _m, y, a, p + n); - } - - // ----------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b>h & r h | b&r = h | h | b&r = h | b>h & r= h points - // in this new interval, all r points dominate b points - // for the ith coordinate - // we can thus ask the recursion fairy to take care of the other - // dj - di - 1 dimensions left - - return context$4$0.delegateYield(bdpdc(__f__, a, i, j, di + 1, dj), "t2", 32); - - case 32: - case "end": - return context$4$0.stop(); - } - }, bdpdc, this); - }); - - return bdpdc; - }; - - exports.__bdpdc__ = __bdpdc__; - - /* js/src/bdp/bdpdn2.js */ - - /** - * Bichromatic dominating pairs using a naïve O(d * n^2) algorithm. - * - * Here the algorithm handles non-strict ( >= ) dominance. - * - * color( point ) - * = 0 if point is blue - * = 1 if point is red - * - * p = split( predicate, a, i, j ) - * rearranges an array so that all elements for which predicate is false - * are in interval [i, p[ and all other elements are in interval [p, j[ - * - */ - - var __bdpdn2__ = function __bdpdn2__(color, split) { - - /** - * a is an array of points - * - * note that we only consider points starting - * at index i and ending at index j-1 in a - * - * points are arrays of coordinates - * - * d = dj - di is the number of coordinates of each point - * - * - * __f__ is a template for a function {coordinates^2} -> {<0, =0, >0} named f - * - * i.e. for coordinates a and b - * - * f( a, b ) < 0 means a < b; - * f( a, b ) = 0 means a = b; - * f( a, b ) > 0 means a > b. - * - */ - - var bdpdn2 = regeneratorRuntime.mark(function bdpdn2(__f__, a, i, j, di, dj) { - var x, y, p, d, f; - return regeneratorRuntime.wrap(function bdpdn2$(context$4$0) { - while (1) switch (context$4$0.prev = context$4$0.next) { - case 0: - x = undefined, y = undefined, p = undefined, d = undefined, f = undefined; - - if (!(i >= j - 1)) { - context$4$0.next = 3; - break; - } - - return context$4$0.abrupt("return"); - - case 3: - - // move all blue points left and all red points right - // (arbitrary choice) - - // [i, p[ contains only blue points - // [p, j[ contains only red points - // p = index of first red point - - p = split(color, a, i, j); - - // for each red point - - x = p; - - case 5: - if (!(x < j)) { - context$4$0.next = 24; - break; - } - - y = i; - - case 7: - if (!(y < p)) { - context$4$0.next = 21; - break; - } - - d = di; - - case 9: - if (!(d < dj)) { - context$4$0.next = 16; - break; - } - - f = __f__(d); - - if (!(f(a[x], a[y]) < 0)) { - context$4$0.next = 13; - break; - } - - return context$4$0.abrupt("continue", 18); - - case 13: - ++d; - context$4$0.next = 9; - break; - - case 16: - context$4$0.next = 18; - return [a[x], a[y]]; - - case 18: - ++y; - context$4$0.next = 7; - break; - - case 21: - ++x; - context$4$0.next = 5; - break; - - case 24: - case "end": - return context$4$0.stop(); - } - }, bdpdn2, this); - }); - - return bdpdn2; - }; - - exports.__bdpdn2__ = __bdpdn2__; - - /* js/src/birthdays */ - /* js/src/birthdays/samebirthday.js */ - - /** - * - * Computes the probability ( [0, 1] ) for at least 1 of k people - * out of n to have his birthday the same day as someone else. - * - * hypothesis : k <= n and k <= days - */ - - var samebirthday = function samebirthday(k, n, days) { - - var i, p; - - p = 1; - - for (i = 1; i < k; ++i) { - - p = p * (days - i) / days; - } - - for (; i < n; ++i) { - - p = p * (days - k) / days; - } - - return 1 - p; - }; - - exports.samebirthday = samebirthday; - - /* js/src/epsilon */ - /* js/src/epsilon/absepsilon.js */ - - var __absepsilon__ = function __absepsilon__(epsilon) { - - return function (a, b) { - - var r; - - r = a - b; - - return r < -epsilon ? -1 : r > epsilon ? 1 : 0; - }; - }; - - exports.__absepsilon__ = __absepsilon__; - - /* js/src/epsilon/relepsilon.js */ - - var __relepsilon__ = function __relepsilon__(epsilon) { - - return function (a, b) { - - var r; - - if (b === 0) { - return a; - } else if (a === 0) { - return -b; - } else { - - r = a / b - 1; - - return r < -epsilon ? -1 : r > epsilon ? 1 : 0; - } - }; - }; - - exports.__relepsilon__ = __relepsilon__; - - /* js/src/matroids */ - /* js/src/matroids/max_independent_set.js */ - - /** - * Greedy algorithm for computing the maximum independent set. - * For max-weight independent set give the input in decreasing order wrt weights. - */ - - var max_independent_set = function max_independent_set(independent, S) { - - var set = []; - - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - loop: for (var _iterator = S[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var u = _step.value; - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - - for (var _iterator2 = set[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var v = _step2.value; - - if (!independent(u, v)) continue loop; - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2["return"]) { - _iterator2["return"](); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - set.push(u); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator["return"]) { - _iterator["return"](); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - return set; - }; - - exports.max_independent_set = max_independent_set; - - /* js/src/minima */ - /* js/src/minima/clarkson.js */ - - /** - * Output sensitive inplace algorithm to find the minima set of a set S of - * elements according to some partial order. - * - * Uses at most 3nA comparisons where A is the cardinality of the minima set. - * - * For (1), at most nA comparisons are used since we compare each element of S - * with each elements of the minima set which is of cardinality at most A - * during the execution of the algorithm. - * - * For (2), for each executed loop we - * obtain a new minimum and increase the size of the constructed minima set by - * 1, hence there are at most A loops execution, each of which loops over at - * most n elements. (2) uses thus at most nA comparisons. - * - * The running time is dominated by the comparison time and thus the complexity - * of this algorihtm is O(nA). - * - * Description and context in - * ------------------------------------------ - * More Output-Sensitive Geometric Algorithms. - * -------------------- Kenneth L. Clarkson - - */ - - var clarkson = function clarkson(prec, a, i, j) { - - // - // This algorithms reorganizes the input array `a` as follows - // - elements that are minima are put at the front of `a` - // - other elements are put at the back of `a` - // - // During the algorithm, `a` looks like this - // - // ------------------------------------------------------ - // | minima set | candidate elements | discarded elements | - // ------------------------------------------------------ - // i min dis j - - var min, dis, k, inc, tmp; - - min = i; - dis = j - 1; - - // While there are candidate elements left. - - while (min <= dis) { - - // (1) Determine if the right-most candidate should be discarded because it - // is dominated by one of the minima elements of the minima set in - // construction. - - for (k = i; k < min && !prec(a[k], a[dis]); ++k); - - // If so, discard it. - - if (k < min) --dis; - - // (2) Otherwise, scan the candidates for a minimum. If at this point the - // candidate set is not empty, at least one of its elements must be a - // minimum. We scan the candidate list to find such a minimum. - - else { - - // Store the current minimum as the left-most candidate. - - tmp = a[dis]; - a[dis] = a[min]; - a[min] = tmp; - - // For each other candidate, right-to-left. - - for (inc = min + 1; inc <= dis;) { - - // If the current minimum precedes the right-most candidate, - // discard the right-most candidate. - - if (prec(a[min], a[dis])) --dis; - - // Else, if the right-most candidate precedes the current - // minimum, we can discard the current minimum and the - // right-most candidate becomes the current minimum. - - else if (prec(a[dis], a[min])) { - tmp = a[dis]; - a[dis] = a[min]; - a[min] = tmp; - --dis; - } - - // Otherwise, we save the candidate for the next round. - - else { - tmp = a[dis]; - a[dis] = a[inc]; - a[inc] = tmp; - ++inc; - } - } - - // The above loop selects a new minimum from the set of candidates - // and places it at position `min`. We now increase the `min` - // counter to move this minimum from the candidate list to the - // minima set. - - ++min; - } - } - - // The algorithm returns the outer right bound of the minima set a[i:min]. - - return min; - }; - - exports.clarkson = clarkson; - - /* js/src/reductions */ - /* js/src/reductions/chan.js */ - - /** - * Timoty Chan (1999) - * Geometric Applications of a Randomized Optimization Technique - * - * Translates any decision algorithm for a question of the type "is the optimal - * value for this problem less/greater than `c`?" to a randomized optimisation - * algortihm that finds the optimal value of `c*` whose expected time complexity - * is within a constant factor of the complexity of the decision algorithm. - * For this to work we must be capable of splitting a problem into a constant - * number of smaller (by a constant factor) subproblems so that the optimal - * value of the original problem is the min/max of the optimal values for the - * subproblems. For example, given a decision algorithm `decide( G , c )` - * that decides whether graph G has diameter greater than c, we can split the - * problem into k^2 subproblems of size (2n/k), that is, the diameter of G is - * the maximum over the diameters of all subgraphs that are the union of 2 - * disjoint subgraphs taken from a partition of G into k disjoint subgraphs of - * size n/k. Finding the optimal k for a given problem requires to solve a - * reccurence expressing the time-complexity of the following meta-algorithm. - * Read Timoty Chan's paper for more information. - */ - - var chan = function chan(split, shuffle, decide, bruteforce, issmall) { - - var solve = function solve(instance) { - - if (issmall(instance)) return bruteforce(instance); - - var _shuffle = shuffle(split(instance)); - - var _shuffle2 = _toArray(_shuffle); - - var first = _shuffle2[0]; - - var rest = _shuffle2.slice(1); - - var _solve = solve(first); - - var _solve2 = _slicedToArray(_solve, 2); - - var current = _solve2[0]; - var optimum = _solve2[1]; - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - - for (var _iterator3 = rest[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var candidate = _step3.value; - - if (decide(candidate, optimum)) { - var _solve3 = solve(candidate); - - var _solve32 = _slicedToArray(_solve3, 2); - - current = _solve32[0]; - optimum = _solve32[1]; - } - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3["return"]) { - _iterator3["return"](); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - return [current, optimum]; - }; - - return solve; - }; - - exports.chan = chan; - - /* js/src/reductions/kldt */ - /* js/src/reductions/kldt/evenkldtto2sum.js */ - - /** - * Transforms an instance of the one-set version of kLDT with k >= 4 even into - * a two-set version of 2SUM. - * - * @param {set} S is the input set for the kLDT problem - * @param {coefficients} a is the array of coefficients - * @param {set} A is one of the input set for 2SUM - * @param {set} B is one of the input set for 2SUM - * - * notes: - * - n = Sj - Si - * - k = aj - ai - 1 - * - a_0 = a[ai] - * - A and B must be of size n^(k/2) each - * - B must be initialized to 0 ... 0 - * - */ - - var evenkldtto2sum = function evenkldtto2sum(S, Si, Sj, a, ai, aj, A, Ai, Aj, B, Bi, Bj) { - - var i, j, p, q, n, halfk; - - n = Sj - Si; - - k = aj - ai - 1; - - halfk = 1 + k / 2; - - // We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , v , w , x , y ] - - // ----------------------------------------------------------------------- - // A <- | t | t | t | t | t | t | t | t | t | - // ----------------------------------------------------------------------- - - for (p = Ai; p < Aj; ++p) { - - A[p] = a[ai]; - } - - // ----------------------------------------------------------------------- - // A += | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // A += | w * 1 | w * 1 | w * 1 | w * 2 | w * 2 | w * 2 | w * 3 | w * 3 | w * 3 | - // ----------------------------------------------------------------------- - - for (j = 1, i = 1; j < halfk; ++j, i *= n) { - - for (p = Ai, q = 0; p < Aj; ++p, q = ((q + 1) / i | 0) % n) { - - A[p] += a[ai + j] * S[Si + q]; - } - } - - // ----------------------------------------------------------------------- - // B += | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // B += | y * 1 | y * 1 | y * 1 | y * 2 | y * 2 | y * 2 | y * 3 | y * 3 | y * 3 | - // ----------------------------------------------------------------------- - - for (i = 1; j <= k; ++j, i *= n) { - - for (p = Bi, q = 0; p < Bj; ++p, q = ((q + 1) / i | 0) % n) { - - B[p] += a[ai + j] * S[Si + q]; - } - } - }; - - exports.evenkldtto2sum = evenkldtto2sum; - - /* js/src/reductions/kldt/oddkldtto3sum.js */ - - /** - * Transforms an instance of the one-set version of kLDT with k >= 3 odd into - * a three-set version of 3SUM. - * - * @param {set} S is the input set for the kLDT problem - * @param {coefficients} a is the array of coefficients - * @param {set} A is one of the input set for 3SUM - * @param {set} B is one of the input set for 3SUM - * @param {set} C is one of the input set for 3SUM - * - * notes: - * - n = Sj - Si - * - k = aj - ai - 1 - * - a_0 = a[ai] - * - A and B must be of size n^((k-1)/2) each - * - A and B must be initialized to 0 ... 0 - * - C must be of size n - * - */ - - var oddkldtto3sum = function oddkldtto3sum(S, Si, Sj, a, ai, aj, A, Ai, Aj, B, Bi, Bj, C, Ci, Cj) { - - var i, j, p, q, n, halfk; - - n = Sj - Si; - - k = aj - ai - 1; - - halfk = 2 + (k - 1) / 2; - - // We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , u , v , w , x , y ] - - // ----------------------------------------------------------------------- - // A += | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // A += | w * 1 | w * 1 | w * 1 | w * 2 | w * 2 | w * 2 | w * 3 | w * 3 | w * 3 | - // ----------------------------------------------------------------------- - - for (j = 2, i = 1; j < halfk; ++j, i *= n) { - - for (p = Ai, q = 0; p < Aj; ++p, q = ((q + 1) / i | 0) % n) { - - A[p] += a[ai + j] * S[Si + q]; - } - } - - // ----------------------------------------------------------------------- - // B += | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // B += | y * 1 | y * 1 | y * 1 | y * 2 | y * 2 | y * 2 | y * 3 | y * 3 | y * 3 | - // ----------------------------------------------------------------------- - - for (i = 1; j <= k; ++j, i *= n) { - - for (p = Bi, q = 0; p < Bj; ++p, q = ((q + 1) / i | 0) % n) { - - B[p] += a[ai + j] * S[Si + q]; - } - } - - // We fill C - - // ----------------------------------- - // C <- | u * 1 + t | u * 2 + t | u * 3 + t | - // ----------------------------------- - - for (q = 0; q < n; ++q) { - - C[Ci + q] = a[ai + 1] * S[Si + q] + a[ai]; - } - }; - - exports.oddkldtto3sum = oddkldtto3sum; - - return exports; - }; - if (typeof exports === "object") { - definition(exports); - } else if (typeof define === "function" && define.amd) { - define("@aureooms/js-algorithms", [], function () { - return definition({}); - }); - } else if (typeof window === "object" && typeof window.document === "object") { - definition(window["algorithms"] = {}); - } else console.error("unable to detect type of module to define for @aureooms/js-algorithms"); -})(); - -// empty or one element array case - -// base case : dj - di = d = 0 -// enumerate all red / blue pairs -// [i, p[ contains only blue points -// [p, j[ contains only red points -// p = index of first red point - -// for each blue point - -/** - * recursion fairy - * - * we compute m such that h is the median of - * the ith coordinate of all points - * - */ - -// empty or one element array case - -// for each blue point \ No newline at end of file diff --git a/js/dist/algorithms.js.map b/js/dist/algorithms.js.map deleted file mode 100644 index 4bc92dc..0000000 --- a/js/dist/algorithms.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"js/dist/algorithms.js.map","sources":["js/dist/algorithms.js"],"names":["_toArray","arr","Array","isArray","from","_slicedToArray","sliceIterator","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","push","value","length","err","Object","TypeError","definition","exports","_3sum_n2","A","ai","aj","B","bi","bj","C","ci","cj","fn","hi","lo","a","b","c","v","sortxy_n3","compare","X","Y","Xi1","Xj1","Yi1","Yj1","Xi2","Xj2","Yi2","Yj2","output","d","s","sortxy_n4","fiter","j","biter","__bdpdc__","select","__eq__","__ne__","color","split","swap","bdpdc","regeneratorRuntime","mark","__f__","di","dj","k","h","x","y","p","q","m","n","_m","wrap","context$4$0","prev","abrupt","delegateYield","stop","this","__bdpdn2__","bdpdn2","f","samebirthday","days","__absepsilon__","epsilon","r","__relepsilon__","max_independent_set","independent","S","set","_iteratorNormalCompletion","_didIteratorError","_iteratorError","loop","_step","_iterator","u","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_step2","_iterator2","clarkson","prec","min","dis","inc","tmp","chan","shuffle","decide","bruteforce","issmall","solve","instance","_shuffle","_shuffle2","first","rest","slice","_solve","_solve2","current","optimum","_iteratorNormalCompletion3","_didIteratorError3","_iteratorError3","_step3","_iterator3","candidate","_solve3","_solve32","evenkldtto2sum","Si","Sj","Ai","Aj","Bi","Bj","halfk","oddkldtto3sum","Ci","Cj","define","amd","window","document","console","error"],"mappings":"AAAA,YAIA,SAASA,UAASC,GAAO,MAAOC,OAAMC,QAAQF,GAAOA,EAAMC,MAAME,KAAKH,GAFtE,GAAII,gBAAiB,WAAe,QAASC,GAAcL,EAAKM,GAAK,GAAIC,MAAeC,GAAK,EAAUC,GAAK,EAAWC,EAAKC,MAAW,KAAM,IAAK,GAAiCC,GAA7BC,EAAKb,EAAIc,OAAOC,cAAmBP,GAAMI,EAAKC,EAAGG,QAAQC,QAAoBV,EAAKW,KAAKN,EAAGO,QAAYb,GAAKC,EAAKa,SAAWd,GAA3DE,GAAK,IAAoE,MAAOa,GAAOZ,GAAK,EAAMC,EAAKW,EAAO,QAAU,KAAWb,GAAMK,EAAG,WAAWA,EAAG,YAAe,QAAU,GAAIJ,EAAI,KAAMC,IAAQ,MAAOH,GAAQ,MAAO,UAAUP,EAAKM,GAAK,GAAIL,MAAMC,QAAQF,GAAQ,MAAOA,EAAY,IAAIc,OAAOC,WAAYO,QAAOtB,GAAQ,MAAOK,GAAcL,EAAKM,EAAa,MAAM,IAAI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AAE0H,EAAK3E,GAAKzC,EAAEX,EAAK,GAAK0E,EAAE6C,EAAKnE,GAAKzC,EAAEX,GAMxC,OAFAH,GAAQiI,cAAgBA,EAEjBjI,EAEe,iBAAZA,SACVD,EAAWC,SACiB,kBAAXoI,SAAyBA,OAAOC,IACjDD,OAAO,4BAA8B,WACpC,MAAOrI,SAEoB,gBAAXuI,SAAkD,gBAApBA,QAAOC,SACtDxI,EAAWuI,OAAmB,eACxBE,QAAQC,MAAM"} \ No newline at end of file diff --git a/js/dist/algorithms.min.js b/js/dist/algorithms.min.js deleted file mode 100644 index 6e0eb80..0000000 --- a/js/dist/algorithms.min.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";function _toArray(r){return Array.isArray(r)?r:Array.from(r)}var _slicedToArray=function(){function r(r,e){var t=[],n=!0,a=!1,o=void 0;try{for(var i,u=r[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(f){a=!0,o=f}finally{try{!n&&u["return"]&&u["return"]()}finally{if(a)throw o}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();!function(){var r=function(r,e){var t=function(r,e,t,n,a,o,i,u,f,c){for(var s,l,v,d,y,b;f>u;++u){l=e,s=o-1;do v=r[l],d=n[s],y=i[u],b=v+d,-y===b&&c(v,d,y),b>-y?--s:++l;while(t>l&&s>=a)}};r._3sum_n2=t;var n=function _(r,e,t,n,a,o,i,u,f,c,s,l){var v,d,y,b,x;n>a||o>i||u>f||c>s||(v=e[n],d=t[i],y=e[f],b=t[c],x=r(v,d,y,b),0===x?(l(n,i,f,c),_(r,e,t,n+1,a,o,i,u,f,c,s,l),_(r,e,t,n,n,o,i-1,u,f,c,s,l),_(r,e,t,n,n,i,i,u,f-1,c,s,l)):0>x?(_(r,e,t,n+1,a,o,i,u,f,c,s,l),_(r,e,t,n,n,o,i,u,f-1,c,s,l)):(_(r,e,t,n,a,o,i-1,u,f,c,s,l),_(r,e,t,n,a,i,i,u,f,c+1,s,l)))};r.sortxy_n3=n;var a=function m(r,e,t,n,a,o,i,u,f,c,s,l){var v,d,y,b,x;n>a||o>i||u>f||c>s||(v=e[n],d=t[o],y=e[u],b=t[c],x=r(v,d,y,b),0===x&&l(n,o,u,c),m(r,e,t,n+1,a,o,i,u,f,c,s,l),m(r,e,t,n,n,o+1,i,u,f,c,s,l),m(r,e,t,n,n,o,o,u+1,f,c,s,l),m(r,e,t,n,n,o,o,u,u,c+1,s,l))};r.sortxy_n4=a;var o=function(r,e,t){for(;e>r;++r)t(r)},i=function(r,e,t){for(;--e>=r;)t(e)};r.fiter=o,r.biter=i;var u=function(r,t,n,a,o,i){var u=regeneratorRuntime.mark(function f(u,c,s,l,v,d){var y,b,x,_,k,m,p,h,w,g;return regeneratorRuntime.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(y=e,b=e,x=e,_=e,k=e,m=e,p=e,h=e,w=e,g=e,!(s>=l-1)){A.next=3;break}return A.abrupt("return");case 3:if(v!==d){A.next=19;break}k=o(a,c,s,l),x=k;case 6:if(!(l>x)){A.next=17;break}_=s;case 8:if(!(k>_)){A.next=14;break}return A.next=11,[c[x],c[_]];case 11:++_,A.next=8;break;case 14:++x,A.next=6;break;case 17:A.next=32;break;case 19:return y=(s+l)/2|0,r(u(v),c,s,l,y),b=c[y][v],x=o(t(v,b),c,s,y),A.delegateYield(f(u,c,s,x,v,d),"t0",24);case 24:return _=o(n(v,b),c,y+1,l),A.delegateYield(f(u,c,_,l,v,d),"t1",26);case 26:return k=o(a,c,s,x),m=o(a,c,_,l),p=x-k,h=l-m,p===h?(i(c,m,l,c,k),l=_):h>p?(i(c,k,x,c,m),w=m+p-_,g=l-(m+p),w>=g?i(c,m+p,l,c,_):i(c,l-w,l,c,_),l=_+g):(i(c,m,l,c,k),w=x-(k+h),g=_-x,w>=g?i(c,x,_,c,k+h):i(c,_-w,_,c,k+h),l=_-w),A.delegateYield(f(u,c,s,l,v+1,d),"t2",32);case 32:case"end":return A.stop()}},f,this)});return u};r.__bdpdc__=u;var f=function(r,t){var n=regeneratorRuntime.mark(function a(n,o,i,u,f,c){var s,l,v,d,y;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(s=e,l=e,v=e,d=e,y=e,!(i>=u-1)){a.next=3;break}return a.abrupt("return");case 3:v=t(r,o,i,u),s=v;case 5:if(!(u>s)){a.next=24;break}l=i;case 7:if(!(v>l)){a.next=21;break}d=f;case 9:if(!(c>d)){a.next=16;break}if(y=n(d),!(y(o[s],o[l])<0)){a.next=13;break}return a.abrupt("continue",18);case 13:++d,a.next=9;break;case 16:return a.next=18,[o[s],o[l]];case 18:++l,a.next=7;break;case 21:++s,a.next=5;break;case 24:case"end":return a.stop()}},a,this)});return n};r.__bdpdn2__=f;var c=function(r,e,t){var n,a;for(a=1,n=1;r>n;++n)a=a*(t-n)/t;for(;e>n;++n)a=a*(t-r)/t;return 1-a};r.samebirthday=c;var s=function(r){return function(e,t){var n;return n=e-t,-r>n?-1:n>r?1:0}};r.__absepsilon__=s;var l=function(r){return function(e,t){var n;return 0===t?e:0===e?-t:(n=e/t-1,-r>n?-1:n>r?1:0)}};r.__relepsilon__=l;var v=function(r,t){var n=[],a=!0,o=!1,i=e;try{r:for(var u,f=t[Symbol.iterator]();!(a=(u=f.next()).done);a=!0){var c=u.value,s=!0,l=!1,v=e;try{for(var d,y=n[Symbol.iterator]();!(s=(d=y.next()).done);s=!0){var b=d.value;if(!r(c,b))continue r}}catch(x){l=!0,v=x}finally{try{!s&&y["return"]&&y["return"]()}finally{if(l)throw v}}n.push(c)}}catch(x){o=!0,i=x}finally{try{!a&&f["return"]&&f["return"]()}finally{if(o)throw i}}return n};r.max_independent_set=v;var d=function(r,e,t,n){var a,o,i,u,f;for(a=t,o=n-1;o>=a;){for(i=t;a>i&&!r(e[i],e[o]);++i);if(a>i)--o;else{for(f=e[o],e[o]=e[a],e[a]=f,u=a+1;o>=u;)r(e[a],e[o])?--o:r(e[o],e[a])?(f=e[o],e[o]=e[a],e[a]=f,--o):(f=e[o],e[o]=e[u],e[u]=f,++u);++a}}return a};r.clarkson=d;var y=function(r,t,n,a,o){var i=function u(i){if(o(i))return a(i);var f=t(r(i)),c=_toArray(f),s=c[0],l=c.slice(1),v=u(s),d=_slicedToArray(v,2),y=d[0],b=d[1],x=!0,_=!1,k=e;try{for(var m,p=l[Symbol.iterator]();!(x=(m=p.next()).done);x=!0){var h=m.value;if(n(h,b)){var w=u(h),g=_slicedToArray(w,2);y=g[0],b=g[1]}}}catch(A){_=!0,k=A}finally{try{!x&&p["return"]&&p["return"]()}finally{if(_)throw k}}return[y,b]};return i};r.chan=y;var b=function(r,e,t,n,a,o,i,u,f,c,s,l){var v,d,y,b,x,_;for(x=t-e,k=o-a-1,_=1+k/2,y=u;f>y;++y)i[y]=n[a];for(d=1,v=1;_>d;++d,v*=x)for(y=u,b=0;f>y;++y,b=((b+1)/v|0)%x)i[y]+=n[a+d]*r[e+b];for(v=1;d<=k;++d,v*=x)for(y=s,b=0;l>y;++y,b=((b+1)/v|0)%x)c[y]+=n[a+d]*r[e+b]};r.evenkldtto2sum=b;var x=function(r,e,t,n,a,o,i,u,f,c,s,l,v,d,y){var b,x,_,m,p,h;for(p=t-e,k=o-a-1,h=2+(k-1)/2,x=2,b=1;h>x;++x,b*=p)for(_=u,m=0;f>_;++_,m=((m+1)/b|0)%p)i[_]+=n[a+x]*r[e+m];for(b=1;x<=k;++x,b*=p)for(_=s,m=0;l>_;++_,m=((m+1)/b|0)%p)c[_]+=n[a+x]*r[e+m];for(m=0;p>m;++m)v[d+m]=n[a+1]*r[e+m]+n[a]};return r.oddkldtto3sum=x,r};"object"==typeof exports?r(exports):"function"==typeof define&&define.amd?define("@aureooms/js-algorithms",[],function(){return r({})}):"object"==typeof window&&"object"==typeof window.document?r(window.algorithms={}):console.error("unable to detect type of module to define for @aureooms/js-algorithms")}(); -//# sourceMappingURL=js/dist/algorithms.js.map \ No newline at end of file diff --git a/js/index.js b/js/index.js deleted file mode 100644 index e6e928c..0000000 --- a/js/index.js +++ /dev/null @@ -1,15 +0,0 @@ -var pkg = require('aureooms-node-package'); - -var fs = require('fs'); -var data = fs.readFileSync(pkg.config, 'utf8'); -var opt = JSON.parse(data); - -opt = { - name : opt.name, - src : __dirname + '/src/', - exports : module.exports, - base : 0, - debug : opt.debug -}; - -pkg.include(opt); diff --git a/js/src/3sum/_3sum_n2.js b/js/src/3sum/_3sum_n2.js deleted file mode 100644 index 6de6ea7..0000000 --- a/js/src/3sum/_3sum_n2.js +++ /dev/null @@ -1,36 +0,0 @@ - - -/** - * Hypothesis : - * - A is sorted in increasing order - * - B is sorted in increasing order - * - |A| > 0 - * - |B| > 0 - */ - -var _3sum_n2 = function (A, ai, aj, B, bi, bj, C, ci, cj, fn) { - - var hi, lo, a, b, c, v; - - for (; ci < cj; ++ci) { - lo = ai; - hi = bj - 1; - - do { - - a = A[lo]; - b = B[hi]; - c = C[ci]; - v = a + b; - - if (-c === v) fn(a, b, c); - - if (-c < v) --hi; - else ++lo; - - } while (lo < aj && hi >= bi); - } - -}; - -exports._3sum_n2 = _3sum_n2; \ No newline at end of file diff --git a/js/src/4sum/sortxy_n3.js b/js/src/4sum/sortxy_n3.js deleted file mode 100644 index a4373ea..0000000 --- a/js/src/4sum/sortxy_n3.js +++ /dev/null @@ -1,61 +0,0 @@ - -/** - * X is sorted in increasing order - * Y is sorted in increasing order - * compare takes 4 arguments and returns <=> 0 - * output takes 4 arguments - * - */ -var sortxy_n3 = function ( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) { - - var a , b , c , d , s ; - - if ( Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2 ) { - return ; - } - - // ----------------------------- - // | X | - // ----------------------------- - // Xi Xj - - // ----------------------------- - // | Y | - // ----------------------------- - // Yi Yj - - a = X[Xi1] ; - b = Y[Yj1] ; - c = X[Xj2] ; - d = Y[Yi2] ; - - s = compare( a , b , c , d ) ; - - if ( s === 0 ) { - - output( Xi1 , Yj1 , Xj2 , Yi2 ) ; - - sortxy_n3( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yi1 , Yj1 - 1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yj1 , Yj1 , Xi2 , Xj2 - 1 , Yi2 , Yj2 , output ) ; - - } - - else if ( s < 0 ) { - - sortxy_n3( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n3( compare , X , Y , Xi1 , Xi1 , Yi1 , Yj1 , Xi2 , Xj2 - 1 , Yi2 , Yj2 , output ) ; - - } - - else { - - sortxy_n3( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 - 1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n3( compare , X , Y , Xi1 , Xj1 , Yj1 , Yj1 , Xi2 , Xj2 , Yi2 + 1 , Yj2 , output ) ; - - } - - -} ; - -exports.sortxy_n3 = sortxy_n3 ; diff --git a/js/src/4sum/sortxy_n4.js b/js/src/4sum/sortxy_n4.js deleted file mode 100644 index 6bd2972..0000000 --- a/js/src/4sum/sortxy_n4.js +++ /dev/null @@ -1,47 +0,0 @@ - -/** - * X is sorted in increasing order - * Y is sorted in increasing order - * compare takes 4 arguments and returns <=> 0 - * output takes 4 arguments - * - */ -var sortxy_n4 = function ( compare , X , Y , Xi1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) { - - var a , b , c , d , s ; - - if ( Xi1 > Xj1 || Yi1 > Yj1 || Xi2 > Xj2 || Yi2 > Yj2 ) { - return ; - } - - // ----------------------------- - // | X | - // ----------------------------- - // Xi Xj - - // ----------------------------- - // | Y | - // ----------------------------- - // Yi Yj - - a = X[Xi1] ; - b = Y[Yi1] ; - c = X[Xi2] ; - d = Y[Yi2] ; - - s = compare( a , b , c , d ) ; - - if ( s === 0 ) { - - output( Xi1 , Yi1 , Xi2 , Yi2 ) ; - - } - - sortxy_n4( compare , X , Y , Xi1 + 1 , Xj1 , Yi1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 + 1 , Yj1 , Xi2 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 , Yi1 , Xi2 + 1 , Xj2 , Yi2 , Yj2 , output ) ; - sortxy_n4( compare , X , Y , Xi1 , Xi1 , Yi1 , Yi1 , Xi2 , Xi2 , Yi2 + 1 , Yj2 , output ) ; - -} ; - -exports.sortxy_n4 = sortxy_n4 ; diff --git a/js/src/array/iter.js b/js/src/array/iter.js deleted file mode 100644 index c24c851..0000000 --- a/js/src/array/iter.js +++ /dev/null @@ -1,19 +0,0 @@ - - - -var fiter = function ( i, j, fn ) { - for ( ; i < j ; ++i ) { - fn( i ); - } -}; - -var biter = function ( i, j, fn ) { - while ( --j >= i ) { - fn( j ); - } -}; - - - -exports.fiter = fiter; -exports.biter = biter; diff --git a/js/src/bdp/bdpdc.js b/js/src/bdp/bdpdc.js deleted file mode 100644 index 91cc787..0000000 --- a/js/src/bdp/bdpdc.js +++ /dev/null @@ -1,351 +0,0 @@ - -/** - * Bichromatic dominating pairs using the divide and conquer chainsaw. - * - * see F. P. Preparata and M. I. Shamos, Computational Geometry, NY, 1985, p. 366. - * - * Here the algorithm handles non-strict ( >= ) dominance. - * - * select( f, a, i, j, k ) where - * f is a comparator - * a the array of points - * [i, j[ the range to search in the array - * k the index to select - * - * select(...) partitions the array in tree regions - * ----------------------------- - * | <= h | h | >= h | - * ----------------------------- - * i .... k k+1 .... j-1 - * - * __eq__( d, v ) template for a function eq( a ) - * returns true iff coordinate d of a equals v - * - * __ne__( d, v ) template for a function ne( y ) - * returns true iff coordinate d of a is not equal to v - * - * color( point ) - * = 0 if point is blue - * = 1 if point is red - * - * p = split( predicate, a, i, j ) - * rearranges an array so that all elements for which predicate is false - * are in interval [i, p[ and all other elements are in interval [p, j[ - * - * swap( a, ai, aj, b, bi ) - * swap elements from a in interval [ai, aj[ with elements from b in interval - * [bi, bi + aj - ai[ - * - */ - - -let __bdpdc__ = function ( select, __eq__, __ne__, color, split, swap ) { - - /** - * a is an array of points - * - * note that we only consider points starting - * at index i and ending at index j-1 in a - * - * points are arrays of coordinates - * - * d = dj - di is the number of coordinates of each point - * - * - * __f__ is a template for a function {coordinates^2} -> {<0, =0, >0} named f - * - * i.e. for coordinates a and b - * - * f( a, b ) < 0 means a < b; - * f( a, b ) = 0 means a = b; - * f( a, b ) > 0 means a > b. - * - * out is the output array - * - */ - - let bdpdc = function* ( __f__, a, i, j, di, dj ) { - - let k, h, x, y, p, q, m, n, _m, _n; - - // empty or one element array case - - if ( i >= j - 1 ) return ; - - // base case : dj - di = d = 0 - // enumerate all red / blue pairs - // [i, p[ contains only blue points - // [p, j[ contains only red points - // p = index of first red point - - if ( di === dj ) { - - // move all blue points left and all red points right - // (arbitrary choice) - - p = split( color, a, i, j ); - - // for each red point - - for ( x = p ; x < j ; ++x ) { - - // for each blue point - - for ( y = i ; y < p ; ++y ) { - - yield [ a[x], a[y] ] ; - - } - } - - } - - /** - * recursion fairy - * - * we compute m such that h is the median of - * the ith coordinate of all points - * - */ - - else { - - - // ------------------------------------------------------- - // | b&r scrambled | - // ------------------------------------------------------- - // i j - - k = ( i + j ) / 2 | 0; - - // ------------------------------------------------------- - // | b&r scrambled | - // ------------------------------------------------------- - // i k j - - // select median element - // O(n) - - select( __f__( di ), a, i, j, k ); - - h = a[k][di]; - - // ------------------------------------------------------- - // | b&r <= h | h | b&r >= h | - // ------------------------------------------------------- - // i k j - - - // we do 3 recursive calls - // - // first: for red and blue points with di < h in R^d - // we do not consider points with di = h because either - // - // 1. red = h, blue < h --> handled by last call - // 2. red < h, blue = h --> red cannot dominate blue - // 3. red = h, blue = h --> handled by last call - // (would be "red cannot dominate blue" for strict dominance - // in this 3rd case) - // - // second: for red and blue points with di > h in R^d - // we do not consider points with di = h for similar reasons as above - // - // last: for red points with di >= h and blue points with di <= h in R^{d-1} - // (would be > and < for strict dominance) - // - // note that we do not need to handle the case where red < h and blue >= h - // or red <= h and blue > h since red cannot dominate blue in those cases - - // first recursive call - // we only consider points that have di < h - // since all points that have di = h will be handled later - - // move median elements from [ i, k [ in the [ x, k [ interval, x >= i - // O(n) - - x = split( __eq__( di, h ), a, i, k ); - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r > h | - // ------------------------------------------------------- - // i x k j - - yield* bdpdc( __f__, a, i, x, di, dj ); - - // move median elements from [ k + 1, j [ in the [ y, j [ interval, y <= j - // O(n) - - y = split( __ne__( di, h ), a, k + 1, j ); - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i x k y j - - yield* bdpdc( __f__, a, y, j, di, dj ); - - // since we do not touch median elements in the first two - // recursive calls they are still at the correct place - - // Now we want to - // - move red points such that di < h to the right - // - move red points such that di >= h to the left - // - // /!\ Note that we also might think that we should - // - move blue points such that di > h to the right - // - move blue points such that di <= h to the left - // but after the selection algorithm this is already the case - - - // ------------------------------------------------------- - // | b&r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i x k y j - - p = split( color, a, i, x ); - - // ------------------------------------------------------- - // | b < h | r < h | b&r = h | h | b&r = h | b&r > h | - // ------------------------------------------------------- - // i p x k y j - - q = split( color, a, y, j ); - - // ------------------------------------------------------- - // | b < h | r < h | b&r = h | h | b&r = h | b > h | r > h | - // ------------------------------------------------------- - // i p x k y q j - - // we now want to swap r < h elements with r > h elements - // we have 3 cases - // 1. x - p = j - q - // 2. x - p < j - q - // 3. x - p > j - q - - m = x - p; - n = j - q; - - - // 1. x - p = j - q - - if ( m === n ) { - swap( a, q, j, a, p ); - - // ------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | - // ------------------------------------------------------- - // i p x k y q j - - j = y; - - // ------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | - // ------------------------------------------------------- - // i p x k j ... - - } - - - // 2. x - p < j - q - - else if ( m < n ) { - - swap( a, p, x, a, q ); - - // --------------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b > h | r < h | r > h | - // --------------------------------------------------------------- - // i p x k y q q+m j - - // we now want to swap b > h and r < h elements with r > h elements - // [y,q[ [q,q+m[ [q+m,j[ - // we have 2 cases - // 1. (q + m) - y >= j - (q + m) [OR >] - // 2. (q + m) - y < j - (q + m) [OR <=] - - _m = (q + m) - y; - _n = j - (q + m); - - // 1. (q + m) - y >= j - (q + m) - if ( _m >= _n ) { - swap( a, q + m, j, a, y ); - } - // 2. (q + m) - y < j - (q + m) - else { - swap( a, j - _m, j, a, y ); - } - - // --------------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | r > h | b>h & r h | b&r = h | h | b&r = h | r > h | b>h & r j - q - - else { - - swap( a, q, j, a, p ); - - // --------------------------------------------------------------- - // | b < h | r > h | r < h | b&r = h | h | b&r = h | b > h | r < h | - // --------------------------------------------------------------- - // i p p+n x k y q j - - // we now want to swap r < h with b&r = h elements - // we have 2 cases - // 1. x - (p + n) >= y - x - // 2. x - (p + n) < y - x - - _m = x - (p + n); - _n = y - x; - - // 1. x - (p + n) >= y - x - if ( _m >= _n ) { - swap( a, x, y, a, p + n ); - } - // 2. x - (p + n) < y - x - else { - swap( a, y - _m, y, a, p + n ); - } - - // ----------------------------------------------------------- - // | b < h | r > h | b&r = h | h | b&r = h | b>h & r h | b&r = h | h | b&r = h | b>h & r= h points - // in this new interval, all r points dominate b points - // for the ith coordinate - // we can thus ask the recursion fairy to take care of the other - // dj - di - 1 dimensions left - - yield* bdpdc( __f__, a, i, j, di + 1, dj ); - - } - - }; - - return bdpdc; - -}; - -exports.__bdpdc__ = __bdpdc__; diff --git a/js/src/bdp/bdpdn2.js b/js/src/bdp/bdpdn2.js deleted file mode 100644 index d825529..0000000 --- a/js/src/bdp/bdpdn2.js +++ /dev/null @@ -1,87 +0,0 @@ - -/** - * Bichromatic dominating pairs using a naïve O(d * n^2) algorithm. - * - * Here the algorithm handles non-strict ( >= ) dominance. - * - * color( point ) - * = 0 if point is blue - * = 1 if point is red - * - * p = split( predicate, a, i, j ) - * rearranges an array so that all elements for which predicate is false - * are in interval [i, p[ and all other elements are in interval [p, j[ - * - */ - - -let __bdpdn2__ = function ( color, split ) { - - /** - * a is an array of points - * - * note that we only consider points starting - * at index i and ending at index j-1 in a - * - * points are arrays of coordinates - * - * d = dj - di is the number of coordinates of each point - * - * - * __f__ is a template for a function {coordinates^2} -> {<0, =0, >0} named f - * - * i.e. for coordinates a and b - * - * f( a, b ) < 0 means a < b; - * f( a, b ) = 0 means a = b; - * f( a, b ) > 0 means a > b. - * - */ - - let bdpdn2 = function* ( __f__, a, i, j, di, dj ) { - - let x, y, p, d, f; - - // empty or one element array case - - if ( i >= j - 1 ) return ; - - // move all blue points left and all red points right - // (arbitrary choice) - - // [i, p[ contains only blue points - // [p, j[ contains only red points - // p = index of first red point - - p = split( color, a, i, j ); - - // for each red point - - red : for ( x = p ; x < j ; ++x ) { - - // for each blue point - - blue : for ( y = i ; y < p ; ++y ) { - - for ( d = di ; d < dj ; ++d ) { - - f = __f__( d ); - - if ( f( a[x], a[y] ) < 0 ) { - continue blue; - } - - } - - yield [ a[x], a[y] ] ; - - } - } - - }; - - return bdpdn2; - -}; - -exports.__bdpdn2__ = __bdpdn2__; diff --git a/js/src/birthdays/samebirthday.js b/js/src/birthdays/samebirthday.js deleted file mode 100644 index 4fade14..0000000 --- a/js/src/birthdays/samebirthday.js +++ /dev/null @@ -1,34 +0,0 @@ - - -/** - * - * Computes the probability ( [0, 1] ) for at least 1 of k people - * out of n to have his birthday the same day as someone else. - * - * hypothesis : k <= n and k <= days - */ - -var samebirthday = function ( k, n, days ) { - - var i, p; - - p = 1; - - for ( i = 1 ; i < k ; ++i ) { - - p = p * ( days - i ) / days; - - } - - for ( ; i < n ; ++i ) { - - p = p * ( days - k ) / days; - - } - - - return 1 - p; - -}; - -exports.samebirthday = samebirthday; diff --git a/js/src/matroids/max_independent_set.js b/js/src/matroids/max_independent_set.js deleted file mode 100644 index 699572b..0000000 --- a/js/src/matroids/max_independent_set.js +++ /dev/null @@ -1,25 +0,0 @@ - -/** - * Greedy algorithm for computing the maximum independent set. - * For max-weight independent set give the input in decreasing order wrt weights. - */ - -const max_independent_set = function ( independent , S ) { - - const set = [ ] ; - - loop : for ( const u of S ) { - - for ( const v of set ) { - if ( !independent( u , v ) ) continue loop ; - } - - set.push( u ) ; - - } - - return set ; - -} ; - -exports.max_independent_set = max_independent_set ; diff --git a/js/src/reductions/chan.js b/js/src/reductions/chan.js deleted file mode 100644 index 7bf26d5..0000000 --- a/js/src/reductions/chan.js +++ /dev/null @@ -1,49 +0,0 @@ - -/** - * Timoty Chan (1999) - * Geometric Applications of a Randomized Optimization Technique - * - * Translates any decision algorithm for a question of the type "is the optimal - * value for this problem less/greater than `c`?" to a randomized optimisation - * algortihm that finds the optimal value of `c*` whose expected time complexity - * is within a constant factor of the complexity of the decision algorithm. - * For this to work we must be capable of splitting a problem into a constant - * number of smaller (by a constant factor) subproblems so that the optimal - * value of the original problem is the min/max of the optimal values for the - * subproblems. For example, given a decision algorithm `decide( G , c )` - * that decides whether graph G has diameter greater than c, we can split the - * problem into k^2 subproblems of size (2n/k), that is, the diameter of G is - * the maximum over the diameters of all subgraphs that are the union of 2 - * disjoint subgraphs taken from a partition of G into k disjoint subgraphs of - * size n/k. Finding the optimal k for a given problem requires to solve a - * reccurence expressing the time-complexity of the following meta-algorithm. - * Read Timoty Chan's paper for more information. - */ - -const chan = function ( split , shuffle , decide , bruteforce , issmall ) { - - const solve = function ( instance ) { - - if ( issmall( instance ) ) return bruteforce( instance ) ; - - const [ first , ...rest ] = shuffle( split( instance ) ) ; - - let [ current , optimum ] = solve( first ) ; - - for ( const candidate of rest ) { - - if ( decide( candidate , optimum ) ) { - [ current , optimum ] = solve( candidate ) ; - } - - } - - return [ current , optimum ] ; - - } ; - - return solve ; - -} ; - -exports.chan = chan ; diff --git a/js/src/reductions/kldt/evenkldtto2sum.js b/js/src/reductions/kldt/evenkldtto2sum.js deleted file mode 100644 index 24a00d7..0000000 --- a/js/src/reductions/kldt/evenkldtto2sum.js +++ /dev/null @@ -1,79 +0,0 @@ - - -/** - * Transforms an instance of the one-set version of kLDT with k >= 4 even into - * a two-set version of 2SUM. - * - * @param {set} S is the input set for the kLDT problem - * @param {coefficients} a is the array of coefficients - * @param {set} A is one of the input set for 2SUM - * @param {set} B is one of the input set for 2SUM - * - * notes: - * - n = Sj - Si - * - k = aj - ai - 1 - * - a_0 = a[ai] - * - A and B must be of size n^(k/2) each - * - B must be initialized to 0 ... 0 - * - */ - -var evenkldtto2sum = function ( S , Si , Sj , a , ai , aj , A , Ai , Aj , B , Bi , Bj ) { - - var i , j , p , q , n , halfk ; - - n = Sj - Si ; - - k = aj - ai - 1 ; - - halfk = 1 + k / 2 ; - - // We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , v , w , x , y ] - - // ----------------------------------------------------------------------- - // A <- | t | t | t | t | t | t | t | t | t | - // ----------------------------------------------------------------------- - - for ( p = Ai ; p < Aj ; ++p ) { - - A[p] = a[ai] ; - - } - - // ----------------------------------------------------------------------- - // A += | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // A += | w * 1 | w * 1 | w * 1 | w * 2 | w * 2 | w * 2 | w * 3 | w * 3 | w * 3 | - // ----------------------------------------------------------------------- - - for ( j = 1 , i = 1 ; j < halfk ; ++j , i *= n ) { - - for ( p = Ai , q = 0 ; p < Aj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { - - A[p] += a[ai + j] * S[Si + q] ; - - } - - } - - // ----------------------------------------------------------------------- - // B += | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // B += | y * 1 | y * 1 | y * 1 | y * 2 | y * 2 | y * 2 | y * 3 | y * 3 | y * 3 | - // ----------------------------------------------------------------------- - - for ( i = 1 ; j <= k ; ++j , i *= n ) { - - for ( p = Bi , q = 0 ; p < Bj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { - - B[p] += a[ai + j] * S[Si + q] ; - - } - - } - -} ; - -exports.evenkldtto2sum = evenkldtto2sum; diff --git a/js/src/reductions/kldt/oddkldtto3sum.js b/js/src/reductions/kldt/oddkldtto3sum.js deleted file mode 100644 index 3b1b2cb..0000000 --- a/js/src/reductions/kldt/oddkldtto3sum.js +++ /dev/null @@ -1,83 +0,0 @@ - - -/** - * Transforms an instance of the one-set version of kLDT with k >= 3 odd into - * a three-set version of 3SUM. - * - * @param {set} S is the input set for the kLDT problem - * @param {coefficients} a is the array of coefficients - * @param {set} A is one of the input set for 3SUM - * @param {set} B is one of the input set for 3SUM - * @param {set} C is one of the input set for 3SUM - * - * notes: - * - n = Sj - Si - * - k = aj - ai - 1 - * - a_0 = a[ai] - * - A and B must be of size n^((k-1)/2) each - * - A and B must be initialized to 0 ... 0 - * - C must be of size n - * - */ - -var oddkldtto3sum = function ( S , Si , Sj , a , ai , aj , A , Ai , Aj , B , Bi , Bj , C , Ci , Cj ) { - - var i , j , p , q , n , halfk ; - - n = Sj - Si ; - - k = aj - ai - 1 ; - - halfk = 2 + ( k - 1 ) / 2 ; - - // We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , u , v , w , x , y ] - - // ----------------------------------------------------------------------- - // A += | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | v * 1 | v * 2 | v * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // A += | w * 1 | w * 1 | w * 1 | w * 2 | w * 2 | w * 2 | w * 3 | w * 3 | w * 3 | - // ----------------------------------------------------------------------- - - for ( j = 2 , i = 1 ; j < halfk ; ++j , i *= n ) { - - for ( p = Ai , q = 0 ; p < Aj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { - - A[p] += a[ai + j] * S[Si + q] ; - - } - - } - - // ----------------------------------------------------------------------- - // B += | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | x * 1 | x * 2 | x * 3 | - // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- - // B += | y * 1 | y * 1 | y * 1 | y * 2 | y * 2 | y * 2 | y * 3 | y * 3 | y * 3 | - // ----------------------------------------------------------------------- - - for ( i = 1 ; j <= k ; ++j , i *= n ) { - - for ( p = Bi , q = 0 ; p < Bj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { - - B[p] += a[ai + j] * S[Si + q] ; - - } - - } - - // We fill C - - // ----------------------------------- - // C <- | u * 1 + t | u * 2 + t | u * 3 + t | - // ----------------------------------- - - for ( q = 0 ; q < n ; ++q ) { - - C[Ci + q] = a[ai + 1] * S[Si + q] + a[ai] ; - - } - -} ; - -exports.oddkldtto3sum = oddkldtto3sum; diff --git a/kldt/evenkldtto2sum.html b/kldt/evenkldtto2sum.html new file mode 100644 index 0000000..6a1cec8 --- /dev/null +++ b/kldt/evenkldtto2sum.html @@ -0,0 +1,52 @@ +kldt/evenkldtto2sum

      Transforms an instance of the one-set version of kLDT with k >= 4 even into +a two-set version of 2SUM.

      +

      Parameters:

      +
        +
      • S must be a set.
        (is the input set for the kLDT problem)

        +
      • +
      • a must be a coefficients.
        (is the array of coefficients)

        +
      • +
      • A must be a set.
        (is one of the input set for 2SUM)

        +
      • +
      • B must be a set.
        (is one of the input set for 2SUM notes: - n = Sj - Si - k = aj - ai - 1 - a_0 = a[ai] - A and B must be of size n^(k/2) each - B must be initialized to 0 ... 0)

        +
      • +
      var evenkldtto2sum = function ( S , Si , Sj , a , ai , aj , A , Ai , Aj , B , Bi , Bj ) { + + var i , j , p , q , n , halfk ; + + n = Sj - Si ; + + k = aj - ai - 1 ; + + halfk = 1 + k / 2 ;

      We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , v , w , x , y ]

        -----------------------------------------------------------------------
      +

      A <- | t | t | t | t | t | t | t | t | t |

      for ( p = Ai ; p < Aj ; ++p ) { + + A[p] = a[ai] ; + + }
        -----------------------------------------------------------------------
      +

      A += | v 1 | v 2 | v 3 | v 1 | v 2 | v 3 | v 1 | v 2 | v * 3 |

      +
        -----------------------------------------------------------------------
      +

      A += | w 1 | w 1 | w 1 | w 2 | w 2 | w 2 | w 3 | w 3 | w * 3 |

      for ( j = 1 , i = 1 ; j < halfk ; ++j , i *= n ) { + + for ( p = Ai , q = 0 ; p < Aj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { + + A[p] += a[ai + j] * S[Si + q] ; + + } + + }
        -----------------------------------------------------------------------
      +

      B += | x 1 | x 2 | x 3 | x 1 | x 2 | x 3 | x 1 | x 2 | x * 3 |

      +
        -----------------------------------------------------------------------
      +

      B += | y 1 | y 1 | y 1 | y 2 | y 2 | y 2 | y 3 | y 3 | y * 3 |

      for ( i = 1 ; j <= k ; ++j , i *= n ) { + + for ( p = Bi , q = 0 ; p < Bj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { + + B[p] += a[ai + j] * S[Si + q] ; + + } + + } + +} ; + +exports.evenkldtto2sum = evenkldtto2sum;
      \ No newline at end of file diff --git a/kldt/oddkldtto3sum.html b/kldt/oddkldtto3sum.html new file mode 100644 index 0000000..4649240 --- /dev/null +++ b/kldt/oddkldtto3sum.html @@ -0,0 +1,54 @@ +kldt/oddkldtto3sum

      Transforms an instance of the one-set version of kLDT with k >= 3 odd into +a three-set version of 3SUM.

      +

      Parameters:

      +
        +
      • S must be a set.
        (is the input set for the kLDT problem)

        +
      • +
      • a must be a coefficients.
        (is the array of coefficients)

        +
      • +
      • A must be a set.
        (is one of the input set for 3SUM)

        +
      • +
      • B must be a set.
        (is one of the input set for 3SUM)

        +
      • +
      • C must be a set.
        (is one of the input set for 3SUM notes: - n = Sj - Si - k = aj - ai - 1 - a_0 = a[ai] - A and B must be of size n^((k-1)/2) each - A and B must be initialized to 0 ... 0 - C must be of size n)

        +
      • +
      var oddkldtto3sum = function ( S , Si , Sj , a , ai , aj , A , Ai , Aj , B , Bi , Bj , C , Ci , Cj ) { + + var i , j , p , q , n , halfk ; + + n = Sj - Si ; + + k = aj - ai - 1 ; + + halfk = 2 + ( k - 1 ) / 2 ;

      We fill A and B for example with S = [ 1 , 2 , 3 ] and a = [ t , u , v , w , x , y ]

        -----------------------------------------------------------------------
      +

      A += | v 1 | v 2 | v 3 | v 1 | v 2 | v 3 | v 1 | v 2 | v * 3 |

      +
        -----------------------------------------------------------------------
      +

      A += | w 1 | w 1 | w 1 | w 2 | w 2 | w 2 | w 3 | w 3 | w * 3 |

      for ( j = 2 , i = 1 ; j < halfk ; ++j , i *= n ) { + + for ( p = Ai , q = 0 ; p < Aj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { + + A[p] += a[ai + j] * S[Si + q] ; + + } + + }
        -----------------------------------------------------------------------
      +

      B += | x 1 | x 2 | x 3 | x 1 | x 2 | x 3 | x 1 | x 2 | x * 3 |

      +
        -----------------------------------------------------------------------
      +

      B += | y 1 | y 1 | y 1 | y 2 | y 2 | y 2 | y 3 | y 3 | y * 3 |

      for ( i = 1 ; j <= k ; ++j , i *= n ) { + + for ( p = Bi , q = 0 ; p < Bj ; ++p , q = ( ( q + 1 ) / i | 0 ) % n ) { + + B[p] += a[ai + j] * S[Si + q] ; + + } + + }

      We fill C

        -----------------------------------
      +

      C <- | u 1 + t | u 2 + t | u * 3 + t |

      for ( q = 0 ; q < n ; ++q ) { + + C[Ci + q] = a[ai + 1] * S[Si + q] + a[ai] ; + + } + +} ; + +exports.oddkldtto3sum = oddkldtto3sum;
      \ No newline at end of file diff --git a/minima/clarkson.html b/minima/clarkson.html new file mode 100644 index 0000000..19c68fc --- /dev/null +++ b/minima/clarkson.html @@ -0,0 +1,58 @@ +minima/clarkson

      Output sensitive inplace algorithm to find the minima set of a set S of +elements according to some partial order.

      +

      Uses at most 3nA comparisons where A is the cardinality of the minima set.

      +

      For (1), at most nA comparisons are used since we compare each element of S +with each elements of the minima set which is of cardinality at most A +during the execution of the algorithm.

      +

      For (2), for each executed loop we +obtain a new minimum and increase the size of the constructed minima set by +1, hence there are at most A loops execution, each of which loops over at +most n elements. (2) uses thus at most nA comparisons.

      +

      The running time is dominated by the comparison time and thus the complexity +of this algorihtm is O(nA).

      +

      Description and context in

      +

      More Output-Sensitive Geometric Algorithms. +-------------------- Kenneth L. Clarkson -

      var clarkson = function ( prec , a , i , j ) {

      This algorithms reorganizes the input array a as follows

      +
        +
      • elements that are minima are put at the front of a
      • +
      • other elements are put at the back of a
      • +
      +

      During the algorithm, a looks like this

      +
      +

      | minima set | candidate elements | discarded elements |

      +

      i min dis j

      var min , dis , k , inc , tmp ; + + min = i ; + dis = j - 1 ;

      While there are candidate elements left.

      while ( min <= dis ) {

      (1) Determine if the right-most candidate should be discarded because it +is dominated by one of the minima elements of the minima set in +construction.

      for ( k = i ; k < min && !prec( a[k] , a[dis] ) ; ++k ) ;

      If so, discard it.

      if ( k < min ) --dis ;

      (2) Otherwise, scan the candidates for a minimum. If at this point the +candidate set is not empty, at least one of its elements must be a +minimum. We scan the candidate list to find such a minimum.

      else {

      Store the current minimum as the left-most candidate.

      tmp = a[dis] ; + a[dis] = a[min] ; + a[min] = tmp ;

      For each other candidate, right-to-left.

      for ( inc = min + 1 ; inc <= dis ; ) {

      If the current minimum precedes the right-most candidate, +discard the right-most candidate.

      if ( prec( a[min] , a[dis] ) ) --dis ;

      Else, if the right-most candidate precedes the current +minimum, we can discard the current minimum and the +right-most candidate becomes the current minimum.

      else if ( prec( a[dis] , a[min] ) ) { + tmp = a[dis] ; + a[dis] = a[min] ; + a[min] = tmp ; + --dis ; + }

      Otherwise, we save the candidate for the next round.

      else { + tmp = a[dis] ; + a[dis] = a[inc] ; + a[inc] = tmp ; + ++inc ; + } + + }

      The above loop selects a new minimum from the set of candidates +and places it at position min. We now increase the min +counter to move this minimum from the candidate list to the +minima set.

      ++min ; + + } + + }

      The algorithm returns the outer right bound of the minima set a[i:min].

      return min ; + +} ; + +exports.clarkson = clarkson ;
      \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index 8cba910..0000000 --- a/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "@aureooms/js-algorithms", - "description": "Playground for algorithms in JavaScript", - "homepage": "https://make-github-pseudonymous-again.github.io/js-algorithms", - "main": "js/dist/algorithms.js", - "version": "3.0.7", - "repository": { - "url": "https://github.com/make-github-pseudonymous-again/js-algorithms.git", - "type": "git" - }, - "keywords": [ - "adt", - "algorithm", - "complexity", - "ender", - "javascript", - "js", - "template" - ], - "scripts": { - "build": "./node_modules/.bin/aureooms-node-package-build", - "test": "./node_modules/.bin/aureooms-node-package-test", - "doc": "./node_modules/.bin/groc" - }, - "author": "aureooms", - "devDependencies": { - "@aureooms/js-array": "^4.0.0", - "@aureooms/js-compare": "^1.4.3", - "@aureooms/js-functools": "^2.0.3", - "@aureooms/js-itertools": "^3.0.0", - "@aureooms/js-operator": "^1.0.2", - "@aureooms/js-partition": "^8.0.0", - "@aureooms/js-random": "^2.0.0", - "@aureooms/js-selection": "^9.0.0", - "@aureooms/js-sort": "^7.0.0", - "@aureooms/js-splitting": "^4.0.2", - "aureooms-node-package": "^6.0.1" - }, - "bugs": { - "url": "https://github.com/make-github-pseudonymous-again/js-algorithms/issues" - }, - "dependencies": {}, - "license": "AGPL-3.0", - "spm": { - "main": "js/dist/algorithms.js" - } -} diff --git a/pkg.json b/pkg.json deleted file mode 100644 index 39a1fe2..0000000 --- a/pkg.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "algorithms", - "code": { - "main": [ - "js", - "dist", - "algorithms.js" - ], - "test": [ - "test", - "js" - ] - }, - "src": "js/src/", - "debug": false, - "out": "js/dist/", - "babel": true -} diff --git a/test/js/index.js b/test/js/index.js deleted file mode 100644 index 869a49d..0000000 --- a/test/js/index.js +++ /dev/null @@ -1,10 +0,0 @@ -var pkg = require('aureooms-node-package'); - - -var opt = { - src : __dirname + '/src/', - exports : module.exports, - base : 0 -}; - -pkg.include(opt); diff --git a/test/js/src/3sum.js b/test/js/src/3sum.js deleted file mode 100644 index a36f2db..0000000 --- a/test/js/src/3sum.js +++ /dev/null @@ -1,75 +0,0 @@ - -var util = require( "util" ); -var array = require( "@aureooms/js-array" ); - -test("3sum", function(){ - - console.log("3sum"); - - var iota = array.iota; - - var n = 100; - - var A = new Array(n); - var B = new Array(n); - var C = new Array(n); - - iota(A, 0, n, -n/2); - iota(B, 0, n, -n/2); - iota(C, 0, n, -n/2); - - var contains = function(a, x) { - var i, y, k; - it : for (i = 0; i < a.length; ++i) { - y = a[i]; - for (k = 0; k < 3; ++k) { - if (x[k] !== y[k]) continue it; - } - return true; - } - return false; - }; - - var _3sum_n3 = function(A, ai, aj, B, bi, bj, C, ci, cj, fn) { - var a, b, c, i, j, k; - for (i = ai; i < aj; ++i) { - a = A[i]; - for (j = bi; j < bj; ++j) { - b = B[j]; - for (k = ci; k < cj; ++k) { - c = C[k]; - if (a + b + c === 0) { - fn(a, b, c); - } - } - } - } - }; - - _3sum_n2 = algorithms._3sum_n2; - - var w = []; - var u = []; - - var __fn__ = function (w) { - return function(a, b, c) { - w.push([a, b, c]); - }; - }; - - var fnw = __fn__(w); - var fnu = __fn__(u); - - - _3sum_n2(A, 0, n, B, 0, n, C, 0, n, fnw); - _3sum_n3(A, 0, n, B, 0, n, C, 0, n, fnu); - - - deepEqual(w.length, u.length, "length check"); - - var k; - for (k = 0; k < w.length; ++k) { - deepEqual(contains(u, w[k]), true, w[k] + " in list"); - } - -}); diff --git a/test/js/src/bdp.js b/test/js/src/bdp.js deleted file mode 100644 index 85092bf..0000000 --- a/test/js/src/bdp.js +++ /dev/null @@ -1,216 +0,0 @@ - - -var n; - -var itertools = require( "@aureooms/js-itertools" ); -var functools = require( "@aureooms/js-functools" ); -var splitting = require( "@aureooms/js-splitting" ); -var partition = require( "@aureooms/js-partition" ) ; -var selection = require( "@aureooms/js-selection" ) ; -var operator = require( "@aureooms/js-operator" ); -var compare = require( "@aureooms/js-compare" ); -var random = require( "@aureooms/js-random" ); -var array = require( "@aureooms/js-array" ); - -var one = function ( bdp, __f__, a, i, j, di, dj, expected ) { - - ++n; - - random.shuffle( a, i, j ); - - var out = itertools.list( bdp( __f__, a, i, j, di, dj, [] ) ); - - var outputordering = compare.lexicographical( compare.lexicographical( compare.increasing ) ); - - array.sort( outputordering, out ); - array.sort( outputordering, expected ); - - deepEqual( out, expected, n ); - -}; - -var all = function ( name, algo ) { - - n = 0; - - test( name, function ( ) { - - var f, __f__; - - f = function ( i, a, b ) { - return a[i] - b[i]; - }; - - __f__ = functools.curry( f, 3 ); - - one( algo, __f__, [], 0, 0, 1, 1, [] ); - - one( algo, __f__, [ [0] ], 0, 1, 1, 1, [] ); - - one( algo, __f__, [ [1] ], 0, 1, 1, 1, [] ); - - one( algo, __f__, [ [0], [0], [0], [0] ], 0, 4, 1, 1, [] ); - - one( algo, __f__, [ [1], [1], [1], [1] ], 0, 4, 1, 1, [] ); - - one( - algo, - __f__, - [ [0], [0], [1], [1] ], - 0, 4, - 1, 1, - [ - [ [1], [0] ], - [ [1], [0] ], - [ [1], [0] ], - [ [1], [0] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5], [0, 1], [1, 1], [1, 0.5] ], - 0, 4, - 1, 2, - [ - [ [1, 1], [0, 1] ], - [ [1, 1], [0, 0.5] ], - [ [1, 0.5], [0, 0.5] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [1, 1, 1], [1, 0.5, 2] ], - 0, 4, - 1, 3, - [ - [ [1, 1, 1], [0, 0.5, 1] ], - [ [1, 0.5, 2], [0, 0.5, 1] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [1, 1, 1], [1, 0.5, 2], [1, 1, 1], [1, 0.5, 2] ], - 0, 6, - 1, 3, - [ - [ [1, 1, 1], [0, 0.5, 1] ], - [ [1, 0.5, 2], [0, 0.5, 1] ], - [ [1, 1, 1], [0, 0.5, 1] ], - [ [1, 0.5, 2], [0, 0.5, 1] ] - ] - ); - - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [1, 1, 1], [1, 0.5, 2], [1, 1, 3], [1, 1, 2] ], - 0, 6, - 1, 3, - [ - [ [1, 1, 1], [0, 0.5, 1] ], - [ [1, 0.5, 2], [0, 0.5, 1] ], - [ [1, 1, 3], [0, 0.5, 1] ], - [ [1, 1, 2], [0, 0.5, 1] ], - [ [1, 1, 3], [0, 1, 2] ], - [ [1, 1, 2], [0, 1, 2] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [1, 1, 1], [1, 0.5, 2], [1, 1, 3], [0, 105, 1], [0, 1, 20], [1, 1, 2] ], - 0, 8, - 1, 3, - [ - [ [1, 1, 1], [0, 0.5, 1] ], - [ [1, 0.5, 2], [0, 0.5, 1] ], - [ [1, 1, 3], [0, 0.5, 1] ], - [ [1, 1, 2], [0, 0.5, 1] ], - [ [1, 1, 3], [0, 1, 2] ], - [ [1, 1, 2], [0, 1, 2] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [0, 105, 1], [0, 1, 20], [1, 105, 20], [1, 105, 20], [1, 106, 20] ], - 0, 7, - 1, 3, - [ - [ [1, 105, 20], [0, 0.5, 1] ], - [ [1, 105, 20], [0, 1, 2] ], - [ [1, 105, 20], [0, 105, 1] ], - [ [1, 105, 20], [0, 1, 20] ], - [ [1, 105, 20], [0, 0.5, 1] ], - [ [1, 105, 20], [0, 1, 2] ], - [ [1, 105, 20], [0, 105, 1] ], - [ [1, 105, 20], [0, 1, 20] ], - [ [1, 106, 20], [0, 0.5, 1] ], - [ [1, 106, 20], [0, 1, 2] ], - [ [1, 106, 20], [0, 105, 1] ], - [ [1, 106, 20], [0, 1, 20] ] - ] - ); - - one( - algo, - __f__, - [ [0, 0.5, 1], [0, 1, 2], [0, 105, 1], [0, 1, 20], [1, 105, 20], [1, 105, 20], [1, 106, 20], [0, 107, 1], [0, 107, 1] ], - 0, 9, - 1, 3, - [ - [ [1, 105, 20], [0, 0.5, 1] ], - [ [1, 105, 20], [0, 1, 2] ], - [ [1, 105, 20], [0, 105, 1] ], - [ [1, 105, 20], [0, 1, 20] ], - [ [1, 105, 20], [0, 0.5, 1] ], - [ [1, 105, 20], [0, 1, 2] ], - [ [1, 105, 20], [0, 105, 1] ], - [ [1, 105, 20], [0, 1, 20] ], - [ [1, 106, 20], [0, 0.5, 1] ], - [ [1, 106, 20], [0, 1, 2] ], - [ [1, 106, 20], [0, 105, 1] ], - [ [1, 106, 20], [0, 1, 20] ] - ] - ); - - - }); - -}; - -[ - [ - "algorithms.__bdpdc__", - algorithms.__bdpdc__( - selection.single( partition.hoare ) , // select, - functools.curry( function ( i, v, a ) { // __eq__, - return + ( v === a[i] ); - }, 3 ), - functools.curry( function ( i, v, a ) { // __ne__, - return + ( v !== a[i] ); - }, 3 ), - operator.itemgetter( 0 ), // color, - splitting.hoare, // split, - array.swapranges // swap - ) - ], - - [ - "algorithms.__bdpdn2__", - algorithms.__bdpdn2__( - operator.itemgetter( 0 ), // color, - splitting.hoare // split - ) - ] - -].forEach( functools.partial( functools.star, [all] ) ); diff --git a/test/js/src/birthdays.js b/test/js/src/birthdays.js deleted file mode 100644 index 8e81841..0000000 --- a/test/js/src/birthdays.js +++ /dev/null @@ -1,25 +0,0 @@ - -var compare = algorithms.__absepsilon__( 1e-4 ); - -var run = function ( k, n, days, expected ) { - - var computed; - - computed = algorithms.samebirthday( k, n, days ); - - equal( compare( computed, expected ), 0, k + ", " + n + ", " + days + " : " + computed ); - -}; - - -test( "birthdays", function () { - - run( 1, 3, 365, 1 - ( 364 / 365 * 364 / 365 ) ); - run( 2, 3, 365, 1 - ( 364 / 365 * 363 / 365 ) ); - run( 10, 10, 365, 0.1169 ); - run( 23, 23, 365, 0.5073 ); - run( 50, 50, 365, 0.9704 ); - run( 100, 100, 365, 1 - 3.072e-7 ); - run( 365, 365, 365, 0.9999 ); - -} ); diff --git a/test/js/src/iter.js b/test/js/src/iter.js deleted file mode 100644 index 86113bd..0000000 --- a/test/js/src/iter.js +++ /dev/null @@ -1,24 +0,0 @@ - -var array = require( "@aureooms/js-array" ); - -test( "iter", function () { - - var f, b, fe, be, n; - - f = []; - b = []; - fe = []; - be = []; - - n = 10; - - array.iota( fe, 0, n, 0 ); - array.reversed( fe, be ); - - algorithms.fiter( 0, n, f.push.bind(f) ); - algorithms.biter( 0, n, b.push.bind(b) ); - - deepEqual( f, fe, "forward" ); - deepEqual( b, be, "backward" ); - -}); diff --git a/test/js/src/ksum/sortxy.js b/test/js/src/ksum/sortxy.js deleted file mode 100644 index a099062..0000000 --- a/test/js/src/ksum/sortxy.js +++ /dev/null @@ -1,76 +0,0 @@ - -var util = require( "util" ) ; -var array = require( "@aureooms/js-array" ) ; - -test( "sortxy" , function ( ) { - - var n , X , Y , v , w , k , __fn__ , contains , compare ; - - console.log( "sortxy" ); - - n = 20 ; - - X = array.alloc( n ) ; - Y = array.alloc( n ) ; - - array.iota( X , 0 , n , 0 ) ; - array.iota( Y , 0 , n , 1000 ) ; - - contains = function ( a , x ) { - - var i , y , k ; - - it : for ( i = 0 ; i < a.length ; ++i ) { - - y = a[i] ; - - for ( k = 0 ; k < 4 ; ++k ) { - - if ( x[k] !== y[k] ) { - continue it ; - } - - } - - return true ; - } - - return false ; - - } ; - - v = [] ; - w = [] ; - - __fn__ = function ( w ) { - - return function ( a , b , c , d ) { - w.push( [ a , b , c , d ] ) ; - } ; - - } ; - - - compare = function ( a , b , c , d ) { - return a + b - c - d ; - } ; - - - algorithms.sortxy_n3( compare , X , Y , 0 , n - 1 , 0 , n - 1 , 0 , n - 1 , 0 , n - 1 , __fn__( v ) ) ; - algorithms.sortxy_n4( compare , X , Y , 0 , n - 1 , 0 , n - 1 , 0 , n - 1 , 0 , n - 1 , __fn__( w ) ) ; - - - for ( k = 0 ; k < w.length ; ++k ) { - - if ( w[k][0] > w[k][2] ) { - continue ; - } - - if ( w[k][0] === w[k][2] && w[k][1] <= w[k][3] ) { - continue ; - } - - deepEqual( contains( v , w[k] ), true, w[k] + " in list" ) ; - } - -} ) ;