https://github.com/imjaroiswebdev/pf_challenge
https://github.com/imjaroiswebdev/pf_challenge
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/imjaroiswebdev/pf_challenge
- Owner: imjaroiswebdev
- Created: 2019-01-28T00:49:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T09:32:17.000Z (over 7 years ago)
- Last Synced: 2025-01-29T05:28:23.843Z (over 1 year ago)
- Language: JavaScript
- Size: 50.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PF Challenge
## Excute
```shell
$ npm i
$ npm run printMatrix
$ npm test
```
## 1. Spiral Matrix
__Def:__ Write a function named printMatrix, that takes an array of integers representing a 2d square matrix and the number of elements on each side as parameters. This function should start at the upper left hand corner of the matrix and print each element in a counterclockwise spiral.
__Example:__ The 3x3 matrix
Is represented by the array m, and the size n:
The result of executing the function printMatrix with m and n as parameters is: 123456789
|1 8 7| |2 9 6| |3 4 5|
m = [1, 8, 7, 2, 9, 6, 3, 4, 5] n=3
Valid values for the elements of m and n are: 0 <= a ∈ m <= 2^31-1 1 <= n <= 2^15