From 0e3b825b3b7be1f4899aff174923787e51fab96d Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sun, 12 Dec 2021 12:14:49 +0100 Subject: [PATCH] appending method --- day12.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/day12.swift b/day12.swift index eef9531..766f205 100644 --- a/day12.swift +++ b/day12.swift @@ -20,6 +20,10 @@ struct Day12: Puzzle { struct Path { var rooms: [Int] = [] + + func appending(_ room: Int) -> Path { + Path(rooms: rooms + [room]) + } } struct Matrix { @@ -37,8 +41,7 @@ struct Day12: Puzzle { return [continuing] } - var current = continuing - current.rooms.append(from) + let current = continuing.appending(from) var result: [Path] = [] for next in neighbors(of: from) {