Skip to content

Commit

Permalink
Add whitespace for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 9, 2024
1 parent 71c124d commit b111dfe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lua/src/p0017.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ local function to_string_len(n)
if n >= 1000
then
local thousands = to_string_len(math.floor(n / 1000 % 100)) + 8

if n % 1000 ~= 0
then
thousands = thousands + to_string_len(n % 1000)
end

return thousands
end

if n >= 100
then
local hundreds = to_string_len(math.floor(n / 100 % 10)) + 7

if n % 100 ~= 0
then
hundreds = hundreds + 3 + to_string_len(n % 100)
end

return hundreds
end

if n >= 20
then
local tens_t = {
Expand All @@ -47,12 +53,15 @@ local function to_string_len(n)
[9] = 6,
}
local tens = tens_t[math.floor(n / 10)]

if n % 10 ~= 0
then
tens = tens + to_string_len(n % 10)
end

return tens
end

local final = {
[0] = 4,
[1] = 3,
Expand Down

0 comments on commit b111dfe

Please sign in to comment.