Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,201,214 members, 7,977,577 topics. Date: Thursday, 17 October 2024 at 10:26 AM |
Nairaland Forum / Science/Technology / Programming / Coding For D Gurus:#challange (1994 Views)
I Will Mentor/ Teach Coding For Free / Apply For Union Bank Campus Innovation Challange / Learn Coding For Free, With Microverse, Pay The Tuition When You Start Earning. (2) (3) (4)
Coding For D Gurus:#challange by Nobody: 10:26pm On Apr 07, 2020 |
Firstly am not a guru bt if u r then am sure this challange shld be a breeze for you the challange is to write a program to manipulate a matrix it shld be able to do the following to a matrix: 1.Transpose a matrix: Input: 1 2 3 4 5 6 7 8 9 Output:1 4 7 2 5 8 3 6 9 2. Find the dot product of a matrix: Input: 1 2 3 4 5 6 *2 7 8 9 Output: 2 4 6 8 10 12 14 16 18 3. Create a Matrix: Input:4*3 Output: 1 2 3 4 5 6 7 8 9 10 11 12 ################################## This challenge is for those who just love a bit of a challange nd the gurus who i hav been seeing dishing out some nice pice of algo. Not for money or any cash prize just for the joy of CODE Enjoy ################################## P.s after 3 days i will post the answer written in python bt it is still an algorithm so just follow it to understand python is kinda like pseude - code ################################### |
Re: Coding For D Gurus:#challange by Nobody: 7:55pm On Apr 08, 2020 |
Is that no one tried or even attempted to solve it damn even if it wrong it is cool to try tor tommorrow i will be posting it. Seems that majority only code for cash not for joy sadden take care |
Re: Coding For D Gurus:#challange by Nobody: 5:32pm On Apr 09, 2020 |
#Firts we make a function called sizen that returns the cols and rows in a matrix a try and catch block is been put incase it is not a matrix that is been inputed def Size(matrix): row=len(matrix)-1 col=0 try: for i in matrix[row]: col+=1 except TypeError: pass row+=1 return row,col #This function creates a matrix by the rows and cols inputted def Create_Matrix(self,rows,cols): matrix=[] temp_num=0 for i in range(rows): inner_list=[] matrix.append(inner_list) for i in matrix: for num in range(cols): i.append(temp_num) temp_num+=1 return matrix #This function transposes a matrix def Trans_Matrix(self,mat): row,col=Size(mat) dummy_matrix=Create_Matrix(row,col) for i in range(row): for j in range(col): dummy_matrix[j][i]=mat[i][j] return dummy_matrix Here are the codes i left one out just so that with this ones u guyz could pice it together to code the last one |
Re: Coding For D Gurus:#challange by progeek37(m): 6:09pm On Apr 09, 2020 |
Lawren76: Okay why not join my coding group to share your ideas there with other programmers? There are actually many redundant lines of code in your solution. Maybe if you join my coding WhatsApp group you can see a more improved solution. |
Re: Coding For D Gurus:#challange by Maskyy(m): 11:02pm On Apr 09, 2020 |
You want to be a programmer, developer, data scientists, designer and mobile dev with full guide and motoring with tasks. Codefans is helping a budding techie person Like you. Join their community and get train. Fill this form to get started https://docs.google.com/forms/d/18cWuMdfV2fZ7ERJHRkwzpAmqaAwA-_W5R4cpE0zGeFw/edit?usp=drivesdk |
Re: Coding For D Gurus:#challange by Nobody: 11:36pm On Apr 09, 2020 |
progeek37: Hmmm i will think abt it cos in d past some grps hav mess me up so currently solo bt ppl change |
Re: Coding For D Gurus:#challange by Shepherdd(m): 10:08am On Apr 10, 2020 |
Lawren76: def transpose(array): Note that your matrix creation contains an error. Matrix size is (row x column) not (column x row). And no assertion and type checking is done n my code. |
Re: Coding For D Gurus:#challange by Nobody: 11:08am On Apr 10, 2020 |
Shepherdd:def transpose(array): First of all am very happy u did it,secondly if u check it the program knows which come first i.e row then column So urs don't have type checking it works that all i do first then i make it efficent next |
Re: Coding For D Gurus:#challange by Shepherdd(m): 3:35pm On Apr 10, 2020 |
Lawren76: My bad. I made the comment based on the example and not on the actual code..... |
Re: Coding For D Gurus:#challange by Nobody: 8:23pm On Apr 10, 2020 |
Shepherdd: No prob. Bro |
Re: Coding For D Gurus:#challange by Nobody: 8:47pm On Apr 10, 2020 |
progeek37: Here my number for d grp 07013927220 |
Re: Coding For D Gurus:#challange by 2muchopoTBdope(m): 9:43pm On Apr 10, 2020 |
Lawren76: Can I do this with MATLAB?? |
Re: Coding For D Gurus:#challange by 2muchopoTBdope(m): 9:44pm On Apr 10, 2020 |
Lawren76: Should I do this with MATLAB Cos I understand that language better?? |
Re: Coding For D Gurus:#challange by Nobody: 7:23am On Apr 11, 2020 |
2muchopoTBdope: Well it your choice which language to use cos python is kinda like pesudo code sontp understand the algorithm would be simple |
Re: Coding For D Gurus:#challange by Nobody: 2:13pm On Apr 11, 2020 |
2muchopoTBdope: If u want to cos it an algorithm just follow d algorithm nd code it |
Re: Coding For D Gurus:#challange by nosagold(m): 4:10pm On Apr 11, 2020 |
Lawren76: #assuming each matrix takes the following format matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] def transpose_matrix(matrix): list = [] for row in range(len(matrix)): ma = [] for item in range(len(matrix[row])): ma.append(matrix[item][row]) list.append(ma) return list def dot_product(matrix, dot): list = [] for row in range(len(matrix)): ma = [] for item in range(len(matrix[row])): ma.append(matrix[row][item] * dot) list.append(ma) return list def create_matrix(rows, columns): start = 0 list = [] for row in range(rows): ma = [] for item in range(columns): start += 1 ma.append(start) list.append(ma) return list |
Re: Coding For D Gurus:#challange by nosagold(m): 4:13pm On Apr 11, 2020 |
nosagold: sorry about the indentation, somehow nairaland text editor keeps messing with it |
Re: Coding For D Gurus:#challange by 2muchopoTBdope(m): 5:34pm On Apr 11, 2020 |
Lawren76: OK but MATLAB already has a function for transpose. There might be no need to create a code for it when there is a function for it already. If u want, I could do it, snap and send to u. 1 Like |
Re: Coding For D Gurus:#challange by Nobody: 9:21pm On Apr 11, 2020 |
2muchopoTBdope: In a way still do it cos me i did it in python nd python has numpy for matrix manipulation bt still did it to test my algorithm skills so consider it like a test to ascert how goodnyoubare at algorithms 1 Like |
Re: Coding For D Gurus:#challange by Nobody: 9:25pm On Apr 11, 2020 |
nosagold: Nice try |
Re: Coding For D Gurus:#challange by nosagold(m): 10:23pm On Apr 11, 2020 |
Lawren76: It does work. There's a shorter way though but this does work |
Re: Coding For D Gurus:#challange by Nobody: 10:25pm On Apr 11, 2020 |
nosagold: I know that y i put nice meaning thumbs up |
Re: Coding For D Gurus:#challange by Runningwater(m): 5:17am On Jun 15, 2020 |
Matrix A for example A' would transpose the matrix A in Matlab ,similar to Octave but don't know of Scilab. It's better using the right tools(s) for the right job after all it's about getting the job done most times. Info: Matlab sees everything as a matrix, hence the name MATrix LABoratory. Anyway, for learning sake it's okay understanding the algorithm. |
(1) (Reply)
Why It's Important To Be Very Well-rounded Today / ERROR finding a girlfriend! / Help Convert This WHILE Loop Into A FOR Loop
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 59 |