We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d382946 + eb7a7e6 commit 46f3727Copy full SHA for 46f3727
internal/puzzles/solutions/2016/day01/solution.go
@@ -186,12 +186,14 @@ func (d direction) strikeTo(t turn) direction {
186
}
187
188
type cab struct {
189
+ mu *sync.Mutex
190
curDir direction
191
n navigator
192
193
194
func newCab() cab {
195
return cab{
196
+ mu: &sync.Mutex{},
197
curDir: northDirection,
198
n: newNavigator(),
199
@@ -204,6 +206,9 @@ const (
204
206
)
205
207
208
func (c *cab) Move(t turn, steps int) error {
209
+ c.mu.Lock()
210
+ defer c.mu.Unlock()
211
+
212
c.curDir = c.curDir.strikeTo(t)
213
if !c.curDir.isValid() {
214
return errInvalidDirect
0 commit comments