• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

Matrix Number Game

  • January 29, 2020
  • CODE OF GEEKS
  • 2

Given m*n matrix where m defines number of rows and n defines number of columns. Your job is to check whether a number is consecutive for 3 times either in row, column, or diagonal. If there are more than one such numbers then print the minimum one.

Note : n = m+1

Input : 

First Input : m, displaying number of rows

Second Input : m*n matrix

Output : 

Integer

Sample Testcases :

I/P 1:

2 3 4 5 6 2 4 3

2 3 4 7 6 7 6 2

2 3 5 5 5 5 2 5

2 3 1 1 2 1 3 6

1 1 1 1 9 0 3 5

2 3 1 1 5 1 2 7

O/P 1 : 1

Note : Make combinations with 4 integers only.


Solution :

r = int(input())
mat = []
for i in range(r):
    mat.append(list(map(int,input().split())))
c = r+1
res=[]
for i in range(r):
    for j in range(c-2):
        if mat[i][j] == mat[i][j+1] == mat[i][j+2]:
              res.append(mat[i][j])
for i in range(r-2):
    for j in range(c):
        if mat[i][j] == mat[i+1][j] == mat[i+2][j]:
              res.append(mat[i][j])
for i in range(r-2):
    for j in range(c-2):
        if mat[i][j] == mat[i+1][j+1] == mat[i+2][j+2]:
              res.append(mat[i][j])
print(res)


Tags: infosys last year handson problemsinfytqinfytq examinfytq handson problems of last yearinfytq handson questionsinfytq last year problemsinfytq last year questionsLast year questions Infytqmatrix problem for infytqmatrix problem infytqprepare infytq question
  • Previous Exam Pattern for InfyTQ Screening Test
  • Next Great Sum

2 comments on “Matrix Number Game”

  1. Divya Munot says:
    June 12, 2020 at 10:25 am

    The solution you mentioned for the given problem statement is incorrect.

    Reply
    1. Shreyansh Dwivedi Shreyansh Dwivedi says:
      June 12, 2020 at 10:35 am

      This Python solution was provided by our user. If you think, your solution is better than this, then please go ahead and post your solution here.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

TCS Reasoning 2021
  • October 4, 2021
TCS Verbal 2021
  • October 4, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →