Generating Unique Codes Not Including All Words (Angular + TS)

Discussão em 'Angular' iniciado por Wicked, Novembro 16, 2024.

  1. Wicked

    Wicked Guest

    I have the following:

    https://stackblitz.com/edit/stackblitz-starters-ujlmy6?file=src/main.ts

    Where I am trying to generate a code based on an input. For my example above I have:

    input: Project Tracker Tool & Category Beta (BET)

    output: PROTTERTBET and POCTERTOBET and so on...

    (it ends with the same category depending on the input category)

    But I have the issue where ideally I want the code to be more meaningful because my code only slices the first 8 characters which means for the word "Tool", none of its characters are included in the final output. My desired output is:


    • At least 1 character at minimum from each word is included.


    • It maintains the ordering of the characters so no randomization of selected characters


    • For longer inputs ideally all max out 8 characters, can vary e.g. selects 3 characters from first word, 3 from second, 2 from 3rd and so on. By this I mean the itemName maxes at 8 not the entire output.


    • Will also have smaller inputs e.g. "Tool" where it will maybe just use the entire word.


    • 6 character words MyItem maybe MyItem or MYITM.


    • Should generate new outputs (chances of the having same output is fine).

    Project Tracker Tool examples should output PRJTRTOL or PJCTTKTL

    Continue reading...

Compartilhe esta Página