From 3e52cd595769aa03740ac7264524f14135c57c82 Mon Sep 17 00:00:00 2001 From: ASL97 Date: Mon, 11 Dec 2023 14:11:14 +0800 Subject: [PATCH] Implement the first version of b i n g o grouping card format (CSB) --- index.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3e8cdc9..0917537 100644 --- a/index.html +++ b/index.html @@ -846,7 +846,23 @@

Batch Card Printer

[/^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* _(){