#100DaysOfCode | Day 2

banji220

Banji

Posted on July 26, 2020

#100DaysOfCode | Day 2

▄█ █▀█ █▀█ █▀▄ ▄▀█ █▄█ █▀ █▀█ █▀▀ █▀▀ █▀█ █▀▄ █▀▀
░█ █▄█ █▄█ █▄▀ █▀█ ░█░ ▄█ █▄█ █▀░ █▄▄ █▄█ █▄▀ ██▄

Heyyyyya
I'm here again to share my last day experience in dev.to!
today was a little bit hard for me cuz I only solved 1 problem from exercism, the level of that problem was Easy but I failed to solve it.

I spend my whole day to solve that problem but to be honest it was so tough for me to solve.
So yeah I couldn't to solve at least 2 problem but I think it's worth it.

so let's look at my code challenge, I know I know It seems so easy for most of the senior developer or python programmer but take it easy and encourage me through my journey, hahaha....

*Problem: *

Given a string representing a matrix of numbers,
return the rows and columns of
that matrix.

So given a string with embedded newlines like:

Enter fullscreen mode Exit fullscreen mode


text
9 8 7
5 3 2
6 6 7


representing this matrix:

Enter fullscreen mode Exit fullscreen mode


text
1 2 3
|---------
1 | 9 8 7
2 | 5 3 2
3 | 6 6 7


your code should be able to spit out:

- A list of the rows,
  reading each row left-to-right while moving
  top-to-bottom across the rows,
- A list of the columns,
  reading each column top-to-bottom while moving
  from left-to-right.

The rows for our example matrix:

- 9, 8, 7
- 5, 3, 2
- 6, 6, 7

And its columns:

- 9, 5, 6
- 8, 3, 6
- 7, 2, 7
Enter fullscreen mode Exit fullscreen mode

and I couldn't find a solution for it, so finally I read the others code and their solution to understand how to solve it, and here's the solution for it:

Solution:

class Matrix:
 def __init__(self, matrix_string):
    self.matrix = [[int(x) for x in line.split()] for line in  matrix_string.split("\n")]


    def row(self, index: int):
        return self.matrix[index -1]


    def column(self, index: int):
        return [x[index -1] for x in self.matrix]
Enter fullscreen mode Exit fullscreen mode

I didn't know about split() method and that was my first Inline for LOOOOOOOOOOOOOOOP ever!

Alt Text
When you see Inline Loop for the first time!

I couldn't even understand Inline loop at first when I saw.
finally I got it but I'm not comfort with it, need to practice and play ...

That was my previous day experience briefly, I hope you enjoy my post and the way I'm writing my experience ;)

I know I'm still not a good writer but I'll do my best.
If you have any Idea about me and the way I'm write or any advice to improve my coding skills just let me know and Leave a comment below.
Thank you for spending your time to read my post .
I appreciate it
_Code With _

💖 💪 🙅 🚩
banji220
Banji

Posted on July 26, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

#100DaysOfCode | Day 10, 11
challenge #100DaysOfCode | Day 10, 11

August 5, 2020

#100DaysOfCode | Day3,4
challenge #100DaysOfCode | Day3,4

July 28, 2020

#100DaysOfCode | Day 2
challenge #100DaysOfCode | Day 2

July 26, 2020

#100DaysOfCode | Day 1
challenge #100DaysOfCode | Day 1

July 25, 2020