mirror of
https://bitbucket.org/Mattrixwv/projecteulerlua.git
synced 2025-12-06 17:43:57 -05:00
Updated problems to be more in line with conventions
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
--ProjectEuler/lua/Problem17.lua
|
||||
--Matthew Ellison
|
||||
-- Created: 02-07-19
|
||||
--Modified: 03-28-19
|
||||
--Modified: 06-19-20
|
||||
--If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
|
||||
--All of my requires, unless otherwise listed, can be found at https://bitbucket.org/Mattrixwv/luaClasses
|
||||
--[[
|
||||
Copyright (C) 2019 Matthew Ellison
|
||||
Copyright (C) 2020 Matthew Ellison
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -25,12 +25,12 @@
|
||||
require "Stopwatch"
|
||||
|
||||
|
||||
timer = Stopwatch:create();
|
||||
local timer = Stopwatch:create();
|
||||
timer:start();
|
||||
|
||||
--This function takes a number and returns it as a string in english
|
||||
--This function only works for numbers -1,000,000 < num < 1,000,000
|
||||
function getStringFromNum(number)
|
||||
local function getStringFromNum(number)
|
||||
local numberString = "";
|
||||
--Starting with the largest digit create a string based on the number passed in
|
||||
--Check for negative
|
||||
@@ -144,7 +144,7 @@ function getStringFromNum(number)
|
||||
end
|
||||
|
||||
--This function returns the number of letters in a string, ignoring punctuation, whitespace, and numbers
|
||||
function getNumberChars(number)
|
||||
local function getNumberChars(number)
|
||||
local sumOfLetters = 0;
|
||||
--Start at location 1 and count the number of letters, ignoring punctuation and whitespace
|
||||
for location=1,string.len(number) do
|
||||
|
||||
Reference in New Issue
Block a user