This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Testing "not containing 101" for the first 1024 non-empty binary words: | |
| 0: 0 => goal: true, r1: true, r2: true, 3: true | |
| 1: 1 => goal: true, r1: false ERROR, r2: true, 3: true | |
| 2: 10 => goal: true, r1: true, r2: true, 3: true | |
| 3: 11 => goal: true, r1: false ERROR, r2: true, 3: true | |
| 4: 100 => goal: true, r1: true, r2: true, 3: true | |
| 5: 101 => goal: false, r1: false, r2: false, 3: false | |
| 6: 110 => goal: true, r1: false ERROR, r2: true, 3: true | |
| 7: 111 => goal: true, r1: false ERROR, r2: true, 3: true | |
| 8: 1000 => goal: true, r1: true, r2: true, 3: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lp-alloc.R | |
| # | |
| # Allocate 3 employes to 4 departments | |
| # | |
| # usage: | |
| # source('lp-alloc.R') | |
| # help: | |
| # http://lpsolve.r-forge.r-project.org/ | |
| # ?make.lp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lp-alloc2.R | |
| # | |
| # Allocate 3 employes to 4 departments | |
| # Using flexible quota | |
| # | |
| # usage: | |
| # source('lp-alloc2.R') | |
| # help: | |
| # http://lpsolve.r-forge.r-project.org/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lp-alloc3.R | |
| # | |
| # Allocate 3 employes to 4 departments | |
| # Using flexible quota. | |
| # Using maximum quota. | |
| # | |
| # usage: | |
| # source('lp-alloc3.R') | |
| # help: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lp-alloc4.R | |
| # | |
| # Allocate 3 employes to 4 departments | |
| # Using flexible quota. | |
| # Using minimum total quota per department. | |
| # | |
| # usage: | |
| # source('lp-alloc4.R') | |
| # help: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # lp-beer.R | |
| # | |
| # "Max your beer" | |
| # | |
| # usage: | |
| # source('lp-beer.R') | |
| # help: | |
| # http://lpsolve.r-forge.r-project.org/ | |
| # ?make.lp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > source('lp-beer.R') | |
| r = 30 round(s) | |
| n = 155 + 120 = 275 variables | |
| saving model as model.txt .. | |
| Model name: '' - run #1 | |
| Objective: Maximize(R0) | |
| SUBMITTED | |
| Model size: 185 constraints, 275 variables, 725 non-zeros. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Objective function */ | |
| max: +A1T +A2T +A3T +A4T +A5T +A6T +A7T +A8T +A9T +A10T +A11T +A12T +A13T +A14T +A15T +A16T +A17T +A18T +A19T | |
| +A20T +A21T +A22T +A23T +A24T +A25T +A26T +A27T +A28T +A29T +A30T; | |
| /* Constraints */ | |
| A1: +U0B = 10; | |
| A2: +U0D = 0; | |
| A3: +U0F = 0; | |
| A4: +U0C = 0; | |
| A5: +U0E = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_digits(n) | |
| ns = n.to_s | |
| nsl = ns.length | |
| digits = Array.new(10, 0) | |
| nsl.times do |k| | |
| d = ns[k].to_i | |
| digits[d] += 1 | |
| end | |
| digits | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| searching .. | |
| k = 1: | |
| n digits: | |
| [0:1, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0] | |
| OK - congrats! | |
| k = 2017: | |
| n digits: | |
| [0:198, 1:202, 2:202, 3:201, 4:202, 5:202, 6:201, 7:202, 8:202, 9:201] | |
| OK - congrats! |