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/Problem15.lua
|
||||
--Matthew Ellison
|
||||
-- Created: 02-07-19
|
||||
--Modified: 03-28-19
|
||||
--Modified: 06-19-20
|
||||
--How many routes from the top left corner to the bottom right corner are there through a 20×20 grid if you can only move right and down?
|
||||
--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,13 +25,13 @@
|
||||
require "Stopwatch"
|
||||
|
||||
|
||||
timer = Stopwatch:create();
|
||||
local timer = Stopwatch:create();
|
||||
timer:start();
|
||||
|
||||
GRID_WIDTH = 20;
|
||||
GRID_HEIGHT = 20;
|
||||
lowestXReached = 20;
|
||||
function movement(currentX, currentY)
|
||||
local lowestXReached = 20;
|
||||
local function movement(currentX, currentY)
|
||||
--Return 1 if you are at the finish location
|
||||
if((currentX == GRID_WIDTH) and (currentY == GRID_HEIGHT)) then
|
||||
return 1;
|
||||
@@ -59,7 +59,7 @@ function movement(currentX, currentY)
|
||||
end
|
||||
|
||||
--Start the recursion at the correct location and catch what is returned
|
||||
numberMoves = movement(0, 0);
|
||||
local numberMoves = movement(0, 0);
|
||||
|
||||
timer:stop();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user