https://github.com/runattekky/polynomial-problem
https://github.com/runattekky/polynomial-problem
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/runattekky/polynomial-problem
- Owner: RunAtTekky
- Created: 2025-08-31T09:38:17.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-31T09:55:04.000Z (10 months ago)
- Last Synced: 2025-08-31T11:35:34.436Z (10 months ago)
- Language: Go
- Homepage: https://blog.runat.xyz/post/polynomial-problem/
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Polynomial Problem
[Notion Link for input format](https://honorable-marimba-e75.notion.site/Hashira-Placements-Assignment-Online-16c880a946cf805f9ab6c3aacd180f8d)
I didn't attend the process where this problem was asked but I found the problem statement very interesting.
So here is my attempt to solve it with [Test Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development) as I am also learning [Go with tests](https://github.com/RunAtTekky/Learn-GO-with-tests)
> Basically you are given system of linear equations. Solve it.
> I am solving this problem with [Gaussian Elimination Method](https://www.geeksforgeeks.org/dsa/gaussian-elimination/) which uses [Row Echelon Form](https://en.wikipedia.org/wiki/Row_echelon_form) and Back Substitution
### Input
```json
{
"keys": {
"n": 4,
"k": 3
},
"1": {
"base": "10",
"value": "4"
},
"2": {
"base": "2",
"value": "111"
},
"3": {
"base": "10",
"value": "12"
},
"6": {
"base": "4",
"value": "213"
}
}
```
### JSON Parser
Input: input.json
Output: Unmarshal data into keys `Keys` and entries `map[string]Entry`
Also we get n, the number of entries given
We get k, which is equations required to solve polynomial.
We get m, which is degree of polynomial.
### Conversion
Convert bases (say from base 2 to base 6)
Input: base, value
Output: Value in decimal
### Create equation
Input: x, y, m
Output: Linear equation {expression, y}
### Create Augmented Matrix
Input: Linear equations and their values y
Output: Matrix with linear equations and y
### Gaussian Elimination Method
#### Row Echelon Form
Input: Augmented matrix
Output: Convert to row echelon form
#### Back substitution
Input: Row echelon form
Output: Give the value of variables in a map {a: X, b: X, c: X, ....}
> We got our answer