Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 8x 3x 3x 3x 1x 1x 1x 6x 3x 1x 1x 3x 7x 3x 10x 7x 17x 3x 3x 3x 21x 21x 21x 76x 76x 76x 76x 21x 3x 8x | import {stde} from '../stde';
class Or extends stde {
constructor(group_count: number[] | number, in_count?: number) {
let seed = 1;
let in_carr: number[] = [];
if (group_count instanceof Array) {
in_carr = group_count;
group_count = group_count.length;
seed = Math.max(...in_carr);
} else {
in_carr = Array.from({length: group_count}, () => 1);
}
if (in_count) {
seed = in_count;
in_carr = Array(group_count).fill(in_count).flat();
}
let in_arr: string[] = [];
let out_arr: string[] = Array.from({length: seed}, (_, k) => String(k + 1));
in_carr.forEach((i, idx) => {
if (i > 1) {
for (let j = 0; j < i; j++) {
in_arr.push(String.fromCharCode(idx + 65) + '_' + String(j+1));
}
} else {
in_arr.push(String.fromCharCode(idx + 65));
}
});
let start = parseInt('0'.repeat(seed), 2);
super('OR', in_arr, out_arr, (a) => {
let currentIndex = 0;
let st = start;
for (let i = 0; i < group_count; i++) {
const groupSize = in_carr[i];
const substring = a.slice(currentIndex, currentIndex + groupSize);
st = st | parseInt(substring.padStart(seed, '0'), 2);
currentIndex += groupSize;
}
return st.toString(2).padStart(seed, '0');
});
}
}
function or(group_count: number | number[], in_count?: number) {
return new Or(group_count, in_count);
}
export {Or, or};
|