Skip to content

Zigzag (or diagonal) traversal of Matrix with combine function

Notifications You must be signed in to change notification settings

felicepagano/matrix-diagonal-combine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Matrix unraveling

Given an MxN matrix of characters, write a method that returns a String which contains the concatenation of all the matrix’s diagonals, from top to bottom, right to left.

For example, input

1 A 5 7 B N
2 B 6 8 K R
5 Q N 3 B 1

Output has to be: 1 A2 5B5 76Q B8N NK3 RB 1 as a result (with or without spaces, doesn't matter)

This matrix show why shift could be a solution for the problem

(0,0)
(0,1) (1,0)
(0,2) (1,1) (2,0)
(0,3) (1,2) (2,1)
(0,4) (1,3) (2,2)
(0,5) (1,4) (2,3)
(1,5) (2,4)
(2,5)

In this exercise I'm trying to solve the problem using different techniques and languages:

  • imperative style
  • fp style
  • TDD
  • java
  • kotlin
  • scala
  • WIP: scala with cats

About

Zigzag (or diagonal) traversal of Matrix with combine function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published