spin_rings

package
v0.0.0-...-86b9fec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 0 Imported by: 0

README

Spin Rings

Write a function that takes in a square-shaped (n x n) two-dimensional array representing a set of rings. For instance, a 4 x 4 array is made up of the following two rings:

[
  [-, -, -, -],
  [-,  ,  , -],
  [-,  ,  , -]
  [-, -, -, -],
]
[
  [ ,  ,  ,  ],
  [ , -, -,  ],
  [ , -, -,  ]
  [ ,  ,  ,  ],
]

The function should spin the rings in the array in a clockwise direction. In other words, every value in each respective ring should be shifted by one position in a clockwise direction.

This operation should be done in place; it should mutate the input array.

Sample Input

array = [
  [1, 2, 3, 4],
  [5, 6, 7, 8],
  [9, 10, 11, 12],
  [13, 14, 15, 16]
]

Sample Output

// This is the mutated input array.
[
  [5, 1, 2, 3],
  [9, 10, 6, 4],
  [13, 11, 7, 8],
  [14, 15, 16, 12]
]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SpinRings

func SpinRings(array [][]int)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL