![]() |
Levenshtein Distance
Calculate the distance between two strings temp.s and temp.t.
This is an implementation of the dynamic programming approach. Time complexity of O(m*n). For an explanation of the algorithm, see the Wikipedia article. PHP Code:
PHP Code:
|
Any practical Graal usage for this?
|
Quote:
|
It could be used anywhere where you wanted to determine if a player entered a command wrong or something to that effect. Normally you'd want to keep the deviation value low if you're doing that.
It was just an exercise though, and I figured it could save someone trouble if they ever needed it. Anyways, you could just add it onto my pile of useless crap that no one cares about that I've posted in here, like Boyer-Moore, introsort, heapsort, quicksort, bitap, Rijndael, etc. |
Quote:
|
Quote:
|
Quote:
Actually, it's a nice looking script. But I'm curious, every time you use the temp.'chr's, is it required for you to keep saying "temp."? Does GScript not support enumeration? |
Quote:
|
That's a hell of a lot of temp's though! And is there really a lot of confusion? I mean in this day and age usually if you see a var without a prefix you can undoubtedly know that it is a temp var. And it looks so much neater!
PHP Code:
|
Quote:
|
Quote:
I do not see how enumerated types are related though. Quote:
|
| All times are GMT +2. The time now is 01:58 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.