Skip to content

Instantly share code, notes, and snippets.

@fracz
Last active September 21, 2025 13:42
Show Gist options
  • Select an option

  • Save fracz/d29bdcb884f3f1539da16ced66bcc705 to your computer and use it in GitHub Desktop.

Select an option

Save fracz/d29bdcb884f3f1539da16ced66bcc705 to your computer and use it in GitHub Desktop.
GC helpers
'N 50° 02. [G(A x E) : (A-C) + 2(F x H) + (B - 6C) -1]'.replace(/\[/g, '(').replace(/\]/g, ')').replace(/x/g, '*').replace(/:/g, '/').replace(/(\d)([A-Z\(])/g, '$1*$2').replace(/([A-Z])([\(])/g, '$1*$2')
letterValue = (letter) => letter.toUpperCase().charCodeAt(0) - 64;
letterValues = (word) => word.split('').map(letterValue);
wordValue = (word) => letterValues(word).reduce((a,b) => a+b, 0);
sumDigits = (number) => ('' + number).split('').reduce((a,b) => (+a)+(+b), 0);
sumToOneDigit = (number) => sumDigits(number) === number ? number : sumToOneDigit(sumDigits(number));
// [A,B,C] = letterValues('KOT');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment