JSFiddle - React, Tailwind, and code Playground

HTML

<div id="output">
output
</div>

TypeScript

const patternMatch = (pattern: string, source: string): number => {
	let count = 0;
  const matches = [];
  const vowels: string = 'aeiouy';
  const VOWEL: string = '0';
  const CONSONANT: string = '1';
  
  for (let i: number = 0; i<source.length - pattern.length + 1; i++) {
  	let isMatch = true;
    for (let offset: number = 0; offset<pattern.length; offset++) {
			if (pattern[offset] === VOWEL && !vowels.includes(source[i + offset])) {
      	isMatch = false;
        break;
      }
      else if (pattern[offset] === CONSONANT && vowels.includes(source[i + offset])) { 
      	isMatch = false;
      	break;
      }
    }
    
    count += isMatch ? 1 : 0;
    if (isMatch) {
    	matches.push(source.substring(i, i + pattern.length));
    }
  }
  
  return { count, matches };
};

console.log(patternMatch('010', 'amazing'));
console.log(patternMatch('100', 'codesignal'));
console.log(patternMatch('110', 'frosty'));
console.log(patternMatch('0110', 'thisisalongsentence'));

const powersOf2 = (numbers: [number]): number => {
	let count: number = 0;
  const counts = {};
  const matches: [ [number] ] = [];
  
  for (let i: number = 0; i<numbers.length; i++) {
  	const element = numbers[i];
    counts[element] = counts[element] ? counts[element] + 1 : 1;
    
    for (let twoPower: number = 0; twoPower < 21; twoPower++) {
    	// Calculate the amount remaining to get to this power of two.
      const second_element = (1 << twoPower) - element;
      
      // If the remainder exists in our lookup table, then we have a match.
      count += counts[second_element] ? counts[second_element] : 0;
      if (counts[second_element]) {
      	matches.push([element, second_element]);
      }
    }
  }
  
  return { count, matches };
}

console.log(powersOf2([1, -1, 2, 3])); // 5
console.log(powersOf2([-2, -1, 0, 1, 2)); // 5
console.log(powersOf2([3, 5, 7, 9])); // 2