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,7 +1,7 @@
|
||||
--ProjectEuler/lua/Problem11.lua
|
||||
--Matthew Ellison
|
||||
-- Created: 02-06-19
|
||||
--Modified: 03-28-19
|
||||
--Modified: 06-19-20
|
||||
--What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid?
|
||||
--[[
|
||||
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
|
||||
@@ -27,7 +27,7 @@
|
||||
]]
|
||||
--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
|
||||
@@ -47,7 +47,7 @@
|
||||
require "Stopwatch"
|
||||
|
||||
|
||||
timer = Stopwatch:create();
|
||||
local timer = Stopwatch:create();
|
||||
timer:start();
|
||||
|
||||
--Setup the grid of numbers
|
||||
@@ -74,7 +74,7 @@ GRID[19] = {20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 5
|
||||
GRID[20] = {1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48};
|
||||
|
||||
--This function returns the product of all elements in a table
|
||||
function getTableProduct(numbers)
|
||||
local function getTableProduct(numbers)
|
||||
local product = 1; --Start with 1 because you are working with multiplication
|
||||
--Loop through ever element in a table and multiply them all together
|
||||
for location=1,#numbers do
|
||||
|
||||
Reference in New Issue
Block a user