Skip to content

Commit

Permalink
Implement the first version of b i n g o grouping card format (CSB)
Browse files Browse the repository at this point in the history
  • Loading branch information
asl97 committed Dec 11, 2023
1 parent 0d9d318 commit 3e52cd5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,23 @@ <h1>Batch Card Printer</h1>
[/^cs(\d+)-(\d+)$/gi, (match)=>{
let arr = this.randomize_array(match[2], parseInt(match[1]));
return arr.slice(0, 25);
}]
}],
[/^csb(\d+)-(\d+)$/gi, (match=>{
let arr = this.randomize_array(match[2], parseInt(match[1]));
// an extra array for number that exceed the grouping length
// grouping length is gotten by dividing the total number by 5
// and dropping the remainder.
//
// eg: in normal bingo 76 would be outside of the b i n g o
// groups, it should overflow into group b
let groups = Array(6).fill().map(()=>[]);
let group_range = Math.floor(arr.length/5);
arr.forEach((num, i)=>groups[Math.floor(num/group_range)].push(num))
// excess numbers to be distributed
groups[5].forEach((num, i)=>groups[i].push(num))
delete groups[5]
return this.arr_2d_flip(groups.map((x)=>x.slice(0,5)).flat(), 5)
})]
],

to_arrays: function (c){return function* _(){
Expand Down

0 comments on commit 3e52cd5

Please sign in to comment.