# kakuro-cross-sums / solver / ruby / t / check-perms.rb

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75``` ```require "kakuro-perms.rb" def human_get_perms(mutator, sum, num) perms = mutator.get_perms(*mutator.human_to_internal(sum, num)) return perms.map {|x| mutator.internal_to_human(x) } end describe "Kakuro" do before do @perm = Kakuro::Perms.new end it "human->internal transform for 3/2" do @perm.human_to_internal(3,2).should eql([1,2]) end it "human->internal transform for 5/2" do @perm.human_to_internal(5,2).should eql([3,2]) end it "human->internal transform for 10/4" do # 10 = 1 + 2 + 3 + 4 # 10/int = 0 + 1 + 2 + 3 == 6 @perm.human_to_internal(10,4).should eql([6,4]) end it "internal->human transform for 1+2+3+4" do @perm.internal_to_human( (1 << (1-1)) | (1 << (2-1)) | (1 << (3-1)) | (1 << (4-1)) ).should eql([1,2,3,4]) end it "internal->human transform for 7+9" do @perm.internal_to_human( (1 << (7-1)) | (1 << (9-1)) ).should eql([7,9]) end it "10/4 is 1,2,3,4" do (@perm.get_perms(*@perm.human_to_internal(10,4)).map {|x| @perm.internal_to_human(x) }).should eql([[1,2,3,4]]) end it "get_perms(10/4)" do human_get_perms(@perm, 10, 4).should eql([[1,2,3,4]]) end it "get_perms(3/2)" do human_get_perms(@perm, 3, 2).should eql([[1,2]]) end it "get_perms(16/2)" do human_get_perms(@perm, 16, 2).should eql([[7,9]]) end it "get_perms(7/3)" do human_get_perms(@perm, 7, 3).should eql([[1,2,4]]) end it "gen_perms(25/5)" do human_get_perms(@perm, 25, 5).should eql([ [1,2,5,8,9], [1,2,6,7,9], [1,3,4,8,9], [1,3,5,7,9], [1,3,6,7,8], [1,4,5,6,9], [1,4,5,7,8], [2,3,4,7,9], [2,3,5,6,9], [2,3,5,7,8], [2,4,5,6,8], [3,4,5,6,7], ]) end end ```
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.