String Comparing | Percentage Calculator

Heya!
I was kind-of bored in the last 30 minutes, and I asked myself a long time ago: Is it possible to make a Percentage calculator for strings? Is it possible, to compare two strings and get a percentage?

Answer: Yes! I kinda figured it out today, it’s not that hard.
And so I did. Introducing: String Percentage Calculator!!

And before anything, yes I know you could make this very fast by just writing one of your own, but it would take some time. So, I made a module script which you can require from every script to calculate the equality of two strings in a percentage form.

How to get started

First off, you would need to require the following ID: 11095284024. This ID leads to the asset I made,
Click here to view.

You can require this by doing the following:

local variable_name = require(11095284024)

How to use it

So, basically, what you need are two strings! One is the string that the other is compared too, which is the first argument of the function I am going to show you. The second one can be any input, if you want.

Let me show you!

local string_compare = require(11095284024)

print(string_compare.calculate(
"Hey!!!", --[[This is the string that the second argument is being compared to!]]
"Hey!!" --[[This is the string that is being compared to the first argument!]]
))

The outcome of this would be: 83 (% but It’s returning an integer for easier use!)
And that’s basically it, feel free to use this without credit, I don’t need it.

You can suggest updates in the comments!

Many thanks,
quezSypher!

5 Likes

Nice job! Thanks for letting the public access this. :slight_smile:

1 Like

Wow this is odd never thought of it

1 Like

What is the percentage calculator based on? Length? Similarity?

1 Like

You can divide the percentage by 100 if you cant put a percentage sign

1 Like

As I stated within the post, on equality. So basically: Similarity.

All good, I am actually willing to do it without the percentage sign for easier use; if you want I can add some function that automatically adds a “%” to it.

I meant that 51% === 0.51 so ypu can divide it by a hundred if u are not willing to do the sign.

1 Like

100*math.min(#str1,#str2)/math.max(#str1,#str2)

2 Likes

You can also open up a github or show source code so we can read it directly

1 Like

Maybe, I’ll think about that. I am not sure if I want to right now, though.

Ye, that’s way easier. I never thought of that, but thanks.