Skip to content

Commit

Permalink
DLang: use arithmetic trick to save time
Browse files Browse the repository at this point in the history
on multiplication.
  • Loading branch information
renatoathaydes committed Jan 14, 2024
1 parent b927bc9 commit 0cbfd41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/d/src/dencoder.d
Expand Up @@ -43,8 +43,8 @@ private Int128 wordToNumber(string word)
{
if (c.isAlpha)
{
result *= 10;
result += digitByLetter[c];
result <<= 4;
result += digitByLetter[c] + '0';
}
}
return result;
Expand All @@ -70,8 +70,8 @@ void printTranslations(string[][Int128] dict, ISolutionHandler shandler,
Int128 n = Int128(1L);
foreach (i, c; digits)
{
n *= 10;
n += c - '0';
n <<= 4;
n += c;
string[]* foundWords = n in dict;
if (foundWords !is null)
{
Expand Down

0 comments on commit 0cbfd41

Please sign in to comment.