• 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
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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: 17735
302
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: 5669
214
  • 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: 5669
214
  • 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.
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic