• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Reducing A Matrix Into A Reduced Row Echelon Form

 
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am currently working on a project from JetBrains Academy which requires me to read a file containing a matrix and reduce it into reduced row echelon form.
The project requirement can be found here https://hyperskill.org/projects/40/stages/211/implement

This is my current implementation, it only reads the file into two dimensional integer array.

Any recommendations to make the current implementation robust will be appreciated.



This how the content of the file looks like
The first line determines the row length of the matrix
3
1 1 2 9
2 4 -3 1
3 6 -5 0

Thank you.
 
Sheriff
Posts: 17696
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would have used a Scanner and Scanner.nextInt() to eliminate the need to do readLine.split() and Integer.parseInt()--that's just too much hoop-jumping for my taste.
 
Bartender
Posts: 5558
213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing wrong with your code, but I would use this:

The method Files.lines may throw an IOException, so either this code must run in a try/catch block, or the method must be declared to throw such an Exception.
 
Piet Souris
Bartender
Posts: 5558
213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops... when writing the above code I started from a wrong example. Sorry. I meant this code:
 
Kelvin Okornoe
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the suggestion so far, I have noted them.
Am still working on the program and I will be posting it here for more reviews.
Thank you.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic