summaryrefslogtreecommitdiff
path: root/3
diff options
context:
space:
mode:
Diffstat (limited to '3')
-rw-r--r--3/part1.c2
-rw-r--r--3/part2.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/3/part1.c b/3/part1.c
index 0373328..b664b7d 100644
--- a/3/part1.c
+++ b/3/part1.c
@@ -33,5 +33,5 @@ int count_trees(const char *filename)
int main(int argc, char *argv[])
{
- printf("%i", count_trees(argv[1]));
+ printf("%i", count_trees(argv[argc - 1]));
}
diff --git a/3/part2.c b/3/part2.c
index 7362c12..29319b4 100644
--- a/3/part2.c
+++ b/3/part2.c
@@ -35,6 +35,7 @@ int count_trees(int inc_right, int inc_down, const char *filename)
int main(int argc, char *argv[])
{
- long mul = (long)count_trees(1, 1, argv[1]) * count_trees(3, 1, argv[1]) * count_trees(5, 1, argv[1]) * count_trees(7, 1, argv[1]) * count_trees(1, 2, argv[1]);
+ int arg = argv[argc - 1];
+ long mul = (long)count_trees(1, 1, arg) * count_trees(3, 1, arg) * count_trees(5, 1, arg) * count_trees(7, 1, arg) * count_trees(1, 2, arg);
printf("%li\n", mul);
}