Skip to content

ShotsMan2/Lucky-Number-In-Matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Matrix Lucky Number Finder (Saddle Point)

This project solves a specific matrix problem where the goal is to find a "Lucky Number" (also known as a Saddle Point in game theory context) within a randomly generated grid.

📜 Problem Definition

Based on Quiz 6 requirements:

  1. Input: User provides dimension $N$.
  2. [cite_start]Generation: Create an $N \times N$ matrix filled with random, unique numbers between $1$ and $N^2$.
  3. Lucky Number Definition: A number is "Lucky" if:
    • [cite_start]It is the Minimum in its row[cite: 106].
    • [cite_start]It is the Maximum in its column[cite: 107].

⚙️ Logic

  1. Unique Filling: The program uses a nested check to ensure no duplicate numbers exist during matrix population.
  2. Search: It iterates through every cell $(i, j)$:
    • Checks horizontal neighbors to verify if matris[i][j] is the row minimum.
    • Checks vertical neighbors to verify if matris[i][j] is the column maximum.
  3. Output: Prints the matrix and the result.

🚀 Example Scenarios

Scenario 1: Lucky Number Exists

 7   3  20  11  15 
14   5   9   2   8 
18  12   4  16   6 
22  10  21  13   1 
19  17  23  25  24 

Output: Bu matriste sansli sayi 17 dir.

About

A C program that generates a random NxN matrix with unique integers and identifies 'Lucky Numbers' (Saddle Points), defined as the minimum element in its row and maximum in its column.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages